Skip to content

Instantly share code, notes, and snippets.

@brockpalen
Last active January 4, 2016 04:59
Show Gist options
  • Select an option

  • Save brockpalen/8572398 to your computer and use it in GitHub Desktop.

Select an option

Save brockpalen/8572398 to your computer and use it in GitHub Desktop.
This example shows simple use of gpuArray() to use built in GPU functions on MATLAB
%Brock Palen [email protected] 1/2014
%To compare against a single core run:
% hwloc-bind core:0 matlab -r caenfft\(1e7\)
function caenfft(dim)
if ischar(dim)
dim=str2num(dim);
end
%wakeup the gpu takes ~12 seconds
II = gpuArray.eye(10,'int32');
i=1:dim;
a=2.0*pi*i/10;
disp('CPU fft call')
tic; fft(a); toc
disp(' ')
disp('Time to move array to GPU and run the GPU fft copy results back to host')
tic;
Ga=gpuArray(a);
Gout = fft(Ga);
out = gather(Gout);
toc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment