Need some help in linking Magma

Dear All,

I am getting a generic error when I try to call the magma_dysgvd from a fortran code.

Here`s a snippet of my code:

! DSYGVD Example Program Text


! MAGMA INTERFACE

module magmafor
interface dsygvdmagma
subroutine dsygvdDev (ITYPE, JOBZ, UPLO, N, A, LDA, B, LDB, W, WORK, &
LWORK,IWORK, LIWORK, INFO) bind (c, name = ‘magma_dsygvd’)
use iso_c_binding
integer(c_int), value :: ITYPE, N, LDA, LDB, LWORK, LIWORK, INFO
character(kind = c_char), value :: JOBZ, UPLO
double precision(c_double), device, allocatable :: A(:,:), B(:,:), W(:), WORK(:)
! double precision(c_double), device, dimension (:) :: W(N), WORK(LWORK)
integer(c_int), device, ALLOCATABLE :: IWORK(:)
end subroutine dsygvdDev
end interface
end module magmafor

program main

use magmafor

INTEGER NIN, NOUT
PARAMETER (NIN=5,NOUT=6)
INTEGER NB, NMAX
PARAMETER (NB=64,NMAX=10)
INTEGER LDA, LDB, LIWORK, LWORK, error
PARAMETER (LDA=NMAX,LDB=NMAX,LIWORK=3+5NMAX,&
LWORK=1+(6+2
NMAX)*NMAX)

DOUBLE PRECISION, allocatable :: A(:,:), B(:,:), &
W(:), WORK(:)
double precision, device, allocatable :: dA(:,:), dB(:,:), &
dW(:), dWORK(:)
INTEGER IWORK(LIWORK)
integer, device, allocatable :: dIWORK(:)

WRITE (NOUT,) ‘DSYGVD Example Program Results’
WRITE (NOUT,
)

! Skip heading in data file
READ (NIN,)
READ (NIN,
) N
IF (N.LE.NMAX) THEN
!
allocate (A(LDA,NMAX),B(LDA,NMAX), W(NMAX), WORK(LWORK), stat=error)
if(stat1.ne.0) then
print*,‘error: couldn`t alloc memory’
end if

! Read the upper triangular parts of the matrices A and B

READ (NIN,) ((A(I,J),J=I,N),I=1,N)
READ (NIN,
) ((B(I,J),J=I,N),I=1,N)

allocate (dA(LDA,NMAX), dB(LDA,NMAX), dW(NMAX), dWORK(LWORK))
allocate (dIWORK(LIWROK))

dA = A
dB = B
dW = W
dWORK = WORK

! Magma call

call dsygvdmagma(1,‘V’,‘U’,N,dA,LDA,dB,dW,dWORK,LWORK,dIWORK,LIWORK,INFO)
!
! Solve the generalized symmetric eigenvalue problem
! ABx = lambdax (ITYPE = 2)
!
! CALL DSYGVD(2,‘Vectors’,‘Upper’,N,A,LDA,B,LDB,W,WORK,LWORK, &
! IWORK,LIWORK,INFO)
LWOPT = WORK(1)
LIWOPT = IWORK(1)
IF (INFO.EQ.0) THEN
!
W = dW
A = dA
! Print solution
!
WRITE (NOUT,
) ‘Eigenvalues’
WRITE (NOUT,99999) (W(J),J=1,N)
WRITE (NOUT,*) ‘Eigenvectors’
WRITE (NOUT,99999) ((A(I,J),J=1,N),I=1,N)

END IF



! Print workspace information
!
IF (LWORK.LT.LWOPT) THEN
WRITE (NOUT,)
WRITE (NOUT,99995) 'Optimum workspace required = ', LWOPT, &
'Workspace provided = ', LWORK
END IF
IF (LIWORK.LT.LIWOPT) THEN
WRITE (NOUT,
)
WRITE (NOUT,99995) 'Integer workspace required = ', LIWOPT, &
'Integer workspace provided = ', LIWORK
END IF
ELSE
WRITE (NOUT,*) ‘NMAX too small’
END IF

