MATLAB: Does GPU processing not offer significant speed-up over CPU processing for simple processes like addition of two matrices

gpugpuarrayParallel Computing Toolboxperformancespeedspeed up

I measured the time required to create two large matrices using RANDN and then to add them. There was no significant difference between the times taken by the CPU and the GPU.
The code to measure the CPU processing time is:
size = 10000;
tic
x = rand(size);
y = rand(size);
z = x + y;
toc
The code to measure the GPU processing time is:
size = 10000;
tic
xm = gpuArray(rand(size));
ym = gpuArray(rand(size));
zm = xm + ym;
toc
The attached excel sheet tabulates the speed-up for different sizes of the matrices.

Best Answer

The process of adding two matrices is not computationally intensive. The GPU is not able to exploit its computational efficiency for such simplistic operations. The overhead of transferring data to and from the GPU in this case outweighs the advantages of GPU processing.
As the processes get more complex, the speed-up offered by GPU processing becomes more apparent.
For example, after executing the following CPU processing code:
size = 10000;
tic
x = rand(size);
X = fft(x) ;
toc
The output is:
Elapsed time is 5.020353 seconds.
After executing the following GPU processing code:
size = 10000;
function gpu_test
xm = gpuArray(rand(size));
Xm = fft(xm) ;
end
t = gputimeit(gpu_test)
t = 0.42515 seconds.