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

Tweak examples to emphasize importance of retaining kernels

parent a80586c8
No related branches found
No related tags found
1 merge request!134Speed up enqueue
Pipeline #121420 failed
...@@ -23,7 +23,8 @@ __kernel void sum( ...@@ -23,7 +23,8 @@ __kernel void sum(
""").build() """).build()
res_g = cl.Buffer(ctx, mf.WRITE_ONLY, a_np.nbytes) res_g = cl.Buffer(ctx, mf.WRITE_ONLY, a_np.nbytes)
prg.sum(queue, a_np.shape, None, a_g, b_g, res_g) knl = prg.sum # Use this Kernel object for repeated calls
knl(queue, a_np.shape, None, a_g, b_g, res_g)
res_np = np.empty_like(a_np) res_np = np.empty_like(a_np)
cl.enqueue_copy(queue, res_np, res_g) cl.enqueue_copy(queue, res_np, res_g)
......
...@@ -22,6 +22,7 @@ prg = cl.Program(ctx, """ ...@@ -22,6 +22,7 @@ prg = cl.Program(ctx, """
} }
""").build() """).build()
prg.sum(queue, a.shape, None, a_dev.data, b_dev.data, dest_dev.data) knl = prg.sum # Use this Kernel object for repeated calls
knl(queue, a.shape, None, a_dev.data, b_dev.data, dest_dev.data)
print(la.norm((dest_dev - (a_dev+b_dev)).get())) print(la.norm((dest_dev - (a_dev+b_dev)).get()))
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