FORTRAN UNDERSCORE

Open discussion for MAGMA library (Matrix Algebra on GPU and Multicore Architectures)
Post Reply
rom828
Posts: 2
Joined: Thu Jan 22, 2015 7:14 pm

FORTRAN UNDERSCORE

Post by rom828 » Fri Jan 23, 2015 1:58 am

I am new to this group and searched the forums, but could not find a solution.

I am trying to call MAGMA ( 1.6 ) libs from FORTRAN. e.g. I call "DLACPY". I have two issues:

1) The entry points have "magmablas_" at the front:

nvidialx <153> nm lib/libmagma.so | grep 'T magmablas_dlacpy'
00000000002e1170 T magmablas_dlacpy

While I can write a script to change my LAPACK calls to
add "magmablas_" to the call, that seems odd that I need to do it.
Is there a build flag so this does not happen?

2 ) My fortran is looking for names with trailing underscores, so even if I
change my code, my .o file will have:

NODE<105> nm FILE.o | grep -i dlacpy
U magmablas_dlacpy_

From the forums:

1 ) viewtopic.php?f=2&t=865&p=2326&hilit=underscore#p2326

implied if I changed include/magma_dlapack.h by adding an "_" it might work, but then I could not build:
#define lapackf77_dlacpy FORTRAN_NAME( dlacpy, DLACPY )

2 ) viewtopic.php?f=2&t=1065&p=2918&hilit=underscore#p2918

Implied by adding -DADD_ it would work, but it did not.

3 ) viewtopic.php?f=2&t=47&p=175&hilit=underscore#p175

Implied using "-fno-underscoring" but that is not an option.

mgates3
Posts: 918
Joined: Fri Jan 06, 2012 2:13 pm

Re: FORTRAN UNDERSCORE

Post by mgates3 » Mon Jan 26, 2015 9:03 pm

Regarding your points:
1) We provide Fortran wrappers around many magma routines, e.g., magmaf_dgetrf around magma_dgetrf. Note the "f" in magmaf_. E.g.,

Code: Select all

nm lib/libmagma.so | grep dgetrf | grep -v '_batched|_gpu|_mgpu|_nb|_nopiv|_piv'
                 U _dgetrf_
0000000000091820 T _magma_dgetrf
0000000000095f40 T _magma_dgetrf_m
00000000001d97c0 T _magmaf_dgetrf_
00000000001da970 T _magmaf_dgetrf_m_
However, we have not yet made wrappers around magmablas routines.

Yes, you need to add the magmaf_ prefix. This allows distinguishing between a call to LAPACK and a call to MAGMA. In many cases, these calls are not identical -- MAGMA may add a workspace, or take a matrix in GPU memory instead of in CPU memory, so they cannot be simply substituted for each other. In the case that you cite, lapack's zlacpy copies a matrix in CPU memory, while magmablas_zlacpy copies a matrix in GPU memory.

2) The magmaf_ wrappers automatically have a trailing underscore appended, as shown above, if need as indicated by the -DADD_ flag in the make.inc file. It is not (easily) possible to directly call a C routine from Fortran, as C and Fortran pass arguments differently. That is why a wrapper is required to translate from Fortran argument conventions to C argument conventions.

-mark

rom828
Posts: 2
Joined: Thu Jan 22, 2015 7:14 pm

Re: FORTRAN UNDERSCORE

Post by rom828 » Tue Jan 27, 2015 12:52 pm

Mark,

Thanks! I was looking at "dlacpy" for my test, but found all the other routines.

Have an excellent day,
Regards,
Joe

Post Reply