Monday, September 22, 2014

My CUDA debug tour

1. Copy array from device to host and print it.


-------------------------------------------------------------------------------

2. Cuda-gdb

When fundamental functions like cudaMalloc failed,usually it shouldn't be its problem. So, first check if there is cuda device available now (driver problem?), then check if problems happen before cudaMalloc.

Tips: you have to be very careful about memory reading and writing. For example, you read from shared memory with the right index. But if you didn't write to it before, it can cause a hidden error! Usually you would think it should be a random value. But in CUDA, your fundamental functions can fail because of this hidden error!

Before you read, you write. Before you write, you check.

No comments:

Post a Comment