Tutorial: Introduction to CUDA Fortran | GTC 2013
Tutorial: Introduction to CUDA Fortran | GTC 2013
Tutorial: Introduction to CUDA Fortran | GTC 2013
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 (2/2)<br />
istat = cudaSetDevice(1)<br />
istat = cudaDeviceEnablePeerAccess(0, 0)<br />
istat = cudaSetDevice(0)<br />
allocate(a0_d(n))<br />
istat = cudaSetDevice(1)<br />
allocate(a1_d(n))<br />
istat = cudaSetDevice(0)<br />
a = 0.0; a0_d = a<br />
call inc(a0_d, 1.0)<br />
istat = cudaSetDevice(1)<br />
a1_d = a0_d<br />
call inc(a1_d, 1.0)<br />
a = a1_d<br />
write(*,*) 'max error = ', maxval(abs(a-2))<br />
deallocate(a1_d)<br />
istat = cudaSetDevice(0)<br />
deallocate(a0_d)<br />
end program minimal