Page 1 of 1

Compiling MAGMA sparse

Posted: Wed Oct 29, 2014 5:37 am
by Noran
Hello all,
I've got trouble to compile MAGMA sparse.
At the begin i didn't known where are the functions for the sparse Algorithms of MAGMA, hence I corresponded with Mark Gates. He told me, that they are in the folder sparse-iter and need to be compiled extra.
So i looked in this folder. The next step were to compile the source. First i compiled it as a static library. All went good. But when i try to compile it as shared library i get some errors (look below). I didn't changed anything in the makefile of sparse-iter. Does anybody know what to do?

Thank you and Greetz Noran


Code: Select all

#   -- MAGMA (version 1.5.0) --
#      Univ. of Tennessee, Knoxville
#      Univ. of California, Berkeley
#      Univ. of Colorado, Denver
#      @date September 2014

# GPU_TARGET contains one or more of Tesla, Fermi, or Kepler,
# to specify for which GPUs you want to compile MAGMA:
#     Tesla  - NVIDIA compute capability 1.x cards
#     Fermi  - NVIDIA compute capability 2.x cards
#     Kepler - NVIDIA compute capability 3.x cards
# The default is all, "Tesla Fermi Kepler".
# See

CC        = gcc
CXX       = g++
NVCC      = nvcc
FORT      = gfortran

ARCH      = ar
RANLIB    = ranlib

FFLAGS    = -fPIC -O3 -DADD_
F90FLAGS  = -fPIC -O3 -DADD_ -x f95-cpp-input
NVCCFLAGS = -O3 -DADD_ -Xcompiler "-fno-strict-aliasing -fPIC"
LDFLAGS   = -fPIC -fopenmp

# Depending on how ATLAS and LAPACK were compiled, you may need one or more of:
# -lifcore -ldl -lf2c -lgfortran
LIB       = -llapack -lf77blas -latlas -lcblas -lcublas -lcudart -lstdc++ -lm -lgfortran -ldl

# define library directories here or in your environment
LAPACKDIR = /usr/lib
ATLASDIR  = /usr
CUDADIR   = /usr/local/cuda
-include make.check-atlas
-include make.check-cuda

            -L$(ATLASDIR)/lib \

INC       = -I$(CUDADIR)/include
Linking command:

Code: Select all

