I’m using cuda-gdb for debugging the kernel part with two 2D arrays of different type(A and B) as arguments passed in.
unsigned int A // all initialized to 0
unsigned char B // all initialized to 1
unsigned int* d_A;
cutilSafeCall(cudaMallocPitch( (void**) &d_A, &pitch_dA, sizeof(unsigned char) * WIDE, HEIGHT));
cudaMemcpy2D(d_A, pitch_dA, A, sizeof(unsigned char) * WIDE, sizeof(unsigned char) * WIDE, HEIGHT, cudaMemcpyHostToDevice);
unsigned char* d_B;
cutilSafeCall(cudaMallocPitch( (void**) &d_B, &pitch_dB, sizeof(unsigned char) * WIDE, HEIGHT));
cudaMemcpy2D(d_B, pitch_dB, B, sizeof(unsigned char) * WIDE, sizeof(unsigned char) * WIDE, HEIGHT, cudaMemcpyHostToDevice);
kernel<<< 1, 32 >>>(d_A, pitch_dA/sizeof(unsigned int), HEIGHT, d_B, pitch_dB/sizeof(unsigned char), HEIGHT);
cutilCheckMsg(“Kernel execution failed”);
I set a break point at kernel and when step in, I can print A for all the x, but when print B, no matter which x I set, the print result shows like: 0 ‘\0’, always have something quoted by ‘’ after the value that I stored and need to read. I dont know what does it mean. And this influenced my logic computation later.
btw, when stop at the break point, it shows some infomation like below:
Breakpoint 1, kernel<<<(1,1,1),(32,1,1)>>> (A=0x200100000, A_width=128, B=0x200300000 “”, B_width=32768)at test.cu:367
The value (0, 8, 128, 18) in front part are what I expect to get, but " " after that is something beyond my imagination. I’m suspicious of the “” which I highlighted above to be some hint of failure for 2Dmemcpy of unsigned char array, but not sure.