This is a simple example to illustrate one possible way to use Kokkos inside an application built with CMake.
Please note that in this application kokkos is used as a git submodule. As such kokkos will be built by the top level cmake using the provided architecture information.
In order to download both mandelbrot_kokkos sources and kokkos itself, either use the following lines
git clone https://github.com/tpadioleau/mandelbrot_kokkos_cmake.git
cd mandelbrot_kokkos
git submodule init
git submodule update
or do the same in one step (clone mandelbrot_kokkos and kokkos):
git clone --recursive https://github.com/tpadioleau/mandelbrot_kokkos_cmake.git
- Build with target no device
mkdir build_serial && cd build_serial
cmake ..
make
# then you can run the application
./src/mandelbrot_kokkos
- Build with target device OpenMP
mkdir build_openmp && cd build_openmp
cmake -DCMAKE_CXX_COMPILER=YOUR COMPILER HERE -DKOKKOS_ENABLE_OPENMP=ON ..
make
# then you can run the application
./src/mandelbrot_kokkos
Optionally you can enable HWLOC by passing -DKOKKOS_ENABLE_HWLOC=ON on cmake's command line (or in ccmake curse gui).
- Build with target device CUDA
You NEED to use nvcc_wrapper as the CXX compiler. nvcc_wrapper is located in kokkos sources, bin subdirectory.
mkdir build_cuda && cd build_cuda
cmake -DCMAKE_CXX_COMPILER=path/to/kokkos/bin/nvcc_wrapper -DKOKKOS_ENABLE_CUDA=ON -DKOKKOS_ARCH=Maxwell ..
make
# then you can run the application as before
./src/mandelbrot_kokkos
Of course, you will need to adapt variable KOKKOS_ARCH to your actual GPU architecture (use cuda sample device_query to probe the architecture).