cuMemAllocPitch

Hi,
I have to change my code from runtime API to driver API.
So, could you tell me what elementSizeBytes means?

CUresult cuMemAllocPitch(CUdeviceptr* devPtr,
unsigned int* pitch,
unsigned int widthInBytes,
unsigned int height,
unsigned int elementSizeBytes);

I think its sizeof(float) if I want to use float.
I just want to be sure.

Another question. Can I do that?

CUdeviceptr ptr1;
CUdeviceptr ptr2;

ptr2 = ptr1+N;

I want that ptr2 be a pointer on the N-th cell of ptr1.
I know that it’s possible in C (and very used).

Thanks,

Vince

Hi, I don’t know about the cuMemAllocPitch, though I wish I could help. I’d guess that you were right though.

About the pointers, yes, I’d say you can do that. I have done very similar things outside of a kernel. Inside of a kernel, I’ve done something very similar to ptr2 = &ptr1[offset]. This is the same as ptr1 + offset * sizeof(type) AFAIK. It should be, at least.