12.07.2015 Views

CUBLAS Library

CUBLAS Library

CUBLAS Library

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.

CHAPTER A<strong>CUBLAS</strong> Fortran Bindingscalls. Longer function names and possible macro expansion arecontributing factors. Inadvertently exceeding the maximum linelength can lead to run‐time errors that are difficult to find, so careshould be taken not to exceed the 72‐column limit if fixed form isretained.The following examples show a small application implemented inFortran 77 on the host, and show the same application using the nonthunkingwrappers after it has been ported to use <strong>CUBLAS</strong>.Example A.1. Fortran 77 Application Executing on the Hostsubroutine modify (m, ldm, n, p, q, alpha, beta)implicit noneinteger ldm, n, p, qreal*4 m(ldm,*), alpha, betaexternal sscalcall sscal (n-p+1, alpha, m(p,q), ldm)call sscal (ldm-p+1, beta, m(p,q), 1)returnendprogram matrixmodimplicit noneinteger M, Nparameter (M=6, N=5)real*4 a(M,N)integer i, jdo j = 1, Ndo i = 1, Ma(i,j) = (i-1) * M + jenddoenddocall modify (a, M, N, 2, 3, 16.0, 12.0)do j = 1, Ndo i = 1, Mwrite(*,"(F7.0$)") a(i,j)enddowrite (*,*) ""PG-00000-002_V1.1 77NVIDIA

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

Saved successfully!

Ooh no, something went wrong!