You basically have two options: either create and uninitialized mxGPUArray and fill the values using CUDA code (either a kernel, or one of the cuMemset* variants if your data type is small enough), or pass in to your MEX function an array of ones that you create in MATLAB using ones(...,'gpuArray').
How to set all one gpuArray in mex?
2 次查看(过去 30 天)
显示 更早的评论
Hi,
I need to set a all-one double gpuArray. I think I could use mxGPUCreateGPUArray to initial it. But it seems mxGPUCreateGPUArray could only initial a all-zero array like below.
mxGPUArray *x = mxGPUCreateGPUArray(ndim, dims, mxDOUBLE_CLASS, mxREAL, MX_GPU_INITIALIZE_VALUES);
Is there any good way to do this? Do I need to write a kernel function to do it with cuda function? Thank you.
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 GPU CUDA and MEX Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!