I am using matlab GPU computing with function arrayfun and a gpuArray object to do element-wise function on elements of the gpuArray variable on my function:
[ output ] = MyFunc( element, SharedMatrix )
//
// Process element with Shared Matrix
//
end
and my code is like so:
SharedMatrix = magic(5000); %Large Memory Object
SharedMatrix = gpuArray(SharedMatrix);
elements = magic(5);
gpuElements = gpuArray(elements );
//Error on next line, SharedMatrix object must be a scaler.
result = arrayfun(@MyFunc,gpuElements,SharedMatrix);
I’ve heard that global variables can’t be used in GPU computing.
Is there a way to do so with arrayfun ?
arrayfuncurrently require all inputs to be compatible sizes (or scalars), and the processing is done in an elementwise manner.Also,
Parallel Computing Toolboxin Matlab don’t supportGlobal Variables, So it can’t be done using theParallel Computing Toolbox.