Undefined reference to pardiso_ with Intel MKL (oneAPI toolkit)

Hello,

Has anyone faced error with MKL Pardiso? What worked for you? I tried the Feacluster makefile too but it didnt help. I have been trying to compile ccx with the Intel MKL Pardiso bt get following error:

ccx_PardisoMKL_gcc.a(pardiso.o): In function `pardiso_factor':
/home/pc/CalculiX_mod/CalculiX/ccx_2.17/src/pardiso.c:296: undefined reference to `pardiso_'
ccx_PardisoMKL_gcc.a(pardiso.o): In function `pardiso_solve':
/home/pc/CalculiX_mod/CalculiX/ccx_2.17/src/pardiso.c:333: undefined reference to `pardiso_'
ccx_PardisoMKL_gcc.a(pardiso.o): In function `pardiso_cleanup':
/home/pc/CalculiX_mod/CalculiX/ccx_2.17/src/pardiso.c:359: undefined reference to `pardiso_'
ccx_PardisoMKL_gcc.a(pardiso.o): In function `pardiso_solve':
/home/pc/CalculiX_mod/CalculiX/ccx_2.17/src/pardiso.c:333: undefined reference to `pardiso_'
ccx_PardisoMKL_gcc.a(pardiso.o): In function `pardiso_cleanup':
/home/pc/CalculiX_mod/CalculiX/ccx_2.17/src/pardiso.c:359: undefined reference to `pardiso_'
ccx_PardisoMKL_gcc.a(pardiso_as.o):/home/pc/CalculiX_mod/CalculiX/ccx_2.17/src/pardiso_as.c:161: more undefined references to `pardiso_' follow
collect2: error: ld returned 1 exit status
Makefile:49: recipe for target 'ccx_PardisoMKL_gcc' failed
make: *** [ccx_PardisoMKL_gcc] Error 1

My makefile is as follows:
OPT = -g -O3
CFLAGS = -Wall (OPT) -fopenmp -DARCH="Linux" -DARPACK -DPARDISO -DMATRIXSTORAGE -DUSE_MT=1 -DMKL_ILP64 -I{MKL_INCLUDE} FFLAGS = -Wall (OPT) (OPTIONS) -I(MKL_INCLUDE) -fopenmp

#ARPACK
#CFLAGS+= -I ../../../ARPACK -DARPACK

#BLAS and LAPACK
#CFLAGS+= -llpack -lblas

CC=gcc
FC=gfortran


OPTIONS = -w -fno-second-underscore -fcray-pointer -x f77-cpp-input
FPPSTOP= -x none


#INTEL MKL
MKL_LIB = /opt/intel/oneapi/mkl/2021.1.1/lib/intel64
MKL_INCLUDE=/opt/intel/oneapi/mkl/2021.1.1/include
CMPLR_PATH = /opt/intel/oneapi/compiler/2021.1.1/linux/compiler/lib/intel64


.c.o :
        $(CC) $(CFLAGS) -c $<
.f.o :
        $(FC) $(FFLAGS) -c $<

include Makefile.inc

SCCXMAIN = ccx_2.17.c

OCCXF = $(SCCXF:.f=.o)
OCCXC = $(SCCXC:.c=.o)
OCCXMAIN = $(SCCXMAIN:.c=.o)

LIBS= ../../../ARPACK/libarpack_UBUNTU.a -lpthread -lm -lc

ccx_PardisoMKL_gcc: $(OCCXMAIN) ccx_PardisoMKL_gcc.a $(LIBS)
        ./date.pl; $(CC) $(CFLAGS) -c ccx_2.17.c; \
        $(FC) $(OPT)p $(FFLAGS) -o $@ $(FPPSTOP) $(OCCXMAIN) ccx_PardisoMKL_gcc.a $(LIBS)
        -Wl,--start-group \
        $(MKL_LIB)/libmkl_intel_ilp64.a \
        $(MKL_LIB)/libmkl_intel_thread.a \
        $(MKL_LIB)/libmkl_core.a \
        $(MKL_LIB)/libmkl_blacs_openmpi_ilp64.a \
        -Wl,--end-group \
        -L$(CMPLR_PATH) -liomp5 -lpthread -lm -ldl

ccx_PardisoMKL_gcc.a: $(OCCXF) $(OCCXC)

Many thanks.

Hi @manny9808, shouldn’t you be using CC=mpiicc / CC=icc and FC=mpiifort / FC=ifort? Or can they be mixed?

Hello,
icc and ifort are intel compilers. I wanted to use GNU compilers, hence gcc and gfortran.

I managed to get my makefile to work (added below for record).While I am not sure what made it work, I made following changes: upon installation of intel library, ran

./varsh.sh intel64

in env directory in installation; then in makefile

(LDFLAGS) before (LIBS)

and

“space” before -Wl

(threw me error if not done).

Makefile:

OPT = -g -O2
CFLAGS = -Wall $(OPT) -fopenmp -DARCH="Linux" -DARPACK -DPARDISO -DMATRIXSTORAGE -DUSE_MT=1 -DMKL_LP64 -I{MKL_INCLUDE}
FFLAGS = -Wall $(OPT) $(OPTIONS) -I$(MKL_INCLUDE) -fopenmp

#ARPACK
#CFLAGS+= -I /usr/local/ARPACK -DARPACK

#SPOOLES
#CFLAGS+= -I /usr/local/SPOOLES.2.2 -DSPOOLES

#BLAS and LAPACK
#CFLAGS+= -llpack -lblas

CC=gcc
FC=gfortran

OPTIONS = -w -fno-second-underscore -fcray-pointer -x f77-cpp-input
FPPSTOP= -x none

#INTEL MKL
MKL_LIB = /opt/intel/oneapi/mkl/2021.1.1/lib/intel64
MKL_INCLUDE=/opt/intel/oneapi/mkl/2021.1.1/include
CMPLR_PATH = /opt/intel/oneapi/compiler/2021.1.1/linux/compiler/lib/intel64 


.c.o :
	$(CC) $(CFLAGS) -c $<
.f.o :
	$(FC) $(FFLAGS) -c $<

include Makefile.inc

SCCXMAIN = ccx_2.15.c

OCCXF = $(SCCXF:.f=.o)
OCCXC = $(SCCXC:.c=.o)
OCCXMAIN = $(SCCXMAIN:.c=.o)


LIBS= ../../../ARPACK/libarpack_UBUNTU.a -lpthread -lm -lc

ccx_PardisoMKL_gcc: $(OCCXMAIN) ccx_PardisoMKL_gcc.a $(LDFLAGS) $(LIBS)\
        ./date.pl; $(CC) $(CFLAGS) -c ccx_2.15.c; \
        $(FC) $(OPT)p $(FFLAGS) -o $@ $(FPPSTOP) $(OCCXMAIN) ccx_PardisoMKL_gcc.a $(LDFLAGS) $(LIBS)\
         -Wl,--start-group \
        $(MKL_LIB)/libmkl_gf_lp64.a \
        $(MKL_LIB)/libmkl_gnu_thread.a \
        $(MKL_LIB)/libmkl_core.a \
        $(MKL_LIB)/libmkl_blacs_openmpi_lp64.a \
         -Wl,--end-group \
        -L$(CMPLR_PATH) -lgomp -lpthread -lm -ldl

ccx_PardisoMKL_gcc.a: $(OCCXF) $(OCCXC)
	ar vr $@ $?
clean:
	rm *.a *.o ccx_PardisoMKL_gcc

I am getting significant gains in computation vs SPOOLES, still, the gain in multithreading for pardiso is not where I want it to be. For simple cantilever with 200k hex elements:

Hence,I will be looking to compile with MPI.