{"id":23207923,"url":"https://github.com/pkestene/kokkos-proj-tmpl","last_synced_at":"2025-08-19T03:30:37.260Z","repository":{"id":86494648,"uuid":"133020368","full_name":"pkestene/kokkos-proj-tmpl","owner":"pkestene","description":"A minimal cmake based project skeleton for developping a kokkos application","archived":false,"fork":false,"pushed_at":"2024-11-28T17:12:03.000Z","size":951,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-28T18:24:46.770Z","etag":null,"topics":["cea","cuda","gpu","kokkos","openmp","parallel-computing","parallelization","performance-portability"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pkestene.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-11T09:35:53.000Z","updated_at":"2024-11-28T17:12:07.000Z","dependencies_parsed_at":"2024-11-28T21:15:49.462Z","dependency_job_id":null,"html_url":"https://github.com/pkestene/kokkos-proj-tmpl","commit_stats":null,"previous_names":[],"tags_count":1,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkestene%2Fkokkos-proj-tmpl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkestene%2Fkokkos-proj-tmpl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkestene%2Fkokkos-proj-tmpl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkestene%2Fkokkos-proj-tmpl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pkestene","download_url":"https://codeload.github.com/pkestene/kokkos-proj-tmpl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230312431,"owners_count":18206852,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cea","cuda","gpu","kokkos","openmp","parallel-computing","parallelization","performance-portability"],"created_at":"2024-12-18T17:26:36.244Z","updated_at":"2024-12-18T17:26:37.199Z","avatar_url":"https://github.com/pkestene.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kokkos-proj-tmpl\n\nA minimal cmake based project skeleton for developping a kokkos application\n\n## Download this skeleton\n\n```bash\ngit clone --recursive git@github.com:pkestene/kokkos-proj-tmpl.git\n```\n\n## How to build ?\n\n### Requirement\n\n- [cmake](https://cmake.org/) version 3.16\n\n- **note**: if you are on a fairly recent OS (ex: Ubuntu 21.10, or any OS using glibc \u003e= 2.34), you may need to turn off linking with libdl when using kokkos/cuda backend. See [this issue](https://github.com/kokkos/kokkos/issues/4824), 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.\n\n```shell\n# run this to know your glibc version\nldd --version\n```\n\n### Build with target device OpenMP\n\nDefault behavior is to download and build kokkos from source; thus you need to specifiy for which hardware target (aka Kokkos backend) you want\n\n```bash\nmkdir -p build/openmp\ncd build/openmp\nCXX=YOUR_COMPILER_HERE cmake -DKOKKOS_PROJ_TMPL_BACKEND=OpenMP ../..\nmake\n# then you can run the application\n./src/saxpy_kokkos_lambda.openmp\n```\n\nNote that option `-DKokkos_ENABLE_HWLOC=ON` is enabled by default.\n\nIf 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.\n\n### Build with target device CUDA\n\nYou need to have Nvidia compiler `nvcc` in your PATH.\n\nCMake and Kokkos will set the compiler to `nvcc_wrapper` (located in kokkos sources, cloned as git submodule).\n\n```bash\nmkdir -p build/cuda\ncd build/cuda\ncmake -DKOKKOS_PROJ_TMPL_BACKEND=Cuda -DKokkos_ARCH_AMPERE86=ON ../..\nmake\n# then you can run the application as before\n./src/saxpy_kokkos_lambda.cuda\n```\n\nOf course, you will need to adapt variable **Kokkos_ARCH** to your actual GPU architecture (use cuda sample device_query to probe the architecture).\n\nDepending 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\n\n### Build with target device HIP (AMD GPU)\n\nCMake and Kokkos will set the compiler to `hipcc` (located in kokkos sources, cloned as git submodule).\n\nExample:\n```bash\nmkdir build_hip\ncd build_hip\ncmake -DKOKKOS_PROJ_TMPL_BACKEND=HIP -DKokkos_ARCH_VEGA908=ON ..\nmake\n# then you can run the application as before\n./src/saxpy_kokkos_lambda.hip\n```\n\n## Additional notes\n\n### Stream benchmark\n\nThe stream benchmark source code is slightly adapted from [BabelStream](https://github.com/UoB-HPC/BabelStream).\n\n### Stencil benchmark\n\nHere are the results obtained on different computing platforms:\n\nIntel Skylake (2x20 cores, Intel Xeon Gold 5115, icpc 2018.0.128)\n\n![stencil bench skylake icpc](https://github.com/pkestene/kokkos-proj-tmpl/raw/master/doc/stencil/stencil_bench_alfven_skylake_icpc.png \"Skylake (2x20 cores, Intel Xeon Gold 5115, icpc 2018.0.128)\")\n\nIntel KNL (icpc 2017.0.6.256, OMP_NUM_THREADS=64)\n\n![stencil bench knl icpc_omp_64](https://github.com/pkestene/kokkos-proj-tmpl/raw/master/doc/stencil/stencil_bench_irene_knl_omp_64.png \"Skylake (Intel KNL, icpc 2017.0.6.256, 64 threads)\")\n\nNvidia K80, cuda 9.2\n\n![stencil bench nvidia k80](https://github.com/pkestene/kokkos-proj-tmpl/raw/master/doc/stencil/stencil_bench_ouessant_k80.png \"Nvidia K80, cuda 9.2\")\n\nNvidia P100, cuda 9.2\n\n![stencil bench nvidia p100](https://github.com/pkestene/kokkos-proj-tmpl/raw/master/doc/stencil/stencil_bench_ouessant_p100.png \"Nvidia P100, cuda 9.2\")\n\n### glibc 2.34 and nvlink error\n\nIf using glibc version \u003e= 2.34 you get the following link error when building with Cuda backend:\n\n```shell\n[ 65%] Linking CXX executable saxpy_kokkos_lambda.cuda\nnvlink fatal   : Could not open input file '/usr/lib/x86_64-linux-gnu/libdl.a'\nmake[2]: *** [src/CMakeFiles/saxpy_kokkos_lambda.cuda.dir/build.make:118: src/saxpy_kokkos_lambda.cuda] Error 1\nmake[1]: *** [CMakeFiles/Makefile2:1047: src/CMakeFiles/saxpy_kokkos_lambda.cuda.dir/all] Error 2\nmake: *** [Makefile:136: all] Error 2\n```\n\nOne temporary solution (until fixed in a future nvcc release ?) is mentionned here:\nhttps://matsci.org/t/lammps-users-kokkos-linker-error-nvidia-libdl-a/41050\n\nfor simplicity, you just need to create a fake `libdl.a`, e.g. in current build dirrector\n```shell\ntouch empty.c\ngcc -fpic -c empty.c\nar rcsv libdl.a empty.o\n```\nand then reconfigure cmake with additionnal flag `-DLIBDL_LIBRARY=$PWD/libdl.a` and the build will work as expected.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkestene%2Fkokkos-proj-tmpl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpkestene%2Fkokkos-proj-tmpl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkestene%2Fkokkos-proj-tmpl/lists"}