Skip to content

Commit

Permalink
Fix, test program-valued GetInfo queries
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Jul 27, 2015
1 parent 551057c commit 1c750e0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pyopencl/cffi_cl.py
Expand Up @@ -150,12 +150,21 @@ def _generic_info_to_python(info):
_lib.CLASS_COMMAND_QUEUE: CommandQueue
}[info.opaque_class]

if klass is _Program:
def create_inst(val):
from pyopencl import Program
return Program(_Program._create(val))

else:
create_inst = klass._create

if type_.endswith(']'):
ret = list(map(klass._create, value))
ret = list(map(create_inst, value))
_lib.free_pointer(info.value)
return ret
else:
return klass._create(value)
return create_inst(value)

if type_ == 'char*':
ret = _ffi_pystr(value)
elif type_.startswith('char*['):
Expand Down
17 changes: 17 additions & 0 deletions test/test_wrapper.py
Expand Up @@ -764,6 +764,23 @@ def test_buffer_get_host_array(ctx_factory):
pass


def test_program_valued_get_info(ctx_factory):
ctx = ctx_factory()

prg = cl.Program(ctx, """
__kernel void
reverse(__global float *out)
{
out[get_global_id(0)] *= 2;
}
""").build()

knl = prg.reverse

assert knl.program == prg
knl.program.binaries[0]


if __name__ == "__main__":
# make sure that import failures get reported, instead of skipping the tests.
import pyopencl # noqa
Expand Down

0 comments on commit 1c750e0

Please sign in to comment.