Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors when compiling CHAP #20

Open
eric-jm-lang opened this issue Oct 31, 2019 · 1 comment
Open

Errors when compiling CHAP #20

eric-jm-lang opened this issue Oct 31, 2019 · 1 comment

Comments

@eric-jm-lang
Copy link

Hi,
I have been trying to compile CHAP on our local cluster but ran into a number of issues.
First the I encountered the same problem as described in #5
However, the suggested fix didn't work (Adding include_directories(${LAPACKE_INCLUDE_DIRS}) or target_include_directories(chap PUBLIC ${LAPACKE_INCLUDE_DIRS}) to CMakeLists.txt). Instead I had to add the explicit path to CMakeLists.txt (I am mainly mentioning it in case others run into the same problem).

I have however further problems during compuilation. With an intel compiler (which was used to compile Gromacs), I get the following error:

[ 42%] Building CXX object CMakeFiles/chap.dir/src/statistics/weighted_kernel_density_estimator.cpp.o
[ 43%] Building CXX object CMakeFiles/chap.dir/src/trajectory-analysis/chap_trajectory_analysis.cpp.o
/mnt/storage/home/el14718/el14718/SOFTWARE/chap-version_0_9_1/src/trajectory-analysis/chap_trajectory_analysis.cpp(87): error #3291: invalid narrowing conversion from "double" to "float"
      pfInitProbePos_ = {std::nan(""), std::nan(""), std::nan("")};
                         ^

/mnt/storage/home/el14718/el14718/SOFTWARE/chap-version_0_9_1/src/trajectory-analysis/chap_trajectory_analysis.cpp(87): error #3291: invalid narrowing conversion from "double" to "float"
      pfInitProbePos_ = {std::nan(""), std::nan(""), std::nan("")};
                                       ^

/mnt/storage/home/el14718/el14718/SOFTWARE/chap-version_0_9_1/src/trajectory-analysis/chap_trajectory_analysis.cpp(87): error #3291: invalid narrowing conversion from "double" to "float"
      pfInitProbePos_ = {std::nan(""), std::nan(""), std::nan("")};
                                                     ^

/mnt/storage/home/el14718/el14718/SOFTWARE/chap-version_0_9_1/src/trajectory-analysis/chap_trajectory_analysis.cpp(1633): warning #192: unrecognized character escape sequence
                   <<"\% complete"
                      ^

/mnt/storage/home/el14718/el14718/SOFTWARE/chap-version_0_9_1/src/trajectory-analysis/chap_trajectory_analysis.cpp(1775): warning #192: unrecognized character escape sequence
               <<"\% complete"
                  ^

compilation aborted for /mnt/storage/home/el14718/el14718/SOFTWARE/chap-version_0_9_1/src/trajectory-analysis/chap_trajectory_analysis.cpp (code 2)
make[2]: *** [CMakeFiles/chap.dir/src/trajectory-analysis/chap_trajectory_analysis.cpp.o] Error 2
make[1]: *** [CMakeFiles/chap.dir/all] Error 2
make: *** [all] Error 2

So I tried to switch to gcc, but then I got this error:

[ 44%] Building CXX object CMakeFiles/chap.dir/config/config.cpp.o
[ 45%] Linking CXX executable chap
c++: error: unrecognized command line option '-qopenmp'; did you mean '-fopenmp'?
make[2]: *** [chap] Error 1
make[1]: *** [CMakeFiles/chap.dir/all] Error 2
make: *** [all] Error 2

I thought it could be a problem of gcc version (I used GCC 7.2.0) so I tried with the same GCC version (5.4.0) as the one used on my desktop for with the installation was a success (Ubuntu desktop with all prerequisite libraries installed with apt-get).

Do you have any ideas on how to fix it?
I am happy to replace -qopenmp with -fopenmp but I don't know where to change it.

Many thanks

@Fravadona
Copy link

Fravadona commented Dec 11, 2019

Hi eric-jm-lang,

I successfully built and ran CHAP, linked to GROMACS 2018.8, with everything compiled with Intel Compilers 2018.3 and Intel MKL 2018.3.

First you would need to apply the patch file at the end of #22 that fixes a few bugs and compilation issues.
Then, if you want to be able to relocate CHAP after installation then you'll also need to apply the patch in #23 .
And if you want to compile CHAP with MKL's LAPACK/LAPACKE/BLAS/CBLAS then you should also change this:

--- chap-version_0_9_1/src/geometry/cubic_spline_interp_1D.cpp.orig	2018-05-02 13:22:36.000000000 +0200
+++ chap-version_0_9_1/src/geometry/cubic_spline_interp_1D.cpp	2019-12-06 16:47:52.052585866 +0100
@@ -26,7 +26,7 @@
 #include <stdexcept>
 #include <string>
 
-#include <lapacke.h>
+#include <mkl_lapacke.h>
 
 #include "geometry/basis_spline.hpp"
 #include "geometry/cubic_spline_interp_1D.hpp"
--- chap-version_0_9_1/src/geometry/cubic_spline_interp_3D.cpp.orig	2018-05-02 13:22:36.000000000 +0200
+++ chap-version_0_9_1/src/geometry/cubic_spline_interp_3D.cpp	2019-12-06 16:48:16.509297021 +0100
@@ -26,7 +26,7 @@
 #include <stdexcept>
 #include <string>
 
-#include <lapacke.h>
+#include <mkl_lapacke.h>
 
 #include "geometry/basis_spline.hpp"
 #include "geometry/cubic_spline_interp_3D.hpp"

For CHAP compilation with MKL there's a trick in the CMAKE command, which is to specify a dot for all related LAPACK and BLAS stuff.
So here's my CMAKE command, with AVX2 processor acceleration but you can change it. GROMACS and BOOST are supposed to be installed in a "3rdparty" directory inside the CHAP directory:

# First source the Intel environement (Compilers and MKL)
. /opt/intel/XXXXXX/compilervars.sh intel64
. /opt/intel/XXXXXX/mklvars intel64

CHAPDIR='/opt/chap-gmx2018.8-intel2018.3-avx2'
IFLAGS='-xCORE-AVX2 -mkl=sequential'

cmake3 \
-DCMAKE_INSTALL_PREFIX=${CHAPDIR} \
-DGROMACS_DIR=${CHAPDIR}/3rdparty/share/cmake/gromacs \
-DBOOST_ROOT=${CHAPDIR}/3rdparty \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DCMAKE_C_COMPILER="$(which icc)" \
-DCMAKE_C_FLAGS="${IFLAGS}" \
-DCMAKE_CXX_COMPILER="$(which icpc)" \
-DCMAKE_CXX_FLAGS="${IFLAGS}" \
-DLAPACKE_CBLAS_INCLUDE_DIR=. \
-DLAPACKE_LAPACKE_INCLUDE_DIR=. \
-DLAPACKE_LIB=. \
-DLAPACK_LIB=. \
-DBLAS_LIB=. \
-DCBLAS_LIB=. \
..

Remark: As GROMACS utilises MKL in sequential mode, it may be a good idea to specify it for CHAP also (I'm not very sure).

Remark: If BOOST isn't installed on a standard location then the BOOST_ROOT won't work unless it is installed in the same place than GROMACS.

Remark: If you want to statically link the Intel libraries to the binary, just add -static-intel after -mkl=sequential (though GROMACS would also need to be compiled this way because it doesn't make sense otherwise).

That's all, I hope this will prove useful to you.
Cheers.

PS: If you you to compile GROMACS with static Intel libraries I can provide the CMAKE command for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants