Check number and types of args passed to RawKernel function?
See original GitHub issueHello CuPy developers, I noticed that if you pass the wrong number or types of input arguments to RawKernel that CuPy crashes. What do you think about adding some checks?
source = "extern "C" __global__ void test(float *arg1, float *arg2, const int n) { } "
test = cupy.RawKernel(source, "test")
grid=(1,)
block=(1,)
# 1. Too few input arguments
args = (arg1, arg2)
# Segmentation fault (CUDA_ERROR_ILLEGAL_ADDRESS)
# test(grid, block, args)
# 2. Too many input arguments
args = (arg1, arg2, arg2, n)
# 3. Wrong type for input argument #1 (0-based)
args = (arg1, n, arg2)
If you think it is a good idea, I would be happy to try to contribute a PR.
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (11 by maintainers)
Top Results From Across the Web
User-Defined Kernels — CuPy 11.4.0 documentation
CuPy provides easy ways to define three types of CUDA kernels: elementwise ... for arguments passed to the kernel, including types and number...
Read more >Passing structure to raw kernel in cupy - Stack Overflow
It seems like it should work if you check look at the function module in cupy's source code. It just passes on the...
Read more >New RawKernel Calling Convention / Kernel Occupancy ...
I looked at numba, and it seems to just make the stream a 3rd argument in the [ ] . Haven't found an...
Read more >How can I find the number of arguments of a Python function?
We get a list of all arguments of a function foo() by using inspect.getargspec(foo). The first of this list is again a list...
Read more >CuPy Documentation - Read the Docs
The ElementwiseKernel class first checks the output arguments and ... Python primitive types and NumPy scalars are passed to the kernel by ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@leofang No problem. I just need a few days to create an example to submit. I’m swamped with my new position!
We might need to file a bug. Having too many parameter should return a illegal address error