Pointer arithmatic Incrementing device pointers on the CPU

I’m fairly sure I know the answer to this, but I’m going to ask anyway…

If I have a device pointer:

double *pointer_device;

and I want a new incremented device pointer:

double *pointer_device2 = &pointer_device[1];

is this a safe operation on the CPU?

I am not saying this with authority as i have not completly fixed my problem, but when i tried to do:

udata = kernel->udata + iip * nur;

udata[offset + last_rindex];

Where udata and kernel->udata are float*, the program would crash.


Works (params.knur = nur)

Maybe some of the answer is there, but as i said, dont take this for granted!

Hmm, I assume that works, but now that you ask, it could explain some wrong output I am seeing if this turn out to be actually not supported…

I’ll try to report back asap to see if my problem is fixed when I change this.

Not sure yet, I think it works. After splitting things up, I end up with the same incorrect answers in the second array, so it looks like the results are the same and I have a bug somewhere else in my code…


I have been using such assignments without any problem:

float e; float *d_e; float *dptr; int *nx; int *ny; int *nout;

   unsigned int mem_size = sizeof(float);

   __constant__ int dmiscint[32];



   dptr = &d_e[miscint[16] * ((*ny+1) * (*nout - 1) + (*ny+1)/2) + (*nx+1)/2 ];

   CUDA_SAFE_CALL(cudaMemcpy(&e, dptr, mem_size, cudaMemcpyDeviceToHost));