Tseng
1
hi everyone !
i’ve created my 2D host array : h_ucPicture[8192][16] ( BIG ARRAY :) )
and my 2D device array : *d_ucPicture=0;
Now, I’d like to allocate this device array. I want to use the cudaMallocPitch function :
this is what i’ve already done :
unsigned char h_ucPicture[HEIGHT][WIDTH];
unsigned char* d_ucPicture=0;
size_t pitch=sizeof(unsigned char)*HEIGHT*WIDTH;
cutilSafeCall( cudaMallocPitch((void**) &d_ucPicture, &pitch, WIDTH, HEIGHT));
Is this right ? because i dont really understand how this function works…
After, i decide to copy all datas from h_ucPicture to d_ucPicture :
I remember that WIDTH = 8192 and WIDTH = 16
It compiles but after excecuting i have a runtime error …
thanks for help! ! :unsure: :unsure:
cudaMallocPitch((void**) &d_ucPicture, &pitch, WIDTH, HEIGHT)), the third parameter should be WIDTH*sizeof(datatype).
You can check the detailed definition in http://developer.download.nvidia.com/compu…6e49be4a0b6d8db
And it isn’t need to assign the value to pitch because it will be filled after calling cudaMallocPitch.