gcc -fPIC -fopenmp -shared -o ../lib/ src/cbaiter.o src/cbicgstab_merge2.o src/cbicgstab_merge.o src/cbicgstab.o src/ccg_merge.o src/ccg.o src/ccg_res.o src/ccuilu.o src/cgmres.o src/citerref.o src/cjacobi.o src/clobpcg.o src/cpastix.o src/cpbicgstab.o src/cpcg.o src/cpgmres.o src/cresidual.o src/dbaiter.o src/dbicgstab_merge2.o src/dbicgstab_merge.o src/dbicgstab.o src/dcg_merge.o src/dcg.o src/dcg_res.o src/dcuilu.o src/dgmres.o src/diterref.o src/djacobi.o src/dlobpcg.o src/dpastix.o src/dpbicgstab.o src/dpcg.o src/dpgmres.o src/dresidual.o src/magma_ccuspmm.o src/magma_c_precond_wrapper.o src/magma_c_solver_wrapper.o src/magma_dcuspmm.o src/magma_d_precond_wrapper.o src/magma_d_solver_wrapper.o src/magma_scuspmm.o src/magma_s_precond_wrapper.o src/magma_s_solver_wrapper.o src/magma_zcuspmm.o src/magma_z_precond_wrapper.o src/magma_z_solver_wrapper.o src/sbaiter.o src/sbicgstab_merge2.o src/sbicgstab_merge.o src/sbicgstab.o src/scg_merge.o src/scg.o src/scg_res.o src/scuilu.o src/sgmres.o src/siterref.o src/sjacobi.o src/slobpcg.o src/spastix.o src/spbicgstab.o src/spcg.o src/spgmres.o src/sresidual.o src/zbaiter.o src/zbicgstab_merge2.o src/zbicgstab_merge.o src/zbicgstab.o src/zcg_merge.o src/zcg.o src/zcg_res.o src/zcuilu.o src/zgmres.o src/ziterref.o src/zjacobi.o src/zlobpcg.o src/zpastix.o src/zpbicgstab.o src/zpcg.o src/zpgmres.o src/zresidual.o control/magma_ccsrsplit.o control/magma_c_free.o control/magma_cgeneratematrix.o control/magma_c_init.o control/magma_c_matrixchar.o control/magma_c_mconverter.o control/magma_cmdiff.o control/magma_cmscale.o control/magma_cp2p.o control/magma_csolverinfo.o control/magma_c_transfer.o control/magma_ctranspose.o control/magma_cutil_sparse.o control/magma_c_vio.o control/magma_dcsrsplit.o control/magma_d_free.o control/magma_dgeneratematrix.o control/magma_d_init.o control/magma_d_matrixchar.o control/magma_d_mconverter.o control/magma_dmdiff.o control/magma_dmscale.o control/magma_dp2p.o control/magma_dsolverinfo.o control/magma_d_transfer.o control/magma_dtranspose.o control/magma_dutil_sparse.o control/magma_d_vio.o control/magma_scsrsplit.o control/magma_s_free.o control/magma_sgeneratematrix.o control/magma_s_init.o control/magma_s_matrixchar.o control/magma_s_mconverter.o control/magma_smdiff.o control/magma_smscale.o control/magma_sp2p.o control/magma_ssolverinfo.o control/magma_s_transfer.o control/magma_stranspose.o control/magma_sutil_sparse.o control/magma_s_vio.o control/magma_zcsrsplit.o control/magma_z_free.o control/magma_zgeneratematrix.o control/magma_z_init.o control/magma_z_matrixchar.o control/magma_z_mconverter.o control/magma_zmdiff.o control/magma_zmscale.o control/magma_zp2p.o control/magma_zsolverinfo.o control/magma_z_transfer.o control/magma_ztranspose.o control/magma_zutil_sparse.o control/magma_z_vio.o control/matrix_cio.o control/matrix_dio.o control/matrix_sio.o control/matrix_zio.o control/mmio.o blas/cbajac_csr.o blas/cbcsrcpy.o blas/cbcsrlugemm.o blas/cbcsrlupivloc.o blas/cbcsrswp.o blas/cbcsrtrsv.o blas/ccompact.o blas/cgecsrmv.o blas/cgeellmv.o blas/cgeellrtmv.o blas/cgeelltmv.o blas/cgesellcmmv.o blas/cgesellcmv.o blas/cjacobisetup.o blas/clag2z_sparse.o blas/clobpcg_maxpy.o blas/clobpcg_residuals.o blas/clobpcg_shift.o blas/cmdot.o blas/cmergebicgstab2.o blas/cmergebicgstab.o blas/cmergecg.o blas/cmgecsrmv.o blas/cmgeellmv.o blas/cmgeelltmv.o blas/cmgesellcmmv.o blas/cpipelinedgmres.o blas/dbajac_csr.o blas/dbcsrcpy.o blas/dbcsrlugemm.o blas/dbcsrlupivloc.o blas/dbcsrswp.o blas/dbcsrtrsv.o blas/dcompact.o blas/dgecsrmv.o blas/dgeellmv.o blas/dgeellrtmv.o blas/dgeelltmv.o blas/dgesellcmmv.o blas/dgesellcmv.o blas/djacobisetup.o blas/dlag2s_sparse.o blas/dlobpcg_maxpy.o blas/dlobpcg_residuals.o blas/dlobpcg_shift.o blas/dmdot.o blas/dmergebicgstab2.o blas/dmergebicgstab.o blas/dmergecg.o blas/dmgecsrmv.o blas/dmgeellmv.o blas/dmgeelltmv.o blas/dmgesellcmmv.o blas/dpipelinedgmres.o blas/magma_c_blaswrapper.o blas/magma_clag2z.o blas/magma_d_blaswrapper.o blas/magma_dlag2s.o blas/magma_s_blaswrapper.o blas/magma_slag2d.o blas/magma_z_blaswrapper.o blas/magma_zlag2c.o blas/sbajac_csr.o blas/sbcsrcpy.o blas/sbcsrlugemm.o blas/sbcsrlupivloc.o blas/sbcsrswp.o blas/sbcsrtrsv.o blas/scompact.o blas/sgecsrmv.o blas/sgeellmv.o blas/sgeellrtmv.o blas/sgeelltmv.o blas/sgesellcmmv.o blas/sgesellcmv.o blas/sjacobisetup.o blas/slag2d_sparse.o blas/slobpcg_maxpy.o blas/slobpcg_residuals.o blas/slobpcg_shift.o blas/smdot.o blas/smergebicgstab2.o blas/smergebicgstab.o blas/smergecg.o blas/smgecsrmv.o blas/smgeellmv.o blas/smgeelltmv.o blas/smgesellcmmv.o blas/spipelinedgmres.o blas/zbajac_csr.o blas/zbcsrcpy.o blas/zbcsrlugemm.o blas/zbcsrlupivloc.o blas/zbcsrswp.o blas/zbcsrtrsv.o blas/zcompact.o blas/zgecsrmv.o blas/zgeellmv.o blas/zgeellrtmv.o blas/zgeelltmv.o blas/zgesellcmmv.o blas/zgesellcmv.o blas/zjacobisetup.o blas/zlag2c_sparse.o blas/zlobpcg_maxpy.o blas/zlobpcg_residuals.o blas/zlobpcg_shift.o blas/zmdot.o blas/zmergebicgstab2.o blas/zmergebicgstab.o blas/zmergecg.o blas/zmgecsrmv.o blas/zmgeellmv.o blas/zmgeelltmv.o blas/zmgesellcmmv.o blas/zpipelinedgmres.o \
	-L../lib -lmagma \
	-L/usr/lib -L/usr/lib -L/usr/local/cuda/lib64 \
	-llapack -lf77blas -latlas -lcblas -lcublas -lcudart -lstdc++ -lm -lgfortran -ldl
