From c2c4040c1e52c2461864e56ce96f70806413b33c Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 21 Nov 2011 20:21:36 -0500 Subject: [PATCH] Test/fix building a Program from a binary. --- pyopencl/__init__.py | 3 +++ test/test_wrapper.py | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py index a22c5565..0c4f9b06 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 156ac4cd..7dfca6ad 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() + -- GitLab