Guidance on building FORTRAN wrappers

Open discussion for MAGMA library (Matrix Algebra on GPU and Multicore Architectures)
Post Reply
fletchjp
Posts: 203
Joined: Mon Dec 27, 2010 7:29 pm

Guidance on building FORTRAN wrappers

Post by fletchjp » Mon Sep 21, 2015 6:19 pm

I am wishing to run some routines such as magma_zcgesv from FORTRAN. There are wrappers for quite a lot of routines but not for this one.

I can see that the control subdirectory contains the files magma_zfortran.F90 and magma_zf77.cpp and it looks as though I can use some of the code there as a model to build my own wrappers. The macro FORTRAN_NAME is defined in include/magma_mangling.h

Are there any notes to follow to make a wrapper?

I may also want to build a modified version of magma_zcgesv and build a wrapper for that, compiling it outside magma. Would that be any different?

Thanks

John

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

Re: Guidance on building FORTRAN wrappers

Post by mgates3 » Tue Sep 22, 2015 1:40 am

The attached may help. I just did these real quick with a script that we use, but they do at least compile. Let us know if you have any problems with them.
-mark
Attachments
mixed_wrappers.tar.gz
(1.49 KiB) Downloaded 73 times

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

Re: Guidance on building FORTRAN wrappers

Post by fletchjp » Tue Sep 22, 2015 4:24 am

Mark

Thank you for the quick response. I have had a look at these files. Presumably I just compile and link these files into my code.

John

P.S. I am currently using Magma 1.6.2

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

Re: Guidance on building FORTRAN wrappers

Post by mgates3 » Wed Sep 23, 2015 1:29 pm

Yes. They mirror existing files in the control directory, adding Fortran wrappers for the mixed precision routines. We base the Fortran wrappers off the header files (e.g., include/magma_z.h), and the mixed routines have their own header files (e.g., include/magma_zc.h), which is why they weren't included before.

I don't think we've changed any of these routines since 1.6.2, so they should still work there.

-mark

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

Re: Guidance on building FORTRAN wrappers

Post by fletchjp » Thu Sep 24, 2015 6:26 am

Mark

Thank you for this. I will give these a try out.

John

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

Re: Guidance on building FORTRAN wrappers

Post by fletchjp » Sat Sep 26, 2015 12:32 pm

I have built the attached Fortran program testing_zcgesv_gpu_f by extending the Fortran one for zgetrf_gpu with material suggested by the C++ one for zcgesv_gpu.

This routine does a similar calculation to the one in the Fortran one for zgetrf_gpu with magma_zcgesv_gpu as well and prints both sets of answers.

The output is like this:

Code: Select all

 size_of_int =            4
 ZCGESV iters :            3

 Solving A x = b using mixed precision factorization:
                         || A || =  1.063E+03
                         || b || =  9.994E-01
                         || x || =  1.908E+00
                   || b - A x || =  3.642E-14

   Gflops  =    38.019799967504056     

                Solution is CORRECT

 Solving A x = b using LU factorization:
                         || A || =  1.063E+03
                         || b || =  9.994E-01
                         || x || =  1.908E+00
                   || b - A x || =  9.535E-13

   Gflops  =    13.994576034374978     

                Solution is CORRECT
I hope this is useful

John

P.S. As this is my 200th message, I want to thank the MAGMA team for all your help over the years I have been in contact with you. Best wishes.
Attachments
testing_zcgesv_gpu_f.F90.txt
Test file for zcgesv_gpu from Fortran. I added the extension .txt as the system does not allow F90 as an extension!
(7.07 KiB) Downloaded 66 times

Post Reply