Beginner's Question: Linking clmagma with fortran

Open discussion for MAGMA

Beginner's Question: Linking clmagma with fortran

Postby Jan Kucera » Tue Dec 10, 2013 8:17 am

Please, can someone give a simple example how one can compile and link an existing fortran (f77) program (containing calls to magma) with the magma library?
The programs in the testing directory seem to work, the usual -I... , ldconfig -v, -L... ... done (Of course be more specific... but I feel I am missing something really elementary).
However I try, I am still getting:

program.f:(.text+0x4243): undefined reference to `magmaf_zheevd_'

Thanks in advance,

Jan
Jan Kucera
 
Posts: 5
Joined: Tue Nov 26, 2013 4:58 am

Re: Beginner's Question: Linking clmagma with fortran

Postby mgates3 » Tue Dec 10, 2013 4:05 pm

That looks like the correct function name to be linking to. Can you provide some more information? Your make.inc file and the compiler command you use on your program.f file would be helpful. E.g.,

gfortran -o program program.f -lmagma ...

You can also check the contents of your MAGMA library using nm to see if the function is there:

Code: Select all
romulus ~/magma-trunk> nm lib/libmagma.a | grep magmaf_zheevd
00000000000021a0 T magmaf_zheevd_
00000000000004a0 T magmaf_zheevd_gpu_
0000000000001410 T magmaf_zheevd_m_
00000000000020a0 T magmaf_zheevdx_
0000000000001fa0 T magmaf_zheevdx_2stage_
0000000000001060 T magmaf_zheevdx_2stage_m_
0000000000000370 T magmaf_zheevdx_gpu_
00000000000012a0 T magmaf_zheevdx_m_
mgates3
 
Posts: 415
Joined: Fri Jan 06, 2012 2:13 pm

Re: Beginner's Question: Linking clmagma with fortran

Postby Jan Kucera » Thu Dec 12, 2013 1:05 pm

Hallo and thanks,

You can also check the contents of your MAGMA library using nm to see if the function is there:


It is really not there!
nm ./libclmagma.a does not show it, although all the files in the "control" directory were apparently compiled, archived
into and indexed in libclmagma.a

Your make.inc file would be helpful.


Here it is:

Code: Select all
#   -- MAGMA (version 1.1.0-beta2) --

GPU_TARGET = AMD

CC        = g++
FORT      = gfortran

ARCH      = ar
ARCHFLAGS = cr
RANLIB    = ranlib

OPTS      = -fPIC -O3 -DADD_ -Wall
FOPTS     = -fPIC -O3 -DADD_ -Wall -x f95-cpp-input
F77OPTS   = -fPIC -O3 -DADD_ -Wall
LDOPTS    = -fPIC

ACMLDIR = /opt/acml5.3.1
clBLAS  = /opt/clAmdBlas-1.10.321
#ADDED BY JAN KUCERA
AMDLIBMDIR = /opt/amdlibm3.1

# I have my own libcblas_acml added in the
# $(ACMLDIR)/gfortran64/lib and $(ACMLDIR)/fortran64_mp/lib 

LIB        = -lacml_mp -lamdlibm  -lcblas_acml
LIB       += -lclAmdBlas -lOpenCL

LIBDIR    = -L$(ACMLDIR)/gfortran64/lib    \
            -L$(ACMLDIR)/gfortran64_mp/lib \
            -L$(AMDLIBMDIR)/lib \
            -L$(clBLAS)/lib64

INC       = -I$(clBLAS)/include


I am using debian jessie, and all the libraries needed from AMD-APP-SDK are installed via the
debian "experimental" packages. All my libraries (including the CBLAS ... named cblas_acml and put in the
same directory as the corresponding acml library... do you want my Makefile for CBLAS as well?)
are also shared. All are made available through ldconfig with a corresponding file in ld.so.conf.d directory.

I do set the variable GPU_FORCE_64BIT_PTR=1 to make at least 2GB of the 6GB of my 7970 HD
available for computing.

Thanks again... Jan
Jan Kucera
 
Posts: 5
Joined: Tue Nov 26, 2013 4:58 am

Re: Beginner's Question: Linking clmagma with fortran

Postby mgates3 » Thu Dec 12, 2013 5:52 pm

I missed that you were using clmagma instead of cuda magma. I think the Fortran interfaces just haven't been updated in clmagma. I'll see about doing that before the release. You can try uncommenting the MAGMAF_ZHEEVD function in control/magma_zf77.cpp but I'm not sure if that will work or not.
-mark
mgates3
 
Posts: 415
Joined: Fri Jan 06, 2012 2:13 pm

Re: Beginner's Question: Linking clmagma with fortran

Postby mgates3 » Thu Dec 12, 2013 8:56 pm

I updated the Fortran wrappers, but ran into a problem. There's a cl_command_queue that gets passed into every function. At the moment, we don't have a representation of a queue in Fortran, nor a way to generate a queue in Fortran. So the wrappers will require some more work before they're useful.
-mark
mgates3
 
Posts: 415
Joined: Fri Jan 06, 2012 2:13 pm

Re: Beginner's Question: Linking clmagma with fortran

Postby Jan Kucera » Fri Dec 13, 2013 10:07 am

mgates3 wrote:I updated the Fortran wrappers, but ran into a problem. There's a cl_command_queue that gets passed into every function...
-mark


Thanks for all your help. I knew I missed something elementary...

So at the moment it probably means to rewrite the old code in C (with the OpenCL API)...? I may try if all else fails... but there is so much useful code written in fortran that it would make sense to put some effort into this...

I realized there is a FortranCL project (at the moment only in alpha stage) which should enable running Fortran (f90) code
on a GPU. I looked at the sources and it seems the cl_command_queue is already implemented.

So I shall start by rewriting the old f77 code into f90 and trying where I can get with clmagma compiled using FortranCL

JK
Jan Kucera
 
Posts: 5
Joined: Tue Nov 26, 2013 4:58 am


Return to User discussion

Who is online

Users browsing this forum: Bing [Bot] and 1 guest