magmaf_sgetrf_gpu - rank mismatch

12 views
Skip to first unread message

Daniele Peri

unread,
Oct 30, 2025, 4:25:27 PM (6 days ago) Oct 30
to MAGMA User
Hi all,
I'm trying libraries on a fairly simple problem of factoring a square matrix in Fortran.
Unfortunately I see that the documentation is only for version C, so I can only find the description of the arguments related to implementation C

magma_int_t magma_sgetrf_gpu ( magma_int_t m,
magma_int_t n,
magmaFloat_ptr dA,
magma_int_t ldda,
magma_int_t * ipiv,
magma_int_t * info )

but the same for magmaf_sgetrf_gpu is not available.

If I try to compile, I see

NVFORTRAN-S-0446-Argument number 3 to magmaf_sgetrf_gpu: rank mismatch.

Does anyone have some sort of explanation for the correct use of this subroutine?

Thanks in advance,

Daniele

P.S.: magmaf_sgetrf works perfectly, but I need the _gpu version too.

Natalie Beams

unread,
Oct 30, 2025, 4:39:50 PM (6 days ago) Oct 30
to Daniele Peri, MAGMA User
Hi Daniele,

It might be helpful if you could show us your code of how you are trying to use magma_sgetrf_gpu.

Also, there is testing/testing_zgetrf_gpu_f.F90, which shows an example of using zgetrf_gpu for Fortran and is used to generate tests for the other precisions. If you build the sgetrf version (`make testing/testing_sgetrf_gpu_f`), it should generate the single precision version of the test.


-- Natalie

--
You received this message because you are subscribed to the Google Groups "MAGMA User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to magma-user+...@icl.utk.edu.
To view this discussion visit https://groups.google.com/a/icl.utk.edu/d/msgid/magma-user/d870fe22-731a-4ac9-9e5a-f99ed1de2c28n%40icl.utk.edu.

Daniele Peri

unread,
Oct 31, 2025, 9:25:35 AM (6 days ago) Oct 31
to MAGMA User, Natalie Beams, MAGMA User, Daniele Peri
Dear Natalie,

if I try to compile testing_zgetrf_gpu_f.f90 I get the error

NVFORTRAN-S-0034-Syntax error at or near :: (testing_zgetrf_gpu_f.f90: 22)
NVFORTRAN-S-0034-Syntax error at or near :: (testing_zgetrf_gpu_f.f90: 23)

where line 22 and 23 are

    magma_devptr_t                :: dA, dB, dX, dwork
    magma_devptr_t                :: queue

MAGMA is the one from the github website, compilation as successful.

I compile with

nvfortran $1.f90 -Minfo=accel -fast -acc -gpu=ccnative -tp=native -L$MAGMADIR/lib -I$MAGMADIR/include -lm -lmagma -lmagma_sparse -lcuda -lstdc++ -lcudart -lcusparse -lcublas -lblas -llapack -o $1

where $1 is the file name without extension.

Any suggestion?

Thanhs!

Daniele

Natalie Beams

unread,
Oct 31, 2025, 11:51:56 AM (6 days ago) Oct 31
to Daniele Peri, MAGMA User
Hi Daniele,

We (some MAGMA developers) just had a discussion about this at a meeting. We have two suggestions:

1) try another compiler, like gfortran. Or,
2) try using `iso_c_binding` and calling the C version of the routine (magma_sgetrf_gpu). An example of this is in testing_zgetrf_gpu_f.cuf 
(https://github.com/icl-utk-edu/magma/blob/master/testing/testing_zgetrf_gpu_f.cuf). 

-- Natalie

Mark Gates

unread,
Oct 31, 2025, 1:47:21 PM (6 days ago) Oct 31
to Natalie Beams, Daniele Peri, MAGMA User
Hi Daniele,

Did you define magma_devptr_t anywhere? I don't see it on your compile line. Normally, the Makefile defines this:

gfortran ... -Dmagma_devptr_t="integer(kind=8)" -c testing/testing_zgetrf_gpu_f.F90

Mark

Daniele Peri

unread,
Nov 3, 2025, 10:06:23 AM (3 days ago) Nov 3
to MAGMA User, mga...@icl.utk.edu, Daniele Peri, MAGMA User, Natalie Beams
Hi, Natalia and Mark,
unfortunately, none of the suggestions work in my installation.

I cannot use gfortran, since magma was compiled with nvfortarn, so gfortran does not recognize magma.mod

use magma
      |         1
Fatal Error: File ‘/opt/magma/bin/2.9.0/nvf/25.9/include/magma.mod’ opened at (1) is not a GNU Fortran module file

and also cudafor

  13 |       use cudafor
      |           1
Fatal Error: Cannot open module file ‘cudafor.mod’ for reading at (1): No such file or directory

To use gfrotran, I must recompile magma, but at the end this is good for debugging purpose only, since gfortran does not support gpu.

The key point appears to be "magma_devptr_t". If I try the fortran version magmaf_, as from testing_zgetrf_gpu_f, I have

NVFORTRAN-S-0034-Syntax error at or near :: (testing_zgetrf_gpu_f.f90: 23)
NVFORTRAN-S-0034-Syntax error at or near :: (testing_zgetrf_gpu_f.f90: 24)

and the two lines are

    magma_devptr_t                :: dA, dB, dX, dwork
    magma_devptr_t                :: queue

If I simply defint dA, dB... as

    integer ( kind=8 ), pointer   :: dA, dB, dX, dwork
    integer ( kind=8 ), pointer   :: queue

implicitly following the suggestion by Mark, the code complies but once I run it I have

Segmentation fault (core dumped)

If I remove ",pointer", magically

    n   nrhs     nb         error        error2       Gflop/s  status
  100     10     32    0.6273E-18    0.6273E-18        0.0920  ok              
  200     10     32    0.4941E-18    0.5181E-18        0.0328  ok              
  300     10     32    0.4094E-18    0.4120E-18        5.8084  ok              
  400     10     32    0.3657E-18    0.3688E-18       11.8452  ok              
  500     10     32    0.3812E-18    0.3830E-18       17.0900  ok              
  600     10     32    0.3945E-18    0.3932E-18       20.6277  ok              
  700     10     32    0.2965E-18    0.2978E-18       37.1873  ok              
  800     10     32    0.3567E-18    0.3550E-18       46.4642  ok              
  900     10     32    0.3151E-18    0.3166E-18       53.3761  ok              
 1000     10     32    0.3051E-18    0.3049E-18       60.4794  ok

and I have not added the option -Dmagma_devptr_t="integer(kind=8)"

Applying all the corrections to the single precision version (I need), a fast check on a 2x2 matrix appears to be positive

A
    2.000000        1.000000
    3.000000        4.000000    

Inv(A)
   0.8000000      -0.2000000
  -0.6000000       0.4000000

Thank you very much for all your work!!!

Daniele
Reply all
Reply to author
Forward
0 new messages