how can i debuging a progrem runs on gpu?
There are multiple ways to debug in CUDA.
-
run your application with cuda-memcheck. https://developer.nvidia.com/cuda-memcheck
-
check the return status of CUDA API. http://stackoverflow.com/questions/14038589/what-is-the-canonical-way-to-check-for-errors-using-the-cuda-runtime-api
-
you could also print out the variables in cuda kernel to see the values. e.g.
#include <stdio.h>
#include <assert.h>
#include <cuda.h>
#include <cuda_runtime.h>
__global__ void test(){
printf("Hi Cuda World");
}
int main( int argc, char** argv )
{
test<<<1,1>>>();
cudaDeviceSynchronize();
return 0;
}
There are debuggers available.
On linux you can use cuda-gdb or the debugger personality built into nsight eclipse edition (both are part of the CUDA toolkit)
On Windows, the nsight visual studio edition plug in for MS VS provides device code debugging support.