Skip to content
Open
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
9d26afe
Ignore object files in git.
cedricchevalier19 Mar 9, 2020
1b2b56a
Add a root CMakeLists.txt
cedricchevalier19 May 12, 2024
50bf4e0
More exercises in the global CMake
cedricchevalier19 May 12, 2024
56003c8
CMake directory order follows tutorial
cedricchevalier19 May 12, 2024
6268211
Adding SIMD to CMakeLists.txt
cedricchevalier19 May 12, 2024
dec987e
Use `find_package(Kokkos REQUIRED)` in all exercises
cedricchevalier19 Jun 3, 2024
4f30736
`subview` now compiles with the DefaultExecutionSpace.
cedricchevalier19 Jun 3, 2024
f2cc0c8
Add CMake warnings when using device enabled Kokkos for the 2 first e…
cedricchevalier19 Jun 5, 2024
9ebf652
Adding 'instances' exercise to main CMake
cedricchevalier19 Jun 5, 2024
c4451a0
Adding 'scatter_view/Usage' to CMake
cedricchevalier19 Jun 5, 2024
1a9d282
Adding 'random_number' to CMake
cedricchevalier19 Jun 5, 2024
1b1dedc
Comment out some Kokkos call in Begin exercises
cedricchevalier19 Jun 5, 2024
1a07316
Adding 'unique_token' to CMake
cedricchevalier19 Jun 5, 2024
9bce058
Adding 'unordered_map' to CMake
cedricchevalier19 Jun 5, 2024
7c6a676
Adding 'virtual_functions' to CMake
cedricchevalier19 Jun 5, 2024
8b5cd95
List exercises to add to global cmake.
cedricchevalier19 Jun 5, 2024
5779c0f
Add `fortran_interface` to global cmake
cedricchevalier19 Jun 5, 2024
dacde70
Add `multi_gpu_cuda` to global cmake
cedricchevalier19 Jun 5, 2024
2bc96df
Add `minimd` to global cmake
cedricchevalier19 Jun 5, 2024
46fa1d0
Cleaning up exercise makefile.
cedricchevalier19 Jun 5, 2024
d6e6530
Fetch Kokkos sources into CMAKE_BINARY_DIR
cedricchevalier19 Jun 5, 2024
fe583b3
Use list(APPEND CMAKE_MODULE_PATH)
cedricchevalier19 Jun 11, 2024
5656d32
Fix no newline at end-of-file
cedricchevalier19 Jun 11, 2024
af3141e
Remove warning fixes that are not related to CMake
cedricchevalier19 Jun 11, 2024
5ccfe61
Use Kokkos_ENABLE_CUDA
cedricchevalier19 Jun 11, 2024
7bdf80c
Explicitly list accelerator backends for the 2 first exercise
cedricchevalier19 Jun 11, 2024
bfe7e16
Missing some newline at end-of-file
cedricchevalier19 Jun 11, 2024
798effa
Remove unneeded comment
cedricchevalier19 Jun 13, 2024
a451ee4
Add "" for appending to CMAKE_MODULE_PATH
cedricchevalier19 Jun 13, 2024
0e178f0
Only one top-level CMakeLists.txt
cedricchevalier19 Jun 14, 2024
90f978c
Make KokkostTutorials_FORECE_INTERNAL_Kokkos an official CMake option
cedricchevalier19 Jun 14, 2024
40db39d
Update README.md
cedricchevalier19 Jun 14, 2024
96cf66d
Add `KokkosTutorials_FORCE_EXTERNAL_Kokkos` option
cedricchevalier19 Jun 14, 2024
dba7191
Allow to configure Kokkos source dir
cedricchevalier19 Jun 14, 2024
b4d1484
Merge remote-tracking branch 'upstream/main' into fork/cedricchevalie…
cedricchevalier19 Feb 26, 2025
99b1c78
Use Kokkos 4.5.01
cedricchevalier19 Feb 26, 2025
93462e7
Move CMake utilities from .cmake to cmake
cedricchevalier19 Feb 26, 2025
f2e44a3
Share downloaded kokkos
cedricchevalier19 Feb 26, 2025
a96a6e2
Remove obsolete reference to SPACK_CXX
cedricchevalier19 Feb 26, 2025
f1b5bff
Macro to warn about using gpu backends on non-ready exercises
cedricchevalier19 Feb 26, 2025
208dcb6
Fix global compilation
cedricchevalier19 Feb 26, 2025
263297e
Update README.md
cedricchevalier19 Feb 26, 2025
1a6e198
Do not try to hide find_package(Kokkos)
cedricchevalier19 Feb 26, 2025
1c404fc
Use tarball to download Kokkos
cedricchevalier19 Feb 26, 2025
0b9221a
Fix include in mpi_exch directory
cedricchevalier19 Feb 26, 2025
cd94126
Update README.md
cedricchevalier19 Feb 26, 2025
4ec18a0
Update README.md
cedricchevalier19 Feb 26, 2025
e0ee40b
Update README.md
cedricchevalier19 Feb 26, 2025
d21fe57
Fix unique_token example compilation
cedricchevalier19 Feb 26, 2025
d3daa7f
Cleaning up
cedricchevalier19 Feb 26, 2025
bffe62b
Move SetUpKokkos to Exercices
cedricchevalier19 Feb 26, 2025
5f3a382
Merge remote-tracking branch 'upstream/main' into fork/cedricchevalie…
cedricchevalier19 Feb 26, 2025
cdb445f
Fix cmake policy for downloading Kokkos Core
cedricchevalier19 Apr 3, 2025
e514fc7
Merge remote-tracking branch 'origin/master' into cmake
cedricchevalier19 Apr 3, 2025
b148a85
Download Kokkos in Exercises/dep
cedricchevalier19 Jul 25, 2025
8a3aca6
Merge remote-tracking branch 'upstream/main' into fork/cedricchevalie…
cedricchevalier19 Jul 25, 2025
c47a017
Remove references to tasking example
cedricchevalier19 Jul 25, 2025
21baf0d
Follow @pzehner advice to fix time stamping
cedricchevalier19 Jul 25, 2025
1bafe0e
Add diagnostic messages for Kokkos location
cedricchevalier19 Jul 25, 2025
9e10417
Upgrade to Kokkos 4.6.02
cedricchevalier19 Jul 25, 2025
e6e1c66
Add an example with a custom Kokkos source directory
cedricchevalier19 Jul 25, 2025
0e4b265
Remove a confusing warning
cedricchevalier19 Jul 28, 2025
84c657b
Simplify README.md
cedricchevalier19 Jul 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 3.16)
project(KokkosTutorials)

