coin-or / Ipopt

COIN-OR Interior Point Optimizer IPOPT
https://coin-or.github.io/Ipopt
Other
1.43k stars 284 forks source link

Compilation with PARDISO and WSMP #353

Closed tasseff closed 4 years ago

tasseff commented 4 years ago

I'm trying to configure Ipopt with PARDISO (non-MKL) and WSMP on Linux using GCC 7.4.0. Prior to version 3.13.0, this could be accomplished via something similar to

ADD_CFLAGS="-fopenmp -fPIC -fno-common -fexceptions" \
ADD_CXXFLAGS="-fopenmp -fPIC -fno-common -fexceptions" \
ADD_FFLAGS="-fopenmp -fPIC -fexceptions" \
./configure --with-pardiso="-L/path/to/libdir -lpardiso600-GNU720-X86-64 -lgfortran -lquadmath" \
            --with-wsmp="/path/to/libwsmp64.a -lpthread"

Using 3.13.0, similar configuration with just PARDISO returns

configure: error: Symbol pardiso_ipopt_newinterface not found with Pardiso flags -L/path/to/libdir -lpardiso600-GNU720-X86-64 -lgfortran -lquadmath and Lapack. Require Pardiso >= 4.0.

and configuration with just WSMP returns

configure: error: Symbol wssmp not found with WSMP flags /path/to/libwsmp64.a -lpthread.

It appears that whatever is used for the new AC_COIN_TRY_LINK method in configure.ac does not work for these two libraries. Could you confirm? Also, any pointers to get around these errors would be appreciated.

tasseff commented 4 years ago

I should also note that I can confirm pardiso_ipopt_newinterface indeed exists as a symbol in the PARDISO library by using

objdump -T libpardiso600-GNU720-X86-64.so | grep ipopt

and that wssmp_ exists as a symbol in the WSMP library by using

nm -g libwsmp64.a | grep wssmp
svigerske commented 4 years ago

Try adding the -fopenmp into --with-pardiso. Also have a look into config.log about the actual linking error. That usually helps to figure out what other libs are missing.

ghost commented 4 years ago

I got the same issue today. After checking out config.log I realized it was because I did not provide the correct -L path to Pardiso. Looking at your command, I think the "-L/path/to/libdir" flag in your command might be the culprit. Is "/path/to/libdir" really the path to your Pardiso folder?

tasseff commented 4 years ago

No, I used /path/to/libdir as an example path to not confuse readers.

I did manage to get Ipopt compiled with PARDISO and WSMP using the following:

export MKLSEQ="-L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl"
ADD_CFLAGS="-fopenmp -fPIC -fno-common -fexceptions" \
ADD_CXXFLAGS="-fopenmp -fPIC -fno-common -fexceptions" \
ADD_FFLAGS="-fopenmp -fPIC -fexceptions" \
../configure CXXFLAGS="-O0" --with-pic \
             --prefix="${IPOPTDIR}" \
             --with-pardiso="-L${PARDISODIR} -lpardiso600-GNU720-X86-64 -fopenmp -lgfortran -lquadmath" \
             --with-wsmp="${WSMPDIR}/libwsmp64.a -lpthread -lgfortran ${MKLSEQ}"
make -j $(nproc --all)
make install

However, note the use of CXXFLAGS="-O0" in the configure options. I've found that if this is not included, Ipopt will encounter a segmentation fault when using PARDISO. @svigerske, any ideas on how to resolve this?

svigerske commented 4 years ago

And some cleanup you could do:

tasseff commented 4 years ago

Thank you very much @svigerske, I'm just getting back to this. I seem to have resolved the problem via some minor changes to my configure options, so I will close the issue. I will leave some information below for future readers who might stumble upon this.

Regarding your point about -lmkl_intel_lp64 versus -lmkl_gf_lp64: to my knowledge, they are meant to be used when compiling with Intel versus GNU compilers, respectively. In this case, I was using GCC 7.4.0 (but still taking advantage of the Intel MKL).

Here is the final sequence I used for configuration:

export MKLSEQ="-L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl"
../configure --prefix="${IPOPTSEQDIR}" \
             --with-blas-lib="${MKLSEQ} -lmkl_lapack95_lp64" \
             --with-lapack-lib="${MKLSEQ} -lmkl_lapack95_lp64" \
             --with-pardiso="-L${PARDISODIR} -lpardiso600-GNU720-X86-64 -fopenmp -lgfortran -lquadmath ${MKLSEQ}" \
             --with-wsmp="${WSMPDIR}/libwsmp64.a -lpthread -lgfortran ${MKLSEQ}"

I should also note that, with your suggestions, I initially resolved the configuration issue pretty quickly, but Ipopt produced segmentation faults when executed with PARDISO. The segmentation faults were corrected upon adding ${MKLSEQ} to the --with-pardiso line, so I assume there indeed might have been a mismatch with BLAS/LAPACK libraries. Thanks again!