How can I accelerate this function with GPU arrayfun
Afficher commentaires plus anciens
Hi,
I want to accelerate a function like below with GPU. The real code is too complex so I put a simplified version here.
The main problem of this code is at the 5th line of nestedFcn: Indexing is not supported.
And the 1st line of nestedFcn : The size and shape for all variables must be the same. Variable 'test2' differs from 'test'.
Is there any way to do that?
% code
function gtest
Np=10;
test = zeros(Np);
test(1,1)=1;
E = rand(1,Np);
gpuVector = gpuArray.colon(1, Np);
function out = nestedFcn(k)
test2 = test*acos(E(k));
temp = rdivide(1,(rand()-test2));
% need a diag function below
for i_d=1:Np
out(i_d,1) = temp(i_d,i_d);
end
end
% Call arrayfun.
arrayfun(@nestedFcn, gpuVector)
end
1 commentaire
Viraj Gandhi
le 28 Déc 2022
Hey, I have the same problem. Could you find a solution?
Réponses (0)
Catégories
En savoir plus sur GPU Computing dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!