Difficulty Compiling Magma in Fortran

Open discussion for MAGMA library (Matrix Algebra on GPU and Multicore Architectures)

Re: Difficulty Compiling Magma in Fortran

Postby fletchjp » Wed Jan 05, 2011 5:19 am


Thank you. I think I need to be patient and wait for RC3 for the FORTRAN interfaces. That is not too bad as I am back to the university and have lots of other things to do. I was so frustrated not having any CUDA hardware last autumn that I went and bought my own so it is at home. I did a lot of the work over the holiday. I know a shop in London (Yoyotech) and last time I was down there for a meeting I went to see them and when I saw they had a 2 Gig version of the GTX 460 I bought one and a box to run it on.

I work with a colleague who has some large matrix problems which I help him to run. We currently run the larger ones on ScaLAPACK and Parpack. I am using this work as a pilot to work out how much quicker we could run things if we had some GPUs as well.

I agree with you about single precision speed and I think that for the larger sizes the mixed precision will be the best option for problems where I want to solve Ax=b type problems. See dsgesv results below.

Two thoughts there. For my particular problem, it is more efficient to store the transpose of the matrix because it is generated a row at a time. There is an option to solve the transpose problem when using DGETRF and DGETRS separately, and I see gains with that with GotoBLAS (without GPU). There is not the same option with DGESV and DSGESV. I suspect I could get inside the code and generate a transpose version, but would that be an option which could be added?

Also, in some codes I want to factorise once and then solve several times. What would be needed to use the mixed precision approach to that?

Here are some results. This may be a mix of magma_blas and CUblas.

Code: Select all
fletcher@fletcher-desktop:~/magma_1.0.0-rc2/testing$ ./testing_dsgesv_gpu
device 0: GeForce GTX 460, 1400.0 MHz clock, 2047.2 MB memory

  testing_dsgesv_gpu -nrhs 1 -N 1024

Epsilon(double): 1.110223e-16
Epsilon(single): 5.960464e-08

  N   DP-Factor  DP-Solve  SP-Factor  SP-Solve  MP-Solve  ||b-Ax||/||A||  NumIter
 1024 32.70     26.48     43.38      37.64      11.56     1.565239e-16      3
 2048 48.86     44.12    122.34     119.92      42.16     1.120209e-15      3
 3072 58.57     54.45    176.71     168.60      66.74     1.795437e-16      3
 4032 63.05     59.39    256.07     250.92      78.07     4.456418e-14      4
 5184 66.34     63.62    286.66     282.16     118.01     3.926494e-16      3
 6016 67.78     65.28    299.07     293.68     116.43     1.428188e-14      4
 7040 69.05     66.99    307.25     304.99     147.38     1.091337e-15      3
 8064 70.37     68.50    320.73     316.82     141.02     2.429935e-16      4
 9088 71.22     69.49    327.65     322.49     156.68     8.076463e-15      4
10240 71.50     70.01    331.08     327.58     168.54     1.963176e-14      4

Best wishes

Posts: 203
Joined: Mon Dec 27, 2010 7:29 pm

Re: Difficulty Compiling Magma in Fortran

Postby LINDENSEO3 » Mon Jan 10, 2011 12:24 pm

thank you for the advise.
Posts: 2
Joined: Mon Jan 10, 2011 12:07 pm

Re: Difficulty Compiling Magma in Fortran

Postby LINDENSEO3 » Mon Jan 10, 2011 12:27 pm

thank you for the info
Posts: 2
Joined: Mon Jan 10, 2011 12:07 pm

Re: Difficulty Compiling Magma in Fortran

Postby DUCOM » Mon Nov 10, 2014 6:46 am

I have been trying to replace scalapack function pdgetrf() by magma's magma_dgetrf() for a while now. I use grortran comiler not PGI fortran compiler. I have read the article suggested above and replaced it accordingly. But, can't get a success in compiling the fortran source code. The following is a list of errorrs i am facing. any help please?

module magma_dfortran
Error: Non-numeric character in statement label at (1)

use magma_param
Error: Non-numeric character in statement label at (1)
Included at dmumps_part7.F:117:
Posts: 5
Joined: Thu Sep 25, 2014 1:39 am

Re: Difficulty Compiling Magma in Fortran

Postby mgates3 » Mon Nov 10, 2014 11:40 am

It's unclear to me exactly where you are getting this error. Do you get this error while compiling MAGMA, or while compiling your own code?

