Skip to content

Instantly share code, notes, and snippets.

@arghdos arghdos/predicate.py Secret
Created Aug 21, 2017

Embed
What would you like to do?
Predicated access range
import loopy as lp
import pyopencl as cl
import numpy as np
ctx = cl.create_some_context()
queue = cl.CommandQueue(ctx)
knl = lp.make_kernel('{[i]: 0 <= i < n}',
"""
a[i] = 0
if i < n - 1
b[i] = 1
end
""",
[lp.GlobalArg("a", np.float32, shape=("n",)),
lp.GlobalArg("b", np.float32, shape=("n - 1",))],
assumptions="n > 0")
_, a, b = knl(queue)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.