How to set all one gpuArray in mex?
조회 수: 3 (최근 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
채택된 답변
Edric Ellis
2021년 2월 16일
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').
댓글 수: 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!