본문 바로가기

LAMMPS

LAMMPS Intel build w/ Python module

찌꺼기 제거

make uninstall
xargs sudo rm < install_manifest.txt
rm -rf *

 

환경변수 세팅

source /opt/intel/oneapi/setvars.sh
module load compiler-intel-llvm/latest

 

cmake

cmake ../cmake \
   -D BUILD_MPI=yes \
   -D BUILD_OMP=yes \
   -DCMAKE_C_COMPILER=icx \
   -DCMAKE_CXX_COMPILER=icpx \
   -DCMAKE_Fortran_COMPILER=ifx \
   -D PKG_INTEL=yes \
   -D PKG_OPENMP=yes \
   -D PKG_GRANULAR=yes \
   -D PKG_RIGID=yes \
   -D PKG_MOLECULE=yes \
   -D PKG_PYTHON=yes \
   -D PKG_VTK=yes \
   -D PKG_EXTRA-FIX=yes \
   -D VTK_DIR=/usr/local/vtk_intelOneAPI/lib/cmake/vtk-9.4 \
   -D Python_EXECUTABLE=/usr/bin/python3 \
   -D INTEL_ARCH=cpu \
   -D INTEL_LRT_MODE=threads \
   -D BUILD_SHARED_LIBS=yes \
   -D CMAKE_INSTALL_PREFIX=~\LAMMPS_intelOneAPI

 

VTK_DIR과 같이 외부 C++ source 를 엮을 때는 VTKConfig.cmake 와 같이 링크되는 src의 .cmake 파일이 있는 위치를 적어야 된다.

 

make -j 4

 

하면 아래와 같은 에러가 뜨는데,

 

[ 44%] Building CXX object CMakeFiles/lammps.dir/home/hp-z8/Downloads/lammps/src/lammps.cpp.o
In file included from /home/hp-z8/Downloads/lammps/src/lammps.cpp:24:
In file included from /home/hp-z8/Downloads/lammps/build_intelOneAPI/styles/style_dump.h:10:
In file included from /home/hp-z8/Downloads/lammps/src/VTK/dump_vtk.h:31:
In file included from /usr/local/include/vtk-9.4/vtkCellArray.h:126:
In file included from /usr/local/include/vtk-9.4/vtkAbstractCellArray.h:18:
In file included from /usr/local/include/vtk-9.4/vtkObject.h:33:
In file included from /usr/local/include/vtk-9.4/vtkObjectBase.h:42:
In file included from /usr/local/include/vtk-9.4/vtkIndent.h:16:
In file included from /usr/local/include/vtk-9.4/vtkSystemIncludes.h:31:
In file included from /usr/local/include/vtk-9.4/vtkType.h:9:
In file included from /usr/local/include/vtk-9.4/vtk_kwiml.h:7:
/usr/local/include/vtk-9.4/vtkkwiml/abi.h:544:1: error: redeclaration of 'KWIML_ABI_detail_VERIFY_KWIML_ABI___INT64_IS_LONG_v1' with a different type: 'int (*)(long *)' vs 'int (*)(long long *)'
  544 | KWIML_ABI_private_VERIFY_SAME(KWIML_ABI___INT64_IS_LONG, __int64, long);
      | ^
/usr/local/include/vtk-9.4/vtkkwiml/abi.h:525:48: note: expanded from macro 'KWIML_ABI_private_VERIFY_SAME'
  525 | #define KWIML_ABI_private_VERIFY_SAME(m, x, y) KWIML_ABI_private_VERIFY_SAME_IMPL(KWIML_ABI_detail_VERIFY_##m, x, y)
      |                                                ^
/usr/local/include/vtk-9.4/vtkkwiml/abi.h:511:53: note: expanded from macro 'KWIML_ABI_private_VERIFY_SAME_IMPL'
  511 | #define KWIML_ABI_private_VERIFY_SAME_IMPL(n, x, y) KWIML_ABI_private_VERIFY_SAME_IMPL_0(KWIML_ABI_private_VERSION, n, x, y)
      |                                                     ^
/usr/local/include/vtk-9.4/vtkkwiml/abi.h:512:58: note: expanded from macro 'KWIML_ABI_private_VERIFY_SAME_IMPL_0'
  512 | #define KWIML_ABI_private_VERIFY_SAME_IMPL_0(V, n, x, y) KWIML_ABI_private_VERIFY_SAME_IMPL_1(V, n, x, y)
      |                                                          ^
/usr/local/include/vtk-9.4/vtkkwiml/abi.h:513:99: note: expanded from macro 'KWIML_ABI_private_VERIFY_SAME_IMPL_1'
  513 | #define KWIML_ABI_private_VERIFY_SAME_IMPL_1(V, n, x, y) extern int (*n##_v##V)(x*); extern int (*n##_v##V)(y*)
      |                                                                                                   ^
