Magma compilation error

Open discussion for MAGMA library (Matrix Algebra on GPU and Multicore Architectures)

Magma compilation error

Postby linuxfreak » Wed Nov 02, 2016 4:20 pm

Dear MAGMA developers,

I am getting the following, when compiling MAGMA 2.1.0 (either with gcc4.9.2 or with gcc 4.6.3 (for the latter I comment out the line with CXXFLAGS := $(CFLAGS) -std=c++11)):

Makefile:15: No Fortran compiler was given in FORT in make.inc. Some testers will not be able to check their results.
g++ -fopenmp -Wl,-rpath,../lib \
-o testing/testing_cblas_z testing/testing_cblas_z.o \
-L./lib -lmagma \
-L./testing -ltest \
-L./testing/lin -llapacktest \
-L/net/software/local/cuda/7.0/lib64 -L/net/software/local/lapack/3.5.0/lib -L/net/software/local/atlas/3.10.2/lib -llapack -lf77blas -latlas -lstdc++ -lm -lgfortran -lcublas -lcusparse -lcudart
./testing/libtest.a(magma_util.o):magma_util.cpp:function magma_opts::parse_opts(int, char**): error: undefined reference to 'magma_vec_const'
./testing/libtest.a(magma_util.o):magma_util.cpp:function magma_opts::parse_opts(int, char**): error: undefined reference to 'magma_vec_const'
collect2: error: ld returned 1 exit status
make: *** [testing/testing_cblas_z] Error 1

The make.inc is:
#//////////////////////////////////////////////////////////////////////////////
# -- MAGMA (version 2.1.0) --
# Univ. of Tennessee, Knoxville
# Univ. of California, Berkeley
# Univ. of Colorado, Denver
# @date August 2016
#//////////////////////////////////////////////////////////////////////////////

# GPU_TARGET contains one or more of Fermi, Kepler, or Maxwell,
# to specify for which GPUs you want to compile MAGMA:
# Fermi - NVIDIA compute capability 2.x cards
# Kepler - NVIDIA compute capability 3.x cards
# Maxwell - NVIDIA compute capability 5.x cards
# The default is "Fermi Kepler".
# Note that NVIDIA no longer supports 1.x cards, as of CUDA 6.5.
# See http://developer.nvidia.com/cuda-gpus
#
#GPU_TARGET ?= Fermi Kepler

# --------------------
# programs

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

ARCH = ar
ARCHFLAGS = cr
RANLIB = ranlib


# --------------------
# flags

# Use -fPIC to make shared (.so) and static (.a) library;
# can be commented out if making only static library.
##
## Our ATLAS installation has only static libraries, and one can't
## build a shared library against a static library, so disable FPIC.
##FPIC = -fPIC

CFLAGS = -O3 $(FPIC) -DADD_ -Wall -fopenmp
FFLAGS = -O3 $(FPIC) -DADD_ -Wall -Wno-unused-dummy-argument
F90FLAGS = -O3 $(FPIC) -DADD_ -Wall -Wno-unused-dummy-argument -x f95-cpp-input
NVCCFLAGS = -O3 -DADD_ -Xcompiler "$(FPIC)"
LDFLAGS = $(FPIC) -fopenmp

# C++11 (gcc >= 4.7) is not required, but has benefits like atomic operations
CXXFLAGS := $(CFLAGS) -std=c++11
CFLAGS += -std=c99

# --------------------
# libraries

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

LIB += -lcublas -lcusparse -lcudart


# --------------------
# directories

# define library directories preferably in your environment, or here.
#LAPACKDIR ?= /opt/lapack
#ATLASDIR ?= /opt/atlas
#CUDADIR ?= /usr/local/cuda
-include make.check-atlas
-include make.check-cuda

LIBDIR = -L$(CUDADIR)/lib64 \
-L$(LAPACKDIR) \
-L$(ATLASDIR)/lib

INC = -I$(CUDADIR)/include
linuxfreak
 
Posts: 4
Joined: Wed Nov 02, 2016 4:09 pm

Re: Magma compilation error

Postby linuxfreak » Thu Nov 03, 2016 5:59 am

I managed to solve the problem. libmagma was linked before libtest, which uses libmagma.
After swapping lines 612 and 613 in makefile, so that -lmagma is after -ltest, the compilation runs smooth.
Below I am posting the modified fragment.

# link testing_foo from testing_foo.o
$(testers): %: %.$(o_ext)
$(CXX) $(LDFLAGS) $(RPATH) \
-o $@ $< \
-L./testing -ltest \
-L./lib -lmagma \
-L./testing/lin -llapacktest \
$(LIBS)

One additional note is that for gcc 4.6.3 I had to replace in make.inc:
CXXFLAGS := $(CFLAGS) -std=c++11
with:
CXXFLAGS := $(CFLAGS) -std=c++0x

Otherwise one gets errors due to auto keyword.
linuxfreak
 
Posts: 4
Joined: Wed Nov 02, 2016 4:09 pm

Re: Magma compilation error

Postby mgates3 » Mon Nov 07, 2016 8:50 pm

Thanks. We noticed the same problem just the other day. Often, it is obscured by using shared libraries, where the order of linking is not as important.
-mark
mgates3
 
Posts: 738
Joined: Fri Jan 06, 2012 2:13 pm


Return to User discussion

Who is online

Users browsing this forum: No registered users and 3 guests

cron