How can I accelerate this function with GPU arrayfun
Show older comments
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 Comment
Viraj Gandhi
on 28 Dec 2022
Hey, I have the same problem. Could you find a solution?
Answers (0)
Categories
Find more on GPU Computing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!