The compiler says it can’t see what sr.lambert->cd points to assuming global memory, but it should assume constant memory. Is what I’m trying to do possible? If not, how can I solve this? Please help
Create a local variable that is a pointer to constant memory. Assign the pointer from the struct to the local variable. Use the local variable instead to dereference the pointer.
Declare a constant memory variable (e.g. array of size 0), initialize a pointer to it. Come on, this can’t be that hard. ;)
This might only solve the compiler warning, but I also notice a second problem:
You are copying the structs to global memory using CudaMemCpyToSymbol(), however the pointer stored in the struct will continue pointing to HOST MEMORY, guaranteeing a crash of the kernel. You would also have to fix the pointer after copying the struct. Best by querying for the address of the struct on the device with the symbol name and writing that into the pointer in the other struct (CudaMemCpyToSymbol will accept an offset parameter). Depending on the number of structs, this may get a little slow.
Maybe instead of using pointers, store an integer array index only that identifies the struct being pointed to.
Thanks man, yes you are very clever. I did think to have an array index member field within the struct so I can access the other struct in the other array easier -I think I will have to do this.