santi
santi

Reputation: 87

Cuda device code doesn't throw an error when segfaults

Having a cuda kernel like this

__global__ void kernel(...)
{
    free( 48190);
}

is probably not a good idea. Let's say that 48190 is not a valid address to deallocate during the current execution.

If we were on the host, the runtime would probably stop execution right away, throw a segfault error and give us some nasty description of what happened like "A heap has been corrupted" or something.

But what if it did all that except for the message? what if when it hits that point, it blows up and exits without telling me anything about what happened. That is what that code gives me. If I wrote the above kernel on my machine, it would compile, run, and if that was everything my program did (just call that kernel) it would happily exit with no error message :(. I only find out later when I try to do a cudaMemcpy that something went wrong because it fails with error code 30: unknown error

My question is: is this supposed to happen? is there any way to enable some kind of error description when something goes wrong in a kernel call?

Upvotes: 0

Views: 667

Answers (1)

Robert Crovella
Robert Crovella

Reputation: 152289

is there any way to enable some kind of message description when something goes wrong in a kernel call?

Yes, do cuda error checking. It's described here.

Upvotes: 3

Related Questions