add_subdirectory(Exercises)
44 changes: 44 additions & 0 deletions Exercises/.cmake/FindKokkos.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Early return if Kokkos is already set up
# We do not use Kokkos_FOUND as it is not globally defined
if (TARGET Kokkos::kokkos)
return()
endif ()

set(SPACK_CXX $ENV{SPACK_CXX})
if (SPACK_CXX)
message("found spack compiler ${SPACK_CXX}")
set(CMAKE_CXX_COMPILER ${SPACK_CXX} CACHE STRING "the C++ compiler" FORCE)
set(ENV{CXX} ${SPACK_CXX})
endif ()

if (NOT CMAKE_BUILD_TYPE)
set(default_build_type "RelWithDebInfo")
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING
"Choose the type of build, options are: Debug, Release, RelWithDebInfo and MinSizeRel."
FORCE)
endif ()

set(Kokkos_COMMON_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/dep/Kokkos)

if (NOT KokkosTutorials_FORCE_INTERNAL_Kokkos)
find_package(Kokkos CONFIG)
endif ()

if (Kokkos_FOUND)
message(STATUS "Found Kokkos: ${Kokkos_DIR} (version \"${Kokkos_VERSION}\")")
else ()
if (EXISTS ${Kokkos_COMMON_SOURCE_DIR})
add_subdirectory(${Kokkos_COMMON_SOURCE_DIR} Kokkos)
else ()
include(FetchContent)
FetchContent_Declare(
Kokkos
GIT_REPOSITORY https://github.com/kokkos/kokkos.git
GIT_TAG 4.0.01
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not the latest release? Did you intend to update in a separate pull request?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I thought a separate PR made more sense.

SOURCE_DIR ${Kokkos_COMMON_SOURCE_DIR}
)
FetchContent_MakeAvailable(Kokkos)
set(Kokkos_FOUND True)
endif ()
endif ()
13 changes: 11 additions & 2 deletions Exercises/01/Begin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
cmake_minimum_required(VERSION 3.16)
project(KokkosTutorial01)
include(../../common.cmake)

