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)
[url]http://docs.nvidia.com/cuda/index.html#tools[/url]
On Windows, the nsight visual studio edition plug in for MS VS provides device code debugging support.
[url]https://developer.nvidia.com/nvidia-nsight-visual-studio-edition[/url]