I am writing a MEX function containing CUDA code and in the Host function I need to reset all array A
values to float 0.0
. This seems to work by destroying and re-creating the array:
mxGPUDestroyGPUArray(A);
A = mxGPUCreateGPUArray(1, &dims, mxSINGLE_CLASS, mxREAL, MX_GPU_INITIALIZE_VALUES);
Is there a more natural/elegant way to achieve the same result?
cudaMemset
expects a device pointer, whereas mxGPUCreateGPUArray
returns an mxGPUobject
. According to the documentation, one should be able to get this pointer using mxGPUGetData
. Also, the value
parameter needs to be of type int, instead of the float you're giving it. Luckily a floating point value of 0.0 corresponds to a binary (/integer) representation of 0
.
(question 'migrated' from comment)