-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PyOpenCL executor: accept device scalars for ValueArgs #453
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This was surprisingly lightweight. 😄 Two things below.
c4a5afe
to
6f3be3f
Compare
preprocess_translation_unit_before_codegen -> preprocess_translation_unit_for_passed_args Co-authored-by: Andreas Klöckner <inform@tiker.net>
6f3be3f
to
1b341f0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Will go in after #451.
Actually, scratch that. Goes in now. :) Thanks again. |
I think I will revert this; it does not properly do what it claims to do, because it looks at arguments at a point when it shouldn't. Case in point, if we change the test to: def test_pyopencl_execution_accepts_device_scalars(ctx_factory):
import pyopencl.array as cla
ctx = ctx_factory()
cq = cl.CommandQueue(ctx)
knl = lp.make_kernel("{:}",
"""
y = 2*x
""")
evt, (out,) = knl(cq, x=cla.to_device(cq, np.asarray(21)))
np.testing.assert_allclose(out.get(), 42)
# adding this bit:
evt, (out,) = knl(cq, x=np.int32(21))
np.testing.assert_allclose(out.get(), 42) things break, because the kernel to be executed got specialized to device scalars when it shouldn't have. Fixing this is non-trivial without a major hit to invocation performance, because to do this properly, we would need to compare the types of all arguments on every invocation. We can currently avoid that for kernels that do not have runtime-typed variables, resulting in a major cost savings that I do not want to give up. |
#797 contains the revert. |
-Closes #452.