Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Way to verify kernel was executed in CUDA

Tags:

When I call a kernel with ill-set parameters (e.g. more than 512 threads per block) or when the operations inside it require more than what my device has to offer (e.g. too many registers) the kernel is simply not executed. There is no exception or return value to indicate what happened though.

I'd like to know if there's a way to verify if a kernel was executed or not.

like image 227
Renan Avatar asked Jun 21 '11 02:06

Renan


People also ask

How do I check CUDA error?

In a CUDA program implementation, both development and production code, always check the return value of each CUDA runtime synchronous or asynchronous API call to see if there is any CUDA synchronous error, always run CUDA runtime error capturing API calls, such as cudaGetLastError , after kernel launch calls to see if ...

Which is the correct way to launch a CUDA kernel?

In order to launch a CUDA kernel we need to specify the block dimension and the grid dimension from the host code. I'll consider the same Hello World! code considered in the previous article. In the above code, to launch the CUDA kernel two 1's are initialised between the angle brackets.

What is kernel launch in CUDA?

The kernel is a function executed on the GPU. Every CUDA kernel starts with a __global__ declaration specifier. Programmers provide a unique global ID to each thread by using built-in variables. Figure 2. CUDA kernels are subdivided into blocks.

Can a CUDA kernel launch another kernel?

CUDA Dynamic Parallelism Under dynamic parallelism, one kernel may launch another kernel, and that kernel may launch another, and so on. Each subordinate launch is considered a new “nesting level,” and the total number of levels is the “nesting depth” of the program.


2 Answers

try this

kernel<<<blocks, threads>>>(params); cudaError_t err = cudaGetLastError(); if (err != cudaSuccess)      printf("Error: %s\n", cudaGetErrorString(err)); 

This should give you a detailed error about what went wrong.

EDIT: Here's a more detailed answer about how to properly check errors in CUDA:

  • What is the canonical way to check for errors using the CUDA runtime API?
like image 153
Pavan Yalamanchili Avatar answered Sep 18 '22 13:09

Pavan Yalamanchili


Also you could print something from the kernel. This may be useful for debugging.

like image 25
amanda Avatar answered Sep 19 '22 13:09

amanda