How do I construct a complex gpuArray directly on the GPU?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Kevin
le 12 Sep 2017
Commenté : Jacob Lynch August
le 9 Nov 2018
I am trying to initialize a complex gpuArray directly on the GPU (i.e. without first creating a complex array in host memory and then copying it over to the device).
So far the only thing I've found that works is:
foo = gpuArray(complex(0));
bar = zeros(4, 1, 'like',foo);
which seems kinda silly. Is there a way to allocate a complex gpuArray directly using something like gpuArray.zeros?
0 commentaires
Réponse acceptée
Edric Ellis
le 12 Sep 2017
None of MATLAB's build methods (the zeros, ones family) build complex arrays, so the nearest you can get is to do something like:
complex(zeros(3, 'gpuArray'))
which never allocates any host memory, and results in a complex gpuArray.
1 commentaire
Jacob Lynch August
le 9 Nov 2018
What about elements on the host that need to be transferred to the GPU, like
G = complex( gpuArray(V(:,1)), gpuArray(:,2) );
It seems silly to me to have those two temporary gpuArrays.
Plus de réponses (1)
KSSV
le 12 Sep 2017
G = gpuArray(rand(10,1)+1i*rand(10,1));
2 commentaires
Jacob Lynch August
le 9 Nov 2018
Alternatively:
complex(gpuArray.rand(size,type),gpuArray(size,type))
Voir également
Catégories
En savoir plus sur GPU Computing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!