!
99999 FORMAT (3X,(6F11.4))
99998 FORMAT (4X,1P,6E11.1)
99997 FORMAT (1X,A,I4,A)
99996 FORMAT (1X,A,I4)
99995 FORMAT (1X,A,I5,/1X,A,I5)
deallocate(A)
deallocate(B)
deallocate(W,WORK)
deallocate(dA)
deallocate(dB)
deallocate(dW)
deallocate(dWORK)
deallocate(dIWORK)

end program

I compiled with:

dsygvdmagma: dsygvdmagma.f90
pgf90 -Mcuda -c $<
pgf90 -Mcuda -o $@ $@.o -L/sw/keeneland/magma/1.1/centos5.5_gnu4.4/magma_1.1.0/lib -R/sw/keeneland/magma/1.1/centos5.5_gnu4.4/magma_1.1.0/lib -lmagma -lmagmablas -lmagma -lcublas -llapack -lblas -lm

I am following the methodology given in this article:

Hi Ragavan,

When I compile your code I get the following syntax error:

GF90-S-0155-Could not resolve generic procedure dsygvdmagma (magma.F90: 67)

This is because you forgot the “LDB” argument in your call so the compiler can’t match which generic function to use.

Is this the same error that you’re seeing?

  • Mat

Hi Mkcolg,

Thank you so much for pointing it out.

I recompiled and got a bunch of errors :

pgf90 -Mcuda -c dsygvdmagma.f90
pgf90 -Mcuda -o dsygvdmagma dsygvdmagma.o -L/sw/keeneland/magma/1.1/centos5.5_gnu4.4/magma_1.1.0/lib -R/sw/keeneland/magma/1.1/centos5.5_gnu4.4/magma_1.1.0/lib -lmagma -lmagmablas -lmagma -lcublas -lm

