Hi all,
I invoke a child kernel to do sorting of thrust, the result is correct.
But when I use CUDA-GDB/Nsingt to check the program, the “Illegal access to address” exception was captured.
I have read related documents, I’m sure the passed arguments are not local variables. So I try to pass
arguments only, and the kernel so nothing. However, the exception still occurs. Only the kernel without argument can
pass the check. Is it a real bug in my program?
Provide some experiments
__global__ void kernel_sorting(int a){
//nothing
}
__device__ int v;
__global__ void kernel_main(....){
int tid = threadIdx.x + blockDim.x * blockIdx.x;
....
if(tid==0)
kernel_sorting<<<gridDim.x,blockDim.x>>>(v); //pass int
}
GDB show: Illegal access to address (@global)0x70382d540 detected.
So v is in the global memory
__global__ void kernel_sorting(int *a){
//nothing
}
__device__ int v;
__global__ void kernel_main(....){
int tid = threadIdx.x + blockDim.x * blockIdx.x;
....
if(tid==0)
kernel_sorting<<<gridDim.x,blockDim.x>>>(&v); //pass address
}
//GDB show: Illegal access to address (@global)0x70382d540 detected.
//So v is in the global memory
__global__ void kernel_sorting(int *a){
//nothing
}
__device__ int v;
__global__ void kernel_main(int *input){
int tid = threadIdx.x + blockDim.x * blockIdx.x;
....
if(tid==0)
kernel_sorting<<<gridDim.x,blockDim.x>>>(input); //pass an argument of parent kernel, a buffer in global memory
}
provide more GDB’s information
Breakpoint 1, kernel_main<<<(1,1,1),(64,1,1)>>> (…) at …/fpg.cu:583
583 kernel_sorting<<<gridDim.x,blockDim.x>>>(&v);
(cuda-gdb) p &v
$1 = (@global int *) 0x70528dc00
(cuda-gdb) c
Continuing.
Illegal access to address (@global)0x703623d40 detected.
Program received signal CUDA_EXCEPTION_1, Lane Illegal Address.
[Switching focus to CUDA kernel 0, grid 22, block (0,0,0), thread (0,0,0), device 0, sm 4, warp 1, lane 0]
0x00007ffff06340a8 in kernel_main<<<(1,1,1),(64,1,1)>>> (…)at …/fpg.cu:583
583 kernel_sorting<<<gridDim.x,blockDim.x>>>(&v);
//The address triggers the exception is not the address of v. Who touch the address?