Install kokkos package

Hello, I am trying to install kokkos into my lammps, 23Jun2022 version, on ubuntu system.
I have created a Build directory, and cd build
then cmake as below:

cmake -C ../cmake/presets/kokkos-openmp.cmake -D Kokkos_ARCH_HOSTARCH=yes -D Kokkos_ENABLE_OPENMP=yes -D BUILD_OMP=yes ../cmake

But an error occurs, showing
Compiler must support OpenMP 4.0 or later with Kokkos_ENABLE_OPENMP
I don’t why and how to solve this, I have checked my gcc on ubuntu, it shows it’s already the newest version.
Could you help me to solve this?

Please report which GCC version exactly you have an what version of Ubunbtu you have.

Your GCC compiler may be the latest version for your distribution, but it has been detected by the Kokkos support library as not fully supporting the OpenMP 4.0 specifications and thus incompatible with the OpenMP support in Kokkos.
Thus the way to resolve this is most likely to upgrade your Ubuntu version.

1 Like

It shows :
gcc is already the newest version (4:5.3.1-1ubuntu1).
thank you, I will try to upgrade it.

Hi, though I didn’t upgrade the Ubuntu version, I upgrade my gcc version to 12.1.0 now. But it still shows
Compiler must support OpenMP 4.0 or later with Kokkos_ENABLE_OPENMP.
I also checked my cmake version which is cmake version 3.25.0-rc2, the newest one.
Does this mean I still have to update other compliers like gfortran? It seems it’s also an outdated version: GNU Fortran (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609.
Thank you. :slight_smile:

Please provide the entire output of your cmake command and the exact command line that you have used.

1 Like

command line:
lin@lin-virtual-machine:~/Desktop/lammps/lammps-23Jun2022/build$ cmake -C …/cmake/presets/kokkos-openmp.cmake -D Kokkos_ARCH_HOSTARCH=yes -D Kokkos_ENABLE_OPENMP=yes -D BUILD_OMP=yes …/cmake
error:
CMake Error at Modules/Packages/KOKKOS.cmake:19 (message):
Compiler must support OpenMP 4.0 or later with Kokkos_ENABLE_OPENMP
Call Stack (most recent call first):
CMakeLists.txt:638 (include)

This is not the entire output.

1 Like

Thank you, I upgraded my ubuntu system and downloaded some new versions of compliers, and this cmake error doesn’t happen now.
But after the below commands to install kokkos-openmp:
1 cd build
2 cmake -C …/cmake/presets/kokkos-openmp.cmake -D Kokkos_ARCH_WSM=yes -D Kokkos_ENABLE_OPENMP=yes -D BUILD_OMP=yes …/cmake
3 cmake --build .
4 make install

When I go back to run the code:
mpirun -np 4 lmp_kokkos_omp -k on -sf kk -in reaxff_Li_copy.lmp

the following message apprears:

mpirun was unable to find the specified executable file, and therefore
did not launch the job. This error was first reported for process
rank 0; it may have occurred for other processes as well.

NOTE: A common cause for this error is misspelling a mpirun command
line parameter option (remember that mpirun interprets the first
unrecognized command line token as the executable).

Node: lin-virtual-machine
Executable: lmp_kokkos_omp

Is there anything wrong with my cmake procedures? Sorry that I am new to this.

With the commands you used, the name of your executable would be “lmp” and not “lmp_kokkos_omp”. So the problem is, as indicated by the error message, that the mpirun command cannot find the executable you specified. You also have to make certain that the $HOME/.local/bin folder is in your PATH environment variable. Otherwise you must use the full path to the executable.

This is standard Unix/Linux stuff and not really a LAMMPS issue.

1 Like

I have tried change to lmp
mpirun -np 4 lmp -k on -sf kk -pk kokkos -in reaxff_Li_copy.lmp
And also set the HOME/.local/bin as $PATH environment variable.
But still shows: can not use kokkos on without KOKKOS installed, like the below picture:


Do you know how to solve this? :joy:

Often this happens when another LAMMPS program has already been installed on your system, and when you call lmp you end up calling that executable rather than the one you have just compiled.

You can use which lmp or command -v lmp to see where exactly your system calls its default lmp from.

When you self-compile packages, and you are not doing any explicit environment management (e.g. modifying PATH, building your own Lmod module, using a package manager like Spack), it is often useful to specify a path when calling a program – that is, explicitly calling ~/.local/bin/lmp rather than lmp to avoid confusion.

This is also why the LAMMPS CMake procedure includes a flag you can set to name the executable, for example lmp_kokkos_omp – something like LAMMPS_MACHINE_NAME if I recall correctly.

Also note that, as Axel has said, this is very much general operating system stuff rather than LAMMPS-specific.

2 Likes

Thanks a lot srtee and akohlmey, after adding path to lmp, problem solved

1 Like

Hello, I encountered the same problem as two days ago.
The error : Compiler must support OpenMP 4.0 or later with Kokkos_ENABLE_OPENMP
Last time I solved this by upgrading my ubuntu system, but now I am trying to install this KOKKOS package on supercomputer, so cannot upgrade this system, can only load module.
I tried two commands but yielding the same error,

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

The output is shown below.

loading initial cache file …/cmake/presets/basic.cmake

loading initial cache file …/cmake/presets/kokkos-openmp.cmake

– The CXX compiler identification is GNU 6.5.0

– Check for working CXX compiler: /app/gcc/6.5.0/bin/c++

– Check for working CXX compiler: /app/gcc/6.5.0/bin/c++ – works

– Detecting CXX compiler ABI info

– Detecting CXX compiler ABI info - done

– Detecting CXX compile features

– Detecting CXX compile features - done

– Found Git: /usr/bin/git (found version “1.7.1”)

– Appending /app/gcc/SCILibs/lib:/app/gcc/SCILibs/lib64:/app/isl/0.14/lib:/app/mpc/1.0.3/lib:/app/mpfr/3.1.4/lib:/app/gmp/6.1.0/lib to CMAKE_LIBRARY_PATH: /app/gcc/SCILibs/lib:/app/gcc/SCILibs/lib64:/app/isl/0.14/lib:/app/mpc/1.0.3/lib:/app/mpfr/3.1.4/lib:/app/gmp/6.1.0/lib

– Running check for auto-generated files from make-based build system

– Looking for C++ include omp.h

– Looking for C++ include omp.h - found

– Found OpenMP_CXX: -fopenmp (found version “4.5”)

– Found OpenMP: TRUE (found version “4.5”)

– Found JPEG: /usr/lib64/libjpeg.so (found version “62”)

– Found GZIP: /bin/gzip

– Could NOT find FFMPEG (missing: FFMPEG_EXECUTABLE)

– Found PkgConfig: /usr/bin/pkg-config (found version “0.23”)

– Checking for module ‘fftw3’

– Found fftw3, version 3.2.1

– Found FFTW3: /usr/lib64/libfftw3.so

– Looking for C++ include cmath

– Looking for C++ include cmath - found

CMake Error at Modules/Packages/KOKKOS.cmake:19 (message):

Compiler must support OpenMP 4.0 or later with Kokkos_ENABLE_OPENMP

Call Stack (most recent call first):

CMakeLists.txt:638 (include)

I loaded several modules as the below picture,

And complier versions of limited number are available on supercomputer, as the below picture.
I have noticed on the gcc wiki, they says:
GCC 4.9 supports OpenMP 4.0 for C/C++, GCC 4.9.1 also for Fortran. GCC 5 adds support for Offloading. OpenMP 4.5 is supported for C/C++ since GCC 6 and since GCC 7 for Fortran (with omissions, largest missing item is structure element mapping).
So I don’t know what’s wrong with the current version of gcc/4.9.3. Could you help me?

The full OpenMP 4.0 spec is only implemented in GCC version 9.0 and later.

Since you have the source code, you can disable that check at lines 18-20 of cmake/Modules/Packages/KOKKOS.cmake, but that will also mean that with any future KOKKOS issues, you are on your own.

The alternative to using KOKKOS with OpenMP, is to use the OPENMP package, which is compatible with older GCC versions as well.

I’m not following–any GCC version that supports C++14 should work fine with Kokkos OpenMP. You certainly don’t need 9.0 or later. But GCC 4.9.3 is too old for C++14, GCC 6.5 should work though.

I think it should work if you load only the gcc/6.5.0 module, not both 4.9.3 and 6.5.0.

GCC before 9.0 has different semantics for const variables.

So the compilers may implement the full set of OpenMP 4.0 or 4.5 but there is a difference in behavior that at least affects the core part of LAMMPS.

This is a bit of an unfortunate situation, since basically it was an oversight in the specs and none of the compiler vendors initially implemented it, but the OpenMP standard folks decided to keep the different semantics rather revert the requirements to the old behavior. Unlike other compiler vendors that decided to support both variants, the GCC developers made a hard switch and only support pre-OpenMP 4 semantics before version 9.0 and only OpenMP 4/5 semantics since version 9.0

The test for this is around line 405 to 416 in cmake/CMakeLists.txt and cmake/Modules/Packages/KOKKOS.cmake uses the result.

@akohlmey Unless I’m missing something, I think that check is overkill though, at least for Kokkos. We don’t have that same check for the Makefile build system. Here is what the Kokkos wiki says:

Minimum Compiler Versions

    GCC: 5.3.0
    Clang: 4.0.0
    Intel: 17.0.1
    NVCC: 9.2.88
    NVC++: 21.5
    ROCM: 4.3
    MSVC: 19.29
    IBM XL: 16.1.1
    Fujitsu: 4.5.0
    ARM/Clang 20.1

Primary Tested Compilers

    GCC: 5.3.0, 6.1.0, 7.3.0, 8.3, 9.2, 10.0
    NVCC: 9.2.88, 10.1, 11.0
    Clang: 8.0.0, 9.0.0, 10.0.0, 12.0.0
    Intel 17.4, 18.1, 19.5
    MSVC: 19.29
    ARM/Clang: 20.1
    IBM XL: 16.1.1
    ROCM: 4.3.0

Build system:

    CMake >= 3.16: required
    CMake >= 3.18: Fortran linkage. This does not affect most mixed Fortran/Kokkos builds. See build issues.
    CMake >= 3.21.1 for NVC++

If you want to maintain a separate check for which compilers are compatible or drop the check entirely (and deal with the consequences), be my guest.

I’m not sure what you mean by “consequences”. As far as I know, there is no requirement to use v4.0 OpenMP in Kokkos, e.g. using v3.1 is fine. How is Kokkos different from the OPENMP package, which you mentioned is “compatible with older GCC versions”?