Last active
January 4, 2016 04:59
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %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