question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Check number and types of args passed to RawKernel function?

See original GitHub issue

Hello 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:closed
  • Created 3 years ago
  • Comments:15 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
mnicelycommented, Nov 18, 2020

@leofang No problem. I just need a few days to create an example to submit. I’m swamped with my new position!

2reactions
mnicelycommented, Nov 18, 2020

I suspect cuLaunchKernel doesn’t really check (or have no way to check) this.

We might need to file a bug. Having too many parameter should return a illegal address error

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found