/sw/keeneland/magma/1.1/centos5.5_gnu4.4/magma_1.1.0/lib/libmagma.a
(dsygvd.o): In function magma_dsygvd': dsygvd.cpp:(.text+0x8a): undefined reference to lsame_’
dsygvd.cpp:(.text+0x9d): undefined reference to lsame_' dsygvd.cpp:(.text+0x2b9): undefined reference to lsame_’
dsygvd.cpp:(.text+0x31f): undefined reference to lsame_' /sw/keeneland/magma/1.1/centos5.5_gnu4.4/magma_1.1.0/lib/libmagma.a(dpotrf_gpu.o): In function magma_dpotrf_gpu’:
dpotrf_gpu.cpp:(.text+0x58): undefined reference to lsame_' dpotrf_gpu.cpp:(.text+0x1a8): undefined reference to dpotrf_’
dpotrf_gpu.cpp:(.text+0x399): undefined reference to lsame_' dpotrf_gpu.cpp:(.text+0x3ea): undefined reference to dpotrf_’
dpotrf_gpu.cpp:(.text+0x508): undefined reference to dpotrf_' /sw/keeneland/magma/1.1/centos5.5_gnu4.4/magma_1.1.0/lib/libmagma.a(dsygst_gpu.o): In function magma_dsygst_gpu’:
dsygst_gpu.cpp:(.text+0x5c): undefined reference to lsame_' dsygst_gpu.cpp:(.text+0x60f): undefined reference to dsygs2_’
dsygst_gpu.cpp:(.text+0x74e): undefined reference to lsame_' dsygst_gpu.cpp:(.text+0xc73): undefined reference to dsygs2_’
dsygst_gpu.cpp:(.text+0xf19): undefined reference to dsygs2_' dsygst_gpu.cpp:(.text+0x16a6): undefined reference to dsygs2_’
/sw/keeneland/magma/1.1/centos5.5_gnu4.4/magma_1.1.0/lib/libmagma.a(xerbla.o): In function magma_xerbla': xerbla.cpp:(.text+0x1c): undefined reference to xerbla_’
/sw/keeneland/magma/1.1/centos5.5_gnu4.4/magma_1.1.0/lib/libmagma.a(dsyevd_gpu.o): In function magma_dsyevd_gpu': dsyevd_gpu.cpp:(.text+0x86): undefined reference to lsame_’
dsyevd_gpu.cpp:(.text+0x99): undefined reference to lsame_' dsyevd_gpu.cpp:(.text+0x264): undefined reference to dlamch_’
dsyevd_gpu.cpp:(.text+0x276): undefined reference to dlamch_' dsyevd_gpu.cpp:(.text+0x40f): undefined reference to dsterf_’
dsyevd_gpu.cpp:(.text+0x4c9): undefined reference to lsame_' dsyevd_gpu.cpp:(.text+0x4f0): undefined reference to lsame_’
dsyevd_gpu.cpp:(.text+0x5de): undefined reference to dstedc_' dsyevd_gpu.cpp:(.text+0x75c): undefined reference to dscal_’
/sw/keeneland/magma/1.1/centos5.5_gnu4.4/magma_1.1.0/lib/libmagma.a(dsytrd_gpu.o): In function magma_dsytrd_gpu': dsytrd_gpu.cpp:(.text+0x62): undefined reference to lsame_’
dsytrd_gpu.cpp:(.text+0x435): undefined reference to dsytrd_' dsytrd_gpu.cpp:(.text+0x524): undefined reference to lsame_’
dsytrd_gpu.cpp:(.text+0x921): undefined reference to dsytrd_' /sw/keeneland/magma/1.1/centos5.5_gnu4.4/magma_1.1.0/lib/libmagma.a(dlatrd.o): In function magma_dlatrd’:
dlatrd.cpp:(.text+0xaa): undefined reference to lsame_' dlatrd.cpp:(.text+0x160): undefined reference to dlarfg_’
dlatrd.cpp:(.text+0x344): undefined reference to dscal_' dlatrd.cpp:(.text+0x39d): undefined reference to ddot_’
dlatrd.cpp:(.text+0x3f4): undefined reference to daxpy_' dlatrd.cpp:(.text+0x4c9): undefined reference to dgemv_’
dlatrd.cpp:(.text+0x556): undefined reference to dgemv_' dlatrd.cpp:(.text+0x67a): undefined reference to dgemv_’
dlatrd.cpp:(.text+0x6ed): undefined reference to dgemv_' dlatrd.cpp:(.text+0x76e): undefined reference to dlarfg_’
dlatrd.cpp:(.text+0x9c1): undefined reference to dgemv_' dlatrd.cpp:(.text+0xa35): undefined reference to dgemv_’
dlatrd.cpp:(.text+0xab5): undefined reference to dgemv_' dlatrd.cpp:(.text+0xb41): undefined reference to dgemv_’
dlatrd.cpp:(.text+0xb78): undefined reference to dscal_' dlatrd.cpp:(.text+0xbdf): undefined reference to ddot_’
dlatrd.cpp:(.text+0xc41): undefined reference to daxpy_' dlatrd.cpp:(.text+0xcca): undefined reference to dgemv_’
dlatrd.cpp:(.text+0xd5a): undefined reference to dgemv_' dlatrd.cpp:(.text+0xddc): undefined reference to dgemv_’
dlatrd.cpp:(.text+0xe76): undefined reference to dgemv_' dlatrd.cpp:(.text+0xeb3): undefined reference to daxpy_’
/sw/keeneland/magma/1.1/centos5.5_gnu4.4/magma_1.1.0/lib/libmagma.a(dormtr_gpu.o): In function magma_dormtr_gpu': dormtr_gpu.cpp:(.text+0x87): undefined reference to lsame_’
dormtr_gpu.cpp:(.text+0x97): undefined reference to lsame_' dormtr_gpu.cpp:(.text+0xc7): undefined reference to lsame_’
dormtr_gpu.cpp:(.text+0x133): undefined reference to lsame_' dormtr_gpu.cpp:(.text+0x1a9): undefined reference to lsame_’
/sw/keeneland/magma/1.1/centos5.5_gnu4.4/magma_1.1.0/lib/libmagma.a(dormtr_gpu.o):dormtr_gpu.cpp:(.text+0x1cc): more undefined references to lsame_' follow /sw/keeneland/magma/1.1/centos5.5_gnu4.4/magma_1.1.0/lib/libmagma.a(dormqr2_gpu.o): In function magma_dormqr2_gpu’:
dormqr2_gpu.cpp:(.text+0x547): undefined reference to dlarft_' /sw/keeneland/magma/1.1/centos5.5_gnu4.4/magma_1.1.0/lib/libmagma.a(dormql2_gpu.o): In function magma_dormql2_gpu’:
dormql2_gpu.cpp:(.text+0x103): undefined reference to lsame_' dormql2_gpu.cpp:(.text+0x118): undefined reference to lsame_’
dormql2_gpu.cpp:(.text+0x1f9): undefined reference to lsame_' dormql2_gpu.cpp:(.text+0x221): undefined reference to lsame_’
dormql2_gpu.cpp:(.text+0x52b): undefined reference to dlarft_' /sw/keeneland/magma/1.1/centos5.5_gnu4.4/magma_1.1.0/lib/libmagmablas.a(dauxiliary.cu_o): In function cpu_gpu_ddiff’:
tmpxft_0000388c_00000000-1_dauxiliary.cudafe1.cpp:(.text+0x6ad): undefined reference to daxpy_' tmpxft_0000388c_00000000-1_dauxiliary.cudafe1.cpp:(.text+0x6d5): undefined reference to dlange_’
make: *** [dsygvdmagma] Error 2