If while compiling MAGMA, please include details about your setup, e.g., your make.inc file and any environment variables that you set such as MKL_ROOT. Please include the input & output of the compiler on the file that fails to compile. E.g.,

Code: Select all
gfortran -fPIC -Wall -m64 -O3 -DADD_ -x f95-cpp-input -Dmagma_devptr_t="integer(kind=8)" -I/usr/local/cuda/include -I../include -I../control -I../sparse-iter/include -c magma_dfortran.F90 -o magma_dfortran.o

Error: Unclassifiable statement at (1)
make: *** [magma_dfortran.o] Error 1

If while compiling your own code, please include a snippet so we can see how you are calling MAGMA. Again, the complete input & output of the compile that failed is helpful.

Posts: 782
Joined: Fri Jan 06, 2012 2:13 pm

Re: Difficulty Compiling Magma in Fortran

Postby DUCOM » Wed Nov 12, 2014 9:20 am

I have read the suggested article http://www.pgroup.com/lit/articles/insider/v2n4a4.html to use magma from fortran . I am using MAGMA 1.5.0 version and CUDA 6.0. But the article is to use pgfortran. In my case it is gfortran.
I have generated random number using unix's built in function. I have attached the source code. When i try to compile as follows
gfortran -O3 -DADD_ -I/usr/local/cuda-6.0/include -I/home/aait/magma-1.5.0/control -c callmagmafromfortran.f -o callmagmafromfortran.o

it results the following error.

call cublas_set_matrix (M, N, sizeof_double, h_A, lda, d
Error: Syntax error in argument list at (1)

Code: Select all
!-------- include MAGMA module
               use magma_dfortran
!-------- declarations
               double precision,   allocatable, dimension(:) :: h_A, h_R
               integer, allocatable, dimension(:) :: ipiv
               integer :: d_A
               integer :: i, M=1024, N=1024,lda=1024
               REAL  :: rnumber       
              ! integer*8 off
               INTEGER info( 2 )
              ! integer(8) :: sizeof_double
              INTEGER ISEED
              REAL X
!--------- initialize CUBLAS
               call cublas_init()

!---------- allocate CPU memory
               allocate(h_A(M*N), h_R(M*N), ipiv(min(M,N)))

!---------- allocate GPU memory
                call cublas_alloc(M*N, sizeof_double, d_A)

!---------- Initializa the matrix
                do i=1,n*n
                  CALL RANDOM_SEED   (SIZE=ISEED)
                   !call random_number(rnumber)
                   h_A(i) = HARVEST(1)
                   h_R(i) = HARVEST(1)
                end do

!-----------  d_A = h_A
                call cublas_set_matrix (M, N, sizeof_double, h_A, lda, d_A, lda)

!----------- call MAGMA GPU interface
                 call magma_dgetrf_gpu(M, N, d_A, lda, ipiv, info)

!------------ Free GPU memory and exit
                 call cublas_free(d_A)
                 call cublas_shutdown()


Any help please?
Posts: 5
Joined: Thu Sep 25, 2014 1:39 am

Re: Difficulty Compiling Magma in Fortran

Postby mgates3 » Wed Nov 12, 2014 2:42 pm

See attached.

Added magmaf_init() and magmaf_finalize().
Changed magma_dgetrf_gpu to magmaf_dgetrf_gpu (with an F).
Changed h_A, h_R to 2D matrices, and allocate lda-by-N instead of M-by-N. Note that lda >= M. On the GPU, it is best if lda is rounded up to a multiple of 32.
Changed info to integer, not integer array.
Changed d_A to magma_devptr_t, that is, integer(8). Pointers are usually 64 bit nowadays.
Changed the random number generator to LAPACK's dlarnv, because the existing one didn't seem to work on my computer.

In Makefile, changed -I magma-1.5.0/control to -I magma-1.5.0/include. All the Fortran90 module files (*.mod) should be in MAGMA's include directory.
Added -Dmagma_devptr_t="integer(kind=8)", or you can just use integer(8) in the .f90 file.
The -DADD_ is not needed to compile Fortran files. It is used in C files to know how to call Fortran LAPACK & BLAS.
Added fortran.o, compiled from CUDA's file /usr/local/cuda/src/fortran.c. This has all the cublas_alloc, cublas_set_matrix, etc. calls.

(5 KiB) Downloaded 46 times
Posts: 782
Joined: Fri Jan 06, 2012 2:13 pm


Return to User discussion

Who is online

Users browsing this forum: Google [Bot] and 2 guests