# Add a custom module path for find_package
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake)

find_package(Kokkos REQUIRED)

if (Kokkos_ENABLE_CUDA OR Kokkos_ENABLE_HIP OR Kokkos_ENABLE_SYCL OR Kokkos_ENABLE_OPENMPTARGET OR Kokkos_ENABLE_HPX)
message(WARNING "${CMAKE_CURRENT_SOURCE_DIR}"
"a Kokkos accelerator backend is enabled, it might cause issue with the current program"
"Please recompile with only a host backend enabled (e.g. -DKokkos_ENABLE_OPENMP=ON)")
endif ()

add_executable(01_Exercise exercise_1_begin.cpp)
target_link_libraries(01_Exercise Kokkos::kokkos)

5 changes: 5 additions & 0 deletions Exercises/01/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.16)
project(KokkosTutorial01)

add_subdirectory(Begin)
add_subdirectory(Solution)
14 changes: 11 additions & 3 deletions Exercises/01/Solution/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
cmake_minimum_required(VERSION 3.16)
project(KokkosTutorial01)
include(../../common.cmake)

add_executable(01_Exercise exercise_1_solution.cpp)
target_link_libraries(01_Exercise Kokkos::kokkos)
# Add a custom module path for find_package
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake")

find_package(Kokkos REQUIRED)

if (Kokkos_ENABLE_CUDA OR Kokkos_ENABLE_HIP OR Kokkos_ENABLE_SYCL OR Kokkos_ENABLE_OPENMPTARGET OR Kokkos_ENABLE_HPX)
message(WARNING "${CMAKE_CURRENT_SOURCE_DIR}"
"a Kokkos accelerator backend is enabled, it might cause issue with the current program"
"Please recompile with only a host backend enabled (e.g. -DKokkos_ENABLE_OPENMP=ON)")
endif ()

add_executable(01_Solution exercise_1_solution.cpp)
target_link_libraries(01_Solution Kokkos::kokkos)
14 changes: 11 additions & 3 deletions Exercises/02/Begin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
cmake_minimum_required(VERSION 3.16)
project(KokkosTutorial02)
include(../../common.cmake)

add_executable(02_Exercise exercise_2_begin.cpp)
target_link_libraries(02_Exercise Kokkos::kokkos)
# Add a custom module path for find_package
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake")

find_package(Kokkos REQUIRED)

if (Kokkos_ENABLE_CUDA OR Kokkos_ENABLE_HIP OR Kokkos_ENABLE_SYCL OR Kokkos_ENABLE_OPENMPTARGET OR Kokkos_ENABLE_HPX)
message(WARNING "${CMAKE_CURRENT_SOURCE_DIR}"
"A Kokkos accelerator backend is enabled, it might cause issue with the current program"
"Please recompile with only a host backend enabled (e.g. -DKokkos_ENABLE_OPENMP=ON)")
endif ()

add_executable(02_Exercise exercise_2_begin.cpp)
target_link_libraries(02_Exercise Kokkos::kokkos)
5 changes: 5 additions & 0 deletions Exercises/02/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.16)
project(KokkosTutorial02)

add_subdirectory(Begin)
add_subdirectory(Solution)
14 changes: 11 additions & 3 deletions Exercises/02/Solution/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
cmake_minimum_required(VERSION 3.16)
project(KokkosTutorial02)
include(../../common.cmake)