Hi,

The errors were due to the passing of GPU memory as input parameters to the function. In the magma_dsygvd.cpp, I found that they have internal cudaMalloc and Cuda2DMemcpy and hence only a host pointer is reqd.

Though I got rid of all the linking errors, I still get the generic error. This time I have added LDB as per your suggestion.

Here`s my new code:
! MAGMA INTERFACE

module magmafor
interface dsygvd
subroutine dsygvdDev (ITYPE, JOBZ, UPLO, N, A, LDA, B, LDB, W, WORK, &
LWORK,IWORK, LIWORK, INFO) bind (c, name = ‘magma_dsygvd’)
use iso_c_binding
integer(c_int), value :: ITYPE, N, LDA, LDB, LWORK, LIWORK, INFO
character(kind = c_char), value :: JOBZ, UPLO
double precision(c_double), device, allocatable :: A(:,:), B(:,:), W(:), WORK(:)
! double precision(c_double), device, dimension (:) :: W(N), WORK(LWORK)
integer(c_int), device, ALLOCATABLE :: IWORK(:)
end subroutine dsygvdDev
end interface
end module magmafor


program main

use magmafor
integer :: ITYPE,NIN,NOUT,N,NMAX,NB,LDA,LDB,LWORK, LIWORK,INFO,stat
double precision, device, allocatable :: dA(:,:), dB(:,:), dW(:), dWORK(:)
double precision, allocatable :: A(:,:),B(:,:),W(:),WORK(:)
integer, device, allocatable :: dIWORK(:)
integer, allocatable :: IWORK(:)

ITYPE=0;
NIN=5
NOUT=6
NMAX=10
NB=64
LDA=NMAX
LDB=NMAX
LWORK=1+(6+NB+2*NMAX)NMAX
LIWORK=3+5
NMAX

WRITE (NOUT,) ‘DSYGVD Example Program Results’
WRITE (NOUT,
)
! Skip heading in data file
READ (NIN,)
READ (NIN,
) N

IF (N.LE.NMAX) THEN
allocate (A(LDA,NMAX), B(LDA,NMAX), W(NMAX), WORK(LWORK))
! allocate (dA(LDA,NMAX), dB(LDA,NMAX), dWORK(LWORK), dW(NMAX))
allocate (IWORK(LIWORK))
READ (NIN,) ((A(I,J),J=I,N),I=1,N)
READ (NIN,
) ((B(I,J),J=I,N),I=1,N)

subroutine dsygvdDev (ITYPE, JOBZ, UPLO, N, A, LDA, B, LDB, W, WORK, &
LWORK,IWORK, LIWORK, INFO) bind (c, name = ‘magma_dsygvd’)

call dsygvd(2,‘V’,‘U’,N,A,LDA,B,LDB,W,WORK,LWORK,IWORK,LIWORK,INFO)

if (INFO.EQ.0) then
write (NOUT,) ‘Eigenvalues’
write (NOUT,9999) (W(J),J=1,N)
write (NOUT,
) ‘EIGENVECTORS’
write (NOUT,9999) ((A(I,J),J=1,N),I=1,N)

end if
!double precision, device, allocate (dW(N),dWORK(N))
!real*8, dimension(LDA,N) :: A,B

!double precision, device, deallocate(dW,dWORK)
9999 FORMAT (3X,(6F11.4))
!deallocate (dA, dB, dWORK, dW, dIWORK)
deallocate (A, B, WORK, W, IWORK)
END IF
end program

Makefile:

magmatest2: magmatest2.f90
pgf90 -Mcuda -c $<
pgf90 -Mcuda -o $@ $@.o -L/sw/keeneland/magma/1.1/centos5.5_gnu4.4/magma_1.1.0/lib -R/sw/keeneland/magma/1.1/centos5.5_gnu4.4/magma_1.1.0/lib/ -lmagma -lmagmablas -lcublas -lcuda -lm

And I end up with this error again:

pgf90 -Mcuda -c magmatest2.f90
PGF90-S-0155-Could not resolve generic procedure dsygvd (magmatest2.f90: 50)
0 inform, 0 warnings, 1 severes, 0 fatal for main
make: *** [magmatest2] Error 2

When you changed your arguments to pass in the host variables, you forgot to change your interface. You need to remove the “device” attribute from the interface.

  • Mat

Hi Mat,

Thnku so much.
Now, the compiler is unable to find the magma_dsygvd.
But in the module, its bound to the magma_dsygvd routine.


pgf90 -Mcuda -c magmatest2.f90
pgf90 -Mcuda -o magmatest2 magmatest2.o -L /sw/keeneland/magma/1.1/centos5.5_gnu4.4/magma_1.1.0/lib -R /sw/keeneland/magma/1.1/centos5.5_gnu4.4/magma_1.1.0/lib/ -lmagma -lmagmablas -lcublas -lcuda -lm
magmatest2.o: In function main': /nics/c/home/krajag1/Research/./magmatest2.f90:45: undefined reference to magma_dsygvd’
make: *** [magmatest2] Error 2

Hi Ragavan,

How does the “magma_dsygvd” symbol show up in the Magma libraries?

To check run “nm libmagma.a | grep magma_dsygvd” or “nm libmagmablas.a | grep magma_dsygvd”.

Adjust the above commands as needed.

Also, what compiler did you use to build Magma?

  • Mat

U magma_dsygvd

0000000000000000 T magma_dsygvd

Hmm. It’s there so I’m unclear why the linker is not resolving it. Though, it is odd there’s an unresolved reference (the U) as well, Could this be from the magamblas lib?

Try linking with the verbose flag (-v) and let’s see what’s happening under the hood. Also, let’s remove the “-R” flag since it might be trying to dynamically link the magma libs. Finally, add a second “-lmagma” in case magmablas references magma.

pgf90 -v -Mcuda -o magmatest2 magmatest2.o -L /sw/keeneland/magma/1.1/centos5.5_gnu4.4/magma_1.1.0/lib -lmagma -lmagmablas -lcublas -lcuda -lm -lmagma
  • Mat

Hi Mat,

The errors were due to missing lapack and blas libraries in the linker.
Here`s the final makefile:

