Skip to content

Kokkos and KokkosKernels

Paul Kuberry edited this page Mar 6, 2020 · 3 revisions

Installing Kokkos and KokkosKernels

There are three paths for providing a Kokkos and KokkosKernels installation, needed by the toolkit:

A.) Let Compadre Toolkit configure and build Kokkos + KokkosKernels

Since the source code for Kokkos and KokkosKernels is now bundled with the Compadre Toolkit, users can simply leave the CMake variable KokkosCore_PREFIX="" and provide configuration variables such as Kokkos_ENABLE_OPENMP=ON (see more examples at https://github.com/kokkos/kokkos/wiki/Compiling). Architecture can be specified, if desired, by Kokkos_ARCH_SOMEARCH=ON.

Valid choices for Kokkos_ARCH_SOMEARCH:BOOL=ON can be found in kokkos/BUILD.md.

or

B.) Installing Kokkos and KokkosKernels from source and providing the location to the toolkit

1.) Download Kokkos from github via:

>> git clone https://github.com/kokkos/kokkos.git

2.) Create a build directory for kokkos via:

>> cd kokkos
>> mkdir build
>> cd build

3.) Create file called configure.sh, and fill it with the following content (as an example):

cmake \
   -DCMAKE_CXX_STANDARD=11 \
   -DCMAKE_CXX_COMPILER=mpic++ \
   -DCMAKE_CXX_FLAGS=" -fPIC" \
   -DCMAKE_INSTALL_PREFIX=./install \
   -DKokkos_ENABLE_OPENMP=ON \
   -DKokkos_ENABLE_PTHREAD=OFF \
   -DKokkos_ENABLE_CUDA=OFF \
   -DKokkos_ENABLE_DEPRECATED_CODE=OFF \
   -DKokkos_ENABLE_CUDA_LAMBDA=ON \
   -DKokkos_ENABLE_DEBUG=ON \
..

The above example is for a basic CPU build with OpenMP. You can change the install prefix to whatever you would like. if you do not change it, then kokkos will be installed in /some/path/to/kokkos/build/install

4.) Set permissions on configure.sh so it can be run with:

>> chmod u+x configure.sh

5.) Run the script to configure.

>> ./configure.sh

6.) Build make install the project.

>> make -j4
>> make install

7.) Note where you installed Kokkos, as this install folder will be the location that your Compadre Toolkit build scripts should use as the value for the variable KokkosCore_PREFIX.

The instructions for Kokkos-Kernels are similar to the instructions for Kokkos.

Differences are:

  • The repo is at: https://github.com/kokkos/kokkos-kernels.git
  • You need to specify where you installed Kokkos with -DKokkos_ROOT:STRING=/some/path/to/kokkos/build/install
  • Instructions for CMake parameters can be found HERE
  • You will provide the KokkosKernel location to the toolkit with
    -DKokkosKernels_PREFIX:STRING=/some/path/to/kokkos-kernels/build/install

or

C.) Getting Kokkos and KokkosKernels from Trilinos

Provide the toolkit installation CMake variable -DTrilinos_PREFIX=/some/path/to/trilinos/install and be sure that it points to a valid Trilinos installation that at least contains Kokkos and KokkosKernels.