cuda-python icon indicating copy to clipboard operation
cuda-python copied to clipboard

Document best practices in preparing arguments for `cuLaunchKernel`

Open leofang opened this issue 1 year ago • 2 comments

@gigony complained the following example is unclear compared to CuPy's RawKernel, and I agree. https://github.com/NVIDIA/cuda-python/blob/e1e332564c48db556212d59262a149b1a63285e8/docs_src/source/overview.md?plain=1#L208-L223 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 avatar Sep 24 '24 03:09 leofang

https://github.com/NVIDIA/cuda-python/blob/main/cuda_bindings/tests/test_kernelParams.py

To add on, ctypes is another alternative for constructing kernel params. Both the ctypes and numpy approaches are tested in test_kernelParams.

vzhurba01 avatar Oct 15 '24 17:10 vzhurba01

An internal discussion pointed out that we should also document how to pass texture/surface objects: https://github.com/NVIDIA/cuda-python/blob/27317a00c8406a542716072f1f0956d66672147b/cuda_bindings/examples/0_Introduction/simpleCubemapTexture_test.py#L170

leofang avatar Feb 08 '25 04:02 leofang