add_executable(02_Exercise exercise_2_solution.cpp)
target_link_libraries(02_Exercise Kokkos::kokkos)
# Add a custom module path for find_package
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake")

find_package(Kokkos REQUIRED)

if (Kokkos_ENABLE_CUDA OR Kokkos_ENABLE_HIP OR Kokkos_ENABLE_SYCL OR Kokkos_ENABLE_OPENMPTARGET OR Kokkos_ENABLE_HPX)
message(WARNING "${CMAKE_CURRENT_SOURCE_DIR}"
"A Kokkos accelerator backend is enabled, it might cause issue with the current program"
"Please recompile with only a host backend enabled (e.g. -DKokkos_ENABLE_OPENMP=ON)")
endif ()

add_executable(02_Solution exercise_2_solution.cpp)
target_link_libraries(02_Solution Kokkos::kokkos)
8 changes: 5 additions & 3 deletions Exercises/03/Begin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
cmake_minimum_required(VERSION 3.16)
project(KokkosTutorial03)
include(../../common.cmake)

add_executable(03_Exercise exercise_3_begin.cpp)
target_link_libraries(03_Exercise Kokkos::kokkos)
# Add a custom module path for find_package
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake")

find_package(Kokkos REQUIRED)

add_executable(03_Exercise exercise_3_begin.cpp)
target_link_libraries(03_Exercise Kokkos::kokkos)
5 changes: 5 additions & 0 deletions Exercises/03/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.16)
project(KokkosTutorial03)

add_subdirectory(Begin)
add_subdirectory(Solution)
8 changes: 5 additions & 3 deletions Exercises/03/Solution/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
cmake_minimum_required(VERSION 3.16)
project(KokkosTutorial03)
include(../../common.cmake)

add_executable(03_Exercise exercise_3_solution.cpp)
target_link_libraries(03_Exercise Kokkos::kokkos)
# Add a custom module path for find_package
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake")

find_package(Kokkos REQUIRED)

add_executable(03_Solution exercise_3_solution.cpp)
target_link_libraries(03_Solution Kokkos::kokkos)
8 changes: 5 additions & 3 deletions Exercises/04/Begin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
cmake_minimum_required(VERSION 3.16)
project(KokkosTutorial04)
include(../../common.cmake)

add_executable(04_Exercise exercise_4_begin.cpp)
target_link_libraries(04_Exercise Kokkos::kokkos)
# Add a custom module path for find_package
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake")

find_package(Kokkos REQUIRED)

add_executable(04_Exercise exercise_4_begin.cpp)
target_link_libraries(04_Exercise Kokkos::kokkos)
5 changes: 5 additions & 0 deletions Exercises/04/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.16)
project(KokkosTutorial04)

add_subdirectory(Begin)
add_subdirectory(Solution)
8 changes: 5 additions & 3 deletions Exercises/04/Solution/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
cmake_minimum_required(VERSION 3.16)
project(KokkosTutorial04)
include(../../common.cmake)

add_executable(04_Exercise exercise_4_solution.cpp)
target_link_libraries(04_Exercise Kokkos::kokkos)
# Add a custom module path for find_package
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake")

find_package(Kokkos REQUIRED)

add_executable(04_Solution exercise_4_solution.cpp)
target_link_libraries(04_Solution Kokkos::kokkos)
40 changes: 40 additions & 0 deletions Exercises/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
cmake_minimum_required(VERSION 3.16)
project(KokkosTutorialExercices)

# These directories follow IntroFull order of introduction

add_subdirectory(01)
add_subdirectory(02)
add_subdirectory(03)
add_subdirectory(04)

add_subdirectory(dualview)
add_subdirectory(mdrange)
add_subdirectory(subview)
add_subdirectory(scatter_view)
add_subdirectory(team_policy)
add_subdirectory(team_vector_loop)
add_subdirectory(team_scratch_memory)
add_subdirectory(tasking)
add_subdirectory(simd)
# FIXME update the code
# add_subdirectory(simd_warp)

