1
votes

Is there any way to do an arrayfun with a shared matrix in a gpuArray type?

In my case I wanted to make the sum of two or more columns of a gpuArray matrix, but i dont know how to implement in a gpuFunction, arrayfun is the best option?

I wanted to make this easy operation in a CUDA because I need to make a million of this kind of operations with the different combinations.

Thank you very much.

Im going to explain the problem better.If you see my problem is like that

functionarrayfun = @(row)functionMex(data1,data2,row );

i = 1:length(tablaCombinaciones(:,1));%from 1 to end of rows

ratio = arrayfun(functionarrayfun,i);

Error using gpuArray/arrayfun Indexing is not supported. error at line: 6

1
As an alternative to arrayfun, gpuArray and gpuFunction, you could try to write your function directly in CUDA, compiling it with nvcc and then linking it under Matlab as a mex-file. - Vitality
yes i knew it, but im asking because i wanted to know if there were any other way to do it, i wanted to avoid c , but i think i will have to do it - Javi Falces

1 Answers

1
votes

Arrayfun and bsxfun work with a gpuArray:

See the example:

A = gpuArray.rand(100,2);
B = A(:,1);
C = A(:,2);
bsxfun(@plus,A(:,1),A(:,2))
arrayfun(@(x,y)x+y,A(:,1),A(:,2))