Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

More ergonomic way to access builtin kernels with weird names. #782

Closed
jansol opened this issue Aug 27, 2024 · 4 comments · Fixed by #783
Closed

More ergonomic way to access builtin kernels with weird names. #782

jansol opened this issue Aug 27, 2024 · 4 comments · Fixed by #783

Comments

@jansol
Copy link

jansol commented Aug 27, 2024

Sorry for the double post, figured this deserves its own tracking issue. Continuing from #777:

bik_prg = cl.create_program_with_built_in_kernels(ctx, [devices[0]], ["pocl.add.i8"])
bik_prg.build()
for k in bik_prg.all_kernels():
    name = k.get_info(cl.kernel_info.FUNCTION_NAME)
    if name == "pocl.add.i8":
        bik_knl = k
bik_knl(queue, a_np.shape, None, a_g, b_g, bikres_g)

Fetching the kernel via the kernel_name attribute is not possible since the builtin kernel name gets mangled by pyopencl to "pocladdi8" but it seems kernel_name gets passed as is to clCreateKernel which of course fails in this case since it expects "pocl.add.i8". Something like an __getitem__(self, kernel_name) or a helper function to fetch kernels by (string) name would be nice.

@inducer
Copy link
Owner

inducer commented Aug 27, 2024

cl.Kernel(bik_prg, "pocl.add.i8") should work. Does that do the trick for you?

It's documented here, but that's arguably not very discoverable. I'll add a note to the docs.

@inducer
Copy link
Owner

inducer commented Aug 27, 2024

BTW: k.get_info(cl.kernel_info.FUNCTION_NAME) could be k.function_name I think.

@jansol
Copy link
Author

jansol commented Aug 27, 2024

BTW: k.get_info(cl.kernel_info.FUNCTION_NAME) could be k.function_name I think.

Ohh, I see, I've mis-parsed the info section then. That does indeed make more sense. I'll give the constructor a try tomorrow, that should indeed do it.

@jansol
Copy link
Author

jansol commented Aug 28, 2024

Yep, the constructor is as good as it gets. Thanks for the docs clarification!

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants