19.11.2014 Views

Tutorial: Introduction to CUDA Fortran | GTC 2013

Tutorial: Introduction to CUDA Fortran | GTC 2013

Tutorial: Introduction to CUDA Fortran | GTC 2013

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Direct Transfer Example - Host Code (1/2)<br />

program minimal<br />

use cudafor<br />

use kernel<br />

implicit none<br />

integer, parameter :: n=32<br />

real :: a(n)<br />

real, device, allocatable :: a0_d(:), a1_d(:)<br />

integer :: nDevices, istat, access<br />

istat = cudaGetDeviceCount(nDevices)<br />

if (nDevices < 2) then<br />

write(*,*) 'Requires at least two GPUs'<br />

s<strong>to</strong>p<br />

end if<br />

istat = cudaDeviceCanAccessPeer(access, 1, 0)<br />

if (access /= 1) then<br />

write(*,*) 'Peer access not available'<br />

s<strong>to</strong>p<br />

end if

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!