Skip to content
Snippets Groups Projects
Commit 87cfbed1 authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

Merge branch 'master' into cffi

parents 437c2212 d1d4f1eb
No related branches found
No related tags found
No related merge requests found
...@@ -642,6 +642,37 @@ def test_unload_compiler(ctx_factory): ...@@ -642,6 +642,37 @@ def test_unload_compiler(ctx_factory):
skip("Intel proprietary driver does not support unloading compiler") skip("Intel proprietary driver does not support unloading compiler")
cl.unload_platform_compiler(platform) cl.unload_platform_compiler(platform)
def test_enqueue_task(ctx_factory):
ctx = ctx_factory()
queue = cl.CommandQueue(ctx)
mf = cl.mem_flags
prg = cl.Program(ctx, """
__kernel void
reverse(__global const float *in, __global float *out, int n)
{
for (int i = 0;i < n;i++) {
out[i] = in[n - 1 - i];
}
}
""").build()
knl = prg.reverse
n = 100
a = np.random.rand(n).astype(np.float32)
b = np.empty_like(a)
buf1 = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=a)
buf2 = cl.Buffer(ctx, mf.WRITE_ONLY, b.nbytes)
knl.set_args(buf1, buf2, np.int32(n))
cl.enqueue_task(queue, knl)
cl.enqueue_copy(queue, b, buf2).wait()
assert la.norm(a[::-1] - b) == 0
if __name__ == "__main__": if __name__ == "__main__":
# make sure that import failures get reported, instead of skipping the tests. # make sure that import failures get reported, instead of skipping the tests.
import pyopencl # noqa import pyopencl # noqa
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment