diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py index a22c5565ae1c337e16d80baf92cb257bfe05c4e2..0c4f9b060cb9f7746a306b30e87fcc53c0203e4f 100644 --- a/pyopencl/__init__.py +++ b/pyopencl/__init__.py @@ -99,6 +99,9 @@ class Program(object): options = options + ["-I", _find_pyopencl_include_path()] if self._prg is not None: + if isinstance(options, list): + options = " ".join(options) + self._prg._build(options, devices) else: from pyopencl.cache import create_built_program_from_source_cached diff --git a/test/test_wrapper.py b/test/test_wrapper.py index 156ac4cd983c7a667dbe1da5b6f847dff61fb0b8..7dfca6add550ba6ad03f1d424eec02c9663d305c 100644 --- a/test/test_wrapper.py +++ b/test/test_wrapper.py @@ -360,7 +360,6 @@ class TestCL: @pytools.test.mark_test.opencl def test_header_dep_handling(self, ctx_factory): context = ctx_factory() - queue = cl.CommandQueue(context) kernel_src = """ #include @@ -378,7 +377,6 @@ class TestCL: @pytools.test.mark_test.opencl def test_context_dep_memoize(self, ctx_factory): context = ctx_factory() - queue = cl.CommandQueue(context) from pyopencl.tools import context_dependent_memoize @@ -393,6 +391,22 @@ class TestCL: assert counter[0] == 1 + @pytools.test.mark_test.opencl + def test_can_build_binary(self, ctx_factory): + ctx = ctx_factory() + device, = ctx.devices + + program = cl.Program(ctx, """ + __kernel void simple(__global float *in, __global float *out) + { + out[get_global_id(0)] = in[get_global_id(0)]; + }""") + program.build() + binary = program.get_info(cl.program_info.BINARIES)[0] + + foo = cl.Program(ctx, [device], [binary]) + foo.build() +