Giter Site home page Giter Site logo

pkestene / kokkos-proj-tmpl Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 1.0 938 KB

A minimal cmake based project skeleton for developping a kokkos application

License: GNU General Public License v3.0

CMake 4.07% C++ 44.90% C 51.03%
cuda gpu kokkos openmp performance-portability cea parallel-computing parallelization

kokkos-proj-tmpl's Introduction

kokkos-proj-tmpl

A minimal cmake based project skeleton for developping a kokkos application

Download this skeleton

git clone --recursive [email protected]:pkestene/kokkos-proj-tmpl.git

How to build ?

Requirement

  • cmake version 3.16

  • note: if you are on a fairly recent OS (ex: Ubuntu 21.10, or any OS using glibc >= 2.34), you may need to turn off linking with libdl when using kokkos/cuda backend. See this issue, as nvcc (even version 11.6) apparently doesn't seem to handle empty file /usr/lib/x86_64-linux-gnu/libdl.a (stub, libdl is integrated into glibc). Hopefully this will be solved in an upcoming cuda release.

# run this to know your glibc version
ldd --version

Build with target device OpenMP

Default behavior is to download and build kokkos from source; thus you need to specifiy for which hardware target (aka Kokkos backend) you want

mkdir -p build/openmp
cd build/openmp
CXX=YOUR_COMPILER_HERE cmake -DKOKKOS_PROJ_TMPL_BACKEND=OpenMP ../..
make
# then you can run the application
./src/saxpy_kokkos_lambda.openmp

Note that option -DKokkos_ENABLE_HWLOC=ON is enabled by default.

If you already have build and installed kokkos for some target backend (OpenMP, Cuda, HIP, etc...), you don't need to specify cmake option KOKKOS_PROJ_TMPL_BACKEND, it will determine by the build system but of course you need to set env variable CMAKE_PREFIX_PATH to the directory containing file KokkosConfig.cmake inside your kokkos installation.

Build with target device CUDA

You need to have Nvidia compiler nvcc in your PATH.

CMake and Kokkos will set the compiler to nvcc_wrapper (located in kokkos sources, cloned as git submodule).

mkdir -p build/cuda
cd build/cuda
cmake -DKOKKOS_PROJ_TMPL_BACKEND=Cuda -DKokkos_ARCH_AMPERE86=ON ../..
make
# then you can run the application as before
./src/saxpy_kokkos_lambda.cuda

Of course, you will need to adapt variable Kokkos_ARCH to your actual GPU architecture (use cuda sample device_query to probe the architecture).

Depending on your OS, you may need to set variable Kokkos_CUDA_DIR to point to your CUDA SDK (if cmake is not able to figure out by itself); e.g. /usr/local/cuda-9.0

Build with target device HIP (AMD GPU)

CMake and Kokkos will set the compiler to hipcc (located in kokkos sources, cloned as git submodule).

Example:

mkdir build_hip
cd build_hip
cmake -DKOKKOS_PROJ_TMPL_BACKEND=HIP -DKokkos_ARCH_VEGA908=ON ..
make
# then you can run the application as before
./src/saxpy_kokkos_lambda.hip

Additional notes

Stream benchmark

The stream benchmark source code is slightly adapted from BabelStream.

Stencil benchmark

Here are the results obtained on different computing platforms:

Intel Skylake (2x20 cores, Intel Xeon Gold 5115, icpc 2018.0.128)

stencil bench skylake icpc

Intel KNL (icpc 2017.0.6.256, OMP_NUM_THREADS=64)

stencil bench knl icpc_omp_64

Nvidia K80, cuda 9.2

stencil bench nvidia k80

Nvidia P100, cuda 9.2

stencil bench nvidia p100

glibc 2.34 and nvlink error

If using glibc version >= 2.34 you get the following link error when building with Cuda backend:

[ 65%] Linking CXX executable saxpy_kokkos_lambda.cuda
nvlink fatal   : Could not open input file '/usr/lib/x86_64-linux-gnu/libdl.a'
make[2]: *** [src/CMakeFiles/saxpy_kokkos_lambda.cuda.dir/build.make:118: src/saxpy_kokkos_lambda.cuda] Error 1
make[1]: *** [CMakeFiles/Makefile2:1047: src/CMakeFiles/saxpy_kokkos_lambda.cuda.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

One temporary solution (until fixed in a future nvcc release ?) is mentionned here: https://matsci.org/t/lammps-users-kokkos-linker-error-nvidia-libdl-a/41050

for simplicity, you just need to create a fake libdl.a, e.g. in current build dirrector

touch empty.c
gcc -fpic -c empty.c
ar rcsv libdl.a empty.o

and then reconfigure cmake with additionnal flag -DLIBDL_LIBRARY=$PWD/libdl.a and the build will work as expected.

kokkos-proj-tmpl's People

Contributors

pkestene avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

wangyf

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.