Skip to content

Kokkos

A programming model in C++ for writing performance portable applications targeting all major HPC platforms.


Warning

This installation of Kokkos is experimental and under active testing. Errors or inconsistencies may occur until validation is complete. Please report any issues to RCC Support.

Overview#

Kokkos is a C++ performance portability library that enables developers to write applications that can efficiently execute across different architectures without changing the source code. It provides abstractions for parallel execution and data management that simplify cross-platform HPC development.

Two versions of Kokkos are currently available on RCC systems:

  • 4.7.00: Must be used with NVHPC compilers
  • 4.5.1: Musit be used with Intel compilers

Loading Kokkos Modules#

NVHPC Build (4.7.00)#

$ module purge
$ module load nvhpc kokkos

Optional combinations:

1
2
3
$ module load nvhpc openmpi kokkos
# or
$ module load nvhpc/23.11 kokkos/4.7.00

Intel Build (4.5.1)#

$ module purge
$ module load intel kokkos

Optional combinations:

1
2
3
$ module load intel openmpi kokkos
# or
$ module load intel/21 kokkos/4.5.1

Compiling with Kokkos#

Once loaded, the nvcc_wrapper compiler wrapper can be used to build C++ codes that utilize Kokkos.

Example Compilation: NVHPC#

$ nvcc_wrapper example.cpp -o example.x ${KOKKOS_FLAGS}

If needed, you can include the HWLOC paths explicitly:

$ nvcc_wrapper example.cpp -o example.x  -I${KOKKOS_INCLUDE} -I${NVHPC_HWLOC_INCLUDE}  -mp -std=c++17 --extended-lambda  -L${KOKKOS_LIBS} -lkokkoscore  -L${NVHPC_HWLOC_LIBS} -lhwloc

Example Compilation: Intel#

$ nvcc_wrapper example.cpp -o example.x ${KOKKOS_FLAGS}

With explicit HWLOC paths:

$ nvcc_wrapper example.cpp -o example.x  -I${KOKKOS_INCLUDE}  -I/opt/rcc/intel/include  -qopenmp -std=c++17  -L${KOKKOS_LIBS} -lkokkoscore  -L/opt/rcc/intel/lib64 -lhwloc

MPI + Kokkos Compilation Examples#

NVHPC#

1
2
3
4
$ module purge
$ module load nvhpc kokkos openmpi

$ nvcc_wrapper mpicode.cpp -o mpicode.x -I${MPI_INCLUDE} -L${MPI_LIB} -lmpi ${KOKKOS_FLAGS}

Intel#

1
2
3
4
$ module purge
$ module load intel kokkos openmpi

$ nvcc_wrapper mpicode.cpp -o mpicode.x -I${MPI_INCLUDE} -L${MPI_LIB} -lmpi ${KOKKOS_FLAGS}

Example Code#

You can find beginner-friendly examples in the Kokkos Tutorials Repository, including examples for:

  • Simple data parallel patterns and policies
  • Multidimensional array views
  • Execution and memory spaces

Getting Help#

For assistance compiling or running Kokkos programs on RCC systems, contact the RCC Support Team.