Page 1 of 1
Guidance on building FORTRAN wrappers
Posted: Mon Sep 21, 2015 6:19 pm
by fletchjp
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
Re: Guidance on building FORTRAN wrappers
Posted: Tue Sep 22, 2015 1:40 am
by mgates3
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
Re: Guidance on building FORTRAN wrappers
Posted: Tue Sep 22, 2015 4:24 am
by fletchjp
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
Re: Guidance on building FORTRAN wrappers
Posted: Wed Sep 23, 2015 1:29 pm
by mgates3
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
Re: Guidance on building FORTRAN wrappers
Posted: Thu Sep 24, 2015 6:26 am
by fletchjp
Mark
Thank you for this. I will give these a try out.
John
Re: Guidance on building FORTRAN wrappers
Posted: Sat Sep 26, 2015 12:32 pm
by fletchjp
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.