The following script was used to compare performance of GPU vs CPU:
dev = gpuDevice;wait(dev);Narr=[1024:1024:5*1024];for i = 1:numel(Narr) N = Narr(i); A=rand(N,N); tic; x1=fft(A); cpuTime=toc; Ag=gpuArray(A); wait(dev); tic; x2=fft(Ag); wait(dev); gpuTime1=toc; fprintf('Size = %d, speedup = %f\n',N,cpuTime/gpuTime1)end
Why do we need to use the 'wait' function when timing GPU performance while this was not the case in MATLAB 7.13 (R2011b) and prior releases?
Best Answer