Compute Mandelbrot Set using adaptive mesh refinement technique and C++/kokkos library for multi-architecture execution. This is not intended to be efficient computation, but just a simple illustrative example of use of class Kokkos::UnorderedMap container (multi-architecture hash map data container). Mandelbrot set is computed iteratively, refined cells are inserted into the hashmap based data structure.
The following source code is self-contained; C++/kokkos library sources are included as a git submodule.
Example of Mandelbrot set with level_min=6 and level_max=11
./compute_mandelbrot_amr 6 11
Make sure to clone this repository recursively, this will also download kokkos source as a git submodule.
git clone --recurse-submodules https://github.com/pkestene/AMR_mandelbrot.git
Kokkos is built as part of this project with the cmake build system.
To build kokkos/OpenMP backend
mkdir build_openmp; cd build_openmp
ccmake -DKOKKOS_ENABLE_OPENMP=ON -DCMAKE_BUILD_TYPE=Release ..
make
Optionally, you can (recommended) activate HWLOC support by turning ON the flag KOKKOS_ENABLE_HWLOC.
ccmake -DKOKKOS_ENABLE_OPENMP=ON -DCMAKE_BUILD_TYPE=Release -DKOKKOS_ENABLE_HWLOC=ON ..
Obviously, you need to have Nvidia/CUDA driver and toolkit installed on your platform. Then you need to
-
tell cmake to use kokkos compiler wrapper for cuda:
export CXX=/complete/path/to/kokos/bin/nvcc_wrapper
-
activate CUDA backend in the ccmake interface.
- Just turn on KOKKOS_ENABLE_CUDA
- select cuda architecture, e.g. set KOKKOS_ARCH to Kepler37 (for Nvidia K80 boards)
# example build for cuda mkdir build_cuda; cd build_cuda ccmake -DKOKKOS_ENABLE_CUDA=ON -DKOKKOS_ARCK=Kepler37 -DKOKKOS_ENABLE_CUDA_LAMBDA=ON -DKOKKOS_ENABLE_HWLOC=ON .. make