pgfortran -Mcuda -c magmatest2.f90
pgfortran -v -Mcuda -o magmatest2 magmatest2.o -L/sw/keeneland/magma/1.1/centos5.5_gnu4.4/magma_1.1.0/lib -lcuda -lmagma -lmagmablas -lmagma -lcublas -L/opt/intel/mkl/lib/intel64/ -L/sw/keeneland/cuda/4.0/linux_binary/lib64 -lmkl_intel_lp64 -lmkl_pgi_thread -lmkl_core -mp -lpthread -lcudart -lm -pgf90libs

/usr/bin/ld /usr/lib64/crt1.o /usr/lib64/crti.o /nics/e/sw/local/keeneland/opt/pgi/12.3/linux86-64/12.3/lib/trace_init.o /usr/lib/gcc/x86_64-redhat-linux/4.1.2/crtbegin.o /nics/e/sw/local/keeneland/opt/pgi/12.3/linux86-64/12.3/lib/initmp.o /nics/e/sw/local/keeneland/opt/pgi/12.3/linux86-64/12.3/lib/f90main.o -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /nics/e/sw/local/keeneland/opt/pgi/12.3/linux86-64/12.3/lib/pgi.ld -L/sw/keeneland/magma/1.1/centos5.5_gnu4.4/magma_1.1.0/lib -L/opt/intel/mkl/lib/intel64/ -L/sw/keeneland/cuda/4.0/linux_binary/lib64 -L/nics/e/sw/local/keeneland/opt/pgi/12.3/linux86-64/12.3/lib -L/usr/lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.1.2 magmatest2.o -lcuda -lmagma -lmagmablas -lmagma -lcublas -lmkl_intel_lp64 -lmkl_pgi_thread -lmkl_core -lpthread -lcudart -lm -rpath /nics/e/sw/local/keeneland/opt/pgi/12.3/linux86-64/12.3/lib -rpath /nics/e/sw/local/keeneland/opt/pgi/12.3/linux86-64/2012/cuda/4.0/lib64 -o magmatest2 -lcudafor4 -lcudaforblas4 -L/nics/e/sw/local/keeneland/opt/pgi/12.3/linux86-64/2012/cuda/4.0/lib64 -lcudart -lpgmp -lnuma -lpthread -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -lnspgc -lpgc -lrt -lpthread -lm -lgcc -lc -lgcc /usr/lib/gcc/x86_64-redhat-linux/4.1.2/crtend.o /usr/lib64/crtn.o