<scratch space>:185:1: note: expanded from here
  185 | KWIML_ABI_detail_VERIFY_KWIML_ABI___INT64_IS_LONG_v1
      | ^
/usr/local/include/vtk-9.4/vtkkwiml/abi.h:544:1: note: previous declaration is here
/usr/local/include/vtk-9.4/vtkkwiml/abi.h:525:48: note: expanded from macro 'KWIML_ABI_private_VERIFY_SAME'
  525 | #define KWIML_ABI_private_VERIFY_SAME(m, x, y) KWIML_ABI_private_VERIFY_SAME_IMPL(KWIML_ABI_detail_VERIFY_##m, x, y)
      |                                                ^
/usr/local/include/vtk-9.4/vtkkwiml/abi.h:511:53: note: expanded from macro 'KWIML_ABI_private_VERIFY_SAME_IMPL'
  511 | #define KWIML_ABI_private_VERIFY_SAME_IMPL(n, x, y) KWIML_ABI_private_VERIFY_SAME_IMPL_0(KWIML_ABI_private_VERSION, n, x, y)
      |                                                     ^
/usr/local/include/vtk-9.4/vtkkwiml/abi.h:512:58: note: expanded from macro 'KWIML_ABI_private_VERIFY_SAME_IMPL_0'
  512 | #define KWIML_ABI_private_VERIFY_SAME_IMPL_0(V, n, x, y) KWIML_ABI_private_VERIFY_SAME_IMPL_1(V, n, x, y)
      |                                                          ^
/usr/local/include/vtk-9.4/vtkkwiml/abi.h:513:71: note: expanded from macro 'KWIML_ABI_private_VERIFY_SAME_IMPL_1'
  513 | #define KWIML_ABI_private_VERIFY_SAME_IMPL_1(V, n, x, y) extern int (*n##_v##V)(x*); extern int (*n##_v##V)(y*)
      |                                                                       ^
<scratch space>:183:1: note: expanded from here
  183 | KWIML_ABI_detail_VERIFY_KWIML_ABI___INT64_IS_LONG_v1
      | ^
[ 45%] Building CXX object CMakeFiles/lammps.dir/home/hp-z8/Downloads/lammps/src/lattice.cpp.o
[ 45%] Building CXX object CMakeFiles/lammps.dir/home/hp-z8/Downloads/lammps/src/library.cpp.o
1 error generated.
make[2]: *** [CMakeFiles/lammps.dir/build.make:3257: CMakeFiles/lammps.dir/home/hp-z8/Downloads/lammps/src/lammps.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:176: CMakeFiles/lammps.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

 

이건 intelOneAPI와 VTK간의 변수 길이 체크 문제로 아래의 파일을 찾아서,

/usr/local/vtk_intelOneAPI/include/vtk-9.4/vtkkwiml/abi.h

 

아래의 부분을 주석처리해 버린다.

// --- Begin Patch ---
//#if 0
//#if defined(KWIML_ABI___INT64_IS_LONG)
//KWIML_ABI_private_VERIFY_SAME(KWIML_ABI___INT64_IS_LONG, __int64, long);
//#elif defined(KWIML_ABI___INT64_IS_LONG_LONG)
//KWIML_ABI_private_VERIFY_SAME(KWIML_ABI___INT64_IS_LONG_LONG, __int64, long long);
//#elif defined(KWIML_ABI_SIZEOF___INT64) && KWIML_ABI_SIZEOF___INT64 > 0
//KWIML_ABI_private_VERIFY_DIFF(KWIML_ABI___INT64_NOT_LONG, __int64, long);
//# if defined(KWIML_ABI_SIZEOF_LONG_LONG) && KWIML_ABI_SIZEOF_LONG_LONG > 0
//KWIML_ABI_private_VERIFY_DIFF(KWIML_ABI___INT64_NOT_LONG_LONG, __int64, long long);
//# endif
//#endif
// --- End Patch ---

 

다시

make -j 4
sudo make install

 

파이썬 가상환경 세팅

python3 -m venv ~/my_lammps_venv
source ~/my_lammps_venv/bin/activate

 

파이썬 모듈 설치

sudo make install-python

 

테스트 러닝

python -c "import lammps; lmp = lammps.lammps(); print(lmp.version())"

 

실행

mpirun -np 2 \
  -genv I_MPI_PIN 1 \
  -genv I_MPI_PIN_DOMAIN socket \
  ./lmp -var ompTh 20 -in MWE_5.in

'LAMMPS' 카테고리의 다른 글