cudaMemset3D for cudaArray

Hi,

Is there an equivalent of cudamemset3D for a cudaArray allocated by cudaMalloc3DArray()?

The way I’m doing it now is:

cudaPitchedPtr d_volPPtr;

cudaArray *d_phiArray;

//mem allocations...

cudaMemset3D(d_volPPtr, 0, make_cudaExtent(subvolDim*sizeof(float), subvolDim, subvolDim));

copy3DMemToArray(d_volPPtr, d_phiArray);

But this is wasteful! Any suggestions?

-Oj

[quote name=‘ojaswa’ post=‘509819’ date=‘Feb 24 2009, 09:14 AM’]

Hi,

Is there an equivalent of cudamemset3D for a cudaArray allocated by cudaMalloc3DArray()?

The way I’m doing it now is:

[codebox] const cudaExtent volumeSize = make_cudaExtent(width, height, depth);

float* dummyarray = (float*) calloc(widthheightdepth, sizeof(float));

cudaMemcpy3DParms copyParams = {0};

copyParams.extent   = volumeSize;

copyParams.kind     = cudaMemcpyHostToDevice;

copyParams.srcPtr   = make_cudaPitchedPtr((void*)dummyarray, volumeSize.width*sizeof(float), volumeSize.width, volumeSize.height);

copyParams.dstArray = ca_vx0;

cudaMemcpy3D(&copyParams);

free(dummyarray);[/codebox]

Cheers

Yes, yours should also work, albeit slower than my version, since host to device transfers are slower than device to device transfers.

Although I use host to device transfers if I have to set floating point values other than zero.

This raises another question. Can I really use cudaMemset3D to set any arbitrary floating point value? I guess I would need the correct integer representation of that floaing point value. Is the following correct in that case?

[codebox] const cudaExtent volumeSize = make_cudaExtent(width, height, depth);

float* dummyarray = (float*) calloc(widthheightdepth, sizeof(float));

cudaMemcpy3DParms copyParams = {0};

copyParams.extent   = volumeSize;

copyParams.kind     = cudaMemcpyHostToDevice;

copyParams.srcPtr   = make_cudaPitchedPtr((void*)dummyarray, volumeSize.width*sizeof(float), volumeSize.width, volumeSize.height);

copyParams.dstArray = ca_vx0;

cudaMemcpy3D(&copyParams);

free(dummyarray);[/codebox]

Cheers

[/quote]