我有一个复杂的 Cuda C++ 应用程序,它运行良好,直到我构建 cuda 代码-g -G
。构建调试时,它崩溃了cudaErrorIllegalAddress
,所以我跑了cuda-memcheck
,但没有发现任何问题。我也跑了valgrind
,没有发现任何问题。
当cuda-memcheck
什么都没有找到时,有什么策略可以找出 Cuda 代码中发生非法内存读取或写入的位置?有没有办法cuda-gdb
获得无效内存访问的代码行?
我在下面运行我的应用程序cuda-gdb
,调试器在无效的内存访问处获得了一个断点:
CUDA Exception: Warp Illegal Address
The exception was triggered at PC 0x50225260 (gpu_core.h:275)
Thread 1 "preprocess" received signal CUDA_EXCEPTION_14, Warp Illegal Address.
[Switching focus to CUDA kernel 0, grid 617, block (0,0,0), thread (0,0,0), device 0, sm 0, warp 2, lane 0]
0x0000000050225270 in thrust::cuda_cub::cub::BlockRadixSort<int, 256, 19, int, 6, true, (thrust::cuda_cub::cub::BlockScanAlgorithm)2, (cudaSharedMemConfig)1, 1, 1, 700>::BlockRadixSort (this=0x0, this=0x0, temp_storage=0xffffb17cffff159c, keys=0x1300001d1300001d, values=0x1300001d1300001d, begin_bit=<optimized out>, end_bit=<optimized out>, is_descending=..., is_keys_only=..., num_items=<optimized out>) at /home/user/git/infra/libgpu/src/gpu_core.h:275