Hi,
I have problems with an array of structures. Maybe it’s because of alignment problems, but I don’t understand the CUDA manual about that… I hope some clever people can help me. I have a structure:
[codebox]struct DBDStruct
{
double Temperature;
double DensN;
double DensN2A;
};
[/codebox]
and fill the structure on CPU memory with some initial values, copy that to GPU memory, calculate on GPU and copy it back. The whole code runs with “float” values, but with doubles I get problems. I added the “-arch=sm_13” to the compiler flags ( i have a GTX 285).
My memory allocation on CPU is:
[codebox] struct DBDStruct* oldGridValues = (struct DBDStruct*) malloc(Number_of_gridpoints_xNumber_of_gridpoints_ysizeof(
DBDStruct));[/codebox]
On GPU it is:
[codebox]struct DBDStruct* cuda_oldGridValues;
CUDA_SAFE_CALL(cudaMalloc((void**)&cuda_oldGridValues, Number_of_gridpoints_x*Number_of_gridpoints_y * sizeof(DBDStruct)));[/codebox]
and I copy the stuff to the GPU with:
[codebox]CUDA_SAFE_CALL(cudaMemcpy(cuda_oldGridValues, oldGridValues, Number_of_gridpoints_x*Number_of_gridpoints_y * sizeof(DBDStruct), cudaMemcpyHostToDevice));[/codebox]
copy back to CPU mem with:
[codebox] CUDA_SAFE_CALL(cudaMemcpy(newGridValues, cuda_newGridValues, Number_of_gridpoints_x*Number_of_gridpoints_y * sizeof(DBDStruct), cudaMemcpyDeviceToHost));[/codebox]
What is the easiest way to get it running with doubles?
Thx for any help!!!
Philipp.