control/magma_dutil_sparse.o:(.data.rel.local+0x8): Mehrfachdefinition von `usage_sparse_short'
control/magma_cutil_sparse.o:(.data.rel.local+0x8): first defined here
control/magma_dutil_sparse.o:(.data.rel.local+0x0): multiple definition of `usage_sparse'
control/magma_cutil_sparse.o:(.data.rel.local+0x0): first defined here
control/magma_sutil_sparse.o:(.data.rel.local+0x8): multiple definition of `usage_sparse_short'
control/magma_cutil_sparse.o:(.data.rel.local+0x8): first defined here
control/magma_sutil_sparse.o:(.data.rel.local+0x0): multiple definition of `usage_sparse'
control/magma_cutil_sparse.o:(.data.rel.local+0x0): first defined here
control/magma_zutil_sparse.o:(.data.rel.local+0x8): multiple definition of `usage_sparse_short'
control/magma_cutil_sparse.o:(.data.rel.local+0x8): first defined here
control/magma_zutil_sparse.o:(.data.rel.local+0x0): multiple definition of `usage_sparse'
control/magma_cutil_sparse.o:(.data.rel.local+0x0): first defined here
collect2: ld returned 1 exit status
make[1]: *** [../lib/] Fehler 1
make[1]: Verlasse Verzeichnis '/home/maka7111/uninst/SWDevelopment/magma/sparse-iter'
make: *** [shared] Fehler 2

Re: Compiling MAGMA sparse

Posted: Wed Oct 29, 2014 2:19 pm
by hartwig anzt

I apologize for this bug. The easiest fix is to put '"static" befor ethe definitions of "usage_sparse_short" and "usage_sparse" in the files sparse-iter/control/magma_zutil_sparse.cpp. Line 34ff will become:

// --------------------
static const char *usage_sparse_short =
"Usage: %s [options] [-h|--help] matrices\n\n";

static const char *usage_sparse =

This fix has to be done in all precisions:

Also, you will have to uncomment the cusparse library in line 14 sparse-iter/Makefile.

Finally, remove the zbcsr* kernels in the blas/Makefile.

Sorry for the inconvenience, I usually don't test the shared library.

Please let me know whether this works!

Thanks, Hartwig

Re: Compiling MAGMA sparse

Posted: Thu Oct 30, 2014 4:14 am
by Noran
Hi Hartwig,
I'vo got two things:
1. Yesterday i had done it the "quick and dirty" way: Adding "-Xlinker -zmuldefs" at the compiler commands. Because I saw that this are only output variables, they are the same in all files and doesn't to be so qiet important.
2. Today I've done it like you said. And recognized that it's necessary to run a "make clean" before editing the makefile. Looking forward how the shared library works :)

Greetz Noran

Re: Compiling MAGMA sparse

Posted: Mon Nov 24, 2014 7:19 am
by Noran
Hello again,
after I updated from Magma 1.5 to 1.6, i got a similar Bug by calling "make shared":

Code: Select all

control/magma_dvpass_gpu.o: In function `magma_vget_gpu':
magma_dvpass_gpu.cpp:(.text+0x20): multiple definition of `magma_vget_gpu'
control/magma_cvpass_gpu.o:magma_cvpass_gpu.cpp:(.text+0x20): first defined here
control/magma_dvpass.o: In function `magma_vget':
magma_dvpass.cpp:(.text+0x20): multiple definition of `magma_vget'
control/magma_cvpass.o:magma_cvpass.cpp:(.text+0x20): first defined here
control/magma_svpass_gpu.o: In function `magma_vget_gpu':
magma_svpass_gpu.cpp:(.text+0x20): multiple definition of `magma_vget_gpu'
control/magma_cvpass_gpu.o:magma_cvpass_gpu.cpp:(.text+0x20): first defined here
control/magma_svpass.o: In function `magma_vget':
magma_svpass.cpp:(.text+0x20): multiple definition of `magma_vget'
control/magma_cvpass.o:magma_cvpass.cpp:(.text+0x20): first defined here
control/magma_zvpass_gpu.o: In function `magma_vget_gpu':
magma_zvpass_gpu.cpp:(.text+0x20): multiple definition of `magma_vget_gpu'
control/magma_cvpass_gpu.o:magma_cvpass_gpu.cpp:(.text+0x20): first defined here
control/magma_zvpass.o: In function `magma_vget':
magma_zvpass.cpp:(.text+0x20): multiple definition of `magma_vget'
control/magma_cvpass.o:magma_cvpass.cpp:(.text+0x20): first defined here
Can somebody help me, please?
Thanks and Greetz Noran

Re: Compiling MAGMA sparse

Posted: Mon Nov 24, 2014 10:06 am
by hartwig anzt

yes, there is a precision indicator missing. please add in the "magma_xvpass.cpp" the x before the function definition:


Sorry for that!

However, I use the and it works - although the function may not be usable...

Please let me know whether this works for you!


Re: Compiling MAGMA sparse

Posted: Tue Nov 25, 2014 6:16 am
by Noran
Thank you Hartwig, it worked.
I've done the same with magma_xvget_gpu (...) in magma_xvpass_gpu.cpp

Greetz Noran