Now, I am getting a seg fault from the magma call, when I try the same input data from GitHub - numericalalgorithmsgroup/LAPACK_Examples: Example programs showing how to call LAPACK driver and computational routines (Fortran double precision)

Thanks,
Ragavan

Hi Matt,

I am getting a parameter error for the magma interface. I have tried integer*8 as an input variable too.

Here`s my new code:

MAGMA INTERFACE

module magmafor
interface dsygvdmagma
subroutine dsygvdDev (ITYPE, JOBZ, UPLO, N, A, LDA, B, LDB, W, WORK, &
LWORK,IWORK, LIWORK, INFO) bind (c, name = ‘magma_dsygvd’)
use iso_c_binding
IMPLICIT NONE
!integer(c_int) :: ITYPE, N, LDA, LDB, LWORK, LIWORK, INFO
integer*4 :: ITYPE, N, LDA, LDB, LWORK, LIWORK, INFO
character(kind = c_char) :: JOBZ, UPLO
double precision(c_double) :: A(LDA,N), B(LDA,N), W(N), WORK(LWORK)
integer(c_int) :: IWORK(LIWORK)
end subroutine dsygvdDev
end interface
end module magmafor

program main

use magmafor

INTEGER NIN, NOUT
PARAMETER (NIN=5,NOUT=6)
INTEGER :: NB, NMAX
PARAMETER (NB=64,NMAX=10)
INTEGER4 :: ITYPE,itype4,LDA, LDB, LIWORK, LWORK, error
integer
8 :: itype8
PARAMETER (ITYPE=2,LDA=NMAX,LDB=NMAX,LIWORK=3+5NMAX,&
LWORK=1+(6
NMAXNB+2NMAX*NMAX))

DOUBLE PRECISION :: A(LDA,NMAX), B(LDA,NMAX), &
W(NMAX), WORK(LWORK)

integer :: IWORK(LIWORK)

open(NIN,file=‘dsygvd.dat’,form=‘formatted’)
WRITE (NOUT,) ‘DSYGVD Example Program Results’
WRITE (NOUT,
)

! Skip heading in data file
READ (NIN,)
READ (NIN,
) N
IF (N.LE.NMAX) THEN

! Read the upper triangular parts of the matrices A and B

READ (NIN,) ((A(I,J),J=I,N),I=1,N)
READ (NIN,
) ((B(I,J),J=I,N),I=1,N)

!call DSYGVD(ITYPE,‘V’,‘U’,N,A,LDA,B,LDB,W,WORK,LWORK,IWORK,LIWORK,INFO)

!IF (INFO.EQ.0) THEN
!
! Print solution
!
!WRITE (NOUT,) ‘Eigenvalues’
!WRITE (NOUT,99999) (W(J),J=1,N)
!WRITE (NOUT,
) ‘Eigenvectors’
!WRITE (NOUT,99999) ((A(I,J),J=1,N),I=1,N)

!END IF
! Magma call

itype2=2
itype4=2
itype8=2

call dsygvdmagma(itype4,‘V’,‘U’,N,A,LDA,B,LDB,W,WORK,LWORK,IWORK,LIWORK,INFO)

LWOPT = WORK(1)
LIWOPT = IWORK(1)
!

IF (INFO.EQ.0) THEN
!
! Print solution
!
WRITE (NOUT,) ‘Eigenvalues’
WRITE (NOUT,99999) (W(J),J=1,N)
WRITE (NOUT,
) ‘Eigenvectors’
WRITE (NOUT,99999) ((A(I,J),J=1,N),I=1,N)

END IF

! Print workspace information
!
IF (LWORK.LT.LWOPT) THEN
WRITE (NOUT,)
WRITE (NOUT,99995) 'Optimum workspace required = ', LWOPT, &
'Workspace provided = ', LWORK
END IF
IF (LIWORK.LT.LIWOPT) THEN
WRITE (NOUT,
)
WRITE (NOUT,99995) 'Integer workspace required = ', LIWOPT, &
'Integer workspace provided = ', LIWORK
END IF
ELSE
WRITE (NOUT,*) ‘NMAX too small’
END IF

99999 FORMAT (3X,(6F11.4))
99998 FORMAT (4X,1P,6E11.1)
99997 FORMAT (1X,A,I4,A)
99996 FORMAT (1X,A,I4)
99995 FORMAT (1X,A,I5,/1X,A,I5)
end program


Makefile:

FORT = pgfortran
PGIFLAGS = -Mcuda
TGT = magmatest3
CUDADIR = /sw/keeneland/cuda/4.0/linux_binary/
MAGMALIB = /sw/keeneland/magma/1.1/centos5.5_gnu4.4/magma_1.1.0/lib
#LIB = -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lcublas -lm
CUDADIR = /sw/keeneland/cuda/4.0/linux_binary
MKLROOT = /opt/intel/composer_xe_2011_sp1.8.273/mkl
#LIBDIR = -L/opt/intel/Compiler/11.1/038/lib/intel64 -L$(MKLROOT)/lib/em64t \

LIBDIR = -L/opt/intel/composer_xe_2011_sp1/lib/intel64 -L$(MKLROOT)/lib/intel64 -L$(CUDADIR)/lib64
LIB = -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lcublas -lm
PGILIB = -lmkl_intel_lp64 -lmkl_pgi_thread -lmkl_core -mp -lpthread -lm -pgf90libs -lcublas -lcudart -lm

INCD = -mp -pgf90libs -I$(MKLROOT)/include
$(TGT): $(TGT).f90
$(FORT) -g $(PGIFLAGS) -c $<
$(FORT) $(INCD) -g $(PGIFLAGS) -o $@ $@.o -L$(MAGMALIB) -lcuda -lmagma -lmagmablas -lmagma $(LIBDIR) $(PGILIB)