the following problem was encountered:
- struct A, which contains a pointer to another struct B array
- cudaMalloc for both structs A and B
- cudaMemcpy for both structs A and B
- cudaMemcpy to assign the pointer from struct B to struct A on the GPU
- everything remains in global memory
- running the program produces wrong results when accessing the memory of struct B array through the pointer contained in struct A
- for debugging purposes the pointer to struct B array returned by cudaMalloc is passed in addition to the pointer to struct A into the kernel
- debugging with cuda-gdb reveals:
[indent]- address of the struct B passed directly to the kernel is identical to the one stored in struct A
- accessing the memory region of struct B through the pointer in struct A fails (i.e. produces garbage values, though cuda-gdb displays the layout of struct B correctly. So it must know with what kind of struct it deals)
- accessing the memory region of struct B through the pointer to struct B, which is directly passed to the kernel, works[/indent]
- Ubuntu 64bit 10.04
- Kernel: 2.6.32-26-generic
- Nvidia driver version: 260.19.29
- SDK: 3.2.16
The main questions:
- Why does an access of the same memory through identical addresses produce different results depending on where the pointers are stored?
- Is this a known issue?
Hopefully, this information is enough. Posting of code might be possible, though the current working version of the code uses two separate pointers and it is unlikely that it will be changed back to the nested version. Nevertheless it would be much appreciated if someone can shed some light on this topic as it is strange nevertheless.
Thx & Greetings