Error linking Fortran program with magma

Open discussion for MAGMA library (Matrix Algebra on GPU and Multicore Architectures)
Post Reply
epsilon9
Posts: 2
Joined: Fri Dec 12, 2014 10:09 am

Error linking Fortran program with magma

Post by epsilon9 » Mon Dec 15, 2014 4:45 am

Hi,

when i try to link a Fortran program on MacOSX 10.10 to magma 1.6.0 i get the following error:

Code: Select all

gfortran all-defs.o atomscf.o atomsph.o bhs-defs.o decomp.o dosjnt.o dvpmesh.o force.o ggapot.o hamilt.o hampar.o isetup.o main.o mesh.o miscell.o poisson.o psp-defs.o psp-nlcc.o pspstuff.o wfgrid.o mpistuff.o extpot.o magnet.o efg.o formfak.o hyperf.o nlbfgs.o ezstart.o  copyright.o craylib.o diagon.o myclock.o pbegga.o pw91gga.o  vdW-Grimme.o -o nrlmol.mac.ser  -mcmodel=medium -L/usr/local/cuda/lib -lcudart -lcublas -L/Users/hahn/Soft/magma-1.6.0/lib -lmagma -lstdc++ -Wl,-framework -Wl,Accelerate -Wl,-pie
final section layout:
    __TEXT/__text addr=0x100001B30, size=0x0016AFE6, fileOffset=0x00001B30, type=1
    __TEXT/__text_startup addr=0x10016CB20, size=0x00000026, fileOffset=0x0016CB20, type=1
    __TEXT/__stubs addr=0x10016CB46, size=0x000005A0, fileOffset=0x0016CB46, type=28
    __TEXT/__stub_helper addr=0x10016D0E8, size=0x00000952, fileOffset=0x0016D0E8, type=32
    __TEXT/__cstring addr=0x10016DA40, size=0x000041F2, fileOffset=0x0016DA40, type=13
    __TEXT/__const addr=0x100171C40, size=0x0000E0D0, fileOffset=0x00171C40, type=0
    __TEXT/__gcc_except_tab addr=0x10017FD10, size=0x00000368, fileOffset=0x0017FD10, type=0
    __TEXT/__eh_frame addr=0x100180078, size=0x00008F50, fileOffset=0x00180078, type=19
    __DATA/__got addr=0x100189000, size=0x000000B8, fileOffset=0x00189000, type=29
    __DATA/__nl_symbol_ptr addr=0x1001890B8, size=0x00000010, fileOffset=0x001890B8, type=29
    __DATA/__la_symbol_ptr addr=0x1001890C8, size=0x00000780, fileOffset=0x001890C8, type=27
    __DATA/__mod_init_func addr=0x100189848, size=0x00000148, fileOffset=0x00189848, type=33
    __DATA/__const addr=0x100189990, size=0x00000100, fileOffset=0x00189990, type=0
    __DATA/__data addr=0x100189AC0, size=0x0003FCE8, fileOffset=0x00189AC0, type=0
    __DATA/__static_data addr=0x1001C97A8, size=0x00000007, fileOffset=0x001C97A8, type=0
    __DATA/__pu_bss3 addr=0x1001C97B0, size=0x00000028, fileOffset=0x00000000, type=25
    __DATA/__bss3 addr=0x1001C97D8, size=0x00001A10, fileOffset=0x00000000, type=25
    __DATA/__common addr=0x1001CB200, size=0x00210990, fileOffset=0x00000000, type=25
    __DATA/__bss addr=0x1003DBB90, size=0x00000520, fileOffset=0x00000000, type=25
    __DATA/__bss6 addr=0x1003DC0C0, size=0x006A86D0, fileOffset=0x00000000, type=25
    __DATA/__bss4 addr=0x100A84790, size=0x000008A8, fileOffset=0x00000000, type=25
    __DATA/__bss2 addr=0x100A85038, size=0x00001FAC, fileOffset=0x00000000, type=25
    __DATA/__pu_bss4 addr=0x100A86FF0, size=0x00000020, fileOffset=0x00000000, type=25
    __DATA/__pu_bss5 addr=0x100A87020, size=0x00000030, fileOffset=0x00000000, type=25
    __DATA/__bss0 addr=0x100A87050, size=0x0000006A, fileOffset=0x00000000, type=25
    __DATA/__bss5 addr=0x100A870C0, size=0x000005E0, fileOffset=0x00000000, type=25
    __DATA/__huge addr=0x100A876C0, size=0x12F691450, fileOffset=0x00000000, type=25
    __NV_CUDA/__fatbin addr=0x230119000, size=0x000003D8, fileOffset=0x001CA000, type=0
    __NV_CUDA/__nv_fatbin addr=0x2301193E0, size=0x00224F20, fileOffset=0x001CA3E0, type=0
ld: 32-bit RIP relative reference out of range (5100486325 max is +/-4GB): from __sti____cudaRegisterAll_53_tmpxft_0000f40a_00000000_12_stream_compute_35_cpp1_ii_4a92bd4f()      (0x1000E5140) to __fatDeviceText      (0x230119000) in '__sti____cudaRegisterAll_53_tmpxft_0000f40a_00000000_12_stream_compute_35_cpp1_ii_4a92bd4f()' from /Users/hahn/Soft/magma-1.6.0/lib/libmagma.a(stream.o) for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [nrlmol] Error 1
Has anyone an idea where this error comes from ?

Best,
Torsten.

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

Re: Error linking Fortran program with magma

Post by mgates3 » Wed Jan 07, 2015 12:28 pm

[Sorry for the late reply; somehow this message didn't show up for me earlier.]

Not sure where the error comes from. Can you include your make.inc file, so we know how MAGMA was compiled?

You may need to change the library order. The order we use is -lmagma -lcudart -lcublas. (Also changing the -L directory order as needed.)

-mark

epsilon9
Posts: 2
Joined: Fri Dec 12, 2014 10:09 am

Re: Error linking Fortran program with magma

Post by epsilon9 » Thu Jan 08, 2015 6:15 am

Hi,

changing the order of linking arguments does not help. Here are some more details including the make.inc file from my magma installation.

gfortran --version
GNU Fortran (GCC) 5.0.0 20141005 (experimental)

gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)

nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2014 NVIDIA Corporation
Built on Mon_Oct_20_21:28:13_CDT_2014
Cuda compilation tools, release 6.5, V6.5.24


If you have any further ideas, let me know.
Attachments
make.inc.gz
make.inc file from magma installation (OS X 10.10.1)
(1.08 KiB) Downloaded 104 times

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

Re: Error linking Fortran program with magma

Post by mgates3 » Thu Jan 08, 2015 11:17 am

Did you make a static (.a) or a shared (.so) library? The make.inc file has -fPIC options, which looks like you added to get a shared library, but your error output lists the libmagma.a static library. The -fPIC is missing from F90FLAGS, though. Use -fPIC consistently, either in all the FLAGS variables, or none.

For a static library, use "make lib && make test" (same as "make" by itself). This does not require -fPIC, but using -fPIC doesn't seem to hurt.

For a shared library, use "make shared && make test". This requires -fPIC.

Do the MAGMA testers link and run correctly?

If adding -fPIC to F90FLAGS (then "make clean && make shared && make test") doesn't change anything, I would try removing all the -fPIC and compiling as a static (.a) library only.

I have made MAGMA as a shared library on MacOS, so know it works.

-mark

Post Reply