Skip to content
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

Document best practices in preparing arguments for cuLaunchKernel #127

Open
leofang opened this issue Sep 24, 2024 · 0 comments
Open

Document best practices in preparing arguments for cuLaunchKernel #127

leofang opened this issue Sep 24, 2024 · 0 comments
Labels
documentation Improvements or additions to documentation P1 triage

Comments

@leofang
Copy link
Member

leofang commented Sep 24, 2024

@gigony complained the following example is unclear compared to CuPy's RawKernel, and I agree.

Like `cuMemcpyHtoDAsync`, `cuLaunchKernel` expects `void**` in the argument list. In
the earlier code example, it creates `void**` by grabbing the `void*` value of each
individual argument and placing them into its own contiguous memory.
```{code-cell} python
# The following code example is not intuitive
# Subject to change in a future release
dX = np.array([int(dXclass)], dtype=np.uint64)
dY = np.array([int(dYclass)], dtype=np.uint64)
dOut = np.array([int(dOutclass)], dtype=np.uint64)
args = [a, dX, dY, dOut, n]
args = np.array([arg.ctypes.data for arg in args], dtype=np.uint64)
```
Now the kernel can be launched:

Specifically, how to pass typed pointers and scalars is really unclear.

This also raises the question: It seems NumPy has to be a run-time dependency of cuda-python (which is completely fine, since it is impossible that users have GPU projects installed to an environment where NumPy does not exist, we just need to ensure this intent is expressed as a package dependency).

For comparison, here's cupy.RawKernel's documentation
https://docs.cupy.dev/en/stable/user_guide/kernel.html#kernel-arguments

@leofang leofang added documentation Improvements or additions to documentation P1 labels Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation P1 triage
Projects
None yet
Development

No branches or pull requests

1 participant