This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Kokkos

Build kokkos and kokkos-tutorials

1 - Building Kokkos with CMake on SCOREC (rhel9) machines

  1. Clone the Kokkos Repository: Create a new directory called Kokkos and clone Kokkos repository from GitHUb in that directory. You can do this using Git:
git clone https://github.com/kokkos/kokkos.git
  1. Load required modules: Kokkos requires compiler and cmake to build. Load the following modules. (Note: The modules are as per rhel9 machines. You can’t use it on rhel7 machines.)
module use /opt/scorec/spack/rhel9/v0201_4/lmod/linux-rhel9-x86_64/Core/
module load gcc/12.3.0-iil3lno mpich/4.1.1-xpoyz4t cuda/12.1.1-zxa4msk
module load cmake/3.20.0
  1. Configure with CMake: Create a new file config.sh (you can name anything) in a source directory. Inside config.sh, add the following CMake instructions:
cmake -S . \
     -B build \
     -DCMAKE_CXX_COMPILER=g++ \
     -DBUILD_SHARED_LIBS=ON \
     -DCMAKE_INSTALL_PREFIX=/lore/<username>/Kokkos/Install \
     -DKokkos_ENABLE_OPENMP=ON  
  1. Build and Install: Run the config.sh file with the command . config.sh and go to the build directory (cd build). Run the command make install.

  2. Add in your environment variable: Add the executable to the LD_LIBRARY_PATHenvironment variable. Use the following command to add to the environment variable.

export LD_LIBRARY_PATH=/lore/<username>/Kokkos/Install/lib64:$LD_LIBRARY_PATH

2 - Building kokkos-tutorials

The following instructions is for building a new Kokkos library for each exercise. For more details, check Kokkos Tutorials.

  1. Clone the Kokkos Tutorials Repository: The tutorials for the Kokkos C++ programming. You can clone the tutorials with the following command.
git clone https://github.com/kokkos/kokkos-tutorials.git
  1. Load required modules: Kokkos tutorials requires compiler and make to build. Load the following modules. (Note: The modules are as per rhel9 machines. You can’t use it on rhel7 machines.)
module use /opt/scorec/spack/rhel9/v0201_4/lmod/linux-rhel9-x86_64/Core/
module load gcc/12.3.0-iil3lno mpich/4.1.1-xpoyz4t cuda/12.1.1-zxa4msk
  1. Find the GPU architecture of your machine: To find out the GPU architecture of your machine, follow this.

  2. Build with make: Inside kokkos-tutorials folder, go to Exercises folder.In each exercise folder, there is a makefile to build each exercise. Open the Makefile and make the following changes.

KOKKOS_PATH = /path/to/kokkos 
KOKKOS_DEVICES = "<your GPU language>"
KOKKOS_ARCH = "<your GPU Architecture>"

For example,

KOKKOS_PATH = /lore/<username>/Kokkos/kokkos`
KOKKOS_DEVICES = "Cuda"
KOKKOS_ARCH = "Ada89"

After making changes, run the command make -j8

  1. Run the executable: Once configuring and building the exercise, run an exexutable. ```bash ./