-
Notifications
You must be signed in to change notification settings - Fork 121
Global CMake for tutorials #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 26 commits
9d26afe
1b2b56a
50bf4e0
56003c8
6268211
dec987e
4f30736
f2cc0c8
9ebf652
c4451a0
1a9d282
1b1dedc
1a07316
9bce058
7c6a676
8b5cd95
5779c0f
dacde70
2bc96df
46fa1d0
d6e6530
fe583b3
5656d32
af3141e
5ccfe61
7bdf80c
bfe7e16
798effa
a451ee4
0e178f0
90f978c
40db39d
96cf66d
dba7191
b4d1484
99b1c78
93462e7
f2e44a3
a96a6e2
f1b5bff
208dcb6
263297e
1a6e198
1c404fc
0b9221a
cd94126
4ec18a0
e0ee40b
d21fe57
d3daa7f
bffe62b
5f3a382
cdb445f
e514fc7
b148a85
8a3aca6
c47a017
21baf0d
1bafe0e
9e10417
e6e1c66
0e4b265
84c657b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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) |
cedricchevalier19 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
| 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}) | ||
masterleinad marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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 () | ||
cedricchevalier19 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 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 | ||
|
||
| SOURCE_DIR ${Kokkos_COMMON_SOURCE_DIR} | ||
| ) | ||
| FetchContent_MakeAvailable(Kokkos) | ||
| set(Kokkos_FOUND True) | ||
| endif () | ||
| endif () | ||
| 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) | ||
cedricchevalier19 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 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) | ||
|
|
||
cedricchevalier19 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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) |
| 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) |
| 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 () | ||
cedricchevalier19 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| add_executable(02_Exercise exercise_2_begin.cpp) | ||
| target_link_libraries(02_Exercise Kokkos::kokkos) | ||
| 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) |
| 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) |
| 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) |
| 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) |
| 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) |
| 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) |
| 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) |
| 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) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| cmake_minimum_required(VERSION 3.16) | ||
| project(KokkosTutorialExercices) | ||
cedricchevalier19 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # 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 | ||
cedricchevalier19 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 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) | ||
| 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) | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment here, please propose this change as its own PR.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
|
||
| auto host_view = | ||
| Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, view); | ||
|
|
||
| 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) |
| 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) |
This file was deleted.
| 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) |
| 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) |
| 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) |
Uh oh!
There was an error while loading. Please reload this page.