I am learning matlab GPU functions. My function myfun
takes 2 input parameters delta, p
. Eventually, I will apply myfun
to many combinations of delta,p
. For each combination of delta,p
, 'myfun' will how many V
's satisfies the condition delta*V-p>0
, where V = [0:0.001:1]
. Ideally, I want V
to be a global variable
. But it seems that matlab GPU has some restrictions on global variable. So I use another way to do this thing. The code is as the following:
function result = gpueg2()
dd = 0.1;
DELTA = [dd:dd:1];
dp = 0.001;
P = [0:dp:1];
[p,delta]=meshgrid(P,DELTA);
p = gpuArray(p(:));
delta = gpuArray(delta(:));
V = [0:0.001:1];
function [O] = myfun(delta,p)
O = sum((delta*V-p)>0);
end
result = arrayfun(@myfun,delta,p);
end
However, it through an error message
Function passed as first input argument contains unsupported or unknown function 'sum'.
But I believe sum
is applicable in GPU.
Any advice and suggestions are highly appreciated.