# These directories are "independent" and listed in alphabetical order

add_subdirectory(advanced_reductions)
add_subdirectory(fortran-kokkosinterface) # TODO, Add a check for fortran
add_subdirectory(instances)
add_subdirectory(multi_gpu_cuda)
add_subdirectory(parallel_scan)
add_subdirectory(tools_minimd)
add_subdirectory(random_number)
add_subdirectory(unique_token)
add_subdirectory(unordered_map)
add_subdirectory(virtualfunction)

# Not done yet
# TODO, require Kokkos Kernels
# add_subdirectory(kokkoskernels)
# require remote spaces
# add_subdirectory(vectorshift)
9 changes: 6 additions & 3 deletions Exercises/advanced_reductions/Begin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
cmake_minimum_required(VERSION 3.16)
project(KokkosTutorial01)
include(../../common.cmake)
project(KokkosTutorialAdvancedReductions)

# Add a custom module path for find_package
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake")

find_package(Kokkos REQUIRED)

add_executable(AdvancedReductions advanced_reductions.cpp)
target_link_libraries(AdvancedReductions Kokkos::kokkos)

3 changes: 2 additions & 1 deletion Exercises/advanced_reductions/Begin/advanced_reductions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ int main(int argc, char *argv[]) {
n, KOKKOS_LAMBDA(int i) { view(i) = 1 + i / 10.; });

double result;
Kokkos::parallel_reduce(n, GeometricMean{view}, result);
// EXERCISE uncomment the following line when GeometricMean is implemented
// Kokkos::parallel_reduce(n, GeometricMean{view}, result);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here, please propose this change as its own PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was necessary in order to compile this exercise. I will comment out the add_subdirectory and do a separate PR.


auto host_view =
Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, view);
Expand Down
5 changes: 5 additions & 0 deletions Exercises/advanced_reductions/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.16)
project(KokkosTutorialAdvancedReductions)

add_subdirectory(Begin)
add_subdirectory(Solution)
11 changes: 7 additions & 4 deletions Exercises/advanced_reductions/Solution/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
cmake_minimum_required(VERSION 3.16)
project(KokkosTutorial01)
include(../../common.cmake)
project(KokkosTutorialAdvancedReductions)

add_executable(AdvancedReductions advanced_reductions.cpp)
target_link_libraries(AdvancedReductions Kokkos::kokkos)
# Add a custom module path for find_package
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake")

find_package(Kokkos REQUIRED)

add_executable(AdvancedReductions_Solution advanced_reductions.cpp)
target_link_libraries(AdvancedReductions_Solution Kokkos::kokkos)
35 changes: 0 additions & 35 deletions Exercises/common.cmake

This file was deleted.

8 changes: 5 additions & 3 deletions Exercises/dualview/Begin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
cmake_minimum_required(VERSION 3.16)
project(KokkosTutorialDualView)
include(../../common.cmake)

add_executable(dualview dual_view_exercise.cpp)
target_link_libraries(dualview Kokkos::kokkos)
# Add a custom module path for find_package
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake")

find_package(Kokkos REQUIRED)

add_executable(dualview dual_view_exercise.cpp)
target_link_libraries(dualview Kokkos::kokkos)
5 changes: 5 additions & 0 deletions Exercises/dualview/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.16)
project(KokkosTutorialDualView)

add_subdirectory(Begin)
add_subdirectory(Solution)
8 changes: 5 additions & 3 deletions Exercises/dualview/Solution/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
cmake_minimum_required(VERSION 3.16)
project(KokkosTutorialDualView)
include(../../common.cmake)

add_executable(dualview dual_view_exercise.cpp)
target_link_libraries(dualview Kokkos::kokkos)
# Add a custom module path for find_package
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake")

find_package(Kokkos REQUIRED)

add_executable(dualview_Solution dual_view_exercise.cpp)
target_link_libraries(dualview_Solution Kokkos::kokkos)
Loading