How can a create a vector directly on GPU, just like we can create a vector on CPU?

2 次查看(过去 30 天)
lut = [0;0;1;1;0;0;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1];
How can I create the above vector directly on GPU.
i want to avoid gpuArray(lut). Because it takes extra time for transferring data.

采纳的回答

Joss Knight
Joss Knight 2018-7-4
It's a little bit far-fetched to expect to be able to create an arbitrary array directly on the GPU - after all, the only way to read in the numbers you type is via main memory.
However, there are many standard build functions that create default arrays directly on the GPU: https://uk.mathworks.com/help/distcomp/establish-arrays-on-a-gpu.html#bspvmhe-1
For instance, in your case you might go:
lut = ones(40, 1, 'gpuArray');
lut([1 2 5 6]) = 0;

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 GPU Computing 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by