mir-group / flare_pp

A many-body extension of the FLARE code.
MIT License
35 stars 7 forks source link

compilation problem with lammps-flare for gpu via kokkos #45

Closed eric-yu-zhu closed 2 years ago

eric-yu-zhu commented 2 years ago

Dear flare team,

I am having problem compiling lammps-flare with gpu via kokkos. On the other hand, I can run flare and compile lammps with gpu via kokkos without flare. So the problem might be in the connetion between flare and lammps. Any help would be appreciated!

Version info

Command history

Error message

[ 13%] Building CXX object _deps/kokkoskernels-build/src/CMakeFiles/kokkoskernels.dir/impl/tpls/KokkosBlas_Rocm_tpl.cpp.o
[ 13%] Building CXX object _deps/kokkoskernels-build/src/CMakeFiles/kokkoskernels.dir/impl/tpls/KokkosKernels_tpl_handles.cpp.o
   /home/eric/UserData/user2022b/proj01_NanoMD2/lammps_gpu/build/_deps/kokkoskernels-src/src/common/Kokkos_ArithTraits.hpp(979): error: no instance of function template "Kokkos::abs" matches the argument list  argument types are: (std::enable_if_t<true, float>)
   /home/eric/UserData/user2022b/proj01_NanoMD2/lammps_gpu/build/_deps/kokkoskernels-src/src/common/Kokkos_ArithTraits.hpp(998): error: no instance of overloaded function "Kokkos::pow" matches the argument list  argument types are: (std::enable_if_t<true, float>, std::enable_if_t<true, float>)
   /home/eric/UserData/user2022b/proj01_NanoMD2/lammps_gpu/build/_deps/kokkoskernels-src/src/common/Kokkos_ArithTraits.hpp(1003): error: no instance of function template "Kokkos::sqrt" matches the argument list  argument types are: (std::enable_if_t<true, float>)
   /home/eric/UserData/user2022b/proj01_NanoMD2/lammps_gpu/build/_deps/kokkoskernels-src/src/common/Kokkos_ArithTraits.hpp(1007): error: namespace "Kokkos" has no member "cbrt"
   /home/eric/UserData/user2022b/proj01_NanoMD2/lammps_gpu/build/_deps/kokkoskernels-src/src/common/Kokkos_ArithTraits.hpp(1011): error: no instance of overloaded function "Kokkos::exp" matches the argument list  argument types are: (std::enable_if_t<true, float>)
YuuuXie commented 2 years ago

This seems to be a kokkos version issue? @anjohan

anjohan commented 2 years ago

Hi @eric-yu-zhu ,

I think this is a mismatch between the Kokkos library bundled with LAMMPS and the KokkosKernels that we download.

In lammps/cmake/CMakeLists.txt, locate kokkoskernels near the bottom and add the GIT_TAG line below:

        FetchContent_Declare(
            kokkoskernels
            GIT_REPOSITORY https://github.com/kokkos/kokkos-kernels.git
            GIT_TAG 3.6.00
        )

Btw, I wouldn't necessarily expect

-DKokkos_ENABLE_CUDA=yes -DKokkos_ENABLE_OPENMP=yes

to work together. While I did template PairFLAREKokkos on the device, there is a decent chance that I have forgotten to use it in some places, and I have never tried running Kokkos with OpenMP in a CUDA build.

If you find problems running OpenMP, you can make a separate build directory without CUDA enabled. As of writing, the Kokkos pair style is also optimized for GPUs only, so it will probably be faster to just run the non-Kokkos version with MPI when not using the GPU.

eric-yu-zhu commented 2 years ago

Hi anjohan, thank you so much for your advice. The solution works nicely!

I believe you are right about the -DKokkos_ENABLE_OPENMP flag. It was copied from lammps website.

For those who have trouble with kokkos like me, here's the recipe that worked on my gpu workstation

compilation recipe

anjohan commented 2 years ago

Great!

I'll have a look to see if there's a way to automatically determine the KokkosKernels version based on the LAMMPS+Kokkos versions selected by the user.