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.

Separate Compilation<br />

module kernel_m<br />

contains<br />

attributes(global) subroutine difference(a,b)<br />

use devFunc_m<br />

integer :: a, b, c<br />

c = b<br />

call negate(c)<br />

a = a+c<br />

end subroutine difference<br />

end module kernel_m<br />

$ pgf90 -Mcuda=rdc -c devFunc.cuf<br />

$ pgf90 -Mcuda=rdc -c kernel.cuf<br />

$ pgf90 -Mcuda=rdc aMinusB.cuf devFunc.o kernel.o<br />

module devFunc_m<br />

contains<br />

attributes(device) subroutine negate(a)<br />

integer :: a<br />

a = -a<br />

end subroutine negate<br />

end module devFunc_m<br />

program aMinusB<br />

use kernel_m<br />

integer :: a<br />

integer, device :: a_d, b_d<br />

a_d = 2; b_d = 3<br />

call difference(a_d, b_d)<br />

a = a_d<br />

write(*,"('2-3=',i0)") a<br />

end program aMinusB

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

Saved successfully!

Ooh no, something went wrong!