Install kokkos package

Can you please explain more? Perhaps we should continue discussing by email–I really do want to understand this. Thanks

The OPENMP package uses pre-preprocessor macros to adjust the OpenMP pragmas depending on supported OpenMP semantics.

I see thanks. Can you point to me where in the LAMMPS code this happens? I’m asking the Kokkos developers about this.

I also see this: Porting to GCC 9 - GNU Project.

I think it may be better to have the explanation here, so that others looking for explanations can read it later.

There is a difference in whether variables declared “const” must or must not be listed in the “shared()” entry of an OpenMP pragma.

The OPENMP package tries to use “default(none)” directive wherever possible. This means, that variables that are shared across threads must be explicitly listed with “shared()”. The older semantics determine that variables declared “const” must not appear in a “shared()” list and the compiler errors out, if they do. The newer semantics require that those are listed.

The setting with the old semantics have been extremely helpful in avoiding errors in the parallel sections with unintentional parallel writing to variables. Unfortunately, with the new semantics, the best that can be done is to use the macros to hide the “default(none)” and the “shared()” list and switch to “default(shared)” instead. That is unless we can safely assume that all supported compilers use the new semantics and then the macros can be removed and the “shared()” list adjusted.

1 Like

I have been digging through the CMake documentation, and found that since CMake version 3.10 there is the option have a OpenMP_CXX_VERSION from the find_package(OpenMP). A lot of the CMake script code still has leftovers from when it was written to also support CMake version 2.8. So the test in the KOKKOS.cmake file can be changed to another one liner:

if(OpenMP_CXX_VERSION VERSION_LESS 4.0)

(or of course checking for 3.1 instead).

Would if(OpenMP_CXX_VERSION VERSION_LESS 4.0) error out for GCC 9.0 and above?

No. If I remember correctly, the requirement for C++14 needs a more recent GCC compiler than OpenMP 4.0. I just checked on an Ubuntu 18.04LTS container, and that has GCC 7.5 which reports OpenMP 4.5. (… and that needs an update to CMake to be usable with current Kokkos, FWIW)

@yu_lin we are relaxing the check for Kokkos OpenMP to >= v3.1, see Modernize OpenMP detection and checks in CMake by akohlmey · Pull Request #3500 · lammps/lammps · GitHub. So you should be able to build with your gcc/6.5.0 module with that change.

One thing I will mention is that unless you are running ReaxFF, generally the INTEL or OPENMP packages are faster than the Kokkos OpenMP backend, so I would try those first if the styles in your input are supported by those packages.

Thanks a lot. I am running ReaxFF.
And as the github link, do you mean now I could use with gcc/6.5.0 and minimun required cmake10 now?
Should I add those files to the corrosponding directories? Sorry I still don’t understand after I read this link. The below two commands are those I tried previously, do I need to further change them?
Thank you.

cmake -C …/cmake/presets/basic.cmake -C …/cmake/presets/kokkos-openmp.cmake …/cmake
cmake -C …/cmake/presets/kokkos-openmp.cmake -D Kokkos_ARCH_HSW=yes -D Kokkos_ENABLE_OPENMP=yes -D BUILD_OMP=yes …/cmake

The changes are now merged, so you need to update to the latest version of LAMMPS (develop branch on GitHub) that has those changes. Then it should work to build Kokkos OpenMP with GCC 6.5.