I am trying to feed an n-by-n-by-n structure into a kernel function. I may encounter an issue of illegal memory access when I try to copy the memory from device to host:
0: copyout Memcpy (host=0x0x2b3968ae0020, dev=0x0x10316200000, size=6291456) FAILED: 77(an illegal memory access was encountered)
The size of 6291456 is when n = 64, and there are three 8-byte integer/double in each element of the structure, so that 64x64x64x3x8 = 6291456.
The puzzling thing is that I may encounter the issue alternately at runtime. Or sometimes it runs fine but then it fails when I tried to use cuda-memcheck.
I used to have the bug of the true size of the structure is not correctly extracted, but this time I read in the structure and extract the dimensions using size(grid, dim) where dim is the dimension to be extracted.
The error messages from cuda-memcheck consist mostly of messages as below: ========= Invalid __global__ read of size 8 ========= at 0x0002f628 in photon_module_shoot_photon_ ========= by thread (31,0,0) in block (0,0,0) ========= Address 0x103164011f0 is out of bounds ========= Saved host backtrace up to driver entry point at kernel launch time ...
Your help is greatly appreciated as I was not familiar with memcheck and could not decipher the error messages. It is also greatly appreciated if I am allowed to send in the code and error messages if possible.