How can I accelerate this function with GPU arrayfun
Mostrar comentarios más antiguos
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 comentario
Viraj Gandhi
el 28 de Dic. de 2022
Hey, I have the same problem. Could you find a solution?
Respuestas (0)
Categorías
Más información sobre GPU Computing en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!