From 9d26afed2dce40c2fde25d1db4e46a1f7533c081 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Mon, 9 Mar 2020 15:33:51 +0100 Subject: [PATCH 01/59] Ignore object files in git. --- .gitignore | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index e168daed..22721c9d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,10 @@ spack-build/ spack-build-env.txt spack-build-out.txt cmake_install.cmake +*.o +*.host +*.cuda +KokkosCore_config.h +KokkosCore_config.tmp +*.a + From 1b2b56a0c2b9c586eb4cc81c72b990a2fe329505 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Sun, 12 May 2024 18:14:28 +0200 Subject: [PATCH 02/59] Add a root CMakeLists.txt --- CMakeLists.txt | 4 ++++ Exercises/01/CMakeLists.txt | 5 +++++ Exercises/01/Solution/CMakeLists.txt | 6 ++---- Exercises/02/CMakeLists.txt | 5 +++++ Exercises/02/Solution/CMakeLists.txt | 6 ++---- Exercises/03/CMakeLists.txt | 5 +++++ Exercises/03/Solution/CMakeLists.txt | 4 ++-- Exercises/04/CMakeLists.txt | 5 +++++ Exercises/04/Solution/CMakeLists.txt | 6 ++---- Exercises/CMakeLists.txt | 7 +++++++ Exercises/common.cmake | 5 +++++ 11 files changed, 44 insertions(+), 14 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 Exercises/01/CMakeLists.txt create mode 100644 Exercises/02/CMakeLists.txt create mode 100644 Exercises/03/CMakeLists.txt create mode 100644 Exercises/04/CMakeLists.txt create mode 100644 Exercises/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..38a27f63 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorials) + +add_subdirectory(Exercises) \ No newline at end of file diff --git a/Exercises/01/CMakeLists.txt b/Exercises/01/CMakeLists.txt new file mode 100644 index 00000000..0768411c --- /dev/null +++ b/Exercises/01/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorial01) + +add_subdirectory(Begin) +add_subdirectory(Solution) diff --git a/Exercises/01/Solution/CMakeLists.txt b/Exercises/01/Solution/CMakeLists.txt index 7493cfd5..0eadebc7 100644 --- a/Exercises/01/Solution/CMakeLists.txt +++ b/Exercises/01/Solution/CMakeLists.txt @@ -2,7 +2,5 @@ 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_executable(01_Solution exercise_1_solution.cpp) +target_link_libraries(01_Solution Kokkos::kokkos) diff --git a/Exercises/02/CMakeLists.txt b/Exercises/02/CMakeLists.txt new file mode 100644 index 00000000..557bb89a --- /dev/null +++ b/Exercises/02/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorial02) + +add_subdirectory(Begin) +add_subdirectory(Solution) diff --git a/Exercises/02/Solution/CMakeLists.txt b/Exercises/02/Solution/CMakeLists.txt index 940870cd..55378e7c 100644 --- a/Exercises/02/Solution/CMakeLists.txt +++ b/Exercises/02/Solution/CMakeLists.txt @@ -2,7 +2,5 @@ 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_executable(02_Solution exercise_2_solution.cpp) +target_link_libraries(02_Solution Kokkos::kokkos) diff --git a/Exercises/03/CMakeLists.txt b/Exercises/03/CMakeLists.txt new file mode 100644 index 00000000..40f48f58 --- /dev/null +++ b/Exercises/03/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorial03) + +add_subdirectory(Begin) +add_subdirectory(Solution) diff --git a/Exercises/03/Solution/CMakeLists.txt b/Exercises/03/Solution/CMakeLists.txt index 16890057..dcf88f46 100644 --- a/Exercises/03/Solution/CMakeLists.txt +++ b/Exercises/03/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ 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_executable(03_Solution exercise_3_solution.cpp) +target_link_libraries(03_Solution Kokkos::kokkos) diff --git a/Exercises/04/CMakeLists.txt b/Exercises/04/CMakeLists.txt new file mode 100644 index 00000000..26a0a17f --- /dev/null +++ b/Exercises/04/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorial04) + +add_subdirectory(Begin) +add_subdirectory(Solution) diff --git a/Exercises/04/Solution/CMakeLists.txt b/Exercises/04/Solution/CMakeLists.txt index cfea54b0..41cf3bd9 100644 --- a/Exercises/04/Solution/CMakeLists.txt +++ b/Exercises/04/Solution/CMakeLists.txt @@ -2,7 +2,5 @@ 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_executable(04_Solution exercise_4_solution.cpp) +target_link_libraries(04_Solution Kokkos::kokkos) diff --git a/Exercises/CMakeLists.txt b/Exercises/CMakeLists.txt new file mode 100644 index 00000000..f023a2d3 --- /dev/null +++ b/Exercises/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorialExercices) + +add_subdirectory(01) +add_subdirectory(02) +add_subdirectory(03) +add_subdirectory(04) diff --git a/Exercises/common.cmake b/Exercises/common.cmake index 033b9417..db40aca8 100644 --- a/Exercises/common.cmake +++ b/Exercises/common.cmake @@ -1,3 +1,7 @@ +# Early return if Kokkos is already set up +if (TARGET Kokkos::kokkos) + return() +endif() set(SPACK_CXX $ENV{SPACK_CXX}) if(SPACK_CXX) @@ -31,5 +35,6 @@ else() SOURCE_DIR ${Kokkos_COMMON_SOURCE_DIR} ) FetchContent_MakeAvailable(Kokkos) + set(Kokkos_FOUND True) endif() endif() From 50bf4e00b4d118772ebff4d299b8fc74482c1714 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Sun, 12 May 2024 18:35:22 +0200 Subject: [PATCH 03/59] More exercises in the global CMake --- Exercises/CMakeLists.txt | 10 ++++++++++ Exercises/advanced_reductions/Begin/CMakeLists.txt | 2 +- Exercises/advanced_reductions/CMakeLists.txt | 5 +++++ Exercises/advanced_reductions/Solution/CMakeLists.txt | 7 +++---- Exercises/dualview/Begin/CMakeLists.txt | 2 -- Exercises/dualview/CMakeLists.txt | 5 +++++ Exercises/dualview/Solution/CMakeLists.txt | 6 ++---- Exercises/mdrange/Begin/CMakeLists.txt | 2 -- Exercises/mdrange/CMakeLists.txt | 5 +++++ Exercises/mdrange/Solution/CMakeLists.txt | 6 ++---- Exercises/parallel_scan/Begin/CMakeLists.txt | 3 +-- Exercises/parallel_scan/CMakeLists.txt | 5 +++++ Exercises/parallel_scan/Solution/CMakeLists.txt | 6 +++--- Exercises/scatter_view/Begin/CMakeLists.txt | 4 +--- Exercises/scatter_view/CMakeLists.txt | 5 +++++ Exercises/scatter_view/Solution/CMakeLists.txt | 6 ++---- Exercises/subview/Begin/CMakeLists.txt | 2 -- Exercises/subview/CMakeLists.txt | 5 +++++ Exercises/subview/Solution/CMakeLists.txt | 6 ++---- Exercises/tasking/CMakeLists.txt | 5 +++++ Exercises/tasking/Solution/CMakeLists.txt | 4 ++-- Exercises/team_policy/Begin/CMakeLists.txt | 2 -- Exercises/team_policy/CMakeLists.txt | 5 +++++ Exercises/team_policy/Solution/CMakeLists.txt | 6 ++---- Exercises/team_scratch_memory/Begin/CMakeLists.txt | 2 -- Exercises/team_scratch_memory/CMakeLists.txt | 5 +++++ Exercises/team_scratch_memory/Solution/CMakeLists.txt | 6 ++---- Exercises/team_vector_loop/Begin/CMakeLists.txt | 2 -- Exercises/team_vector_loop/CMakeLists.txt | 5 +++++ Exercises/team_vector_loop/Solution/CMakeLists.txt | 6 ++---- 30 files changed, 85 insertions(+), 55 deletions(-) create mode 100644 Exercises/advanced_reductions/CMakeLists.txt create mode 100644 Exercises/dualview/CMakeLists.txt create mode 100644 Exercises/mdrange/CMakeLists.txt create mode 100644 Exercises/parallel_scan/CMakeLists.txt create mode 100644 Exercises/scatter_view/CMakeLists.txt create mode 100644 Exercises/subview/CMakeLists.txt create mode 100644 Exercises/tasking/CMakeLists.txt create mode 100644 Exercises/team_policy/CMakeLists.txt create mode 100644 Exercises/team_scratch_memory/CMakeLists.txt create mode 100644 Exercises/team_vector_loop/CMakeLists.txt diff --git a/Exercises/CMakeLists.txt b/Exercises/CMakeLists.txt index f023a2d3..1c7f9b7c 100644 --- a/Exercises/CMakeLists.txt +++ b/Exercises/CMakeLists.txt @@ -5,3 +5,13 @@ add_subdirectory(01) add_subdirectory(02) add_subdirectory(03) add_subdirectory(04) + +add_subdirectory(advanced_reductions) +add_subdirectory(dualview) +add_subdirectory(mdrange) +add_subdirectory(parallel_scan) +add_subdirectory(scatter_view) +add_subdirectory(tasking) +add_subdirectory(team_policy) +add_subdirectory(team_scratch_memory) +add_subdirectory(team_vector_loop) diff --git a/Exercises/advanced_reductions/Begin/CMakeLists.txt b/Exercises/advanced_reductions/Begin/CMakeLists.txt index 51527870..de88dd10 100644 --- a/Exercises/advanced_reductions/Begin/CMakeLists.txt +++ b/Exercises/advanced_reductions/Begin/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.16) -project(KokkosTutorial01) +project(KokkosTutorialAdvancedReductions) include(../../common.cmake) add_executable(AdvancedReductions advanced_reductions.cpp) diff --git a/Exercises/advanced_reductions/CMakeLists.txt b/Exercises/advanced_reductions/CMakeLists.txt new file mode 100644 index 00000000..92d62f93 --- /dev/null +++ b/Exercises/advanced_reductions/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorialAdvancedReductions) + +add_subdirectory(Begin) +add_subdirectory(Solution) diff --git a/Exercises/advanced_reductions/Solution/CMakeLists.txt b/Exercises/advanced_reductions/Solution/CMakeLists.txt index 51527870..a36333de 100644 --- a/Exercises/advanced_reductions/Solution/CMakeLists.txt +++ b/Exercises/advanced_reductions/Solution/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required(VERSION 3.16) -project(KokkosTutorial01) +project(KokkosTutorialAdvancedReductions) include(../../common.cmake) -add_executable(AdvancedReductions advanced_reductions.cpp) -target_link_libraries(AdvancedReductions Kokkos::kokkos) - +add_executable(AdvancedReductions_Solution advanced_reductions.cpp) +target_link_libraries(AdvancedReductions_Solution Kokkos::kokkos) diff --git a/Exercises/dualview/Begin/CMakeLists.txt b/Exercises/dualview/Begin/CMakeLists.txt index 56688fb3..529d6360 100644 --- a/Exercises/dualview/Begin/CMakeLists.txt +++ b/Exercises/dualview/Begin/CMakeLists.txt @@ -4,5 +4,3 @@ include(../../common.cmake) add_executable(dualview dual_view_exercise.cpp) target_link_libraries(dualview Kokkos::kokkos) - - diff --git a/Exercises/dualview/CMakeLists.txt b/Exercises/dualview/CMakeLists.txt new file mode 100644 index 00000000..da22cd69 --- /dev/null +++ b/Exercises/dualview/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorialDualView) + +add_subdirectory(Begin) +add_subdirectory(Solution) diff --git a/Exercises/dualview/Solution/CMakeLists.txt b/Exercises/dualview/Solution/CMakeLists.txt index 56688fb3..2e0c2b6e 100644 --- a/Exercises/dualview/Solution/CMakeLists.txt +++ b/Exercises/dualview/Solution/CMakeLists.txt @@ -2,7 +2,5 @@ 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_executable(dualview_Solution dual_view_exercise.cpp) +target_link_libraries(dualview_Solution Kokkos::kokkos) diff --git a/Exercises/mdrange/Begin/CMakeLists.txt b/Exercises/mdrange/Begin/CMakeLists.txt index 7a959829..5467a0d1 100644 --- a/Exercises/mdrange/Begin/CMakeLists.txt +++ b/Exercises/mdrange/Begin/CMakeLists.txt @@ -4,5 +4,3 @@ include(../../common.cmake) add_executable(mdrange_exercise exercise_mdrange_begin.cpp) target_link_libraries(mdrange_exercise Kokkos::kokkos) - - diff --git a/Exercises/mdrange/CMakeLists.txt b/Exercises/mdrange/CMakeLists.txt new file mode 100644 index 00000000..53a9db19 --- /dev/null +++ b/Exercises/mdrange/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorialMDRange) + +add_subdirectory(Begin) +add_subdirectory(Solution) diff --git a/Exercises/mdrange/Solution/CMakeLists.txt b/Exercises/mdrange/Solution/CMakeLists.txt index 75262d21..e1e98bf2 100644 --- a/Exercises/mdrange/Solution/CMakeLists.txt +++ b/Exercises/mdrange/Solution/CMakeLists.txt @@ -2,7 +2,5 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMdRange) include(../../common.cmake) -add_executable(mdrange_exercise exercise_mdrange_solution.cpp) -target_link_libraries(mdrange_exercise Kokkos::kokkos) - - +add_executable(mdrange_Solution exercise_mdrange_solution.cpp) +target_link_libraries(mdrange_Solution Kokkos::kokkos) diff --git a/Exercises/parallel_scan/Begin/CMakeLists.txt b/Exercises/parallel_scan/Begin/CMakeLists.txt index 43c86bd2..5495c711 100644 --- a/Exercises/parallel_scan/Begin/CMakeLists.txt +++ b/Exercises/parallel_scan/Begin/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required(VERSION 3.16) -project(KokkosTutorial01) +project(KokkosTutorialParallelScan) include(../../common.cmake) add_executable(ParallelScan parallel_scan.cpp) target_link_libraries(ParallelScan Kokkos::kokkos) - diff --git a/Exercises/parallel_scan/CMakeLists.txt b/Exercises/parallel_scan/CMakeLists.txt new file mode 100644 index 00000000..09a316ce --- /dev/null +++ b/Exercises/parallel_scan/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorialParallelScan) + +add_subdirectory(Begin) +add_subdirectory(Solution) diff --git a/Exercises/parallel_scan/Solution/CMakeLists.txt b/Exercises/parallel_scan/Solution/CMakeLists.txt index 43c86bd2..93b0987f 100644 --- a/Exercises/parallel_scan/Solution/CMakeLists.txt +++ b/Exercises/parallel_scan/Solution/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.16) -project(KokkosTutorial01) +project(KokkosTutorialParallelScan) include(../../common.cmake) -add_executable(ParallelScan parallel_scan.cpp) -target_link_libraries(ParallelScan Kokkos::kokkos) +add_executable(ParallelScan_Solution parallel_scan.cpp) +target_link_libraries(ParallelScan_Solution Kokkos::kokkos) diff --git a/Exercises/scatter_view/Begin/CMakeLists.txt b/Exercises/scatter_view/Begin/CMakeLists.txt index 397cf33a..152e6c3c 100644 --- a/Exercises/scatter_view/Begin/CMakeLists.txt +++ b/Exercises/scatter_view/Begin/CMakeLists.txt @@ -2,7 +2,5 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialScatterView) include(../../common.cmake) -add_executable(scatterview fe_scatter.cpp) +add_executable(scatterview scatter_view.cpp) target_link_libraries(scatterview Kokkos::kokkos) - - diff --git a/Exercises/scatter_view/CMakeLists.txt b/Exercises/scatter_view/CMakeLists.txt new file mode 100644 index 00000000..b507fcfa --- /dev/null +++ b/Exercises/scatter_view/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorialScatterView) + +add_subdirectory(Begin) +add_subdirectory(Solution) diff --git a/Exercises/scatter_view/Solution/CMakeLists.txt b/Exercises/scatter_view/Solution/CMakeLists.txt index 97610b91..083a14f1 100644 --- a/Exercises/scatter_view/Solution/CMakeLists.txt +++ b/Exercises/scatter_view/Solution/CMakeLists.txt @@ -2,7 +2,5 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialScatterView) include(../../common.cmake) -add_executable(scatterview scatter_view.cpp) -target_link_libraries(scatterview Kokkos::kokkos) - - +add_executable(scatterview_Solution scatter_view.cpp) +target_link_libraries(scatterview_Solution Kokkos::kokkos) diff --git a/Exercises/subview/Begin/CMakeLists.txt b/Exercises/subview/Begin/CMakeLists.txt index 56198faa..248a0345 100644 --- a/Exercises/subview/Begin/CMakeLists.txt +++ b/Exercises/subview/Begin/CMakeLists.txt @@ -4,5 +4,3 @@ include(../../common.cmake) add_executable(subview_exercise exercise_subview_begin.cpp) target_link_libraries(subview_exercise Kokkos::kokkos) - - diff --git a/Exercises/subview/CMakeLists.txt b/Exercises/subview/CMakeLists.txt new file mode 100644 index 00000000..403a7cd1 --- /dev/null +++ b/Exercises/subview/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorialSubview) + +add_subdirectory(Begin) +add_subdirectory(Solution) diff --git a/Exercises/subview/Solution/CMakeLists.txt b/Exercises/subview/Solution/CMakeLists.txt index 7dcbd6bb..8a11fd67 100644 --- a/Exercises/subview/Solution/CMakeLists.txt +++ b/Exercises/subview/Solution/CMakeLists.txt @@ -2,7 +2,5 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSubview) include(../../common.cmake) -add_executable(subview_exercise exercise_subview_solution.cpp) -target_link_libraries(subview_exercise Kokkos::kokkos) - - +add_executable(subview_Solution exercise_subview_solution.cpp) +target_link_libraries(subview_Solution Kokkos::kokkos) diff --git a/Exercises/tasking/CMakeLists.txt b/Exercises/tasking/CMakeLists.txt new file mode 100644 index 00000000..0af10cfc --- /dev/null +++ b/Exercises/tasking/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorialTasking) + +add_subdirectory(Begin) +add_subdirectory(Solution) diff --git a/Exercises/tasking/Solution/CMakeLists.txt b/Exercises/tasking/Solution/CMakeLists.txt index 4cb2f53b..ad8aae47 100644 --- a/Exercises/tasking/Solution/CMakeLists.txt +++ b/Exercises/tasking/Solution/CMakeLists.txt @@ -2,5 +2,5 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTasking) include(../../common.cmake) -add_executable(Tasking tasking_solution.cpp) -target_link_libraries(Tasking Kokkos::kokkos) +add_executable(Tasking_Solution tasking_solution.cpp) +target_link_libraries(Tasking_Solution Kokkos::kokkos) diff --git a/Exercises/team_policy/Begin/CMakeLists.txt b/Exercises/team_policy/Begin/CMakeLists.txt index 96647790..5953f634 100644 --- a/Exercises/team_policy/Begin/CMakeLists.txt +++ b/Exercises/team_policy/Begin/CMakeLists.txt @@ -4,5 +4,3 @@ include(../../common.cmake) add_executable(TeamPolicy team_policy_begin.cpp) target_link_libraries(TeamPolicy Kokkos::kokkos) - - diff --git a/Exercises/team_policy/CMakeLists.txt b/Exercises/team_policy/CMakeLists.txt new file mode 100644 index 00000000..8ddf29eb --- /dev/null +++ b/Exercises/team_policy/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorialTeamPolicy) + +add_subdirectory(Begin) +add_subdirectory(Solution) diff --git a/Exercises/team_policy/Solution/CMakeLists.txt b/Exercises/team_policy/Solution/CMakeLists.txt index 37563f53..e8e4765e 100644 --- a/Exercises/team_policy/Solution/CMakeLists.txt +++ b/Exercises/team_policy/Solution/CMakeLists.txt @@ -2,7 +2,5 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamPolicy) include(../../common.cmake) -add_executable(TeamPolicy team_policy_solution.cpp) -target_link_libraries(TeamPolicy Kokkos::kokkos) - - +add_executable(TeamPolicy_Solution team_policy_solution.cpp) +target_link_libraries(TeamPolicy_Solution Kokkos::kokkos) diff --git a/Exercises/team_scratch_memory/Begin/CMakeLists.txt b/Exercises/team_scratch_memory/Begin/CMakeLists.txt index b9dbe069..1f5e90e5 100644 --- a/Exercises/team_scratch_memory/Begin/CMakeLists.txt +++ b/Exercises/team_scratch_memory/Begin/CMakeLists.txt @@ -4,5 +4,3 @@ include(../../common.cmake) add_executable(TeamScratchMemory team_scratch_memory_begin.cpp) target_link_libraries(TeamScratchMemory Kokkos::kokkos) - - diff --git a/Exercises/team_scratch_memory/CMakeLists.txt b/Exercises/team_scratch_memory/CMakeLists.txt new file mode 100644 index 00000000..a31685f2 --- /dev/null +++ b/Exercises/team_scratch_memory/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorialTeamScratchMemory) + +add_subdirectory(Begin) +add_subdirectory(Solution) diff --git a/Exercises/team_scratch_memory/Solution/CMakeLists.txt b/Exercises/team_scratch_memory/Solution/CMakeLists.txt index b38ec15a..e2b1e465 100644 --- a/Exercises/team_scratch_memory/Solution/CMakeLists.txt +++ b/Exercises/team_scratch_memory/Solution/CMakeLists.txt @@ -2,7 +2,5 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamScratchMemory) include(../../common.cmake) -add_executable(TeamScratchMemory team_scratch_memory_solution.cpp) -target_link_libraries(TeamScratchMemory Kokkos::kokkos) - - +add_executable(TeamScratchMemory_Solution team_scratch_memory_solution.cpp) +target_link_libraries(TeamScratchMemory_Solution Kokkos::kokkos) diff --git a/Exercises/team_vector_loop/Begin/CMakeLists.txt b/Exercises/team_vector_loop/Begin/CMakeLists.txt index ffe63b4e..eee29804 100644 --- a/Exercises/team_vector_loop/Begin/CMakeLists.txt +++ b/Exercises/team_vector_loop/Begin/CMakeLists.txt @@ -4,5 +4,3 @@ include(../../common.cmake) add_executable(TeamVectorLoop team_vector_loop_begin.cpp) target_link_libraries(TeamVectorLoop Kokkos::kokkos) - - diff --git a/Exercises/team_vector_loop/CMakeLists.txt b/Exercises/team_vector_loop/CMakeLists.txt new file mode 100644 index 00000000..6ad47343 --- /dev/null +++ b/Exercises/team_vector_loop/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorialTeamVectorLoop) + +add_subdirectory(Begin) +add_subdirectory(Solution) diff --git a/Exercises/team_vector_loop/Solution/CMakeLists.txt b/Exercises/team_vector_loop/Solution/CMakeLists.txt index 9543c837..24ab2b9c 100644 --- a/Exercises/team_vector_loop/Solution/CMakeLists.txt +++ b/Exercises/team_vector_loop/Solution/CMakeLists.txt @@ -2,7 +2,5 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamVectorLoop) include(../../common.cmake) -add_executable(TeamVectorLoop team_vector_loop_solution.cpp) -target_link_libraries(TeamVectorLoop Kokkos::kokkos) - - +add_executable(TeamVectorLoop_Solution team_vector_loop_solution.cpp) +target_link_libraries(TeamVectorLoop_Solution Kokkos::kokkos) From 56003c829bc656a948c6b0f426cc6698cc0ef64a Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Sun, 12 May 2024 18:43:35 +0200 Subject: [PATCH 04/59] CMake directory order follows tutorial --- Exercises/CMakeLists.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Exercises/CMakeLists.txt b/Exercises/CMakeLists.txt index 1c7f9b7c..847c8aaa 100644 --- a/Exercises/CMakeLists.txt +++ b/Exercises/CMakeLists.txt @@ -6,12 +6,14 @@ add_subdirectory(02) add_subdirectory(03) add_subdirectory(04) -add_subdirectory(advanced_reductions) add_subdirectory(dualview) add_subdirectory(mdrange) -add_subdirectory(parallel_scan) +add_subdirectory(subview) add_subdirectory(scatter_view) -add_subdirectory(tasking) add_subdirectory(team_policy) -add_subdirectory(team_scratch_memory) add_subdirectory(team_vector_loop) +add_subdirectory(team_scratch_memory) +add_subdirectory(tasking) + +add_subdirectory(advanced_reductions) +add_subdirectory(parallel_scan) From 62682113dc318904a38bcea8c551af8d5e1e93f9 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Sun, 12 May 2024 18:47:44 +0200 Subject: [PATCH 05/59] Adding SIMD to CMakeLists.txt --- Exercises/CMakeLists.txt | 3 +++ Exercises/simd/CMakeLists.txt | 5 +++++ Exercises/simd/Solution/CMakeLists.txt | 4 ++-- Exercises/simd_warp/CMakeLists.txt | 5 +++++ Exercises/simd_warp/Solution/CMakeLists.txt | 4 ++-- 5 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 Exercises/simd/CMakeLists.txt create mode 100644 Exercises/simd_warp/CMakeLists.txt diff --git a/Exercises/CMakeLists.txt b/Exercises/CMakeLists.txt index 847c8aaa..d3f8626f 100644 --- a/Exercises/CMakeLists.txt +++ b/Exercises/CMakeLists.txt @@ -14,6 +14,9 @@ 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) add_subdirectory(advanced_reductions) add_subdirectory(parallel_scan) diff --git a/Exercises/simd/CMakeLists.txt b/Exercises/simd/CMakeLists.txt new file mode 100644 index 00000000..fe1d67c9 --- /dev/null +++ b/Exercises/simd/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorialSIMD) + +add_subdirectory(Begin) +add_subdirectory(Solution) diff --git a/Exercises/simd/Solution/CMakeLists.txt b/Exercises/simd/Solution/CMakeLists.txt index 580f4633..cc6060f8 100644 --- a/Exercises/simd/Solution/CMakeLists.txt +++ b/Exercises/simd/Solution/CMakeLists.txt @@ -2,5 +2,5 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSIMD) include(../../common.cmake) -add_executable(SIMD simd_solution.cpp) -target_link_libraries(SIMD Kokkos::kokkos) +add_executable(SIMD_Solution simd_solution.cpp) +target_link_libraries(SIMD_Solution Kokkos::kokkos) diff --git a/Exercises/simd_warp/CMakeLists.txt b/Exercises/simd_warp/CMakeLists.txt new file mode 100644 index 00000000..5d41647c --- /dev/null +++ b/Exercises/simd_warp/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorialSIMDWARP) + +add_subdirectory(Begin) +add_subdirectory(Solution) diff --git a/Exercises/simd_warp/Solution/CMakeLists.txt b/Exercises/simd_warp/Solution/CMakeLists.txt index 80cc6654..b6bcf9e6 100644 --- a/Exercises/simd_warp/Solution/CMakeLists.txt +++ b/Exercises/simd_warp/Solution/CMakeLists.txt @@ -2,5 +2,5 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSIMDWarp) include(../../common.cmake) -add_executable(SIMDWarp simd_warp_solution.cpp) -target_link_libraries(SIMDWarp Kokkos::kokkos) +add_executable(SIMDWarp_Solution simd_warp_solution.cpp) +target_link_libraries(SIMDWarp_Solution Kokkos::kokkos) From dec987ef98708bdd25186f2ce47db7c9beed715c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Chevalier?= Date: Mon, 3 Jun 2024 16:07:06 +0200 Subject: [PATCH 06/59] Use `find_package(Kokkos REQUIRED)` in all exercises This way, the CMakeLists.txt is almost standard. Remove old common.cmake --- Exercises/.cmake/FindKokkos.cmake | 44 ++++++++++++++++ Exercises/01/Begin/CMakeLists.txt | 7 ++- Exercises/01/Solution/CMakeLists.txt | 6 ++- Exercises/02/Begin/CMakeLists.txt | 6 ++- Exercises/02/Solution/CMakeLists.txt | 6 ++- Exercises/03/Begin/CMakeLists.txt | 6 ++- Exercises/03/Solution/CMakeLists.txt | 8 +-- Exercises/04/Begin/CMakeLists.txt | 6 ++- Exercises/04/Solution/CMakeLists.txt | 6 ++- .../advanced_reductions/Begin/CMakeLists.txt | 6 ++- .../Solution/CMakeLists.txt | 6 ++- Exercises/common.cmake | 40 -------------- Exercises/dualview/Begin/CMakeLists.txt | 6 ++- Exercises/dualview/Solution/CMakeLists.txt | 6 ++- .../Begin/CMakeLists.txt | 26 ++++++---- .../Solution/CMakeLists.txt | 34 ++++++------ Exercises/mdrange/Begin/CMakeLists.txt | 6 ++- Exercises/mdrange/Solution/CMakeLists.txt | 6 ++- .../mpi_pack_unpack/Begin/CMakeLists.txt | 6 ++- .../mpi_pack_unpack/Solution/CMakeLists.txt | 6 ++- Exercises/multi_gpu_cuda/Begin/CMakeLists.txt | 8 ++- .../multi_gpu_cuda/Solution/CMakeLists.txt | 6 ++- Exercises/parallel_scan/Begin/CMakeLists.txt | 6 ++- .../parallel_scan/Solution/CMakeLists.txt | 6 ++- Exercises/random_number/Begin/CMakeLists.txt | 6 ++- .../random_number/Solution/CMakeLists.txt | 8 +-- Exercises/scatter_view/Begin/CMakeLists.txt | 6 ++- .../scatter_view/Solution/CMakeLists.txt | 6 ++- Exercises/simd/Begin/CMakeLists.txt | 6 ++- Exercises/simd/Solution/CMakeLists.txt | 6 ++- Exercises/simd_warp/Begin/CMakeLists.txt | 6 ++- Exercises/simd_warp/Solution/CMakeLists.txt | 6 ++- Exercises/subview/Begin/CMakeLists.txt | 6 ++- Exercises/subview/Solution/CMakeLists.txt | 6 ++- Exercises/tasking/Begin/CMakeLists.txt | 6 ++- Exercises/tasking/Solution/CMakeLists.txt | 6 ++- Exercises/team_policy/Begin/CMakeLists.txt | 6 ++- Exercises/team_policy/Solution/CMakeLists.txt | 6 ++- .../team_scratch_memory/Begin/CMakeLists.txt | 6 ++- .../Solution/CMakeLists.txt | 6 ++- .../team_vector_loop/Begin/CMakeLists.txt | 6 ++- .../team_vector_loop/Solution/CMakeLists.txt | 6 ++- Exercises/tools_minimd/CMakeLists.txt | 52 ++++++++++--------- Exercises/unique_token/Begin/CMakeLists.txt | 6 ++- .../unique_token/Solution/CMakeLists.txt | 8 +-- Exercises/unordered_map/Begin/CMakeLists.txt | 8 +-- .../unordered_map/Solution/CMakeLists.txt | 6 ++- .../virtualfunction/Begin/CMakeLists.txt | 8 +-- .../virtualfunction/Solution/CMakeLists.txt | 8 +-- 49 files changed, 327 insertions(+), 148 deletions(-) create mode 100644 Exercises/.cmake/FindKokkos.cmake delete mode 100644 Exercises/common.cmake diff --git a/Exercises/.cmake/FindKokkos.cmake b/Exercises/.cmake/FindKokkos.cmake new file mode 100644 index 00000000..5597b5fd --- /dev/null +++ b/Exercises/.cmake/FindKokkos.cmake @@ -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_SOURCE_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 + SOURCE_DIR ${Kokkos_COMMON_SOURCE_DIR} + ) + FetchContent_MakeAvailable(Kokkos) + set(Kokkos_FOUND True) + endif () +endif () \ No newline at end of file diff --git a/Exercises/01/Begin/CMakeLists.txt b/Exercises/01/Begin/CMakeLists.txt index 9181d277..8d4917de 100644 --- a/Exercises/01/Begin/CMakeLists.txt +++ b/Exercises/01/Begin/CMakeLists.txt @@ -1,7 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial01) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(01_Exercise exercise_1_begin.cpp) target_link_libraries(01_Exercise Kokkos::kokkos) - diff --git a/Exercises/01/Solution/CMakeLists.txt b/Exercises/01/Solution/CMakeLists.txt index 0eadebc7..74052a19 100644 --- a/Exercises/01/Solution/CMakeLists.txt +++ b/Exercises/01/Solution/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial01) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(01_Solution exercise_1_solution.cpp) target_link_libraries(01_Solution Kokkos::kokkos) diff --git a/Exercises/02/Begin/CMakeLists.txt b/Exercises/02/Begin/CMakeLists.txt index d7c83abf..98d472a3 100644 --- a/Exercises/02/Begin/CMakeLists.txt +++ b/Exercises/02/Begin/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial02) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(02_Exercise exercise_2_begin.cpp) target_link_libraries(02_Exercise Kokkos::kokkos) diff --git a/Exercises/02/Solution/CMakeLists.txt b/Exercises/02/Solution/CMakeLists.txt index 55378e7c..9bde9dc5 100644 --- a/Exercises/02/Solution/CMakeLists.txt +++ b/Exercises/02/Solution/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial02) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(02_Solution exercise_2_solution.cpp) target_link_libraries(02_Solution Kokkos::kokkos) diff --git a/Exercises/03/Begin/CMakeLists.txt b/Exercises/03/Begin/CMakeLists.txt index f65fe9f8..e9d4e6a4 100644 --- a/Exercises/03/Begin/CMakeLists.txt +++ b/Exercises/03/Begin/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial03) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${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) diff --git a/Exercises/03/Solution/CMakeLists.txt b/Exercises/03/Solution/CMakeLists.txt index dcf88f46..a7c0ff46 100644 --- a/Exercises/03/Solution/CMakeLists.txt +++ b/Exercises/03/Solution/CMakeLists.txt @@ -1,8 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial03) -include(../../common.cmake) -add_executable(03_Solution exercise_3_solution.cpp) -target_link_libraries(03_Solution Kokkos::kokkos) +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${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) diff --git a/Exercises/04/Begin/CMakeLists.txt b/Exercises/04/Begin/CMakeLists.txt index e391e636..c78db3fd 100644 --- a/Exercises/04/Begin/CMakeLists.txt +++ b/Exercises/04/Begin/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial04) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${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) diff --git a/Exercises/04/Solution/CMakeLists.txt b/Exercises/04/Solution/CMakeLists.txt index 41cf3bd9..352a9c7f 100644 --- a/Exercises/04/Solution/CMakeLists.txt +++ b/Exercises/04/Solution/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial04) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${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) diff --git a/Exercises/advanced_reductions/Begin/CMakeLists.txt b/Exercises/advanced_reductions/Begin/CMakeLists.txt index de88dd10..7de487c8 100644 --- a/Exercises/advanced_reductions/Begin/CMakeLists.txt +++ b/Exercises/advanced_reductions/Begin/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialAdvancedReductions) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(AdvancedReductions advanced_reductions.cpp) target_link_libraries(AdvancedReductions Kokkos::kokkos) diff --git a/Exercises/advanced_reductions/Solution/CMakeLists.txt b/Exercises/advanced_reductions/Solution/CMakeLists.txt index a36333de..5f1d9ca6 100644 --- a/Exercises/advanced_reductions/Solution/CMakeLists.txt +++ b/Exercises/advanced_reductions/Solution/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialAdvancedReductions) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${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) diff --git a/Exercises/common.cmake b/Exercises/common.cmake deleted file mode 100644 index db40aca8..00000000 --- a/Exercises/common.cmake +++ /dev/null @@ -1,40 +0,0 @@ -# Early return if Kokkos is already set up -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_SOURCE_DIR}/../../dep/Kokkos) - -find_package(Kokkos CONFIG) -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() diff --git a/Exercises/dualview/Begin/CMakeLists.txt b/Exercises/dualview/Begin/CMakeLists.txt index 529d6360..8d0b6250 100644 --- a/Exercises/dualview/Begin/CMakeLists.txt +++ b/Exercises/dualview/Begin/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialDualView) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${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) diff --git a/Exercises/dualview/Solution/CMakeLists.txt b/Exercises/dualview/Solution/CMakeLists.txt index 2e0c2b6e..1affbd0c 100644 --- a/Exercises/dualview/Solution/CMakeLists.txt +++ b/Exercises/dualview/Solution/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialDualView) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${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) diff --git a/Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt b/Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt index 2bf37d6b..baf5ca2e 100644 --- a/Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt +++ b/Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt @@ -1,22 +1,26 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialFortran) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) enable_language(Fortran) set(SPACK_FC $ENV{SPACK_FC}) -if(SPACK_FC) - message("Found spack fortran compiler ${SPACK_FC}") - set(CMAKE_Fortran_COMPILER ${SPACK_FC} CACHE STRING "the C++ compiler" FORCE) - set(ENV{FC} ${SPACK_FC}) -endif() +if (SPACK_FC) + message("Found spack fortran compiler ${SPACK_FC}") + set(CMAKE_Fortran_COMPILER ${SPACK_FC} CACHE STRING "the C++ compiler" FORCE) + set(ENV{FC} ${SPACK_FC}) +endif () set(SPACK_F77 $ENV{SPACK_F77}) -if(SPACK_F77) - message("Found spack fortran compiler ${SPACK_F77}") - set(CMAKE_Fortran_COMPILER ${SPACK_F77} CACHE STRING "the C++ compiler" FORCE) - set(ENV{F77} ${SPACK_F77}) -endif() +if (SPACK_F77) + message("Found spack fortran compiler ${SPACK_F77}") + set(CMAKE_Fortran_COMPILER ${SPACK_F77} CACHE STRING "the C++ compiler" FORCE) + set(ENV{F77} ${SPACK_F77}) +endif () add_executable(ftest.x abi.f90 f_interface.f90 main.f90 c_interface.cpp) target_link_libraries(ftest.x Kokkos::kokkos) diff --git a/Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt b/Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt index dce4462b..c4cd18c9 100644 --- a/Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt +++ b/Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt @@ -1,24 +1,28 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialFortran) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) set(SPACK_FC $ENV{SPACK_FC}) -if(SPACK_FC) - message("Found spack fortran compiler ${SPACK_FC}") - set(CMAKE_Fortran_COMPILER ${SPACK_FC} CACHE FILEPATH "the C++ compiler" FORCE) - set(ENV{FC} ${SPACK_FC}) -endif() +if (SPACK_FC) + message("Found spack fortran compiler ${SPACK_FC}") + set(CMAKE_Fortran_COMPILER ${SPACK_FC} CACHE FILEPATH "the C++ compiler" FORCE) + set(ENV{FC} ${SPACK_FC}) +endif () set(SPACK_F77 $ENV{SPACK_F77}) -if(SPACK_F77) - message("Found spack fortran compiler ${SPACK_F77}") - set(CMAKE_Fortran_COMPILER ${SPACK_F77} CACHE FILEPATH "the C++ compiler" FORCE) - set(ENV{F77} ${SPACK_F77}) -endif() - -execute_process ( - COMMAND bash -c "printenv" - OUTPUT_VARIABLE outVar +if (SPACK_F77) + message("Found spack fortran compiler ${SPACK_F77}") + set(CMAKE_Fortran_COMPILER ${SPACK_F77} CACHE FILEPATH "the C++ compiler" FORCE) + set(ENV{F77} ${SPACK_F77}) +endif () + +execute_process( + COMMAND bash -c "printenv" + OUTPUT_VARIABLE outVar ) message("${outVar}") diff --git a/Exercises/mdrange/Begin/CMakeLists.txt b/Exercises/mdrange/Begin/CMakeLists.txt index 5467a0d1..ec60a055 100644 --- a/Exercises/mdrange/Begin/CMakeLists.txt +++ b/Exercises/mdrange/Begin/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMdRange) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(mdrange_exercise exercise_mdrange_begin.cpp) target_link_libraries(mdrange_exercise Kokkos::kokkos) diff --git a/Exercises/mdrange/Solution/CMakeLists.txt b/Exercises/mdrange/Solution/CMakeLists.txt index e1e98bf2..767b9f13 100644 --- a/Exercises/mdrange/Solution/CMakeLists.txt +++ b/Exercises/mdrange/Solution/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMdRange) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(mdrange_Solution exercise_mdrange_solution.cpp) target_link_libraries(mdrange_Solution Kokkos::kokkos) diff --git a/Exercises/mpi_pack_unpack/Begin/CMakeLists.txt b/Exercises/mpi_pack_unpack/Begin/CMakeLists.txt index 997a34a8..9098ed5a 100644 --- a/Exercises/mpi_pack_unpack/Begin/CMakeLists.txt +++ b/Exercises/mpi_pack_unpack/Begin/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMPIPackUnpack) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(MPIPackUnpack mpi_pack_unpack_begin.cpp) target_link_libraries(MPIPackUnpack Kokkos::kokkos) diff --git a/Exercises/mpi_pack_unpack/Solution/CMakeLists.txt b/Exercises/mpi_pack_unpack/Solution/CMakeLists.txt index d5296d06..f9bea50a 100644 --- a/Exercises/mpi_pack_unpack/Solution/CMakeLists.txt +++ b/Exercises/mpi_pack_unpack/Solution/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMPIPackUnpack) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(MPIPackUnpack mpi_pack_unpack_solution.cpp) target_link_libraries(MPIPackUnpack Kokkos::kokkos) diff --git a/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt b/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt index fa346abe..753b52ca 100644 --- a/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt +++ b/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt @@ -1,7 +1,11 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMultiGpuCuda) -include(../../common.cmake) - + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) + add_executable(ExerciseMultiGPU multi_gpu_cuda.cpp) target_link_libraries(ExerciseMultiGPU Kokkos::kokkos) diff --git a/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt b/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt index 99ffce5a..753b52ca 100644 --- a/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt +++ b/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMultiGpuCuda) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(ExerciseMultiGPU multi_gpu_cuda.cpp) target_link_libraries(ExerciseMultiGPU Kokkos::kokkos) diff --git a/Exercises/parallel_scan/Begin/CMakeLists.txt b/Exercises/parallel_scan/Begin/CMakeLists.txt index 5495c711..8a362b7c 100644 --- a/Exercises/parallel_scan/Begin/CMakeLists.txt +++ b/Exercises/parallel_scan/Begin/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialParallelScan) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(ParallelScan parallel_scan.cpp) target_link_libraries(ParallelScan Kokkos::kokkos) diff --git a/Exercises/parallel_scan/Solution/CMakeLists.txt b/Exercises/parallel_scan/Solution/CMakeLists.txt index 93b0987f..637952aa 100644 --- a/Exercises/parallel_scan/Solution/CMakeLists.txt +++ b/Exercises/parallel_scan/Solution/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialParallelScan) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(ParallelScan_Solution parallel_scan.cpp) target_link_libraries(ParallelScan_Solution Kokkos::kokkos) diff --git a/Exercises/random_number/Begin/CMakeLists.txt b/Exercises/random_number/Begin/CMakeLists.txt index 8115ede2..69edd46a 100644 --- a/Exercises/random_number/Begin/CMakeLists.txt +++ b/Exercises/random_number/Begin/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialRNG) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(MC_DartSampler MC_DartSampler.cpp) target_link_libraries(MC_DartSampler Kokkos::kokkos) diff --git a/Exercises/random_number/Solution/CMakeLists.txt b/Exercises/random_number/Solution/CMakeLists.txt index 8115ede2..c734f6f4 100644 --- a/Exercises/random_number/Solution/CMakeLists.txt +++ b/Exercises/random_number/Solution/CMakeLists.txt @@ -1,8 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialRNG) -include(../../common.cmake) -add_executable(MC_DartSampler MC_DartSampler.cpp) -target_link_libraries(MC_DartSampler Kokkos::kokkos) +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +find_package(Kokkos REQUIRED) +add_executable(MC_DartSampler MC_DartSampler.cpp) +target_link_libraries(MC_DartSampler Kokkos::kokkos) diff --git a/Exercises/scatter_view/Begin/CMakeLists.txt b/Exercises/scatter_view/Begin/CMakeLists.txt index 152e6c3c..7442e244 100644 --- a/Exercises/scatter_view/Begin/CMakeLists.txt +++ b/Exercises/scatter_view/Begin/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialScatterView) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(scatterview scatter_view.cpp) target_link_libraries(scatterview Kokkos::kokkos) diff --git a/Exercises/scatter_view/Solution/CMakeLists.txt b/Exercises/scatter_view/Solution/CMakeLists.txt index 083a14f1..3aece83d 100644 --- a/Exercises/scatter_view/Solution/CMakeLists.txt +++ b/Exercises/scatter_view/Solution/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialScatterView) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(scatterview_Solution scatter_view.cpp) target_link_libraries(scatterview_Solution Kokkos::kokkos) diff --git a/Exercises/simd/Begin/CMakeLists.txt b/Exercises/simd/Begin/CMakeLists.txt index ba471215..473130f0 100644 --- a/Exercises/simd/Begin/CMakeLists.txt +++ b/Exercises/simd/Begin/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSIMD) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(SIMD simd_begin.cpp) target_link_libraries(SIMD Kokkos::kokkos) diff --git a/Exercises/simd/Solution/CMakeLists.txt b/Exercises/simd/Solution/CMakeLists.txt index cc6060f8..c5d73082 100644 --- a/Exercises/simd/Solution/CMakeLists.txt +++ b/Exercises/simd/Solution/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSIMD) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(SIMD_Solution simd_solution.cpp) target_link_libraries(SIMD_Solution Kokkos::kokkos) diff --git a/Exercises/simd_warp/Begin/CMakeLists.txt b/Exercises/simd_warp/Begin/CMakeLists.txt index 83dcecbe..eb7df751 100644 --- a/Exercises/simd_warp/Begin/CMakeLists.txt +++ b/Exercises/simd_warp/Begin/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSIMDWarp) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(SIMDWarp simd_warp_begin.cpp) target_link_libraries(SIMDWarp Kokkos::kokkos) diff --git a/Exercises/simd_warp/Solution/CMakeLists.txt b/Exercises/simd_warp/Solution/CMakeLists.txt index b6bcf9e6..9d0f4467 100644 --- a/Exercises/simd_warp/Solution/CMakeLists.txt +++ b/Exercises/simd_warp/Solution/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSIMDWarp) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(SIMDWarp_Solution simd_warp_solution.cpp) target_link_libraries(SIMDWarp_Solution Kokkos::kokkos) diff --git a/Exercises/subview/Begin/CMakeLists.txt b/Exercises/subview/Begin/CMakeLists.txt index 248a0345..78e0e28a 100644 --- a/Exercises/subview/Begin/CMakeLists.txt +++ b/Exercises/subview/Begin/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSubview) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(subview_exercise exercise_subview_begin.cpp) target_link_libraries(subview_exercise Kokkos::kokkos) diff --git a/Exercises/subview/Solution/CMakeLists.txt b/Exercises/subview/Solution/CMakeLists.txt index 8a11fd67..a0214a64 100644 --- a/Exercises/subview/Solution/CMakeLists.txt +++ b/Exercises/subview/Solution/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSubview) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(subview_Solution exercise_subview_solution.cpp) target_link_libraries(subview_Solution Kokkos::kokkos) diff --git a/Exercises/tasking/Begin/CMakeLists.txt b/Exercises/tasking/Begin/CMakeLists.txt index 6adf7ef2..536a6f9b 100644 --- a/Exercises/tasking/Begin/CMakeLists.txt +++ b/Exercises/tasking/Begin/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTasking) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(Tasking tasking_begin.cpp) target_link_libraries(Tasking Kokkos::kokkos) diff --git a/Exercises/tasking/Solution/CMakeLists.txt b/Exercises/tasking/Solution/CMakeLists.txt index ad8aae47..27ebaf6c 100644 --- a/Exercises/tasking/Solution/CMakeLists.txt +++ b/Exercises/tasking/Solution/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTasking) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(Tasking_Solution tasking_solution.cpp) target_link_libraries(Tasking_Solution Kokkos::kokkos) diff --git a/Exercises/team_policy/Begin/CMakeLists.txt b/Exercises/team_policy/Begin/CMakeLists.txt index 5953f634..bc1fd7f8 100644 --- a/Exercises/team_policy/Begin/CMakeLists.txt +++ b/Exercises/team_policy/Begin/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamPolicy) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(TeamPolicy team_policy_begin.cpp) target_link_libraries(TeamPolicy Kokkos::kokkos) diff --git a/Exercises/team_policy/Solution/CMakeLists.txt b/Exercises/team_policy/Solution/CMakeLists.txt index e8e4765e..4f8cac06 100644 --- a/Exercises/team_policy/Solution/CMakeLists.txt +++ b/Exercises/team_policy/Solution/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamPolicy) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(TeamPolicy_Solution team_policy_solution.cpp) target_link_libraries(TeamPolicy_Solution Kokkos::kokkos) diff --git a/Exercises/team_scratch_memory/Begin/CMakeLists.txt b/Exercises/team_scratch_memory/Begin/CMakeLists.txt index 1f5e90e5..1e482bfe 100644 --- a/Exercises/team_scratch_memory/Begin/CMakeLists.txt +++ b/Exercises/team_scratch_memory/Begin/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamScratchMemory) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(TeamScratchMemory team_scratch_memory_begin.cpp) target_link_libraries(TeamScratchMemory Kokkos::kokkos) diff --git a/Exercises/team_scratch_memory/Solution/CMakeLists.txt b/Exercises/team_scratch_memory/Solution/CMakeLists.txt index e2b1e465..3774090a 100644 --- a/Exercises/team_scratch_memory/Solution/CMakeLists.txt +++ b/Exercises/team_scratch_memory/Solution/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamScratchMemory) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(TeamScratchMemory_Solution team_scratch_memory_solution.cpp) target_link_libraries(TeamScratchMemory_Solution Kokkos::kokkos) diff --git a/Exercises/team_vector_loop/Begin/CMakeLists.txt b/Exercises/team_vector_loop/Begin/CMakeLists.txt index eee29804..10e0f846 100644 --- a/Exercises/team_vector_loop/Begin/CMakeLists.txt +++ b/Exercises/team_vector_loop/Begin/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamVectorLoop) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(TeamVectorLoop team_vector_loop_begin.cpp) target_link_libraries(TeamVectorLoop Kokkos::kokkos) diff --git a/Exercises/team_vector_loop/Solution/CMakeLists.txt b/Exercises/team_vector_loop/Solution/CMakeLists.txt index 24ab2b9c..9a6e5349 100644 --- a/Exercises/team_vector_loop/Solution/CMakeLists.txt +++ b/Exercises/team_vector_loop/Solution/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamVectorLoop) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(TeamVectorLoop_Solution team_vector_loop_solution.cpp) target_link_libraries(TeamVectorLoop_Solution Kokkos::kokkos) diff --git a/Exercises/tools_minimd/CMakeLists.txt b/Exercises/tools_minimd/CMakeLists.txt index 83db376e..e890597e 100644 --- a/Exercises/tools_minimd/CMakeLists.txt +++ b/Exercises/tools_minimd/CMakeLists.txt @@ -1,36 +1,40 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTools) -include(../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) option(ENABLE_MPI OFF "Whether to enable the Message Passing Interface (MPI)") -if(ENABLE_MPI) - find_package(MPI REQUIRED) -else() - add_library(mpi_stubs MPI-Stubs/mpi.c) - target_include_directories(mpi_stubs PUBLIC MPI-Stubs) -endif() +if (ENABLE_MPI) + find_package(MPI REQUIRED) +else () + add_library(mpi_stubs MPI-Stubs/mpi.c) + target_include_directories(mpi_stubs PUBLIC MPI-Stubs) +endif () add_executable(miniMD - atom.cpp - comm.cpp - force_eam.cpp - force_lj.cpp - input.cpp - integrate.cpp - ljs.cpp - neighbor.cpp - output.cpp - setup.cpp - thermo.cpp - timer.cpp + atom.cpp + comm.cpp + force_eam.cpp + force_lj.cpp + input.cpp + integrate.cpp + ljs.cpp + neighbor.cpp + output.cpp + setup.cpp + thermo.cpp + timer.cpp ) target_link_libraries(miniMD Kokkos::kokkos) -if(ENABLE_MPI) - target_link_libraries(miniMD MPI::MPI_CXX) -else() - target_link_libraries(miniMD mpi_stubs) -endif() +if (ENABLE_MPI) + target_link_libraries(miniMD MPI::MPI_CXX) +else () + target_link_libraries(miniMD mpi_stubs) +endif () diff --git a/Exercises/unique_token/Begin/CMakeLists.txt b/Exercises/unique_token/Begin/CMakeLists.txt index f8f18460..020cfdc9 100644 --- a/Exercises/unique_token/Begin/CMakeLists.txt +++ b/Exercises/unique_token/Begin/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialUniqueToken) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(uniquetoken unique_token.cpp) target_link_libraries(uniquetoken Kokkos::kokkos) diff --git a/Exercises/unique_token/Solution/CMakeLists.txt b/Exercises/unique_token/Solution/CMakeLists.txt index f8f18460..ab936e97 100644 --- a/Exercises/unique_token/Solution/CMakeLists.txt +++ b/Exercises/unique_token/Solution/CMakeLists.txt @@ -1,8 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialUniqueToken) -include(../../common.cmake) -add_executable(uniquetoken unique_token.cpp) -target_link_libraries(uniquetoken Kokkos::kokkos) +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +find_package(Kokkos REQUIRED) +add_executable(uniquetoken unique_token.cpp) +target_link_libraries(uniquetoken Kokkos::kokkos) diff --git a/Exercises/unordered_map/Begin/CMakeLists.txt b/Exercises/unordered_map/Begin/CMakeLists.txt index 0788b5a0..1ade593e 100644 --- a/Exercises/unordered_map/Begin/CMakeLists.txt +++ b/Exercises/unordered_map/Begin/CMakeLists.txt @@ -1,8 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialUnorderedMap) -include(../../common.cmake) -add_executable(unordered_map unordered_map.cpp) -target_link_libraries(unordered_map Kokkos::kokkos) +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +find_package(Kokkos REQUIRED) +add_executable(unordered_map unordered_map.cpp) +target_link_libraries(unordered_map Kokkos::kokkos) diff --git a/Exercises/unordered_map/Solution/CMakeLists.txt b/Exercises/unordered_map/Solution/CMakeLists.txt index 0788b5a0..521f4590 100644 --- a/Exercises/unordered_map/Solution/CMakeLists.txt +++ b/Exercises/unordered_map/Solution/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialUnorderedMap) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(unordered_map unordered_map.cpp) target_link_libraries(unordered_map Kokkos::kokkos) diff --git a/Exercises/virtualfunction/Begin/CMakeLists.txt b/Exercises/virtualfunction/Begin/CMakeLists.txt index 1a934426..52e9d3b0 100644 --- a/Exercises/virtualfunction/Begin/CMakeLists.txt +++ b/Exercises/virtualfunction/Begin/CMakeLists.txt @@ -1,9 +1,11 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialVirtualFunction) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(virtual_function virtual_function.cpp classes.cpp) target_link_libraries(virtual_function Kokkos::kokkos) target_include_directories(virtual_function PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) - - diff --git a/Exercises/virtualfunction/Solution/CMakeLists.txt b/Exercises/virtualfunction/Solution/CMakeLists.txt index 1a934426..52e9d3b0 100644 --- a/Exercises/virtualfunction/Solution/CMakeLists.txt +++ b/Exercises/virtualfunction/Solution/CMakeLists.txt @@ -1,9 +1,11 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialVirtualFunction) -include(../../common.cmake) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) add_executable(virtual_function virtual_function.cpp classes.cpp) target_link_libraries(virtual_function Kokkos::kokkos) target_include_directories(virtual_function PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) - - From 4f30736b2560e4923d2c42533d3dd228df4b238f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Chevalier?= Date: Mon, 3 Jun 2024 16:54:16 +0200 Subject: [PATCH 07/59] `subview` now compiles with the DefaultExecutionSpace. --- .../subview/Begin/exercise_subview_begin.cpp | 8 ++++++-- .../Solution/exercise_subview_solution.cpp | 16 +++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Exercises/subview/Begin/exercise_subview_begin.cpp b/Exercises/subview/Begin/exercise_subview_begin.cpp index f680b372..98ace825 100644 --- a/Exercises/subview/Begin/exercise_subview_begin.cpp +++ b/Exercises/subview/Begin/exercise_subview_begin.cpp @@ -74,13 +74,17 @@ int main( int argc, char* argv[] ) // typedef Kokkos::Serial ExecSpace; // typedef Kokkos::Threads ExecSpace; // typedef Kokkos::OpenMP ExecSpace; - typedef Kokkos::Cuda ExecSpace; + // typedef Kokkos::Cuda ExecSpace; + + typedef Kokkos::DefaultExecutionSpace ExecSpace; // typedef Kokkos::HostSpace MemSpace; // typedef Kokkos::OpenMP MemSpace; - typedef Kokkos::CudaSpace MemSpace; + // typedef Kokkos::CudaSpace MemSpace; // typedef Kokkos::CudaUVMSpace MemSpace; + typedef Kokkos::DefaultExecutionSpace::memory_space MemSpace; + typedef Kokkos::LayoutLeft Layout; // typedef Kokkos::LayoutRight Layout; diff --git a/Exercises/subview/Solution/exercise_subview_solution.cpp b/Exercises/subview/Solution/exercise_subview_solution.cpp index 4a68a160..9aef4e77 100644 --- a/Exercises/subview/Solution/exercise_subview_solution.cpp +++ b/Exercises/subview/Solution/exercise_subview_solution.cpp @@ -67,20 +67,22 @@ int main( int argc, char* argv[] ) // typedef Kokkos::Serial ExecSpace; // typedef Kokkos::Threads ExecSpace; - typedef Kokkos::OpenMP ExecSpace; + // typedef Kokkos::OpenMP ExecSpace; // typedef Kokkos::Cuda ExecSpace; - // typedef Kokkos::Experimental::HIP ExecSpace; + + typedef Kokkos::DefaultExecutionSpace ExecSpace; // typedef Kokkos::HostSpace MemSpace; - typedef Kokkos::OpenMP MemSpace; + // typedef Kokkos::OpenMP MemSpace; // typedef Kokkos::CudaSpace MemSpace; // typedef Kokkos::CudaUVMSpace MemSpace; - // typedef Kokkos::Experimental::HIPSpace MemSpace; - // typedef Kokkos::LayoutLeft Layout; - typedef Kokkos::LayoutRight Layout; + typedef Kokkos::DefaultExecutionSpace::memory_space MemSpace; + + typedef Kokkos::LayoutLeft Layout; + // typedef Kokkos::LayoutRight Layout; - typedef Kokkos::RangePolicy range_policy; + typedef Kokkos::RangePolicy range_policy; // Allocate y, x vectors and Matrix A on device. typedef Kokkos::View ViewVectorType; From f2cc0c8554d98b0f815b6a751349fc7933eb3a63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Chevalier?= Date: Wed, 5 Jun 2024 11:58:20 +0200 Subject: [PATCH 08/59] Add CMake warnings when using device enabled Kokkos for the 2 first exercises --- Exercises/01/Begin/CMakeLists.txt | 5 +++++ Exercises/01/Solution/CMakeLists.txt | 5 +++++ Exercises/02/Begin/CMakeLists.txt | 5 +++++ Exercises/02/Solution/CMakeLists.txt | 5 +++++ 4 files changed, 20 insertions(+) diff --git a/Exercises/01/Begin/CMakeLists.txt b/Exercises/01/Begin/CMakeLists.txt index 8d4917de..a07d1c16 100644 --- a/Exercises/01/Begin/CMakeLists.txt +++ b/Exercises/01/Begin/CMakeLists.txt @@ -6,5 +6,10 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cm find_package(Kokkos REQUIRED) +if (Kokkos_DEVICES) + message(WARNING "${CMAKE_CURRENT_SOURCE_DIR}" + "Kokkos device is enabled, it might cause issue with the current program") +endif () + add_executable(01_Exercise exercise_1_begin.cpp) target_link_libraries(01_Exercise Kokkos::kokkos) diff --git a/Exercises/01/Solution/CMakeLists.txt b/Exercises/01/Solution/CMakeLists.txt index 74052a19..f903657e 100644 --- a/Exercises/01/Solution/CMakeLists.txt +++ b/Exercises/01/Solution/CMakeLists.txt @@ -6,5 +6,10 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cm find_package(Kokkos REQUIRED) +if (Kokkos_DEVICES) + message(WARNING "${CMAKE_CURRENT_SOURCE_DIR}" + "Kokkos device is enabled, it might cause issue with the current program") +endif () + add_executable(01_Solution exercise_1_solution.cpp) target_link_libraries(01_Solution Kokkos::kokkos) diff --git a/Exercises/02/Begin/CMakeLists.txt b/Exercises/02/Begin/CMakeLists.txt index 98d472a3..78080dfc 100644 --- a/Exercises/02/Begin/CMakeLists.txt +++ b/Exercises/02/Begin/CMakeLists.txt @@ -6,6 +6,11 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cm find_package(Kokkos REQUIRED) +if (Kokkos_DEVICES) + message(WARNING "${CMAKE_CURRENT_SOURCE_DIR}" + "Kokkos device is enabled, it might cause issue with the current program") +endif () + add_executable(02_Exercise exercise_2_begin.cpp) target_link_libraries(02_Exercise Kokkos::kokkos) diff --git a/Exercises/02/Solution/CMakeLists.txt b/Exercises/02/Solution/CMakeLists.txt index 9bde9dc5..9dd7c88c 100644 --- a/Exercises/02/Solution/CMakeLists.txt +++ b/Exercises/02/Solution/CMakeLists.txt @@ -6,5 +6,10 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cm find_package(Kokkos REQUIRED) +if (Kokkos_DEVICES) + message(WARNING "${CMAKE_CURRENT_SOURCE_DIR}" + "Kokkos device is enabled, it might cause issue with the current program") +endif () + add_executable(02_Solution exercise_2_solution.cpp) target_link_libraries(02_Solution Kokkos::kokkos) From 9ebf652388b0340f27ca11ace76da2b605a27efd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Chevalier?= Date: Wed, 5 Jun 2024 14:50:30 +0200 Subject: [PATCH 09/59] Adding 'instances' exercise to main CMake --- Exercises/CMakeLists.txt | 1 + Exercises/instances/Begin/CMakeLists.txt | 10 ++++++++++ Exercises/instances/Begin/instances_begin.cpp | 2 +- Exercises/instances/CMakeLists.txt | 5 +++++ Exercises/instances/Solution/CMakeLists.txt | 10 ++++++++++ Exercises/instances/Solution/instances_solution.cpp | 2 +- 6 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 Exercises/instances/Begin/CMakeLists.txt create mode 100644 Exercises/instances/CMakeLists.txt create mode 100644 Exercises/instances/Solution/CMakeLists.txt diff --git a/Exercises/CMakeLists.txt b/Exercises/CMakeLists.txt index d3f8626f..2449a3f4 100644 --- a/Exercises/CMakeLists.txt +++ b/Exercises/CMakeLists.txt @@ -20,3 +20,4 @@ add_subdirectory(simd) add_subdirectory(advanced_reductions) add_subdirectory(parallel_scan) +add_subdirectory(instances) diff --git a/Exercises/instances/Begin/CMakeLists.txt b/Exercises/instances/Begin/CMakeLists.txt new file mode 100644 index 00000000..fdf09645 --- /dev/null +++ b/Exercises/instances/Begin/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorialInstances) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) + +add_executable(Instances_exercise instances_begin.cpp) +target_link_libraries(Instances_exercise Kokkos::kokkos) diff --git a/Exercises/instances/Begin/instances_begin.cpp b/Exercises/instances/Begin/instances_begin.cpp index 1510ef1c..5334f2c8 100644 --- a/Exercises/instances/Begin/instances_begin.cpp +++ b/Exercises/instances/Begin/instances_begin.cpp @@ -70,7 +70,7 @@ int main( int argc, char* argv[] ) for ( int i = 0; i < argc; i++ ) { if ( ( strcmp( argv[ i ], "-N" ) == 0 ) || ( strcmp( argv[ i ], "-Rows" ) == 0 ) ) { N = atoi( argv[ ++i ] ); - printf( " User N is %d\n", N ); + printf( " User N is %ld\n", N ); } else if ( strcmp( argv[ i ], "-nrepeat" ) == 0 ) { nrepeat = atoi( argv[ ++i ] ); diff --git a/Exercises/instances/CMakeLists.txt b/Exercises/instances/CMakeLists.txt new file mode 100644 index 00000000..a74722aa --- /dev/null +++ b/Exercises/instances/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosInstances) + +add_subdirectory(Begin) +add_subdirectory(Solution) diff --git a/Exercises/instances/Solution/CMakeLists.txt b/Exercises/instances/Solution/CMakeLists.txt new file mode 100644 index 00000000..cca8c5f6 --- /dev/null +++ b/Exercises/instances/Solution/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorialInstances) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) + +add_executable(Instances_solution instances_solution.cpp) +target_link_libraries(Instances_solution Kokkos::kokkos) diff --git a/Exercises/instances/Solution/instances_solution.cpp b/Exercises/instances/Solution/instances_solution.cpp index b6111043..2b8ddefd 100644 --- a/Exercises/instances/Solution/instances_solution.cpp +++ b/Exercises/instances/Solution/instances_solution.cpp @@ -64,7 +64,7 @@ int main( int argc, char* argv[] ) for ( int i = 0; i < argc; i++ ) { if ( ( strcmp( argv[ i ], "-N" ) == 0 ) || ( strcmp( argv[ i ], "-Rows" ) == 0 ) ) { N = atoi( argv[ ++i ] ); - printf( " User N is %d\n", N ); + printf( " User N is %ld\n", N ); } else if ( strcmp( argv[ i ], "-nrepeat" ) == 0 ) { nrepeat = atoi( argv[ ++i ] ); From c4451a00368eb0fc3a745dc35f4dcf78d271aac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Chevalier?= Date: Wed, 5 Jun 2024 14:53:37 +0200 Subject: [PATCH 10/59] Adding 'scatter_view/Usage' to CMake --- Exercises/scatter_view/CMakeLists.txt | 1 + Exercises/scatter_view/Usage/CMakeLists.txt | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 Exercises/scatter_view/Usage/CMakeLists.txt diff --git a/Exercises/scatter_view/CMakeLists.txt b/Exercises/scatter_view/CMakeLists.txt index b507fcfa..0d7b8549 100644 --- a/Exercises/scatter_view/CMakeLists.txt +++ b/Exercises/scatter_view/CMakeLists.txt @@ -3,3 +3,4 @@ project(KokkosTutorialScatterView) add_subdirectory(Begin) add_subdirectory(Solution) +add_subdirectory(Usage) diff --git a/Exercises/scatter_view/Usage/CMakeLists.txt b/Exercises/scatter_view/Usage/CMakeLists.txt new file mode 100644 index 00000000..828d92e7 --- /dev/null +++ b/Exercises/scatter_view/Usage/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorialScatterView) + +# Add a custom module path for find_package +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) + +find_package(Kokkos REQUIRED) + +add_executable(scatterview_usage usage.cpp) +target_link_libraries(scatterview_usage Kokkos::kokkos) From 1a9d2829bef15e6705ba11fc3a1e48487d5e5bde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Chevalier?= Date: Wed, 5 Jun 2024 15:00:24 +0200 Subject: [PATCH 11/59] Adding 'random_number' to CMake --- Exercises/04/Begin/CMakeLists.txt | 2 -- Exercises/CMakeLists.txt | 1 + Exercises/random_number/Begin/CMakeLists.txt | 6 ++---- Exercises/random_number/CMakeLists.txt | 5 +++++ Exercises/random_number/Solution/CMakeLists.txt | 4 ++-- 5 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 Exercises/random_number/CMakeLists.txt diff --git a/Exercises/04/Begin/CMakeLists.txt b/Exercises/04/Begin/CMakeLists.txt index c78db3fd..97bc5f48 100644 --- a/Exercises/04/Begin/CMakeLists.txt +++ b/Exercises/04/Begin/CMakeLists.txt @@ -8,5 +8,3 @@ find_package(Kokkos REQUIRED) add_executable(04_Exercise exercise_4_begin.cpp) target_link_libraries(04_Exercise Kokkos::kokkos) - - diff --git a/Exercises/CMakeLists.txt b/Exercises/CMakeLists.txt index 2449a3f4..fa730a15 100644 --- a/Exercises/CMakeLists.txt +++ b/Exercises/CMakeLists.txt @@ -21,3 +21,4 @@ add_subdirectory(simd) add_subdirectory(advanced_reductions) add_subdirectory(parallel_scan) add_subdirectory(instances) +add_subdirectory(random_number) diff --git a/Exercises/random_number/Begin/CMakeLists.txt b/Exercises/random_number/Begin/CMakeLists.txt index 69edd46a..69634bf8 100644 --- a/Exercises/random_number/Begin/CMakeLists.txt +++ b/Exercises/random_number/Begin/CMakeLists.txt @@ -6,7 +6,5 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cm find_package(Kokkos REQUIRED) -add_executable(MC_DartSampler MC_DartSampler.cpp) -target_link_libraries(MC_DartSampler Kokkos::kokkos) - - +add_executable(random_number_exercise MC_DartSampler.cpp) +target_link_libraries(random_number_exercise Kokkos::kokkos) diff --git a/Exercises/random_number/CMakeLists.txt b/Exercises/random_number/CMakeLists.txt new file mode 100644 index 00000000..7b5acdb5 --- /dev/null +++ b/Exercises/random_number/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorialRNG) + +add_subdirectory(Begin) +add_subdirectory(Solution) diff --git a/Exercises/random_number/Solution/CMakeLists.txt b/Exercises/random_number/Solution/CMakeLists.txt index c734f6f4..40c68ef2 100644 --- a/Exercises/random_number/Solution/CMakeLists.txt +++ b/Exercises/random_number/Solution/CMakeLists.txt @@ -6,5 +6,5 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cm find_package(Kokkos REQUIRED) -add_executable(MC_DartSampler MC_DartSampler.cpp) -target_link_libraries(MC_DartSampler Kokkos::kokkos) +add_executable(random_number_solution MC_DartSampler.cpp) +target_link_libraries(random_number_solution Kokkos::kokkos) From 1b1dedc852fdcf0d003c2b46bc3537c3bf7363aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Chevalier?= Date: Wed, 5 Jun 2024 12:17:15 +0200 Subject: [PATCH 12/59] Comment out some Kokkos call in Begin exercises advanced_reductions.cpp and parallel_scan.cpp cannot compile due to missing code (the exercise). --- Exercises/advanced_reductions/Begin/advanced_reductions.cpp | 3 ++- Exercises/parallel_scan/Begin/parallel_scan.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Exercises/advanced_reductions/Begin/advanced_reductions.cpp b/Exercises/advanced_reductions/Begin/advanced_reductions.cpp index ef9943ca..d5c66460 100644 --- a/Exercises/advanced_reductions/Begin/advanced_reductions.cpp +++ b/Exercises/advanced_reductions/Begin/advanced_reductions.cpp @@ -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); auto host_view = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, view); diff --git a/Exercises/parallel_scan/Begin/parallel_scan.cpp b/Exercises/parallel_scan/Begin/parallel_scan.cpp index 8cef5fad..9eb7e056 100644 --- a/Exercises/parallel_scan/Begin/parallel_scan.cpp +++ b/Exercises/parallel_scan/Begin/parallel_scan.cpp @@ -27,7 +27,8 @@ int main(int argc, char *argv[]) { int n = 10; Kokkos::View view("view", n); - Kokkos::parallel_scan(n, Factorial{view}); + // EXERCISE Uncomment when Factorial is implemented + // Kokkos::parallel_scan(n, Factorial{view}); auto host_view = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, view); From 1a073166f341f25ee66f081261f1b158975309f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Chevalier?= Date: Wed, 5 Jun 2024 15:06:07 +0200 Subject: [PATCH 13/59] Adding 'unique_token' to CMake --- Exercises/CMakeLists.txt | 1 + Exercises/unique_token/Begin/CMakeLists.txt | 9 ++++++--- Exercises/unique_token/CMakeLists.txt | 5 +++++ Exercises/unique_token/Solution/CMakeLists.txt | 4 ++-- 4 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 Exercises/unique_token/CMakeLists.txt diff --git a/Exercises/CMakeLists.txt b/Exercises/CMakeLists.txt index fa730a15..e09ca043 100644 --- a/Exercises/CMakeLists.txt +++ b/Exercises/CMakeLists.txt @@ -22,3 +22,4 @@ add_subdirectory(advanced_reductions) add_subdirectory(parallel_scan) add_subdirectory(instances) add_subdirectory(random_number) +add_subdirectory(unique_token) \ No newline at end of file diff --git a/Exercises/unique_token/Begin/CMakeLists.txt b/Exercises/unique_token/Begin/CMakeLists.txt index 020cfdc9..eb3ae03a 100644 --- a/Exercises/unique_token/Begin/CMakeLists.txt +++ b/Exercises/unique_token/Begin/CMakeLists.txt @@ -6,7 +6,10 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cm find_package(Kokkos REQUIRED) -add_executable(uniquetoken unique_token.cpp) -target_link_libraries(uniquetoken Kokkos::kokkos) - +if (NOT Kokkos_ENABLE_OPENMP) + message(WARNING "This exercise requires OpenMP, enable with -DKokkos_ENABLE_OPENMP=ON") + return() +endif() +add_executable(uniquetoken_exercise unique_token.cpp) +target_link_libraries(uniquetoken_exercise Kokkos::kokkos) diff --git a/Exercises/unique_token/CMakeLists.txt b/Exercises/unique_token/CMakeLists.txt new file mode 100644 index 00000000..f29238ed --- /dev/null +++ b/Exercises/unique_token/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorialUniqueToken) + +add_subdirectory(Begin) +add_subdirectory(Solution) diff --git a/Exercises/unique_token/Solution/CMakeLists.txt b/Exercises/unique_token/Solution/CMakeLists.txt index ab936e97..8dba31a9 100644 --- a/Exercises/unique_token/Solution/CMakeLists.txt +++ b/Exercises/unique_token/Solution/CMakeLists.txt @@ -6,5 +6,5 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cm find_package(Kokkos REQUIRED) -add_executable(uniquetoken unique_token.cpp) -target_link_libraries(uniquetoken Kokkos::kokkos) +add_executable(uniquetoken_solution unique_token.cpp) +target_link_libraries(uniquetoken_solution Kokkos::kokkos) From 9bce058ca2e4ded4ad6c2dd9c6dd8e318e289168 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Chevalier?= Date: Wed, 5 Jun 2024 15:07:48 +0200 Subject: [PATCH 14/59] Adding 'unordered_map' to CMake --- Exercises/CMakeLists.txt | 3 ++- Exercises/unordered_map/Begin/CMakeLists.txt | 4 ++-- Exercises/unordered_map/CMakeLists.txt | 5 +++++ Exercises/unordered_map/Solution/CMakeLists.txt | 6 ++---- 4 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 Exercises/unordered_map/CMakeLists.txt diff --git a/Exercises/CMakeLists.txt b/Exercises/CMakeLists.txt index e09ca043..df3cb5ab 100644 --- a/Exercises/CMakeLists.txt +++ b/Exercises/CMakeLists.txt @@ -22,4 +22,5 @@ add_subdirectory(advanced_reductions) add_subdirectory(parallel_scan) add_subdirectory(instances) add_subdirectory(random_number) -add_subdirectory(unique_token) \ No newline at end of file +add_subdirectory(unique_token) +add_subdirectory(unordered_map) diff --git a/Exercises/unordered_map/Begin/CMakeLists.txt b/Exercises/unordered_map/Begin/CMakeLists.txt index 1ade593e..4e1e8a65 100644 --- a/Exercises/unordered_map/Begin/CMakeLists.txt +++ b/Exercises/unordered_map/Begin/CMakeLists.txt @@ -6,5 +6,5 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cm find_package(Kokkos REQUIRED) -add_executable(unordered_map unordered_map.cpp) -target_link_libraries(unordered_map Kokkos::kokkos) +add_executable(unordered_map_exercise unordered_map.cpp) +target_link_libraries(unordered_map_exercise Kokkos::kokkos) diff --git a/Exercises/unordered_map/CMakeLists.txt b/Exercises/unordered_map/CMakeLists.txt new file mode 100644 index 00000000..2f9a2bb1 --- /dev/null +++ b/Exercises/unordered_map/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorialUnorderedMap) + +add_subdirectory(Begin) +add_subdirectory(Solution) diff --git a/Exercises/unordered_map/Solution/CMakeLists.txt b/Exercises/unordered_map/Solution/CMakeLists.txt index 521f4590..718e9c42 100644 --- a/Exercises/unordered_map/Solution/CMakeLists.txt +++ b/Exercises/unordered_map/Solution/CMakeLists.txt @@ -6,7 +6,5 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cm find_package(Kokkos REQUIRED) -add_executable(unordered_map unordered_map.cpp) -target_link_libraries(unordered_map Kokkos::kokkos) - - +add_executable(unordered_map_solution unordered_map.cpp) +target_link_libraries(unordered_map_solution Kokkos::kokkos) From 7c6a6766b5b9e7daa71c83759bbdef3c20fa4ccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Chevalier?= Date: Wed, 5 Jun 2024 15:14:10 +0200 Subject: [PATCH 15/59] Adding 'virtual_functions' to CMake Use "" for include instead of <> to avoid adding `-I.` flag. --- Exercises/CMakeLists.txt | 1 + Exercises/virtualfunction/Begin/CMakeLists.txt | 1 - Exercises/virtualfunction/Begin/Makefile | 1 - Exercises/virtualfunction/Begin/classes.cpp | 2 +- Exercises/virtualfunction/Begin/virtual_function.cpp | 2 +- Exercises/virtualfunction/CMakeLists.txt | 5 +++++ Exercises/virtualfunction/Solution/CMakeLists.txt | 5 ++--- Exercises/virtualfunction/Solution/Makefile | 1 - Exercises/virtualfunction/Solution/classes.cpp | 2 +- Exercises/virtualfunction/Solution/virtual_function.cpp | 2 +- 10 files changed, 12 insertions(+), 10 deletions(-) create mode 100644 Exercises/virtualfunction/CMakeLists.txt diff --git a/Exercises/CMakeLists.txt b/Exercises/CMakeLists.txt index df3cb5ab..7703a29f 100644 --- a/Exercises/CMakeLists.txt +++ b/Exercises/CMakeLists.txt @@ -24,3 +24,4 @@ add_subdirectory(instances) add_subdirectory(random_number) add_subdirectory(unique_token) add_subdirectory(unordered_map) +add_subdirectory(virtualfunction) diff --git a/Exercises/virtualfunction/Begin/CMakeLists.txt b/Exercises/virtualfunction/Begin/CMakeLists.txt index 52e9d3b0..30421d49 100644 --- a/Exercises/virtualfunction/Begin/CMakeLists.txt +++ b/Exercises/virtualfunction/Begin/CMakeLists.txt @@ -8,4 +8,3 @@ find_package(Kokkos REQUIRED) add_executable(virtual_function virtual_function.cpp classes.cpp) target_link_libraries(virtual_function Kokkos::kokkos) -target_include_directories(virtual_function PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/Exercises/virtualfunction/Begin/Makefile b/Exercises/virtualfunction/Begin/Makefile index b4a36384..8e8c66ee 100644 --- a/Exercises/virtualfunction/Begin/Makefile +++ b/Exercises/virtualfunction/Begin/Makefile @@ -20,7 +20,6 @@ EXE = ${EXE_NAME}.host KOKKOS_ARCH = "BDW" endif -override CXXFLAGS += -I./ LINK = ${CXX} LINKFLAGS = diff --git a/Exercises/virtualfunction/Begin/classes.cpp b/Exercises/virtualfunction/Begin/classes.cpp index 1b9d7cb3..bf5212cd 100644 --- a/Exercises/virtualfunction/Begin/classes.cpp +++ b/Exercises/virtualfunction/Begin/classes.cpp @@ -1,4 +1,4 @@ -#include +#include "classes.hpp" KOKKOS_FUNCTION Foo::Foo() { diff --git a/Exercises/virtualfunction/Begin/virtual_function.cpp b/Exercises/virtualfunction/Begin/virtual_function.cpp index 4ec7a531..73624aa7 100644 --- a/Exercises/virtualfunction/Begin/virtual_function.cpp +++ b/Exercises/virtualfunction/Begin/virtual_function.cpp @@ -1,4 +1,4 @@ -#include +#include "classes.hpp" // Exercise // 1. Launch a parallel kernel an use placement new to create virtual objects on diff --git a/Exercises/virtualfunction/CMakeLists.txt b/Exercises/virtualfunction/CMakeLists.txt new file mode 100644 index 00000000..e7ceb40c --- /dev/null +++ b/Exercises/virtualfunction/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorialVirtualFunction) + +add_subdirectory(Begin) +add_subdirectory(Solution) diff --git a/Exercises/virtualfunction/Solution/CMakeLists.txt b/Exercises/virtualfunction/Solution/CMakeLists.txt index 52e9d3b0..4e45c4d5 100644 --- a/Exercises/virtualfunction/Solution/CMakeLists.txt +++ b/Exercises/virtualfunction/Solution/CMakeLists.txt @@ -6,6 +6,5 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cm find_package(Kokkos REQUIRED) -add_executable(virtual_function virtual_function.cpp classes.cpp) -target_link_libraries(virtual_function Kokkos::kokkos) -target_include_directories(virtual_function PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) +add_executable(virtual_function_solution virtual_function.cpp classes.cpp) +target_link_libraries(virtual_function_solution Kokkos::kokkos) diff --git a/Exercises/virtualfunction/Solution/Makefile b/Exercises/virtualfunction/Solution/Makefile index b4a36384..8e8c66ee 100644 --- a/Exercises/virtualfunction/Solution/Makefile +++ b/Exercises/virtualfunction/Solution/Makefile @@ -20,7 +20,6 @@ EXE = ${EXE_NAME}.host KOKKOS_ARCH = "BDW" endif -override CXXFLAGS += -I./ LINK = ${CXX} LINKFLAGS = diff --git a/Exercises/virtualfunction/Solution/classes.cpp b/Exercises/virtualfunction/Solution/classes.cpp index 1b9d7cb3..bf5212cd 100644 --- a/Exercises/virtualfunction/Solution/classes.cpp +++ b/Exercises/virtualfunction/Solution/classes.cpp @@ -1,4 +1,4 @@ -#include +#include "classes.hpp" KOKKOS_FUNCTION Foo::Foo() { diff --git a/Exercises/virtualfunction/Solution/virtual_function.cpp b/Exercises/virtualfunction/Solution/virtual_function.cpp index a16e0cf7..0db73bb6 100644 --- a/Exercises/virtualfunction/Solution/virtual_function.cpp +++ b/Exercises/virtualfunction/Solution/virtual_function.cpp @@ -1,4 +1,4 @@ -#include +#include "classes.hpp" int main(int argc, char* argv[]) { Kokkos::initialize(argc,argv); From 8b5cd950aac84966d945051aa9bd95a1e5ac43f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Chevalier?= Date: Wed, 5 Jun 2024 15:18:39 +0200 Subject: [PATCH 16/59] List exercises to add to global cmake. --- Exercises/CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Exercises/CMakeLists.txt b/Exercises/CMakeLists.txt index 7703a29f..6931fcc9 100644 --- a/Exercises/CMakeLists.txt +++ b/Exercises/CMakeLists.txt @@ -25,3 +25,14 @@ add_subdirectory(random_number) add_subdirectory(unique_token) add_subdirectory(unordered_map) add_subdirectory(virtualfunction) + +# Not done yet +# TODO, require fortran +# add_subdirectory(fortran-kokkosinterface) +# TODO, require Kokkos Kernels +# add_subdirectory(kokkoskernels) +# TODO +# add_subdirectory(multi_gpu_cuda) +# add_subdirectory(tools_minimd) +# require remote spaces +# add_subdirectory(vectorshift) \ No newline at end of file From 5779c0f550c0c1a9f579bc64e187f9ba6d10e602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Chevalier?= Date: Wed, 5 Jun 2024 15:23:08 +0200 Subject: [PATCH 17/59] Add `fortran_interface` to global cmake --- Exercises/CMakeLists.txt | 4 ++-- .../fortran-kokkosinterface/Begin/CMakeLists.txt | 6 ++---- Exercises/fortran-kokkosinterface/CMakeLists.txt | 5 +++++ .../fortran-kokkosinterface/Solution/CMakeLists.txt | 12 ++---------- 4 files changed, 11 insertions(+), 16 deletions(-) create mode 100644 Exercises/fortran-kokkosinterface/CMakeLists.txt diff --git a/Exercises/CMakeLists.txt b/Exercises/CMakeLists.txt index 6931fcc9..c597a969 100644 --- a/Exercises/CMakeLists.txt +++ b/Exercises/CMakeLists.txt @@ -27,8 +27,8 @@ add_subdirectory(unordered_map) add_subdirectory(virtualfunction) # Not done yet -# TODO, require fortran -# add_subdirectory(fortran-kokkosinterface) +# TODO, Add a check for fortran +add_subdirectory(fortran-kokkosinterface) # TODO, require Kokkos Kernels # add_subdirectory(kokkoskernels) # TODO diff --git a/Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt b/Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt index baf5ca2e..620f3e33 100644 --- a/Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt +++ b/Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt @@ -22,7 +22,5 @@ if (SPACK_F77) set(ENV{F77} ${SPACK_F77}) endif () -add_executable(ftest.x abi.f90 f_interface.f90 main.f90 c_interface.cpp) -target_link_libraries(ftest.x Kokkos::kokkos) - - +add_executable(ftest_exercise abi.f90 f_interface.f90 main.f90 c_interface.cpp) +target_link_libraries(ftest_exercise Kokkos::kokkos) diff --git a/Exercises/fortran-kokkosinterface/CMakeLists.txt b/Exercises/fortran-kokkosinterface/CMakeLists.txt new file mode 100644 index 00000000..81f38016 --- /dev/null +++ b/Exercises/fortran-kokkosinterface/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorialFortranInterface) + +add_subdirectory(Begin) +add_subdirectory(Solution) diff --git a/Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt b/Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt index c4cd18c9..e8fe4139 100644 --- a/Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt +++ b/Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt @@ -20,15 +20,7 @@ if (SPACK_F77) set(ENV{F77} ${SPACK_F77}) endif () -execute_process( - COMMAND bash -c "printenv" - OUTPUT_VARIABLE outVar -) -message("${outVar}") - enable_language(Fortran) -add_executable(ftest.x abi.f90 f_interface.f90 main.f90 c_interface.cpp) -target_link_libraries(ftest.x Kokkos::kokkos) - - +add_executable(ftest_solution abi.f90 f_interface.f90 main.f90 c_interface.cpp) +target_link_libraries(ftest_solution Kokkos::kokkos) From dacde70be4ee9d47e20053722ebb3111c779addd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Chevalier?= Date: Wed, 5 Jun 2024 15:29:47 +0200 Subject: [PATCH 18/59] Add `multi_gpu_cuda` to global cmake Still have to check on a Cuda computer. --- Exercises/CMakeLists.txt | 2 +- Exercises/multi_gpu_cuda/Begin/CMakeLists.txt | 8 ++++++-- Exercises/multi_gpu_cuda/CMakeLists.txt | 5 +++++ Exercises/multi_gpu_cuda/Solution/CMakeLists.txt | 6 +++++- 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 Exercises/multi_gpu_cuda/CMakeLists.txt diff --git a/Exercises/CMakeLists.txt b/Exercises/CMakeLists.txt index c597a969..bc151713 100644 --- a/Exercises/CMakeLists.txt +++ b/Exercises/CMakeLists.txt @@ -32,7 +32,7 @@ add_subdirectory(fortran-kokkosinterface) # TODO, require Kokkos Kernels # add_subdirectory(kokkoskernels) # TODO -# add_subdirectory(multi_gpu_cuda) +add_subdirectory(multi_gpu_cuda) # add_subdirectory(tools_minimd) # require remote spaces # add_subdirectory(vectorshift) \ No newline at end of file diff --git a/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt b/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt index 753b52ca..31163453 100644 --- a/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt +++ b/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt @@ -6,6 +6,10 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cm find_package(Kokkos REQUIRED) -add_executable(ExerciseMultiGPU multi_gpu_cuda.cpp) -target_link_libraries(ExerciseMultiGPU Kokkos::kokkos) +if (NOT Kokkos_DEVICES MATCHES "CUDA") + message(WARNING "This example requires CUDA, enable with -DKokkos_ENABLE_CUDA=ON") + return() +endif() +add_executable(MultiGPU_exercise multi_gpu_cuda.cpp) +target_link_libraries(MultiGPU_exercise Kokkos::kokkos) diff --git a/Exercises/multi_gpu_cuda/CMakeLists.txt b/Exercises/multi_gpu_cuda/CMakeLists.txt new file mode 100644 index 00000000..154ee8b1 --- /dev/null +++ b/Exercises/multi_gpu_cuda/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.16) +project(KokkosTutorialMultiGPUCuda) + +add_subdirectory(Begin) +add_subdirectory(Solution) diff --git a/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt b/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt index 753b52ca..a514e719 100644 --- a/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt +++ b/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt @@ -6,6 +6,10 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cm find_package(Kokkos REQUIRED) +if (NOT Kokkos_DEVICES MATCHES "CUDA") + message(WARNING "This example requires CUDA, enable with -DKokkos_ENABLE_CUDA=ON") + return() +endif() + add_executable(ExerciseMultiGPU multi_gpu_cuda.cpp) target_link_libraries(ExerciseMultiGPU Kokkos::kokkos) - From 2bc96dfeddfc5f8b3a03849e9117087ee83dbdc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Chevalier?= Date: Wed, 5 Jun 2024 15:33:53 +0200 Subject: [PATCH 19/59] Add `minimd` to global cmake --- Exercises/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exercises/CMakeLists.txt b/Exercises/CMakeLists.txt index bc151713..d6c27ce0 100644 --- a/Exercises/CMakeLists.txt +++ b/Exercises/CMakeLists.txt @@ -33,6 +33,6 @@ add_subdirectory(fortran-kokkosinterface) # add_subdirectory(kokkoskernels) # TODO add_subdirectory(multi_gpu_cuda) -# add_subdirectory(tools_minimd) +add_subdirectory(tools_minimd) # require remote spaces # add_subdirectory(vectorshift) \ No newline at end of file From 46fa1d09678a2e1200b0ca632c3be611cb1a3960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Chevalier?= Date: Wed, 5 Jun 2024 15:38:22 +0200 Subject: [PATCH 20/59] Cleaning up exercise makefile. --- Exercises/CMakeLists.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Exercises/CMakeLists.txt b/Exercises/CMakeLists.txt index d6c27ce0..6e299361 100644 --- a/Exercises/CMakeLists.txt +++ b/Exercises/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialExercices) +# These directories follow IntroFull order of introduction + add_subdirectory(01) add_subdirectory(02) add_subdirectory(03) @@ -18,21 +20,21 @@ 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(parallel_scan) +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, Add a check for fortran -add_subdirectory(fortran-kokkosinterface) # TODO, require Kokkos Kernels # add_subdirectory(kokkoskernels) -# TODO -add_subdirectory(multi_gpu_cuda) -add_subdirectory(tools_minimd) # require remote spaces # add_subdirectory(vectorshift) \ No newline at end of file From d6e6530ae118af4ed41ceb9de3285ad9d2c04450 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Chevalier?= Date: Wed, 5 Jun 2024 15:58:28 +0200 Subject: [PATCH 21/59] Fetch Kokkos sources into CMAKE_BINARY_DIR This allows to not pollute the source directory. --- Exercises/.cmake/FindKokkos.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exercises/.cmake/FindKokkos.cmake b/Exercises/.cmake/FindKokkos.cmake index 5597b5fd..47e7fc26 100644 --- a/Exercises/.cmake/FindKokkos.cmake +++ b/Exercises/.cmake/FindKokkos.cmake @@ -19,7 +19,7 @@ if (NOT CMAKE_BUILD_TYPE) FORCE) endif () -set(Kokkos_COMMON_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../dep/Kokkos) +set(Kokkos_COMMON_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/dep/Kokkos) if (NOT KokkosTutorials_FORCE_INTERNAL_Kokkos) find_package(Kokkos CONFIG) From fe583b3bf1114a5fa70a3aef7e3d492419781488 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Tue, 11 Jun 2024 22:27:02 +0200 Subject: [PATCH 22/59] Use list(APPEND CMAKE_MODULE_PATH) As recommended by reviewers. --- Exercises/01/Begin/CMakeLists.txt | 2 +- Exercises/01/Solution/CMakeLists.txt | 2 +- Exercises/02/Begin/CMakeLists.txt | 2 +- Exercises/02/Solution/CMakeLists.txt | 2 +- Exercises/03/Begin/CMakeLists.txt | 2 +- Exercises/03/Solution/CMakeLists.txt | 2 +- Exercises/04/Begin/CMakeLists.txt | 2 +- Exercises/04/Solution/CMakeLists.txt | 2 +- Exercises/advanced_reductions/Begin/CMakeLists.txt | 2 +- Exercises/advanced_reductions/Solution/CMakeLists.txt | 2 +- Exercises/dualview/Begin/CMakeLists.txt | 2 +- Exercises/dualview/Solution/CMakeLists.txt | 2 +- Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt | 2 +- Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt | 2 +- Exercises/instances/Begin/CMakeLists.txt | 2 +- Exercises/instances/Solution/CMakeLists.txt | 2 +- Exercises/mdrange/Begin/CMakeLists.txt | 2 +- Exercises/mdrange/Solution/CMakeLists.txt | 2 +- Exercises/mpi_pack_unpack/Begin/CMakeLists.txt | 2 +- Exercises/mpi_pack_unpack/Solution/CMakeLists.txt | 2 +- Exercises/multi_gpu_cuda/Begin/CMakeLists.txt | 2 +- Exercises/multi_gpu_cuda/Solution/CMakeLists.txt | 2 +- Exercises/parallel_scan/Begin/CMakeLists.txt | 2 +- Exercises/parallel_scan/Solution/CMakeLists.txt | 2 +- Exercises/random_number/Begin/CMakeLists.txt | 2 +- Exercises/random_number/Solution/CMakeLists.txt | 2 +- Exercises/scatter_view/Begin/CMakeLists.txt | 2 +- Exercises/scatter_view/Solution/CMakeLists.txt | 2 +- Exercises/scatter_view/Usage/CMakeLists.txt | 2 +- Exercises/simd/Begin/CMakeLists.txt | 2 +- Exercises/simd/Solution/CMakeLists.txt | 2 +- Exercises/simd_warp/Begin/CMakeLists.txt | 2 +- Exercises/simd_warp/Solution/CMakeLists.txt | 2 +- Exercises/subview/Begin/CMakeLists.txt | 2 +- Exercises/subview/Solution/CMakeLists.txt | 2 +- Exercises/tasking/Begin/CMakeLists.txt | 2 +- Exercises/tasking/Solution/CMakeLists.txt | 2 +- Exercises/team_policy/Begin/CMakeLists.txt | 2 +- Exercises/team_policy/Solution/CMakeLists.txt | 2 +- Exercises/team_scratch_memory/Begin/CMakeLists.txt | 2 +- Exercises/team_scratch_memory/Solution/CMakeLists.txt | 2 +- Exercises/team_vector_loop/Begin/CMakeLists.txt | 2 +- Exercises/team_vector_loop/Solution/CMakeLists.txt | 2 +- Exercises/tools_minimd/CMakeLists.txt | 2 +- Exercises/unique_token/Begin/CMakeLists.txt | 2 +- Exercises/unique_token/Solution/CMakeLists.txt | 2 +- Exercises/unordered_map/Begin/CMakeLists.txt | 2 +- Exercises/unordered_map/Solution/CMakeLists.txt | 2 +- Exercises/virtualfunction/Begin/CMakeLists.txt | 2 +- Exercises/virtualfunction/Solution/CMakeLists.txt | 2 +- 50 files changed, 50 insertions(+), 50 deletions(-) diff --git a/Exercises/01/Begin/CMakeLists.txt b/Exercises/01/Begin/CMakeLists.txt index a07d1c16..410a3732 100644 --- a/Exercises/01/Begin/CMakeLists.txt +++ b/Exercises/01/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial01) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) find_package(Kokkos REQUIRED) diff --git a/Exercises/01/Solution/CMakeLists.txt b/Exercises/01/Solution/CMakeLists.txt index f903657e..ba5d5574 100644 --- a/Exercises/01/Solution/CMakeLists.txt +++ b/Exercises/01/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial01) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/02/Begin/CMakeLists.txt b/Exercises/02/Begin/CMakeLists.txt index 78080dfc..d37e07d3 100644 --- a/Exercises/02/Begin/CMakeLists.txt +++ b/Exercises/02/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial02) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/02/Solution/CMakeLists.txt b/Exercises/02/Solution/CMakeLists.txt index 9dd7c88c..9fbf0693 100644 --- a/Exercises/02/Solution/CMakeLists.txt +++ b/Exercises/02/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial02) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/03/Begin/CMakeLists.txt b/Exercises/03/Begin/CMakeLists.txt index e9d4e6a4..ba223dfa 100644 --- a/Exercises/03/Begin/CMakeLists.txt +++ b/Exercises/03/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial03) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/03/Solution/CMakeLists.txt b/Exercises/03/Solution/CMakeLists.txt index a7c0ff46..d7fc8769 100644 --- a/Exercises/03/Solution/CMakeLists.txt +++ b/Exercises/03/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial03) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/04/Begin/CMakeLists.txt b/Exercises/04/Begin/CMakeLists.txt index 97bc5f48..75450d2b 100644 --- a/Exercises/04/Begin/CMakeLists.txt +++ b/Exercises/04/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial04) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/04/Solution/CMakeLists.txt b/Exercises/04/Solution/CMakeLists.txt index 352a9c7f..f143b605 100644 --- a/Exercises/04/Solution/CMakeLists.txt +++ b/Exercises/04/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial04) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/advanced_reductions/Begin/CMakeLists.txt b/Exercises/advanced_reductions/Begin/CMakeLists.txt index 7de487c8..02fd2df3 100644 --- a/Exercises/advanced_reductions/Begin/CMakeLists.txt +++ b/Exercises/advanced_reductions/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialAdvancedReductions) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/advanced_reductions/Solution/CMakeLists.txt b/Exercises/advanced_reductions/Solution/CMakeLists.txt index 5f1d9ca6..b9aa6ee5 100644 --- a/Exercises/advanced_reductions/Solution/CMakeLists.txt +++ b/Exercises/advanced_reductions/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialAdvancedReductions) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/dualview/Begin/CMakeLists.txt b/Exercises/dualview/Begin/CMakeLists.txt index 8d0b6250..5f3de0ae 100644 --- a/Exercises/dualview/Begin/CMakeLists.txt +++ b/Exercises/dualview/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialDualView) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/dualview/Solution/CMakeLists.txt b/Exercises/dualview/Solution/CMakeLists.txt index 1affbd0c..1c70c597 100644 --- a/Exercises/dualview/Solution/CMakeLists.txt +++ b/Exercises/dualview/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialDualView) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt b/Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt index 620f3e33..fe616d18 100644 --- a/Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt +++ b/Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialFortran) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt b/Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt index e8fe4139..eeed29ea 100644 --- a/Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt +++ b/Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialFortran) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/instances/Begin/CMakeLists.txt b/Exercises/instances/Begin/CMakeLists.txt index fdf09645..06740e62 100644 --- a/Exercises/instances/Begin/CMakeLists.txt +++ b/Exercises/instances/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialInstances) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/instances/Solution/CMakeLists.txt b/Exercises/instances/Solution/CMakeLists.txt index cca8c5f6..3f769d83 100644 --- a/Exercises/instances/Solution/CMakeLists.txt +++ b/Exercises/instances/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialInstances) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/mdrange/Begin/CMakeLists.txt b/Exercises/mdrange/Begin/CMakeLists.txt index ec60a055..327afc73 100644 --- a/Exercises/mdrange/Begin/CMakeLists.txt +++ b/Exercises/mdrange/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMdRange) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/mdrange/Solution/CMakeLists.txt b/Exercises/mdrange/Solution/CMakeLists.txt index 767b9f13..c0d727e7 100644 --- a/Exercises/mdrange/Solution/CMakeLists.txt +++ b/Exercises/mdrange/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMdRange) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/mpi_pack_unpack/Begin/CMakeLists.txt b/Exercises/mpi_pack_unpack/Begin/CMakeLists.txt index 9098ed5a..1e32c4bb 100644 --- a/Exercises/mpi_pack_unpack/Begin/CMakeLists.txt +++ b/Exercises/mpi_pack_unpack/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMPIPackUnpack) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/mpi_pack_unpack/Solution/CMakeLists.txt b/Exercises/mpi_pack_unpack/Solution/CMakeLists.txt index f9bea50a..a0da79bd 100644 --- a/Exercises/mpi_pack_unpack/Solution/CMakeLists.txt +++ b/Exercises/mpi_pack_unpack/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMPIPackUnpack) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt b/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt index 31163453..ac4f0982 100644 --- a/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt +++ b/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMultiGpuCuda) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt b/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt index a514e719..0b4e70c9 100644 --- a/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt +++ b/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMultiGpuCuda) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/parallel_scan/Begin/CMakeLists.txt b/Exercises/parallel_scan/Begin/CMakeLists.txt index 8a362b7c..ab666b80 100644 --- a/Exercises/parallel_scan/Begin/CMakeLists.txt +++ b/Exercises/parallel_scan/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialParallelScan) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/parallel_scan/Solution/CMakeLists.txt b/Exercises/parallel_scan/Solution/CMakeLists.txt index 637952aa..8c812237 100644 --- a/Exercises/parallel_scan/Solution/CMakeLists.txt +++ b/Exercises/parallel_scan/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialParallelScan) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/random_number/Begin/CMakeLists.txt b/Exercises/random_number/Begin/CMakeLists.txt index 69634bf8..9f314ec5 100644 --- a/Exercises/random_number/Begin/CMakeLists.txt +++ b/Exercises/random_number/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialRNG) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/random_number/Solution/CMakeLists.txt b/Exercises/random_number/Solution/CMakeLists.txt index 40c68ef2..c47bd39c 100644 --- a/Exercises/random_number/Solution/CMakeLists.txt +++ b/Exercises/random_number/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialRNG) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/scatter_view/Begin/CMakeLists.txt b/Exercises/scatter_view/Begin/CMakeLists.txt index 7442e244..4d70ebec 100644 --- a/Exercises/scatter_view/Begin/CMakeLists.txt +++ b/Exercises/scatter_view/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialScatterView) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/scatter_view/Solution/CMakeLists.txt b/Exercises/scatter_view/Solution/CMakeLists.txt index 3aece83d..43be5a91 100644 --- a/Exercises/scatter_view/Solution/CMakeLists.txt +++ b/Exercises/scatter_view/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialScatterView) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/scatter_view/Usage/CMakeLists.txt b/Exercises/scatter_view/Usage/CMakeLists.txt index 828d92e7..053b718f 100644 --- a/Exercises/scatter_view/Usage/CMakeLists.txt +++ b/Exercises/scatter_view/Usage/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialScatterView) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/simd/Begin/CMakeLists.txt b/Exercises/simd/Begin/CMakeLists.txt index 473130f0..e09a913b 100644 --- a/Exercises/simd/Begin/CMakeLists.txt +++ b/Exercises/simd/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSIMD) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/simd/Solution/CMakeLists.txt b/Exercises/simd/Solution/CMakeLists.txt index c5d73082..083a6963 100644 --- a/Exercises/simd/Solution/CMakeLists.txt +++ b/Exercises/simd/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSIMD) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/simd_warp/Begin/CMakeLists.txt b/Exercises/simd_warp/Begin/CMakeLists.txt index eb7df751..730adab6 100644 --- a/Exercises/simd_warp/Begin/CMakeLists.txt +++ b/Exercises/simd_warp/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSIMDWarp) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/simd_warp/Solution/CMakeLists.txt b/Exercises/simd_warp/Solution/CMakeLists.txt index 9d0f4467..c72ae6af 100644 --- a/Exercises/simd_warp/Solution/CMakeLists.txt +++ b/Exercises/simd_warp/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSIMDWarp) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/subview/Begin/CMakeLists.txt b/Exercises/subview/Begin/CMakeLists.txt index 78e0e28a..b17ce1eb 100644 --- a/Exercises/subview/Begin/CMakeLists.txt +++ b/Exercises/subview/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSubview) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/subview/Solution/CMakeLists.txt b/Exercises/subview/Solution/CMakeLists.txt index a0214a64..5f88b298 100644 --- a/Exercises/subview/Solution/CMakeLists.txt +++ b/Exercises/subview/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSubview) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/tasking/Begin/CMakeLists.txt b/Exercises/tasking/Begin/CMakeLists.txt index 536a6f9b..40217932 100644 --- a/Exercises/tasking/Begin/CMakeLists.txt +++ b/Exercises/tasking/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTasking) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/tasking/Solution/CMakeLists.txt b/Exercises/tasking/Solution/CMakeLists.txt index 27ebaf6c..d894a8de 100644 --- a/Exercises/tasking/Solution/CMakeLists.txt +++ b/Exercises/tasking/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTasking) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/team_policy/Begin/CMakeLists.txt b/Exercises/team_policy/Begin/CMakeLists.txt index bc1fd7f8..f9071d88 100644 --- a/Exercises/team_policy/Begin/CMakeLists.txt +++ b/Exercises/team_policy/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamPolicy) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/team_policy/Solution/CMakeLists.txt b/Exercises/team_policy/Solution/CMakeLists.txt index 4f8cac06..25b0063f 100644 --- a/Exercises/team_policy/Solution/CMakeLists.txt +++ b/Exercises/team_policy/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamPolicy) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/team_scratch_memory/Begin/CMakeLists.txt b/Exercises/team_scratch_memory/Begin/CMakeLists.txt index 1e482bfe..19bf7e8c 100644 --- a/Exercises/team_scratch_memory/Begin/CMakeLists.txt +++ b/Exercises/team_scratch_memory/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamScratchMemory) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/team_scratch_memory/Solution/CMakeLists.txt b/Exercises/team_scratch_memory/Solution/CMakeLists.txt index 3774090a..ec73caa5 100644 --- a/Exercises/team_scratch_memory/Solution/CMakeLists.txt +++ b/Exercises/team_scratch_memory/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamScratchMemory) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/team_vector_loop/Begin/CMakeLists.txt b/Exercises/team_vector_loop/Begin/CMakeLists.txt index 10e0f846..0c644009 100644 --- a/Exercises/team_vector_loop/Begin/CMakeLists.txt +++ b/Exercises/team_vector_loop/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamVectorLoop) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/team_vector_loop/Solution/CMakeLists.txt b/Exercises/team_vector_loop/Solution/CMakeLists.txt index 9a6e5349..f89d0f59 100644 --- a/Exercises/team_vector_loop/Solution/CMakeLists.txt +++ b/Exercises/team_vector_loop/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamVectorLoop) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/tools_minimd/CMakeLists.txt b/Exercises/tools_minimd/CMakeLists.txt index e890597e..37452b13 100644 --- a/Exercises/tools_minimd/CMakeLists.txt +++ b/Exercises/tools_minimd/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTools) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/unique_token/Begin/CMakeLists.txt b/Exercises/unique_token/Begin/CMakeLists.txt index eb3ae03a..5f6098b7 100644 --- a/Exercises/unique_token/Begin/CMakeLists.txt +++ b/Exercises/unique_token/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialUniqueToken) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/unique_token/Solution/CMakeLists.txt b/Exercises/unique_token/Solution/CMakeLists.txt index 8dba31a9..c407b158 100644 --- a/Exercises/unique_token/Solution/CMakeLists.txt +++ b/Exercises/unique_token/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialUniqueToken) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/unordered_map/Begin/CMakeLists.txt b/Exercises/unordered_map/Begin/CMakeLists.txt index 4e1e8a65..2ed56c7b 100644 --- a/Exercises/unordered_map/Begin/CMakeLists.txt +++ b/Exercises/unordered_map/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialUnorderedMap) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/unordered_map/Solution/CMakeLists.txt b/Exercises/unordered_map/Solution/CMakeLists.txt index 718e9c42..8deeb7f7 100644 --- a/Exercises/unordered_map/Solution/CMakeLists.txt +++ b/Exercises/unordered_map/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialUnorderedMap) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/virtualfunction/Begin/CMakeLists.txt b/Exercises/virtualfunction/Begin/CMakeLists.txt index 30421d49..a79fa8be 100644 --- a/Exercises/virtualfunction/Begin/CMakeLists.txt +++ b/Exercises/virtualfunction/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialVirtualFunction) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/virtualfunction/Solution/CMakeLists.txt b/Exercises/virtualfunction/Solution/CMakeLists.txt index 4e45c4d5..d29a0a4c 100644 --- a/Exercises/virtualfunction/Solution/CMakeLists.txt +++ b/Exercises/virtualfunction/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialVirtualFunction) # Add a custom module path for find_package -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) From 5656d322162e5d9709fb9ba55114623dc042162e Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Tue, 11 Jun 2024 22:44:03 +0200 Subject: [PATCH 23/59] Fix no newline at end-of-file As recommended by reviewers. --- Exercises/.cmake/FindKokkos.cmake | 2 +- Exercises/02/Begin/CMakeLists.txt | 2 -- Exercises/03/Begin/CMakeLists.txt | 2 -- Exercises/advanced_reductions/Begin/CMakeLists.txt | 1 - Exercises/parallel_scan/Solution/CMakeLists.txt | 1 - 5 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Exercises/.cmake/FindKokkos.cmake b/Exercises/.cmake/FindKokkos.cmake index 47e7fc26..e6723f0f 100644 --- a/Exercises/.cmake/FindKokkos.cmake +++ b/Exercises/.cmake/FindKokkos.cmake @@ -41,4 +41,4 @@ else () FetchContent_MakeAvailable(Kokkos) set(Kokkos_FOUND True) endif () -endif () \ No newline at end of file +endif () diff --git a/Exercises/02/Begin/CMakeLists.txt b/Exercises/02/Begin/CMakeLists.txt index d37e07d3..9f9f536f 100644 --- a/Exercises/02/Begin/CMakeLists.txt +++ b/Exercises/02/Begin/CMakeLists.txt @@ -13,5 +13,3 @@ endif () add_executable(02_Exercise exercise_2_begin.cpp) target_link_libraries(02_Exercise Kokkos::kokkos) - - diff --git a/Exercises/03/Begin/CMakeLists.txt b/Exercises/03/Begin/CMakeLists.txt index ba223dfa..fa0ec5de 100644 --- a/Exercises/03/Begin/CMakeLists.txt +++ b/Exercises/03/Begin/CMakeLists.txt @@ -8,5 +8,3 @@ find_package(Kokkos REQUIRED) add_executable(03_Exercise exercise_3_begin.cpp) target_link_libraries(03_Exercise Kokkos::kokkos) - - diff --git a/Exercises/advanced_reductions/Begin/CMakeLists.txt b/Exercises/advanced_reductions/Begin/CMakeLists.txt index 02fd2df3..f06c0e23 100644 --- a/Exercises/advanced_reductions/Begin/CMakeLists.txt +++ b/Exercises/advanced_reductions/Begin/CMakeLists.txt @@ -8,4 +8,3 @@ find_package(Kokkos REQUIRED) add_executable(AdvancedReductions advanced_reductions.cpp) target_link_libraries(AdvancedReductions Kokkos::kokkos) - diff --git a/Exercises/parallel_scan/Solution/CMakeLists.txt b/Exercises/parallel_scan/Solution/CMakeLists.txt index 8c812237..5d5ebf96 100644 --- a/Exercises/parallel_scan/Solution/CMakeLists.txt +++ b/Exercises/parallel_scan/Solution/CMakeLists.txt @@ -8,4 +8,3 @@ find_package(Kokkos REQUIRED) add_executable(ParallelScan_Solution parallel_scan.cpp) target_link_libraries(ParallelScan_Solution Kokkos::kokkos) - From af3141e4937365bb3d31f8aa454e481541da2965 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Tue, 11 Jun 2024 22:53:38 +0200 Subject: [PATCH 24/59] Remove warning fixes that are not related to CMake As recommended by reviewers. --- Exercises/instances/Begin/instances_begin.cpp | 3 +-- Exercises/instances/Solution/instances_solution.cpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Exercises/instances/Begin/instances_begin.cpp b/Exercises/instances/Begin/instances_begin.cpp index 5334f2c8..da43dcdd 100644 --- a/Exercises/instances/Begin/instances_begin.cpp +++ b/Exercises/instances/Begin/instances_begin.cpp @@ -70,7 +70,7 @@ int main( int argc, char* argv[] ) for ( int i = 0; i < argc; i++ ) { if ( ( strcmp( argv[ i ], "-N" ) == 0 ) || ( strcmp( argv[ i ], "-Rows" ) == 0 ) ) { N = atoi( argv[ ++i ] ); - printf( " User N is %ld\n", N ); + printf( " User N is %d\n", N ); } else if ( strcmp( argv[ i ], "-nrepeat" ) == 0 ) { nrepeat = atoi( argv[ ++i ] ); @@ -137,4 +137,3 @@ int main( int argc, char* argv[] ) return 0; } - diff --git a/Exercises/instances/Solution/instances_solution.cpp b/Exercises/instances/Solution/instances_solution.cpp index 2b8ddefd..04fcc057 100644 --- a/Exercises/instances/Solution/instances_solution.cpp +++ b/Exercises/instances/Solution/instances_solution.cpp @@ -64,7 +64,7 @@ int main( int argc, char* argv[] ) for ( int i = 0; i < argc; i++ ) { if ( ( strcmp( argv[ i ], "-N" ) == 0 ) || ( strcmp( argv[ i ], "-Rows" ) == 0 ) ) { N = atoi( argv[ ++i ] ); - printf( " User N is %ld\n", N ); + printf( " User N is %d\n", N ); } else if ( strcmp( argv[ i ], "-nrepeat" ) == 0 ) { nrepeat = atoi( argv[ ++i ] ); @@ -126,4 +126,3 @@ int main( int argc, char* argv[] ) return 0; } - From 5ccfe61f778e7abff0df7c3b3a037363b091e433 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Tue, 11 Jun 2024 22:57:22 +0200 Subject: [PATCH 25/59] Use Kokkos_ENABLE_CUDA Kokkos_DEVICES is not set when using fetched version of Kokkos. As recommended by reviewers. --- Exercises/multi_gpu_cuda/Begin/CMakeLists.txt | 2 +- Exercises/multi_gpu_cuda/Solution/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt b/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt index ac4f0982..97c046fa 100644 --- a/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt +++ b/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt @@ -6,7 +6,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) -if (NOT Kokkos_DEVICES MATCHES "CUDA") +if (NOT Kokkos_ENABLE_CUDA) message(WARNING "This example requires CUDA, enable with -DKokkos_ENABLE_CUDA=ON") return() endif() diff --git a/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt b/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt index 0b4e70c9..82e8e87c 100644 --- a/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt +++ b/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt @@ -6,7 +6,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) -if (NOT Kokkos_DEVICES MATCHES "CUDA") +if (NOT Kokkos_ENABLE_CUDA) message(WARNING "This example requires CUDA, enable with -DKokkos_ENABLE_CUDA=ON") return() endif() From 7bdf80c7529df5bda486f308102eb040c5fb817d Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Tue, 11 Jun 2024 23:09:26 +0200 Subject: [PATCH 26/59] Explicitly list accelerator backends for the 2 first exercise Warn if an accelerator is enabled. As recommended by reviewers. --- Exercises/01/Begin/CMakeLists.txt | 5 +++-- Exercises/01/Solution/CMakeLists.txt | 5 +++-- Exercises/02/Begin/CMakeLists.txt | 5 +++-- Exercises/02/Solution/CMakeLists.txt | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Exercises/01/Begin/CMakeLists.txt b/Exercises/01/Begin/CMakeLists.txt index 410a3732..4357d740 100644 --- a/Exercises/01/Begin/CMakeLists.txt +++ b/Exercises/01/Begin/CMakeLists.txt @@ -6,9 +6,10 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) find_package(Kokkos REQUIRED) -if (Kokkos_DEVICES) +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}" - "Kokkos device is enabled, it might cause issue with the current program") + "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) diff --git a/Exercises/01/Solution/CMakeLists.txt b/Exercises/01/Solution/CMakeLists.txt index ba5d5574..f6ce2995 100644 --- a/Exercises/01/Solution/CMakeLists.txt +++ b/Exercises/01/Solution/CMakeLists.txt @@ -6,9 +6,10 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) -if (Kokkos_DEVICES) +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}" - "Kokkos device is enabled, it might cause issue with the current program") + "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) diff --git a/Exercises/02/Begin/CMakeLists.txt b/Exercises/02/Begin/CMakeLists.txt index 9f9f536f..046d11ec 100644 --- a/Exercises/02/Begin/CMakeLists.txt +++ b/Exercises/02/Begin/CMakeLists.txt @@ -6,9 +6,10 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) -if (Kokkos_DEVICES) +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}" - "Kokkos device is enabled, it might cause issue with the current program") + "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) diff --git a/Exercises/02/Solution/CMakeLists.txt b/Exercises/02/Solution/CMakeLists.txt index 9fbf0693..75d89106 100644 --- a/Exercises/02/Solution/CMakeLists.txt +++ b/Exercises/02/Solution/CMakeLists.txt @@ -6,9 +6,10 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) -if (Kokkos_DEVICES) +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}" - "Kokkos device is enabled, it might cause issue with the current program") + "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) From bfe7e16b27c9cb2c972cea7e2a69ed6a5c8090f6 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Tue, 11 Jun 2024 23:21:12 +0200 Subject: [PATCH 27/59] Missing some newline at end-of-file As recommended by reviewers. --- CMakeLists.txt | 2 +- Exercises/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 38a27f63..b9e3dfbb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorials) -add_subdirectory(Exercises) \ No newline at end of file +add_subdirectory(Exercises) diff --git a/Exercises/CMakeLists.txt b/Exercises/CMakeLists.txt index 6e299361..b5cdb71e 100644 --- a/Exercises/CMakeLists.txt +++ b/Exercises/CMakeLists.txt @@ -37,4 +37,4 @@ add_subdirectory(virtualfunction) # TODO, require Kokkos Kernels # add_subdirectory(kokkoskernels) # require remote spaces -# add_subdirectory(vectorshift) \ No newline at end of file +# add_subdirectory(vectorshift) From 798effa7876c0ad1126ee7f5d992df5fc8302fbf Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Thu, 13 Jun 2024 20:15:13 +0200 Subject: [PATCH 28/59] Remove unneeded comment --- Exercises/CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Exercises/CMakeLists.txt b/Exercises/CMakeLists.txt index b5cdb71e..7e7ad457 100644 --- a/Exercises/CMakeLists.txt +++ b/Exercises/CMakeLists.txt @@ -20,15 +20,13 @@ 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(tools_minimd) add_subdirectory(unique_token) add_subdirectory(unordered_map) add_subdirectory(virtualfunction) From a451ee407b231e50bde5022d95a7449787aac146 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Thu, 13 Jun 2024 20:17:32 +0200 Subject: [PATCH 29/59] Add "" for appending to CMAKE_MODULE_PATH --- Exercises/01/Begin/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exercises/01/Begin/CMakeLists.txt b/Exercises/01/Begin/CMakeLists.txt index 4357d740..375ce2ea 100644 --- a/Exercises/01/Begin/CMakeLists.txt +++ b/Exercises/01/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial01) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") find_package(Kokkos REQUIRED) From 0e178f0e3eb0f905f7034865eb69c9f62ca8186c Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Fri, 14 Jun 2024 10:41:58 +0200 Subject: [PATCH 30/59] Only one top-level CMakeLists.txt --- CMakeLists.txt | 36 +++++++++++++++++++++++++++++++++++- Exercises/CMakeLists.txt | 38 -------------------------------------- 2 files changed, 35 insertions(+), 39 deletions(-) delete mode 100644 Exercises/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index b9e3dfbb..15ada878 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,38 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorials) -add_subdirectory(Exercises) +# These directories follow IntroFull order of introduction + +add_subdirectory(Exercises/01) +add_subdirectory(Exercises/02) +add_subdirectory(Exercises/03) +add_subdirectory(Exercises/04) + +add_subdirectory(Exercises/dualview) +add_subdirectory(Exercises/mdrange) +add_subdirectory(Exercises/subview) +add_subdirectory(Exercises/scatter_view) +add_subdirectory(Exercises/team_policy) +add_subdirectory(Exercises/team_vector_loop) +add_subdirectory(Exercises/team_scratch_memory) +add_subdirectory(Exercises/tasking) +add_subdirectory(Exercises/simd) +# FIXME update the code +# add_subdirectory(Exercises/simd_warp) + +add_subdirectory(Exercises/advanced_reductions) +add_subdirectory(Exercises/fortran-kokkosinterface) # TODO, Add a check for fortran +add_subdirectory(Exercises/instances) +add_subdirectory(Exercises/multi_gpu_cuda) +add_subdirectory(Exercises/parallel_scan) +add_subdirectory(Exercises/random_number) +add_subdirectory(Exercises/tools_minimd) +add_subdirectory(Exercises/unique_token) +add_subdirectory(Exercises/unordered_map) +add_subdirectory(Exercises/virtualfunction) + +# Not done yet +# TODO, require Kokkos Kernels +# add_subdirectory(Exercises/kokkoskernels) +# require remote spaces +# add_subdirectory(Exercises/vectorshift) diff --git a/Exercises/CMakeLists.txt b/Exercises/CMakeLists.txt deleted file mode 100644 index 7e7ad457..00000000 --- a/Exercises/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -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) - -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(random_number) -add_subdirectory(tools_minimd) -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) From 90f978c9d52c94eb998d05add5bc0871801bf669 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Fri, 14 Jun 2024 10:48:15 +0200 Subject: [PATCH 31/59] Make KokkostTutorials_FORECE_INTERNAL_Kokkos an official CMake option --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15ada878..b83ac3b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,12 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorials) +# This option is used to force the use of an internal Kokkos +# It is useful if you have a Kokkos installed but you do not want to use it +# It is especially useful if you have a debian based system with Kokkos installed by apt +# as the CMakeConfig.cmake is partially broken +option(KokkosTutorials_FORCE_INTERNAL_Kokkos "Do not look for any installed Kokkos and use an internal one" OFF) + # These directories follow IntroFull order of introduction add_subdirectory(Exercises/01) From 40db39d55774fea96ae54c5340bd7cd7f4b97b9a Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Fri, 14 Jun 2024 10:58:56 +0200 Subject: [PATCH 32/59] Update README.md --- README.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7b848bfe..f8a32432 100644 --- a/README.md +++ b/README.md @@ -33,13 +33,22 @@ All the tutorial folders can be built using either the `Makefile` or the CMake ` CMake can build against an installed Kokkos library or download one automatically using `FetchContent`. -Without any Kokkos already installed, from an exercise directory, one can run the following: +You can use the global `CMakeLists.txt` at the top level directory to build all the exercises simultaneously. ```shell -cmake -B build_dir # -DKokkos_* options -cmake --build build_dir +cmake -B build_all +cmake --build build_all ``` +A specific CMake option, `KokkosTutorials_FORCE_INTERNAL_Kokkos`, can be used to force the use of the internal Kokkos +library and only use an already installed one that can be too old or not configured as wished. + +```shell +cmake -B build_all -DKokkosTutorials_FORCE_INTERNAL_Kokkos=ON # -DKokkos_* options +cmake --build build_all +``` + +Kokkos setup is covered by the [quickstart guide](https://kokkos.org/kokkos-core-wiki/quick_start.html) and an exhaustive Kokkos options are described in [CMake options](https://kokkos.org/kokkos-core-wiki/keywords.html). For example, OpenMP CPU exercises can be built as: From 96cf66d2b6801eed4fe8ebb9552067e6b541937b Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Fri, 14 Jun 2024 11:13:26 +0200 Subject: [PATCH 33/59] Add `KokkosTutorials_FORCE_EXTERNAL_Kokkos` option The idea is to make sure that the installed Kokkos is used. The cmake "configuration" phase will fail if it is not correctly found. It is also helpful on the air-gapped systems to avoid hanging on `fetch_content.` --- CMakeLists.txt | 9 +++++++++ Exercises/.cmake/FindKokkos.cmake | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b83ac3b9..87b57d1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,15 @@ project(KokkosTutorials) # as the CMakeConfig.cmake is partially broken option(KokkosTutorials_FORCE_INTERNAL_Kokkos "Do not look for any installed Kokkos and use an internal one" OFF) +# This option is used to force the use of an external Kokkos +# It is useful to ensure that the code is compatible with an installed Kokkos +option(KokkosTutorials_FORCE_EXTERNAL_Kokkos "Do not use an internal Kokkos and always look for an installed one" OFF) + +if (KokkosTutorials_FORCE_INTERNAL_Kokkos AND KokkosTutorials_FORCE_EXTERNAL_Kokkos) + message(FATAL_ERROR "You cannot force both internal and external Kokkos:" + "choose one of KokkosTutorials_FORCE_INTERNAL_Kokkos or KokkosTutorials_FORCE_EXTERNAL_Kokkos") +endif() + # These directories follow IntroFull order of introduction add_subdirectory(Exercises/01) diff --git a/Exercises/.cmake/FindKokkos.cmake b/Exercises/.cmake/FindKokkos.cmake index e6723f0f..61ea0408 100644 --- a/Exercises/.cmake/FindKokkos.cmake +++ b/Exercises/.cmake/FindKokkos.cmake @@ -27,7 +27,7 @@ endif () if (Kokkos_FOUND) message(STATUS "Found Kokkos: ${Kokkos_DIR} (version \"${Kokkos_VERSION}\")") -else () +elseif (NOT KokkosTutorials_FORCE_EXTERNAL_Kokkos) if (EXISTS ${Kokkos_COMMON_SOURCE_DIR}) add_subdirectory(${Kokkos_COMMON_SOURCE_DIR} Kokkos) else () From dba7191e6413772f8b7d28ff3607c22cb943eb5f Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Fri, 14 Jun 2024 11:35:09 +0200 Subject: [PATCH 34/59] Allow to configure Kokkos source dir KokkosTutorials_KOKKOS_SOURCE_DIR can be used to point to Kokkos source and avoid downloading. --- Exercises/.cmake/FindKokkos.cmake | 9 +++++---- README.md | 20 ++++++++++++++------ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/Exercises/.cmake/FindKokkos.cmake b/Exercises/.cmake/FindKokkos.cmake index 61ea0408..c3406ea1 100644 --- a/Exercises/.cmake/FindKokkos.cmake +++ b/Exercises/.cmake/FindKokkos.cmake @@ -19,7 +19,8 @@ if (NOT CMAKE_BUILD_TYPE) FORCE) endif () -set(Kokkos_COMMON_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/dep/Kokkos) +# Where to find Kokkos' source code. This might be set by the user. +set(KokkosTutorials_KOKKOS_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/dep/kokkos" CACHE PATH "Description for KokkosTutorials_KOKKOS_SOURCE_DIR") if (NOT KokkosTutorials_FORCE_INTERNAL_Kokkos) find_package(Kokkos CONFIG) @@ -28,15 +29,15 @@ endif () if (Kokkos_FOUND) message(STATUS "Found Kokkos: ${Kokkos_DIR} (version \"${Kokkos_VERSION}\")") elseif (NOT KokkosTutorials_FORCE_EXTERNAL_Kokkos) - if (EXISTS ${Kokkos_COMMON_SOURCE_DIR}) - add_subdirectory(${Kokkos_COMMON_SOURCE_DIR} Kokkos) + if (EXISTS ${KokkosTutorials_KOKKOS_SOURCE_DIR}) + add_subdirectory(${KokkosTutorials_KOKKOS_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} + SOURCE_DIR ${KokkosTutorials_KOKKOS_SOURCE_DIR} ) FetchContent_MakeAvailable(Kokkos) set(Kokkos_FOUND True) diff --git a/README.md b/README.md index f8a32432..0fe82990 100644 --- a/README.md +++ b/README.md @@ -33,24 +33,32 @@ All the tutorial folders can be built using either the `Makefile` or the CMake ` CMake can build against an installed Kokkos library or download one automatically using `FetchContent`. -You can use the global `CMakeLists.txt` at the top level directory to build all the exercises simultaneously. +You can use the global `CMakeLists.txt` at the top level directory to build all the exercises simultaneously. Else, you +can run the very same command in each exercise directory to build them only one by one. ```shell -cmake -B build_all -cmake --build build_all +cmake -B build_dir +cmake --build build_dir ``` A specific CMake option, `KokkosTutorials_FORCE_INTERNAL_Kokkos`, can be used to force the use of the internal Kokkos -library and only use an already installed one that can be too old or not configured as wished. +library and only use an already installed one that can be too old or not configured as wished. An opposite +option, `KokkosTutorials_FORCE_EXTERNAL_Kokkos` can prevent Kokkos from being downloaded. ```shell -cmake -B build_all -DKokkosTutorials_FORCE_INTERNAL_Kokkos=ON # -DKokkos_* options -cmake --build build_all +# Download and build Kokkos and the tutorials +cmake -B build_dir -DKokkosTutorials_FORCE_INTERNAL_Kokkos=ON # -DKokkos_* options +cmake --build build_dir ``` Kokkos setup is covered by the [quickstart guide](https://kokkos.org/kokkos-core-wiki/quick_start.html) and an exhaustive Kokkos options are described in [CMake options](https://kokkos.org/kokkos-core-wiki/keywords.html). +For specific use-cases, like when an internet connection is not available, the `KokkosTutorials_KOKKOS_SOURCE_DIR` can +be used to point to a local Kokkos source directory. + +Here are some examples of building the exercises with CMake: + For example, OpenMP CPU exercises can be built as: ```shell cmake -B build_openmp -DKokkos_ENABLE_OPENMP=ON From 99b1c7896230e6f823de3d05f71835d5eae412d7 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Wed, 26 Feb 2025 10:49:50 +0100 Subject: [PATCH 35/59] Use Kokkos 4.5.01 --- Exercises/.cmake/FindKokkos.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exercises/.cmake/FindKokkos.cmake b/Exercises/.cmake/FindKokkos.cmake index c3406ea1..1a86917f 100644 --- a/Exercises/.cmake/FindKokkos.cmake +++ b/Exercises/.cmake/FindKokkos.cmake @@ -36,7 +36,7 @@ elseif (NOT KokkosTutorials_FORCE_EXTERNAL_Kokkos) FetchContent_Declare( Kokkos GIT_REPOSITORY https://github.com/kokkos/kokkos.git - GIT_TAG 4.0.01 + GIT_TAG 4.5.01 SOURCE_DIR ${KokkosTutorials_KOKKOS_SOURCE_DIR} ) FetchContent_MakeAvailable(Kokkos) From 93462e7fa725bdd0d140eaeb1289521e75adec86 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Wed, 26 Feb 2025 10:52:34 +0100 Subject: [PATCH 36/59] Move CMake utilities from .cmake to cmake --- Exercises/01/Begin/CMakeLists.txt | 2 +- Exercises/01/Solution/CMakeLists.txt | 2 +- Exercises/02/Begin/CMakeLists.txt | 2 +- Exercises/02/Solution/CMakeLists.txt | 2 +- Exercises/03/Begin/CMakeLists.txt | 2 +- Exercises/03/Solution/CMakeLists.txt | 2 +- Exercises/04/Begin/CMakeLists.txt | 2 +- Exercises/04/Solution/CMakeLists.txt | 2 +- Exercises/advanced_reductions/Begin/CMakeLists.txt | 2 +- Exercises/advanced_reductions/Solution/CMakeLists.txt | 2 +- Exercises/{.cmake => cmake}/FindKokkos.cmake | 0 Exercises/dualview/Begin/CMakeLists.txt | 2 +- Exercises/dualview/Solution/CMakeLists.txt | 2 +- Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt | 2 +- Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt | 2 +- Exercises/instances/Begin/CMakeLists.txt | 2 +- Exercises/instances/Solution/CMakeLists.txt | 2 +- Exercises/mdrange/Begin/CMakeLists.txt | 2 +- Exercises/mdrange/Solution/CMakeLists.txt | 2 +- Exercises/mpi_pack_unpack/Begin/CMakeLists.txt | 2 +- Exercises/mpi_pack_unpack/Solution/CMakeLists.txt | 2 +- Exercises/multi_gpu_cuda/Begin/CMakeLists.txt | 2 +- Exercises/multi_gpu_cuda/Solution/CMakeLists.txt | 2 +- Exercises/parallel_scan/Begin/CMakeLists.txt | 2 +- Exercises/parallel_scan/Solution/CMakeLists.txt | 2 +- Exercises/random_number/Begin/CMakeLists.txt | 2 +- Exercises/random_number/Solution/CMakeLists.txt | 2 +- Exercises/scatter_view/Begin/CMakeLists.txt | 2 +- Exercises/scatter_view/Solution/CMakeLists.txt | 2 +- Exercises/scatter_view/Usage/CMakeLists.txt | 2 +- Exercises/simd/Begin/CMakeLists.txt | 2 +- Exercises/simd/Solution/CMakeLists.txt | 2 +- Exercises/simd_warp/Begin/CMakeLists.txt | 2 +- Exercises/simd_warp/Solution/CMakeLists.txt | 2 +- Exercises/subview/Begin/CMakeLists.txt | 2 +- Exercises/subview/Solution/CMakeLists.txt | 2 +- Exercises/tasking/Begin/CMakeLists.txt | 2 +- Exercises/tasking/Solution/CMakeLists.txt | 2 +- Exercises/team_policy/Begin/CMakeLists.txt | 2 +- Exercises/team_policy/Solution/CMakeLists.txt | 2 +- Exercises/team_scratch_memory/Begin/CMakeLists.txt | 2 +- Exercises/team_scratch_memory/Solution/CMakeLists.txt | 2 +- Exercises/team_vector_loop/Begin/CMakeLists.txt | 2 +- Exercises/team_vector_loop/Solution/CMakeLists.txt | 2 +- Exercises/tools_minimd/CMakeLists.txt | 2 +- Exercises/unique_token/Begin/CMakeLists.txt | 2 +- Exercises/unique_token/Solution/CMakeLists.txt | 2 +- Exercises/unordered_map/Begin/CMakeLists.txt | 2 +- Exercises/unordered_map/Solution/CMakeLists.txt | 2 +- Exercises/virtualfunction/Begin/CMakeLists.txt | 2 +- Exercises/virtualfunction/Solution/CMakeLists.txt | 2 +- 51 files changed, 50 insertions(+), 50 deletions(-) rename Exercises/{.cmake => cmake}/FindKokkos.cmake (100%) diff --git a/Exercises/01/Begin/CMakeLists.txt b/Exercises/01/Begin/CMakeLists.txt index 375ce2ea..404fa951 100644 --- a/Exercises/01/Begin/CMakeLists.txt +++ b/Exercises/01/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial01) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/01/Solution/CMakeLists.txt b/Exercises/01/Solution/CMakeLists.txt index f6ce2995..6734afb6 100644 --- a/Exercises/01/Solution/CMakeLists.txt +++ b/Exercises/01/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial01) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/02/Begin/CMakeLists.txt b/Exercises/02/Begin/CMakeLists.txt index 046d11ec..754ff301 100644 --- a/Exercises/02/Begin/CMakeLists.txt +++ b/Exercises/02/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial02) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/02/Solution/CMakeLists.txt b/Exercises/02/Solution/CMakeLists.txt index 75d89106..e4f9527f 100644 --- a/Exercises/02/Solution/CMakeLists.txt +++ b/Exercises/02/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial02) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/03/Begin/CMakeLists.txt b/Exercises/03/Begin/CMakeLists.txt index fa0ec5de..b4f1e0ec 100644 --- a/Exercises/03/Begin/CMakeLists.txt +++ b/Exercises/03/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial03) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/03/Solution/CMakeLists.txt b/Exercises/03/Solution/CMakeLists.txt index d7fc8769..b6e445b9 100644 --- a/Exercises/03/Solution/CMakeLists.txt +++ b/Exercises/03/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial03) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/04/Begin/CMakeLists.txt b/Exercises/04/Begin/CMakeLists.txt index 75450d2b..52b01a20 100644 --- a/Exercises/04/Begin/CMakeLists.txt +++ b/Exercises/04/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial04) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/04/Solution/CMakeLists.txt b/Exercises/04/Solution/CMakeLists.txt index f143b605..0c1fbe8a 100644 --- a/Exercises/04/Solution/CMakeLists.txt +++ b/Exercises/04/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial04) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/advanced_reductions/Begin/CMakeLists.txt b/Exercises/advanced_reductions/Begin/CMakeLists.txt index f06c0e23..0ca4fef4 100644 --- a/Exercises/advanced_reductions/Begin/CMakeLists.txt +++ b/Exercises/advanced_reductions/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialAdvancedReductions) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/advanced_reductions/Solution/CMakeLists.txt b/Exercises/advanced_reductions/Solution/CMakeLists.txt index b9aa6ee5..2d03da6d 100644 --- a/Exercises/advanced_reductions/Solution/CMakeLists.txt +++ b/Exercises/advanced_reductions/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialAdvancedReductions) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/.cmake/FindKokkos.cmake b/Exercises/cmake/FindKokkos.cmake similarity index 100% rename from Exercises/.cmake/FindKokkos.cmake rename to Exercises/cmake/FindKokkos.cmake diff --git a/Exercises/dualview/Begin/CMakeLists.txt b/Exercises/dualview/Begin/CMakeLists.txt index 5f3de0ae..05a81cca 100644 --- a/Exercises/dualview/Begin/CMakeLists.txt +++ b/Exercises/dualview/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialDualView) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/dualview/Solution/CMakeLists.txt b/Exercises/dualview/Solution/CMakeLists.txt index 1c70c597..b36ff223 100644 --- a/Exercises/dualview/Solution/CMakeLists.txt +++ b/Exercises/dualview/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialDualView) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt b/Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt index b9778f1e..8b2117e6 100644 --- a/Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt +++ b/Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialFortran) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt b/Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt index 7c3369fc..e0d723d6 100644 --- a/Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt +++ b/Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialFortran) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/instances/Begin/CMakeLists.txt b/Exercises/instances/Begin/CMakeLists.txt index 06740e62..3f9248ea 100644 --- a/Exercises/instances/Begin/CMakeLists.txt +++ b/Exercises/instances/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialInstances) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/instances/Solution/CMakeLists.txt b/Exercises/instances/Solution/CMakeLists.txt index 3f769d83..17ea3756 100644 --- a/Exercises/instances/Solution/CMakeLists.txt +++ b/Exercises/instances/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialInstances) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/mdrange/Begin/CMakeLists.txt b/Exercises/mdrange/Begin/CMakeLists.txt index 327afc73..4403f148 100644 --- a/Exercises/mdrange/Begin/CMakeLists.txt +++ b/Exercises/mdrange/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMdRange) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/mdrange/Solution/CMakeLists.txt b/Exercises/mdrange/Solution/CMakeLists.txt index c0d727e7..3645d8d8 100644 --- a/Exercises/mdrange/Solution/CMakeLists.txt +++ b/Exercises/mdrange/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMdRange) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/mpi_pack_unpack/Begin/CMakeLists.txt b/Exercises/mpi_pack_unpack/Begin/CMakeLists.txt index 1e32c4bb..efd3d9f0 100644 --- a/Exercises/mpi_pack_unpack/Begin/CMakeLists.txt +++ b/Exercises/mpi_pack_unpack/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMPIPackUnpack) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/mpi_pack_unpack/Solution/CMakeLists.txt b/Exercises/mpi_pack_unpack/Solution/CMakeLists.txt index a0da79bd..1dc8ec9d 100644 --- a/Exercises/mpi_pack_unpack/Solution/CMakeLists.txt +++ b/Exercises/mpi_pack_unpack/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMPIPackUnpack) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt b/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt index 97c046fa..1c79aa4e 100644 --- a/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt +++ b/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMultiGpuCuda) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt b/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt index 82e8e87c..e99e09ad 100644 --- a/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt +++ b/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMultiGpuCuda) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/parallel_scan/Begin/CMakeLists.txt b/Exercises/parallel_scan/Begin/CMakeLists.txt index ab666b80..1154e5ef 100644 --- a/Exercises/parallel_scan/Begin/CMakeLists.txt +++ b/Exercises/parallel_scan/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialParallelScan) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/parallel_scan/Solution/CMakeLists.txt b/Exercises/parallel_scan/Solution/CMakeLists.txt index 5d5ebf96..d8253ee3 100644 --- a/Exercises/parallel_scan/Solution/CMakeLists.txt +++ b/Exercises/parallel_scan/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialParallelScan) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/random_number/Begin/CMakeLists.txt b/Exercises/random_number/Begin/CMakeLists.txt index 9f314ec5..6396ab60 100644 --- a/Exercises/random_number/Begin/CMakeLists.txt +++ b/Exercises/random_number/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialRNG) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/random_number/Solution/CMakeLists.txt b/Exercises/random_number/Solution/CMakeLists.txt index c47bd39c..aed83c01 100644 --- a/Exercises/random_number/Solution/CMakeLists.txt +++ b/Exercises/random_number/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialRNG) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/scatter_view/Begin/CMakeLists.txt b/Exercises/scatter_view/Begin/CMakeLists.txt index 4d70ebec..b34b1929 100644 --- a/Exercises/scatter_view/Begin/CMakeLists.txt +++ b/Exercises/scatter_view/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialScatterView) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/scatter_view/Solution/CMakeLists.txt b/Exercises/scatter_view/Solution/CMakeLists.txt index 43be5a91..fade4652 100644 --- a/Exercises/scatter_view/Solution/CMakeLists.txt +++ b/Exercises/scatter_view/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialScatterView) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/scatter_view/Usage/CMakeLists.txt b/Exercises/scatter_view/Usage/CMakeLists.txt index 053b718f..c9b7a0a4 100644 --- a/Exercises/scatter_view/Usage/CMakeLists.txt +++ b/Exercises/scatter_view/Usage/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialScatterView) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/simd/Begin/CMakeLists.txt b/Exercises/simd/Begin/CMakeLists.txt index e09a913b..436416c8 100644 --- a/Exercises/simd/Begin/CMakeLists.txt +++ b/Exercises/simd/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSIMD) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/simd/Solution/CMakeLists.txt b/Exercises/simd/Solution/CMakeLists.txt index 083a6963..56c6b53e 100644 --- a/Exercises/simd/Solution/CMakeLists.txt +++ b/Exercises/simd/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSIMD) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/simd_warp/Begin/CMakeLists.txt b/Exercises/simd_warp/Begin/CMakeLists.txt index 730adab6..be170920 100644 --- a/Exercises/simd_warp/Begin/CMakeLists.txt +++ b/Exercises/simd_warp/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSIMDWarp) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/simd_warp/Solution/CMakeLists.txt b/Exercises/simd_warp/Solution/CMakeLists.txt index c72ae6af..2a82272f 100644 --- a/Exercises/simd_warp/Solution/CMakeLists.txt +++ b/Exercises/simd_warp/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSIMDWarp) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/subview/Begin/CMakeLists.txt b/Exercises/subview/Begin/CMakeLists.txt index b17ce1eb..f8347902 100644 --- a/Exercises/subview/Begin/CMakeLists.txt +++ b/Exercises/subview/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSubview) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/subview/Solution/CMakeLists.txt b/Exercises/subview/Solution/CMakeLists.txt index 5f88b298..79e92e88 100644 --- a/Exercises/subview/Solution/CMakeLists.txt +++ b/Exercises/subview/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSubview) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/tasking/Begin/CMakeLists.txt b/Exercises/tasking/Begin/CMakeLists.txt index 40217932..6ee2b06a 100644 --- a/Exercises/tasking/Begin/CMakeLists.txt +++ b/Exercises/tasking/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTasking) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/tasking/Solution/CMakeLists.txt b/Exercises/tasking/Solution/CMakeLists.txt index d894a8de..29856f37 100644 --- a/Exercises/tasking/Solution/CMakeLists.txt +++ b/Exercises/tasking/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTasking) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/team_policy/Begin/CMakeLists.txt b/Exercises/team_policy/Begin/CMakeLists.txt index f9071d88..2deef1f9 100644 --- a/Exercises/team_policy/Begin/CMakeLists.txt +++ b/Exercises/team_policy/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamPolicy) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/team_policy/Solution/CMakeLists.txt b/Exercises/team_policy/Solution/CMakeLists.txt index 25b0063f..5f028115 100644 --- a/Exercises/team_policy/Solution/CMakeLists.txt +++ b/Exercises/team_policy/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamPolicy) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/team_scratch_memory/Begin/CMakeLists.txt b/Exercises/team_scratch_memory/Begin/CMakeLists.txt index 19bf7e8c..4de1d126 100644 --- a/Exercises/team_scratch_memory/Begin/CMakeLists.txt +++ b/Exercises/team_scratch_memory/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamScratchMemory) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/team_scratch_memory/Solution/CMakeLists.txt b/Exercises/team_scratch_memory/Solution/CMakeLists.txt index ec73caa5..32410d2c 100644 --- a/Exercises/team_scratch_memory/Solution/CMakeLists.txt +++ b/Exercises/team_scratch_memory/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamScratchMemory) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/team_vector_loop/Begin/CMakeLists.txt b/Exercises/team_vector_loop/Begin/CMakeLists.txt index 0c644009..e0b07ce7 100644 --- a/Exercises/team_vector_loop/Begin/CMakeLists.txt +++ b/Exercises/team_vector_loop/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamVectorLoop) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/team_vector_loop/Solution/CMakeLists.txt b/Exercises/team_vector_loop/Solution/CMakeLists.txt index f89d0f59..2c2fcd2f 100644 --- a/Exercises/team_vector_loop/Solution/CMakeLists.txt +++ b/Exercises/team_vector_loop/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamVectorLoop) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/tools_minimd/CMakeLists.txt b/Exercises/tools_minimd/CMakeLists.txt index 37452b13..03ee5448 100644 --- a/Exercises/tools_minimd/CMakeLists.txt +++ b/Exercises/tools_minimd/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTools) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/unique_token/Begin/CMakeLists.txt b/Exercises/unique_token/Begin/CMakeLists.txt index 5f6098b7..e997ffd4 100644 --- a/Exercises/unique_token/Begin/CMakeLists.txt +++ b/Exercises/unique_token/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialUniqueToken) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/unique_token/Solution/CMakeLists.txt b/Exercises/unique_token/Solution/CMakeLists.txt index c407b158..019fa607 100644 --- a/Exercises/unique_token/Solution/CMakeLists.txt +++ b/Exercises/unique_token/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialUniqueToken) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/unordered_map/Begin/CMakeLists.txt b/Exercises/unordered_map/Begin/CMakeLists.txt index 2ed56c7b..58c53857 100644 --- a/Exercises/unordered_map/Begin/CMakeLists.txt +++ b/Exercises/unordered_map/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialUnorderedMap) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/unordered_map/Solution/CMakeLists.txt b/Exercises/unordered_map/Solution/CMakeLists.txt index 8deeb7f7..43729ef4 100644 --- a/Exercises/unordered_map/Solution/CMakeLists.txt +++ b/Exercises/unordered_map/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialUnorderedMap) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/virtualfunction/Begin/CMakeLists.txt b/Exercises/virtualfunction/Begin/CMakeLists.txt index a79fa8be..fa560a2b 100644 --- a/Exercises/virtualfunction/Begin/CMakeLists.txt +++ b/Exercises/virtualfunction/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialVirtualFunction) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) diff --git a/Exercises/virtualfunction/Solution/CMakeLists.txt b/Exercises/virtualfunction/Solution/CMakeLists.txt index d29a0a4c..bbadc364 100644 --- a/Exercises/virtualfunction/Solution/CMakeLists.txt +++ b/Exercises/virtualfunction/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialVirtualFunction) # Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Kokkos REQUIRED) From f2e44a3dca2c59f011ab89aaa26b578999da0a1a Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Wed, 26 Feb 2025 11:05:20 +0100 Subject: [PATCH 37/59] Share downloaded kokkos --- Exercises/cmake/FindKokkos.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Exercises/cmake/FindKokkos.cmake b/Exercises/cmake/FindKokkos.cmake index 1a86917f..3cf211ea 100644 --- a/Exercises/cmake/FindKokkos.cmake +++ b/Exercises/cmake/FindKokkos.cmake @@ -20,7 +20,11 @@ if (NOT CMAKE_BUILD_TYPE) endif () # Where to find Kokkos' source code. This might be set by the user. -set(KokkosTutorials_KOKKOS_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/dep/kokkos" CACHE PATH "Description for KokkosTutorials_KOKKOS_SOURCE_DIR") +# In order to automatically share the download between exercises when they are compiled individually, +# the default directory is inside the source tree. +# This might break if the default in source directory is called from multiple cmake instances at the same time. + +set(KokkosTutorials_KOKKOS_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../dep/kokkos" CACHE PATH "Description for KokkosTutorials_KOKKOS_SOURCE_DIR") if (NOT KokkosTutorials_FORCE_INTERNAL_Kokkos) find_package(Kokkos CONFIG) From a96a6e2b34b44fc68a9cf3e9761ab59210be20cd Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Wed, 26 Feb 2025 11:35:44 +0100 Subject: [PATCH 38/59] Remove obsolete reference to SPACK_CXX --- Exercises/cmake/FindKokkos.cmake | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Exercises/cmake/FindKokkos.cmake b/Exercises/cmake/FindKokkos.cmake index 3cf211ea..b6acde84 100644 --- a/Exercises/cmake/FindKokkos.cmake +++ b/Exercises/cmake/FindKokkos.cmake @@ -4,13 +4,6 @@ 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.") From f1b5bff1dd60b39683969fd5a9e88500a710f690 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Wed, 26 Feb 2025 11:46:07 +0100 Subject: [PATCH 39/59] Macro to warn about using gpu backends on non-ready exercises --- Exercises/01/Begin/CMakeLists.txt | 6 +----- Exercises/01/Solution/CMakeLists.txt | 6 +----- Exercises/02/Begin/CMakeLists.txt | 6 +----- Exercises/02/Solution/CMakeLists.txt | 6 +----- Exercises/cmake/FindKokkos.cmake | 8 ++++++++ 5 files changed, 12 insertions(+), 20 deletions(-) diff --git a/Exercises/01/Begin/CMakeLists.txt b/Exercises/01/Begin/CMakeLists.txt index 404fa951..3605d4c2 100644 --- a/Exercises/01/Begin/CMakeLists.txt +++ b/Exercises/01/Begin/CMakeLists.txt @@ -6,11 +6,7 @@ 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 () +KokkosTutorials_WarnGPU() add_executable(01_Exercise exercise_1_begin.cpp) target_link_libraries(01_Exercise Kokkos::kokkos) diff --git a/Exercises/01/Solution/CMakeLists.txt b/Exercises/01/Solution/CMakeLists.txt index 6734afb6..3c7bcd83 100644 --- a/Exercises/01/Solution/CMakeLists.txt +++ b/Exercises/01/Solution/CMakeLists.txt @@ -6,11 +6,7 @@ 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 () +KokkosTutorials_WarnGPU() add_executable(01_Solution exercise_1_solution.cpp) target_link_libraries(01_Solution Kokkos::kokkos) diff --git a/Exercises/02/Begin/CMakeLists.txt b/Exercises/02/Begin/CMakeLists.txt index 754ff301..d98cddad 100644 --- a/Exercises/02/Begin/CMakeLists.txt +++ b/Exercises/02/Begin/CMakeLists.txt @@ -6,11 +6,7 @@ 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 () +KokkosTutorials_WarnGPU() add_executable(02_Exercise exercise_2_begin.cpp) target_link_libraries(02_Exercise Kokkos::kokkos) diff --git a/Exercises/02/Solution/CMakeLists.txt b/Exercises/02/Solution/CMakeLists.txt index e4f9527f..6105aabe 100644 --- a/Exercises/02/Solution/CMakeLists.txt +++ b/Exercises/02/Solution/CMakeLists.txt @@ -6,11 +6,7 @@ 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 () +KokkosTutorials_WarnGPU() add_executable(02_Solution exercise_2_solution.cpp) target_link_libraries(02_Solution Kokkos::kokkos) diff --git a/Exercises/cmake/FindKokkos.cmake b/Exercises/cmake/FindKokkos.cmake index b6acde84..a86fcb0c 100644 --- a/Exercises/cmake/FindKokkos.cmake +++ b/Exercises/cmake/FindKokkos.cmake @@ -1,3 +1,11 @@ +macro(KokkosTutorials_WarnGPU) + 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 () +endmacro() + # Early return if Kokkos is already set up # We do not use Kokkos_FOUND as it is not globally defined if (TARGET Kokkos::kokkos) From 208dcb63c9f48bcb36f835c1bdc4469420c0852a Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Wed, 26 Feb 2025 12:06:21 +0100 Subject: [PATCH 40/59] Fix global compilation --- CMakeLists.txt | 2 +- Exercises/subview/Begin/exercise_subview_begin.cpp | 8 ++++++-- Exercises/subview/Solution/exercise_subview_solution.cpp | 6 ++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 87b57d1f..b77f624e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,10 +30,10 @@ add_subdirectory(Exercises/scatter_view) add_subdirectory(Exercises/team_policy) add_subdirectory(Exercises/team_vector_loop) add_subdirectory(Exercises/team_scratch_memory) -add_subdirectory(Exercises/tasking) add_subdirectory(Exercises/simd) # FIXME update the code # add_subdirectory(Exercises/simd_warp) +# add_subdirectory(Exercises/tasking) add_subdirectory(Exercises/advanced_reductions) add_subdirectory(Exercises/fortran-kokkosinterface) # TODO, Add a check for fortran diff --git a/Exercises/subview/Begin/exercise_subview_begin.cpp b/Exercises/subview/Begin/exercise_subview_begin.cpp index 935c9770..fc2d774f 100644 --- a/Exercises/subview/Begin/exercise_subview_begin.cpp +++ b/Exercises/subview/Begin/exercise_subview_begin.cpp @@ -71,15 +71,19 @@ int main( int argc, char* argv[] ) Kokkos::initialize( argc, argv ); { + using ExecSpace = Kokkos::DefaultExecutionSpace; // using ExecSpace = Kokkos::Serial; // using ExecSpace = Kokkos::Threads; // using ExecSpace = Kokkos::OpenMP; - using ExecSpace = Kokkos::Cuda; + // using ExecSpace = Kokkos::Cuda; + // using ExecSpace = Kokkos::HIP; + using MemSpace = Kokkos::DefaultExecutionSpace::memory_space; // using MemSpace = Kokkos::HostSpace; // using MemSpace = Kokkos::OpenMP; - using MemSpace = Kokkos::CudaSpace; + // using MemSpace = Kokkos::CudaSpace; // using MemSpace = Kokkos::CudaUVMSpace; + // using MemSpace = Kokkos::HIPSpace; using Layout = Kokkos::LayoutLeft; // using Layout = Kokkos::LayoutRight; diff --git a/Exercises/subview/Solution/exercise_subview_solution.cpp b/Exercises/subview/Solution/exercise_subview_solution.cpp index 80372f08..2808c29c 100644 --- a/Exercises/subview/Solution/exercise_subview_solution.cpp +++ b/Exercises/subview/Solution/exercise_subview_solution.cpp @@ -65,14 +65,16 @@ int main( int argc, char* argv[] ) Kokkos::initialize( argc, argv ); { + using ExecSpace = Kokkos::DefaultExecutionSpace; // using ExecSpace = Kokkos::Serial; // using ExecSpace = Kokkos::Threads; - using ExecSpace = Kokkos::OpenMP; + // using ExecSpace = Kokkos::OpenMP; // using ExecSpace = Kokkos::Cuda; // using ExecSpace = Kokkos::HIP; + using MemSpace = Kokkos::DefaultExecutionSpace::memory_space; // using MemSpace = Kokkos::HostSpace; - using MemSpace = Kokkos::OpenMP; + // using MemSpace = Kokkos::OpenMP; // using MemSpace = Kokkos::CudaSpace; // using MemSpace = Kokkos::CudaUVMSpace; // using MemSpace = Kokkos::HIPSpace; From 263297e46503519991f4895afd554c15ef9e8223 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Wed, 26 Feb 2025 12:19:28 +0100 Subject: [PATCH 41/59] Update README.md --- README.md | 53 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 98ebdf1d..caf99aa9 100644 --- a/README.md +++ b/README.md @@ -27,35 +27,20 @@ Tutorials in the **Intro-Full** directory cover # Building the Tutorials -All the tutorial folders can be built using CMake. +All the tutorials are built using CMake. -## CMake +## CMake Quickstart -CMake can build against an installed Kokkos library or download one automatically using `FetchContent`. - -You can use the global `CMakeLists.txt` at the top level directory to build all the exercises simultaneously. Else, you -can run the very same command in each exercise directory to build them only one by one. +From the top level directory or from any exercise directory, you can build the tutorials using CMake: ```shell cmake -B build_dir cmake --build build_dir ``` -A specific CMake option, `KokkosTutorials_FORCE_INTERNAL_Kokkos`, can be used to force the use of the internal Kokkos -library and only use an already installed one that can be too old or not configured as wished. An opposite -option, `KokkosTutorials_FORCE_EXTERNAL_Kokkos` can prevent Kokkos from being downloaded. - -```shell -# Download and build Kokkos and the tutorials -cmake -B build_dir -DKokkosTutorials_FORCE_INTERNAL_Kokkos=ON # -DKokkos_* options -cmake --build build_dir -``` +Additional options can be passed to CMake to configure the build, such as the backend to use, the architecture to target, etc. -Kokkos setup is covered by the [quickstart guide](https://kokkos.org/kokkos-core-wiki/quick_start.html) and an exhaustive -Kokkos options are described in [CMake options](https://kokkos.org/kokkos-core-wiki/keywords.html). - -For specific use-cases, like when an internet connection is not available, the `KokkosTutorials_KOKKOS_SOURCE_DIR` can -be used to point to a local Kokkos source directory. +## Examples Here are some examples of building the exercises with CMake: @@ -78,6 +63,34 @@ cmake -B build_cuda -DKokkos_ENABLE_CUDA=ON cmake --build build_cuda ``` +For a AMD gpu, using gpu arch autodetection: + +```shell +cmake -B build_hip -DKokkos_ENABLE_HIP=ON +cmake --build build_hip +``` + +Kokkos setup is covered by the [quickstart guide](https://kokkos.org/kokkos-core-wiki/get-started/quick-start.html) and an exhaustive +Kokkos options are described in [CMake options](https://kokkos.org/kokkos-core-wiki/get-started/configuration-guide.html). + +## Advanced CMake Usage + +CMake can build against an installed Kokkos library or download one automatically using `FetchContent`. + To pass an already installed Kokkos library, you can use classical CMake variables, such as `Kokkos_ROOT`, or `CMAKE_PREFIX_PATH`. +A specific CMake option, `KokkosTutorials_FORCE_INTERNAL_Kokkos`, can be used to force the use of the internal Kokkos +library, discarding any already installed Kokkos. + +An opposite option, `KokkosTutorials_FORCE_EXTERNAL_Kokkos` can prevent Kokkos from being downloaded and is useful to +test against an already installed Kokkos. + +```shell +# Download and build Kokkos and the tutorials, forcing the use of the internal Kokkos +cmake -B build_dir -DKokkosTutorials_FORCE_INTERNAL_Kokkos=ON # -DKokkos_* options +cmake --build build_dir +``` + +For specific use-cases, like when an internet connection is not available, the `KokkosTutorials_KOKKOS_SOURCE_DIR` can +be used to point to a local Kokkos source directory. From 1a6e1985d2df0ffc7cc7d913720b57b0cd1f1aea Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Wed, 26 Feb 2025 12:47:23 +0100 Subject: [PATCH 42/59] Do not try to hide find_package(Kokkos) Before this commit, we had a fake "find_package(Kokkos)" to make tutorial CMakeLists.txt minimal. However, using builtin CMake features like `CMAKE_DISABLE_FIND_PACKAGE_<>` or `CMAKE_REQUIRE_FIND_PACKAGE_<>` was not working properly. This commit use a simple `include(../cmake/SetUpKokkos.cmake)`, and it is this file that can be a fine example of how to integrate Kokkos in a project. --- CMakeLists.txt | 15 --------------- Exercises/01/Begin/CMakeLists.txt | 6 ++---- Exercises/01/Solution/CMakeLists.txt | 6 ++---- Exercises/02/Begin/CMakeLists.txt | 6 ++---- Exercises/02/Solution/CMakeLists.txt | 6 ++---- Exercises/03/Begin/CMakeLists.txt | 6 ++---- Exercises/03/Solution/CMakeLists.txt | 6 ++---- Exercises/04/Begin/CMakeLists.txt | 6 ++---- Exercises/04/Solution/CMakeLists.txt | 6 ++---- .../advanced_reductions/Begin/CMakeLists.txt | 6 ++---- .../advanced_reductions/Solution/CMakeLists.txt | 6 ++---- .../cmake/{FindKokkos.cmake => SetUpKokkos.cmake} | 6 ++---- Exercises/dualview/Begin/CMakeLists.txt | 6 ++---- Exercises/dualview/Solution/CMakeLists.txt | 6 ++---- .../fortran-kokkosinterface/Begin/CMakeLists.txt | 6 ++---- .../Solution/CMakeLists.txt | 12 ++---------- Exercises/instances/Begin/CMakeLists.txt | 6 ++---- Exercises/instances/Solution/CMakeLists.txt | 6 ++---- Exercises/mdrange/Begin/CMakeLists.txt | 6 ++---- Exercises/mdrange/Solution/CMakeLists.txt | 6 ++---- Exercises/mpi_exch/CMakeLists.txt | 4 +++- .../mpi_heat_conduction/Solution/CMakeLists.txt | 4 +++- Exercises/mpi_pack_unpack/Begin/CMakeLists.txt | 6 ++---- Exercises/mpi_pack_unpack/Solution/CMakeLists.txt | 6 ++---- Exercises/multi_gpu_cuda/Begin/CMakeLists.txt | 6 ++---- Exercises/multi_gpu_cuda/Solution/CMakeLists.txt | 6 ++---- Exercises/parallel_scan/Begin/CMakeLists.txt | 6 ++---- Exercises/parallel_scan/Solution/CMakeLists.txt | 6 ++---- Exercises/random_number/Begin/CMakeLists.txt | 6 ++---- Exercises/random_number/Solution/CMakeLists.txt | 6 ++---- Exercises/scatter_view/Begin/CMakeLists.txt | 6 ++---- Exercises/scatter_view/Solution/CMakeLists.txt | 6 ++---- Exercises/scatter_view/Usage/CMakeLists.txt | 6 ++---- Exercises/simd/Begin/CMakeLists.txt | 6 ++---- Exercises/simd/Solution/CMakeLists.txt | 6 ++---- Exercises/simd_warp/Begin/CMakeLists.txt | 6 ++---- Exercises/simd_warp/Solution/CMakeLists.txt | 6 ++---- Exercises/subview/Begin/CMakeLists.txt | 6 ++---- Exercises/subview/Solution/CMakeLists.txt | 6 ++---- Exercises/tasking/Begin/CMakeLists.txt | 6 ++---- Exercises/tasking/Solution/CMakeLists.txt | 6 ++---- Exercises/team_policy/Begin/CMakeLists.txt | 6 ++---- Exercises/team_policy/Solution/CMakeLists.txt | 6 ++---- .../team_scratch_memory/Begin/CMakeLists.txt | 6 ++---- .../team_scratch_memory/Solution/CMakeLists.txt | 6 ++---- Exercises/team_vector_loop/Begin/CMakeLists.txt | 6 ++---- .../team_vector_loop/Solution/CMakeLists.txt | 6 ++---- Exercises/tools_minimd/CMakeLists.txt | 6 ++---- Exercises/unique_token/Begin/CMakeLists.txt | 6 ++---- Exercises/unique_token/Solution/CMakeLists.txt | 6 ++---- Exercises/unordered_map/Begin/CMakeLists.txt | 6 ++---- Exercises/unordered_map/Solution/CMakeLists.txt | 6 ++---- Exercises/virtualfunction/Begin/CMakeLists.txt | 6 ++---- Exercises/virtualfunction/Solution/CMakeLists.txt | 6 ++---- README.md | 6 +++--- 55 files changed, 111 insertions(+), 230 deletions(-) rename Exercises/cmake/{FindKokkos.cmake => SetUpKokkos.cmake} (93%) diff --git a/CMakeLists.txt b/CMakeLists.txt index b77f624e..dff029e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,21 +1,6 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorials) -# This option is used to force the use of an internal Kokkos -# It is useful if you have a Kokkos installed but you do not want to use it -# It is especially useful if you have a debian based system with Kokkos installed by apt -# as the CMakeConfig.cmake is partially broken -option(KokkosTutorials_FORCE_INTERNAL_Kokkos "Do not look for any installed Kokkos and use an internal one" OFF) - -# This option is used to force the use of an external Kokkos -# It is useful to ensure that the code is compatible with an installed Kokkos -option(KokkosTutorials_FORCE_EXTERNAL_Kokkos "Do not use an internal Kokkos and always look for an installed one" OFF) - -if (KokkosTutorials_FORCE_INTERNAL_Kokkos AND KokkosTutorials_FORCE_EXTERNAL_Kokkos) - message(FATAL_ERROR "You cannot force both internal and external Kokkos:" - "choose one of KokkosTutorials_FORCE_INTERNAL_Kokkos or KokkosTutorials_FORCE_EXTERNAL_Kokkos") -endif() - # These directories follow IntroFull order of introduction add_subdirectory(Exercises/01) diff --git a/Exercises/01/Begin/CMakeLists.txt b/Exercises/01/Begin/CMakeLists.txt index 3605d4c2..2f3565e9 100644 --- a/Exercises/01/Begin/CMakeLists.txt +++ b/Exercises/01/Begin/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial01) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) KokkosTutorials_WarnGPU() diff --git a/Exercises/01/Solution/CMakeLists.txt b/Exercises/01/Solution/CMakeLists.txt index 3c7bcd83..bd5457c8 100644 --- a/Exercises/01/Solution/CMakeLists.txt +++ b/Exercises/01/Solution/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial01) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) KokkosTutorials_WarnGPU() diff --git a/Exercises/02/Begin/CMakeLists.txt b/Exercises/02/Begin/CMakeLists.txt index d98cddad..7dbf4c71 100644 --- a/Exercises/02/Begin/CMakeLists.txt +++ b/Exercises/02/Begin/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial02) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) KokkosTutorials_WarnGPU() diff --git a/Exercises/02/Solution/CMakeLists.txt b/Exercises/02/Solution/CMakeLists.txt index 6105aabe..ec6febbb 100644 --- a/Exercises/02/Solution/CMakeLists.txt +++ b/Exercises/02/Solution/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial02) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) KokkosTutorials_WarnGPU() diff --git a/Exercises/03/Begin/CMakeLists.txt b/Exercises/03/Begin/CMakeLists.txt index b4f1e0ec..9cf78b8a 100644 --- a/Exercises/03/Begin/CMakeLists.txt +++ b/Exercises/03/Begin/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial03) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(03_Exercise exercise_3_begin.cpp) target_link_libraries(03_Exercise Kokkos::kokkos) diff --git a/Exercises/03/Solution/CMakeLists.txt b/Exercises/03/Solution/CMakeLists.txt index b6e445b9..5c5e2407 100644 --- a/Exercises/03/Solution/CMakeLists.txt +++ b/Exercises/03/Solution/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial03) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(03_Solution exercise_3_solution.cpp) target_link_libraries(03_Solution Kokkos::kokkos) diff --git a/Exercises/04/Begin/CMakeLists.txt b/Exercises/04/Begin/CMakeLists.txt index 52b01a20..aae6a184 100644 --- a/Exercises/04/Begin/CMakeLists.txt +++ b/Exercises/04/Begin/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial04) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(04_Exercise exercise_4_begin.cpp) target_link_libraries(04_Exercise Kokkos::kokkos) diff --git a/Exercises/04/Solution/CMakeLists.txt b/Exercises/04/Solution/CMakeLists.txt index 0c1fbe8a..a102bf38 100644 --- a/Exercises/04/Solution/CMakeLists.txt +++ b/Exercises/04/Solution/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial04) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(04_Solution exercise_4_solution.cpp) target_link_libraries(04_Solution Kokkos::kokkos) diff --git a/Exercises/advanced_reductions/Begin/CMakeLists.txt b/Exercises/advanced_reductions/Begin/CMakeLists.txt index 0ca4fef4..4ce17fe3 100644 --- a/Exercises/advanced_reductions/Begin/CMakeLists.txt +++ b/Exercises/advanced_reductions/Begin/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) 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 a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(AdvancedReductions advanced_reductions.cpp) target_link_libraries(AdvancedReductions Kokkos::kokkos) diff --git a/Exercises/advanced_reductions/Solution/CMakeLists.txt b/Exercises/advanced_reductions/Solution/CMakeLists.txt index 2d03da6d..0a8ff5f6 100644 --- a/Exercises/advanced_reductions/Solution/CMakeLists.txt +++ b/Exercises/advanced_reductions/Solution/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) 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 a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(AdvancedReductions_Solution advanced_reductions.cpp) target_link_libraries(AdvancedReductions_Solution Kokkos::kokkos) diff --git a/Exercises/cmake/FindKokkos.cmake b/Exercises/cmake/SetUpKokkos.cmake similarity index 93% rename from Exercises/cmake/FindKokkos.cmake rename to Exercises/cmake/SetUpKokkos.cmake index a86fcb0c..745ce7ea 100644 --- a/Exercises/cmake/FindKokkos.cmake +++ b/Exercises/cmake/SetUpKokkos.cmake @@ -27,13 +27,11 @@ endif () set(KokkosTutorials_KOKKOS_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../dep/kokkos" CACHE PATH "Description for KokkosTutorials_KOKKOS_SOURCE_DIR") -if (NOT KokkosTutorials_FORCE_INTERNAL_Kokkos) - find_package(Kokkos CONFIG) -endif () +find_package(Kokkos CONFIG) if (Kokkos_FOUND) message(STATUS "Found Kokkos: ${Kokkos_DIR} (version \"${Kokkos_VERSION}\")") -elseif (NOT KokkosTutorials_FORCE_EXTERNAL_Kokkos) +else () if (EXISTS ${KokkosTutorials_KOKKOS_SOURCE_DIR}) add_subdirectory(${KokkosTutorials_KOKKOS_SOURCE_DIR} Kokkos) else () diff --git a/Exercises/dualview/Begin/CMakeLists.txt b/Exercises/dualview/Begin/CMakeLists.txt index 05a81cca..1d0fde8a 100644 --- a/Exercises/dualview/Begin/CMakeLists.txt +++ b/Exercises/dualview/Begin/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialDualView) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(dualview dual_view_exercise.cpp) target_link_libraries(dualview Kokkos::kokkos) diff --git a/Exercises/dualview/Solution/CMakeLists.txt b/Exercises/dualview/Solution/CMakeLists.txt index b36ff223..0e8fbea4 100644 --- a/Exercises/dualview/Solution/CMakeLists.txt +++ b/Exercises/dualview/Solution/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialDualView) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(dualview_Solution dual_view_exercise.cpp) target_link_libraries(dualview_Solution Kokkos::kokkos) diff --git a/Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt b/Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt index 8b2117e6..635a0b47 100644 --- a/Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt +++ b/Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialFortran) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) enable_language(Fortran) diff --git a/Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt b/Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt index e0d723d6..650f6c0e 100644 --- a/Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt +++ b/Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt @@ -1,16 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialFortran) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) - -execute_process ( - COMMAND bash -c "printenv" - OUTPUT_VARIABLE outVar -) -message("${outVar}") +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) enable_language(Fortran) diff --git a/Exercises/instances/Begin/CMakeLists.txt b/Exercises/instances/Begin/CMakeLists.txt index 3f9248ea..dc496cc8 100644 --- a/Exercises/instances/Begin/CMakeLists.txt +++ b/Exercises/instances/Begin/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialInstances) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(Instances_exercise instances_begin.cpp) target_link_libraries(Instances_exercise Kokkos::kokkos) diff --git a/Exercises/instances/Solution/CMakeLists.txt b/Exercises/instances/Solution/CMakeLists.txt index 17ea3756..fe687480 100644 --- a/Exercises/instances/Solution/CMakeLists.txt +++ b/Exercises/instances/Solution/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialInstances) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(Instances_solution instances_solution.cpp) target_link_libraries(Instances_solution Kokkos::kokkos) diff --git a/Exercises/mdrange/Begin/CMakeLists.txt b/Exercises/mdrange/Begin/CMakeLists.txt index 4403f148..9e1e883c 100644 --- a/Exercises/mdrange/Begin/CMakeLists.txt +++ b/Exercises/mdrange/Begin/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMdRange) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(mdrange_exercise exercise_mdrange_begin.cpp) target_link_libraries(mdrange_exercise Kokkos::kokkos) diff --git a/Exercises/mdrange/Solution/CMakeLists.txt b/Exercises/mdrange/Solution/CMakeLists.txt index 3645d8d8..7a9508aa 100644 --- a/Exercises/mdrange/Solution/CMakeLists.txt +++ b/Exercises/mdrange/Solution/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMdRange) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(mdrange_Solution exercise_mdrange_solution.cpp) target_link_libraries(mdrange_Solution Kokkos::kokkos) diff --git a/Exercises/mpi_exch/CMakeLists.txt b/Exercises/mpi_exch/CMakeLists.txt index 2d25a70a..f3a61a5b 100755 --- a/Exercises/mpi_exch/CMakeLists.txt +++ b/Exercises/mpi_exch/CMakeLists.txt @@ -1,7 +1,9 @@ cmake_minimum_required(VERSION 3.16) project(mpi_exch) -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) + find_package(MPI REQUIRED) add_executable(mpi_exch mpi_exch.cpp) diff --git a/Exercises/mpi_heat_conduction/Solution/CMakeLists.txt b/Exercises/mpi_heat_conduction/Solution/CMakeLists.txt index 7e3645c4..de81b06e 100755 --- a/Exercises/mpi_heat_conduction/Solution/CMakeLists.txt +++ b/Exercises/mpi_heat_conduction/Solution/CMakeLists.txt @@ -1,7 +1,9 @@ cmake_minimum_required(VERSION 3.16) project(heat3d) -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) + find_package(MPI REQUIRED) add_executable(heat3d mpi_heat_conduction_solution.cpp) diff --git a/Exercises/mpi_pack_unpack/Begin/CMakeLists.txt b/Exercises/mpi_pack_unpack/Begin/CMakeLists.txt index efd3d9f0..f0a55b09 100644 --- a/Exercises/mpi_pack_unpack/Begin/CMakeLists.txt +++ b/Exercises/mpi_pack_unpack/Begin/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMPIPackUnpack) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(MPIPackUnpack mpi_pack_unpack_begin.cpp) target_link_libraries(MPIPackUnpack Kokkos::kokkos) diff --git a/Exercises/mpi_pack_unpack/Solution/CMakeLists.txt b/Exercises/mpi_pack_unpack/Solution/CMakeLists.txt index 1dc8ec9d..a3be340d 100644 --- a/Exercises/mpi_pack_unpack/Solution/CMakeLists.txt +++ b/Exercises/mpi_pack_unpack/Solution/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMPIPackUnpack) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(MPIPackUnpack mpi_pack_unpack_solution.cpp) target_link_libraries(MPIPackUnpack Kokkos::kokkos) diff --git a/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt b/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt index 1c79aa4e..dd9ee552 100644 --- a/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt +++ b/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMultiGpuCuda) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) if (NOT Kokkos_ENABLE_CUDA) message(WARNING "This example requires CUDA, enable with -DKokkos_ENABLE_CUDA=ON") diff --git a/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt b/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt index e99e09ad..21638215 100644 --- a/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt +++ b/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMultiGpuCuda) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) if (NOT Kokkos_ENABLE_CUDA) message(WARNING "This example requires CUDA, enable with -DKokkos_ENABLE_CUDA=ON") diff --git a/Exercises/parallel_scan/Begin/CMakeLists.txt b/Exercises/parallel_scan/Begin/CMakeLists.txt index 1154e5ef..f2df32b3 100644 --- a/Exercises/parallel_scan/Begin/CMakeLists.txt +++ b/Exercises/parallel_scan/Begin/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialParallelScan) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(ParallelScan parallel_scan.cpp) target_link_libraries(ParallelScan Kokkos::kokkos) diff --git a/Exercises/parallel_scan/Solution/CMakeLists.txt b/Exercises/parallel_scan/Solution/CMakeLists.txt index d8253ee3..b1a5ade5 100644 --- a/Exercises/parallel_scan/Solution/CMakeLists.txt +++ b/Exercises/parallel_scan/Solution/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialParallelScan) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(ParallelScan_Solution parallel_scan.cpp) target_link_libraries(ParallelScan_Solution Kokkos::kokkos) diff --git a/Exercises/random_number/Begin/CMakeLists.txt b/Exercises/random_number/Begin/CMakeLists.txt index 6396ab60..4766b03b 100644 --- a/Exercises/random_number/Begin/CMakeLists.txt +++ b/Exercises/random_number/Begin/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialRNG) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(random_number_exercise MC_DartSampler.cpp) target_link_libraries(random_number_exercise Kokkos::kokkos) diff --git a/Exercises/random_number/Solution/CMakeLists.txt b/Exercises/random_number/Solution/CMakeLists.txt index aed83c01..39a3657e 100644 --- a/Exercises/random_number/Solution/CMakeLists.txt +++ b/Exercises/random_number/Solution/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialRNG) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(random_number_solution MC_DartSampler.cpp) target_link_libraries(random_number_solution Kokkos::kokkos) diff --git a/Exercises/scatter_view/Begin/CMakeLists.txt b/Exercises/scatter_view/Begin/CMakeLists.txt index b34b1929..02da0585 100644 --- a/Exercises/scatter_view/Begin/CMakeLists.txt +++ b/Exercises/scatter_view/Begin/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialScatterView) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(scatterview scatter_view.cpp) target_link_libraries(scatterview Kokkos::kokkos) diff --git a/Exercises/scatter_view/Solution/CMakeLists.txt b/Exercises/scatter_view/Solution/CMakeLists.txt index fade4652..98f0a9a9 100644 --- a/Exercises/scatter_view/Solution/CMakeLists.txt +++ b/Exercises/scatter_view/Solution/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialScatterView) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(scatterview_Solution scatter_view.cpp) target_link_libraries(scatterview_Solution Kokkos::kokkos) diff --git a/Exercises/scatter_view/Usage/CMakeLists.txt b/Exercises/scatter_view/Usage/CMakeLists.txt index c9b7a0a4..54cd8b2d 100644 --- a/Exercises/scatter_view/Usage/CMakeLists.txt +++ b/Exercises/scatter_view/Usage/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialScatterView) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(scatterview_usage usage.cpp) target_link_libraries(scatterview_usage Kokkos::kokkos) diff --git a/Exercises/simd/Begin/CMakeLists.txt b/Exercises/simd/Begin/CMakeLists.txt index 436416c8..a2bfade8 100644 --- a/Exercises/simd/Begin/CMakeLists.txt +++ b/Exercises/simd/Begin/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSIMD) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(SIMD simd_begin.cpp) target_link_libraries(SIMD Kokkos::kokkos) diff --git a/Exercises/simd/Solution/CMakeLists.txt b/Exercises/simd/Solution/CMakeLists.txt index 56c6b53e..038b4dcf 100644 --- a/Exercises/simd/Solution/CMakeLists.txt +++ b/Exercises/simd/Solution/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSIMD) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(SIMD_Solution simd_solution.cpp) target_link_libraries(SIMD_Solution Kokkos::kokkos) diff --git a/Exercises/simd_warp/Begin/CMakeLists.txt b/Exercises/simd_warp/Begin/CMakeLists.txt index be170920..8f161a02 100644 --- a/Exercises/simd_warp/Begin/CMakeLists.txt +++ b/Exercises/simd_warp/Begin/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSIMDWarp) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(SIMDWarp simd_warp_begin.cpp) target_link_libraries(SIMDWarp Kokkos::kokkos) diff --git a/Exercises/simd_warp/Solution/CMakeLists.txt b/Exercises/simd_warp/Solution/CMakeLists.txt index 2a82272f..1d63a598 100644 --- a/Exercises/simd_warp/Solution/CMakeLists.txt +++ b/Exercises/simd_warp/Solution/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSIMDWarp) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(SIMDWarp_Solution simd_warp_solution.cpp) target_link_libraries(SIMDWarp_Solution Kokkos::kokkos) diff --git a/Exercises/subview/Begin/CMakeLists.txt b/Exercises/subview/Begin/CMakeLists.txt index f8347902..bd327420 100644 --- a/Exercises/subview/Begin/CMakeLists.txt +++ b/Exercises/subview/Begin/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSubview) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(subview_exercise exercise_subview_begin.cpp) target_link_libraries(subview_exercise Kokkos::kokkos) diff --git a/Exercises/subview/Solution/CMakeLists.txt b/Exercises/subview/Solution/CMakeLists.txt index 79e92e88..9d84aca4 100644 --- a/Exercises/subview/Solution/CMakeLists.txt +++ b/Exercises/subview/Solution/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSubview) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(subview_Solution exercise_subview_solution.cpp) target_link_libraries(subview_Solution Kokkos::kokkos) diff --git a/Exercises/tasking/Begin/CMakeLists.txt b/Exercises/tasking/Begin/CMakeLists.txt index 6ee2b06a..5e283f14 100644 --- a/Exercises/tasking/Begin/CMakeLists.txt +++ b/Exercises/tasking/Begin/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTasking) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(Tasking tasking_begin.cpp) target_link_libraries(Tasking Kokkos::kokkos) diff --git a/Exercises/tasking/Solution/CMakeLists.txt b/Exercises/tasking/Solution/CMakeLists.txt index 29856f37..a7310cc2 100644 --- a/Exercises/tasking/Solution/CMakeLists.txt +++ b/Exercises/tasking/Solution/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTasking) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(Tasking_Solution tasking_solution.cpp) target_link_libraries(Tasking_Solution Kokkos::kokkos) diff --git a/Exercises/team_policy/Begin/CMakeLists.txt b/Exercises/team_policy/Begin/CMakeLists.txt index 2deef1f9..589de7ba 100644 --- a/Exercises/team_policy/Begin/CMakeLists.txt +++ b/Exercises/team_policy/Begin/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamPolicy) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(TeamPolicy team_policy_begin.cpp) target_link_libraries(TeamPolicy Kokkos::kokkos) diff --git a/Exercises/team_policy/Solution/CMakeLists.txt b/Exercises/team_policy/Solution/CMakeLists.txt index 5f028115..1688f376 100644 --- a/Exercises/team_policy/Solution/CMakeLists.txt +++ b/Exercises/team_policy/Solution/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamPolicy) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(TeamPolicy_Solution team_policy_solution.cpp) target_link_libraries(TeamPolicy_Solution Kokkos::kokkos) diff --git a/Exercises/team_scratch_memory/Begin/CMakeLists.txt b/Exercises/team_scratch_memory/Begin/CMakeLists.txt index 4de1d126..1e1d15c1 100644 --- a/Exercises/team_scratch_memory/Begin/CMakeLists.txt +++ b/Exercises/team_scratch_memory/Begin/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamScratchMemory) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(TeamScratchMemory team_scratch_memory_begin.cpp) target_link_libraries(TeamScratchMemory Kokkos::kokkos) diff --git a/Exercises/team_scratch_memory/Solution/CMakeLists.txt b/Exercises/team_scratch_memory/Solution/CMakeLists.txt index 32410d2c..b241587f 100644 --- a/Exercises/team_scratch_memory/Solution/CMakeLists.txt +++ b/Exercises/team_scratch_memory/Solution/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamScratchMemory) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(TeamScratchMemory_Solution team_scratch_memory_solution.cpp) target_link_libraries(TeamScratchMemory_Solution Kokkos::kokkos) diff --git a/Exercises/team_vector_loop/Begin/CMakeLists.txt b/Exercises/team_vector_loop/Begin/CMakeLists.txt index e0b07ce7..d41ee68c 100644 --- a/Exercises/team_vector_loop/Begin/CMakeLists.txt +++ b/Exercises/team_vector_loop/Begin/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamVectorLoop) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(TeamVectorLoop team_vector_loop_begin.cpp) target_link_libraries(TeamVectorLoop Kokkos::kokkos) diff --git a/Exercises/team_vector_loop/Solution/CMakeLists.txt b/Exercises/team_vector_loop/Solution/CMakeLists.txt index 2c2fcd2f..aebf9828 100644 --- a/Exercises/team_vector_loop/Solution/CMakeLists.txt +++ b/Exercises/team_vector_loop/Solution/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamVectorLoop) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(TeamVectorLoop_Solution team_vector_loop_solution.cpp) target_link_libraries(TeamVectorLoop_Solution Kokkos::kokkos) diff --git a/Exercises/tools_minimd/CMakeLists.txt b/Exercises/tools_minimd/CMakeLists.txt index 03ee5448..55196e83 100644 --- a/Exercises/tools_minimd/CMakeLists.txt +++ b/Exercises/tools_minimd/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTools) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../cmake/SetUpKokkos.cmake) option(ENABLE_MPI OFF "Whether to enable the Message Passing Interface (MPI)") diff --git a/Exercises/unique_token/Begin/CMakeLists.txt b/Exercises/unique_token/Begin/CMakeLists.txt index e997ffd4..446b17e0 100644 --- a/Exercises/unique_token/Begin/CMakeLists.txt +++ b/Exercises/unique_token/Begin/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialUniqueToken) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) if (NOT Kokkos_ENABLE_OPENMP) message(WARNING "This exercise requires OpenMP, enable with -DKokkos_ENABLE_OPENMP=ON") diff --git a/Exercises/unique_token/Solution/CMakeLists.txt b/Exercises/unique_token/Solution/CMakeLists.txt index 019fa607..cc2bdaab 100644 --- a/Exercises/unique_token/Solution/CMakeLists.txt +++ b/Exercises/unique_token/Solution/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialUniqueToken) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(uniquetoken_solution unique_token.cpp) target_link_libraries(uniquetoken_solution Kokkos::kokkos) diff --git a/Exercises/unordered_map/Begin/CMakeLists.txt b/Exercises/unordered_map/Begin/CMakeLists.txt index 58c53857..89f37791 100644 --- a/Exercises/unordered_map/Begin/CMakeLists.txt +++ b/Exercises/unordered_map/Begin/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialUnorderedMap) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(unordered_map_exercise unordered_map.cpp) target_link_libraries(unordered_map_exercise Kokkos::kokkos) diff --git a/Exercises/unordered_map/Solution/CMakeLists.txt b/Exercises/unordered_map/Solution/CMakeLists.txt index 43729ef4..5290ebc1 100644 --- a/Exercises/unordered_map/Solution/CMakeLists.txt +++ b/Exercises/unordered_map/Solution/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialUnorderedMap) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(unordered_map_solution unordered_map.cpp) target_link_libraries(unordered_map_solution Kokkos::kokkos) diff --git a/Exercises/virtualfunction/Begin/CMakeLists.txt b/Exercises/virtualfunction/Begin/CMakeLists.txt index fa560a2b..815287af 100644 --- a/Exercises/virtualfunction/Begin/CMakeLists.txt +++ b/Exercises/virtualfunction/Begin/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialVirtualFunction) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(virtual_function virtual_function.cpp classes.cpp) target_link_libraries(virtual_function Kokkos::kokkos) diff --git a/Exercises/virtualfunction/Solution/CMakeLists.txt b/Exercises/virtualfunction/Solution/CMakeLists.txt index bbadc364..8ec2cd6c 100644 --- a/Exercises/virtualfunction/Solution/CMakeLists.txt +++ b/Exercises/virtualfunction/Solution/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialVirtualFunction) -# Add a custom module path for find_package -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") - -find_package(Kokkos REQUIRED) +# Add a custom module path for find_package(Kokkos) +include(../../cmake/SetUpKokkos.cmake) add_executable(virtual_function_solution virtual_function.cpp classes.cpp) target_link_libraries(virtual_function_solution Kokkos::kokkos) diff --git a/README.md b/README.md index caf99aa9..ba0c23b9 100644 --- a/README.md +++ b/README.md @@ -80,15 +80,15 @@ CMake can build against an installed Kokkos library or download one automaticall To pass an already installed Kokkos library, you can use classical CMake variables, such as `Kokkos_ROOT`, or `CMAKE_PREFIX_PATH`. -A specific CMake option, `KokkosTutorials_FORCE_INTERNAL_Kokkos`, can be used to force the use of the internal Kokkos +A specific CMake option, `CMAKE_DISABLE_FIND_PACKAGE_Kokkos`, can be used to force the use of the internal Kokkos library, discarding any already installed Kokkos. -An opposite option, `KokkosTutorials_FORCE_EXTERNAL_Kokkos` can prevent Kokkos from being downloaded and is useful to +An opposite option, `CMAKE_REQUIRE_FIND_PACKAGE_Kokkos` can prevent Kokkos from being downloaded and is useful to test against an already installed Kokkos. ```shell # Download and build Kokkos and the tutorials, forcing the use of the internal Kokkos -cmake -B build_dir -DKokkosTutorials_FORCE_INTERNAL_Kokkos=ON # -DKokkos_* options +cmake -B build_dir -DCMAKE_DISABLE_FIND_PACKAGE_Kokkos=ON # -DKokkos_* options cmake --build build_dir ``` From 1c404fcf8a4c8cfdf2619f6ec70f6698d9a92579 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Wed, 26 Feb 2025 12:51:00 +0100 Subject: [PATCH 43/59] Use tarball to download Kokkos This way we can promote the use of SHA256 --- Exercises/cmake/SetUpKokkos.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Exercises/cmake/SetUpKokkos.cmake b/Exercises/cmake/SetUpKokkos.cmake index 745ce7ea..37aa35b2 100644 --- a/Exercises/cmake/SetUpKokkos.cmake +++ b/Exercises/cmake/SetUpKokkos.cmake @@ -35,11 +35,12 @@ else () if (EXISTS ${KokkosTutorials_KOKKOS_SOURCE_DIR}) add_subdirectory(${KokkosTutorials_KOKKOS_SOURCE_DIR} Kokkos) else () + cmake_policy(CMP0135 NEW) # Use extract timestamp for fetch content include(FetchContent) FetchContent_Declare( Kokkos - GIT_REPOSITORY https://github.com/kokkos/kokkos.git - GIT_TAG 4.5.01 + URL https://github.com/kokkos/kokkos/releases/download/4.5.01/kokkos-4.5.01.tar.gz + URL_HASH SHA256=52d003ffbbe05f30c89966e4009c017efb1662b02b2b73190670d3418719564c SOURCE_DIR ${KokkosTutorials_KOKKOS_SOURCE_DIR} ) FetchContent_MakeAvailable(Kokkos) From 0b9221abd9a97b4cd09af12b5439c268326f1686 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Wed, 26 Feb 2025 14:10:26 +0100 Subject: [PATCH 44/59] Fix include in mpi_exch directory --- Exercises/mpi_exch/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exercises/mpi_exch/CMakeLists.txt b/Exercises/mpi_exch/CMakeLists.txt index f3a61a5b..f902729e 100755 --- a/Exercises/mpi_exch/CMakeLists.txt +++ b/Exercises/mpi_exch/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(mpi_exch) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../cmake/SetUpKokkos.cmake) find_package(MPI REQUIRED) From cd941267a8ef9189902f239d793b95d1a0cdb8f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Chevalier?= Date: Wed, 26 Feb 2025 16:50:18 +0100 Subject: [PATCH 45/59] Update README.md Co-authored-by: Paul Zehner --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index ba0c23b9..58aa9b0e 100644 --- a/README.md +++ b/README.md @@ -70,8 +70,7 @@ cmake -B build_hip -DKokkos_ENABLE_HIP=ON cmake --build build_hip ``` -Kokkos setup is covered by the [quickstart guide](https://kokkos.org/kokkos-core-wiki/get-started/quick-start.html) and an exhaustive -Kokkos options are described in [CMake options](https://kokkos.org/kokkos-core-wiki/get-started/configuration-guide.html). +Kokkos setup is covered by the [quickstart guide](https://kokkos.org/kokkos-core-wiki/get-started/quick-start.html) and an exhaustive list of Kokkos options is detailed in the [CMake keywords documentation](https://kokkos.org/kokkos-core-wiki/get-started/configuration-guide.html). ## Advanced CMake Usage From 4ec18a08aff0a59bada5b5773c49045c7b4b41ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Chevalier?= Date: Wed, 26 Feb 2025 16:50:46 +0100 Subject: [PATCH 46/59] Update README.md Co-authored-by: Paul Zehner --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 58aa9b0e..09d23fc3 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ cmake -B build_cuda -DKokkos_ENABLE_CUDA=ON cmake --build build_cuda ``` -For a AMD gpu, using gpu arch autodetection: +For an AMD GPU with autodetection of the GPU architecture: ```shell cmake -B build_hip -DKokkos_ENABLE_HIP=ON From e0ee40b1024a0d704fbd02603d7cc290848ba2e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Chevalier?= Date: Wed, 26 Feb 2025 16:51:07 +0100 Subject: [PATCH 47/59] Update README.md Co-authored-by: Paul Zehner --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 09d23fc3..62fc068e 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ Kokkos setup is covered by the [quickstart guide](https://kokkos.org/kokkos-core ## Advanced CMake Usage -CMake can build against an installed Kokkos library or download one automatically using `FetchContent`. +CMake can build against an existing Kokkos installation or download the source files automatically using `FetchContent`. To pass an already installed Kokkos library, you can use classical CMake variables, such as `Kokkos_ROOT`, or `CMAKE_PREFIX_PATH`. From d21fe573fcb91fced8a49afabbdd3e80ce024caa Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Wed, 26 Feb 2025 16:53:29 +0100 Subject: [PATCH 48/59] Fix unique_token example compilation --- Exercises/unique_token/Solution/unique_token.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Exercises/unique_token/Solution/unique_token.cpp b/Exercises/unique_token/Solution/unique_token.cpp index b13db287..d25c52a7 100644 --- a/Exercises/unique_token/Solution/unique_token.cpp +++ b/Exercises/unique_token/Solution/unique_token.cpp @@ -1,4 +1,5 @@ -#include +#include +#include using atomic_2d_view = Kokkos::View >; From d3daa7fa39ef736c75592c3ab92a280af64d88f8 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Wed, 26 Feb 2025 17:11:19 +0100 Subject: [PATCH 49/59] Cleaning up --- Exercises/cmake/SetUpKokkos.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exercises/cmake/SetUpKokkos.cmake b/Exercises/cmake/SetUpKokkos.cmake index 37aa35b2..b78c08d6 100644 --- a/Exercises/cmake/SetUpKokkos.cmake +++ b/Exercises/cmake/SetUpKokkos.cmake @@ -1,3 +1,4 @@ +# Convenience macro to warn the user if a GPU backend is enabled macro(KokkosTutorials_WarnGPU) 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}" @@ -44,6 +45,5 @@ else () SOURCE_DIR ${KokkosTutorials_KOKKOS_SOURCE_DIR} ) FetchContent_MakeAvailable(Kokkos) - set(Kokkos_FOUND True) endif () endif () From bffe62b9a5a58bda412b45884949f78545e18ece Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Wed, 26 Feb 2025 17:13:36 +0100 Subject: [PATCH 50/59] Move SetUpKokkos to Exercices --- Exercises/01/Begin/CMakeLists.txt | 2 +- Exercises/01/Solution/CMakeLists.txt | 2 +- Exercises/02/Begin/CMakeLists.txt | 2 +- Exercises/02/Solution/CMakeLists.txt | 2 +- Exercises/03/Begin/CMakeLists.txt | 2 +- Exercises/03/Solution/CMakeLists.txt | 2 +- Exercises/04/Begin/CMakeLists.txt | 2 +- Exercises/04/Solution/CMakeLists.txt | 2 +- Exercises/{cmake => }/SetUpKokkos.cmake | 4 ++-- Exercises/advanced_reductions/Begin/CMakeLists.txt | 2 +- Exercises/advanced_reductions/Solution/CMakeLists.txt | 2 +- Exercises/dualview/Begin/CMakeLists.txt | 2 +- Exercises/dualview/Solution/CMakeLists.txt | 2 +- Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt | 2 +- Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt | 2 +- Exercises/instances/Begin/CMakeLists.txt | 2 +- Exercises/instances/Solution/CMakeLists.txt | 2 +- Exercises/mdrange/Begin/CMakeLists.txt | 2 +- Exercises/mdrange/Solution/CMakeLists.txt | 2 +- Exercises/mpi_exch/CMakeLists.txt | 2 +- Exercises/mpi_heat_conduction/Solution/CMakeLists.txt | 2 +- Exercises/mpi_pack_unpack/Begin/CMakeLists.txt | 2 +- Exercises/mpi_pack_unpack/Solution/CMakeLists.txt | 2 +- Exercises/multi_gpu_cuda/Begin/CMakeLists.txt | 2 +- Exercises/multi_gpu_cuda/Solution/CMakeLists.txt | 2 +- Exercises/parallel_scan/Begin/CMakeLists.txt | 2 +- Exercises/parallel_scan/Solution/CMakeLists.txt | 2 +- Exercises/random_number/Begin/CMakeLists.txt | 2 +- Exercises/random_number/Solution/CMakeLists.txt | 2 +- Exercises/scatter_view/Begin/CMakeLists.txt | 2 +- Exercises/scatter_view/Solution/CMakeLists.txt | 2 +- Exercises/scatter_view/Usage/CMakeLists.txt | 2 +- Exercises/simd/Begin/CMakeLists.txt | 2 +- Exercises/simd/Solution/CMakeLists.txt | 2 +- Exercises/simd_warp/Begin/CMakeLists.txt | 2 +- Exercises/simd_warp/Solution/CMakeLists.txt | 2 +- Exercises/subview/Begin/CMakeLists.txt | 2 +- Exercises/subview/Solution/CMakeLists.txt | 2 +- Exercises/tasking/Begin/CMakeLists.txt | 2 +- Exercises/tasking/Solution/CMakeLists.txt | 2 +- Exercises/team_policy/Begin/CMakeLists.txt | 2 +- Exercises/team_policy/Solution/CMakeLists.txt | 2 +- Exercises/team_scratch_memory/Begin/CMakeLists.txt | 2 +- Exercises/team_scratch_memory/Solution/CMakeLists.txt | 2 +- Exercises/team_vector_loop/Begin/CMakeLists.txt | 2 +- Exercises/team_vector_loop/Solution/CMakeLists.txt | 2 +- Exercises/tools_minimd/CMakeLists.txt | 2 +- Exercises/unique_token/Begin/CMakeLists.txt | 2 +- Exercises/unique_token/Solution/CMakeLists.txt | 2 +- Exercises/unordered_map/Begin/CMakeLists.txt | 2 +- Exercises/unordered_map/Solution/CMakeLists.txt | 2 +- Exercises/virtualfunction/Begin/CMakeLists.txt | 2 +- Exercises/virtualfunction/Solution/CMakeLists.txt | 2 +- 53 files changed, 54 insertions(+), 54 deletions(-) rename Exercises/{cmake => }/SetUpKokkos.cmake (91%) diff --git a/Exercises/01/Begin/CMakeLists.txt b/Exercises/01/Begin/CMakeLists.txt index 2f3565e9..2c1955e7 100644 --- a/Exercises/01/Begin/CMakeLists.txt +++ b/Exercises/01/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial01) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) KokkosTutorials_WarnGPU() diff --git a/Exercises/01/Solution/CMakeLists.txt b/Exercises/01/Solution/CMakeLists.txt index bd5457c8..b7284372 100644 --- a/Exercises/01/Solution/CMakeLists.txt +++ b/Exercises/01/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial01) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) KokkosTutorials_WarnGPU() diff --git a/Exercises/02/Begin/CMakeLists.txt b/Exercises/02/Begin/CMakeLists.txt index 7dbf4c71..b644ccaf 100644 --- a/Exercises/02/Begin/CMakeLists.txt +++ b/Exercises/02/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial02) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) KokkosTutorials_WarnGPU() diff --git a/Exercises/02/Solution/CMakeLists.txt b/Exercises/02/Solution/CMakeLists.txt index ec6febbb..1e0beeba 100644 --- a/Exercises/02/Solution/CMakeLists.txt +++ b/Exercises/02/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial02) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) KokkosTutorials_WarnGPU() diff --git a/Exercises/03/Begin/CMakeLists.txt b/Exercises/03/Begin/CMakeLists.txt index 9cf78b8a..6b6f174b 100644 --- a/Exercises/03/Begin/CMakeLists.txt +++ b/Exercises/03/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial03) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(03_Exercise exercise_3_begin.cpp) target_link_libraries(03_Exercise Kokkos::kokkos) diff --git a/Exercises/03/Solution/CMakeLists.txt b/Exercises/03/Solution/CMakeLists.txt index 5c5e2407..4b31b52d 100644 --- a/Exercises/03/Solution/CMakeLists.txt +++ b/Exercises/03/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial03) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(03_Solution exercise_3_solution.cpp) target_link_libraries(03_Solution Kokkos::kokkos) diff --git a/Exercises/04/Begin/CMakeLists.txt b/Exercises/04/Begin/CMakeLists.txt index aae6a184..b3d0199a 100644 --- a/Exercises/04/Begin/CMakeLists.txt +++ b/Exercises/04/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial04) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(04_Exercise exercise_4_begin.cpp) target_link_libraries(04_Exercise Kokkos::kokkos) diff --git a/Exercises/04/Solution/CMakeLists.txt b/Exercises/04/Solution/CMakeLists.txt index a102bf38..b714305b 100644 --- a/Exercises/04/Solution/CMakeLists.txt +++ b/Exercises/04/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorial04) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(04_Solution exercise_4_solution.cpp) target_link_libraries(04_Solution Kokkos::kokkos) diff --git a/Exercises/cmake/SetUpKokkos.cmake b/Exercises/SetUpKokkos.cmake similarity index 91% rename from Exercises/cmake/SetUpKokkos.cmake rename to Exercises/SetUpKokkos.cmake index b78c08d6..6679bf60 100644 --- a/Exercises/cmake/SetUpKokkos.cmake +++ b/Exercises/SetUpKokkos.cmake @@ -1,7 +1,7 @@ # Convenience macro to warn the user if a GPU backend is enabled macro(KokkosTutorials_WarnGPU) 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}" + message(WARNING "cmake" "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 () @@ -26,7 +26,7 @@ endif () # the default directory is inside the source tree. # This might break if the default in source directory is called from multiple cmake instances at the same time. -set(KokkosTutorials_KOKKOS_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../dep/kokkos" CACHE PATH "Description for KokkosTutorials_KOKKOS_SOURCE_DIR") +set(KokkosTutorials_KOKKOS_SOURCE_DIR "dep/kokkos" CACHE PATH "Description for KokkosTutorials_KOKKOS_SOURCE_DIR") find_package(Kokkos CONFIG) diff --git a/Exercises/advanced_reductions/Begin/CMakeLists.txt b/Exercises/advanced_reductions/Begin/CMakeLists.txt index 4ce17fe3..5ed570eb 100644 --- a/Exercises/advanced_reductions/Begin/CMakeLists.txt +++ b/Exercises/advanced_reductions/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialAdvancedReductions) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(AdvancedReductions advanced_reductions.cpp) target_link_libraries(AdvancedReductions Kokkos::kokkos) diff --git a/Exercises/advanced_reductions/Solution/CMakeLists.txt b/Exercises/advanced_reductions/Solution/CMakeLists.txt index 0a8ff5f6..3082148f 100644 --- a/Exercises/advanced_reductions/Solution/CMakeLists.txt +++ b/Exercises/advanced_reductions/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialAdvancedReductions) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(AdvancedReductions_Solution advanced_reductions.cpp) target_link_libraries(AdvancedReductions_Solution Kokkos::kokkos) diff --git a/Exercises/dualview/Begin/CMakeLists.txt b/Exercises/dualview/Begin/CMakeLists.txt index 1d0fde8a..5b73704d 100644 --- a/Exercises/dualview/Begin/CMakeLists.txt +++ b/Exercises/dualview/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialDualView) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(dualview dual_view_exercise.cpp) target_link_libraries(dualview Kokkos::kokkos) diff --git a/Exercises/dualview/Solution/CMakeLists.txt b/Exercises/dualview/Solution/CMakeLists.txt index 0e8fbea4..621514e8 100644 --- a/Exercises/dualview/Solution/CMakeLists.txt +++ b/Exercises/dualview/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialDualView) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(dualview_Solution dual_view_exercise.cpp) target_link_libraries(dualview_Solution Kokkos::kokkos) diff --git a/Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt b/Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt index 635a0b47..2d5c6070 100644 --- a/Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt +++ b/Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialFortran) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) enable_language(Fortran) diff --git a/Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt b/Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt index 650f6c0e..384dc276 100644 --- a/Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt +++ b/Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialFortran) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) enable_language(Fortran) diff --git a/Exercises/instances/Begin/CMakeLists.txt b/Exercises/instances/Begin/CMakeLists.txt index dc496cc8..25157210 100644 --- a/Exercises/instances/Begin/CMakeLists.txt +++ b/Exercises/instances/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialInstances) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(Instances_exercise instances_begin.cpp) target_link_libraries(Instances_exercise Kokkos::kokkos) diff --git a/Exercises/instances/Solution/CMakeLists.txt b/Exercises/instances/Solution/CMakeLists.txt index fe687480..731780cb 100644 --- a/Exercises/instances/Solution/CMakeLists.txt +++ b/Exercises/instances/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialInstances) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(Instances_solution instances_solution.cpp) target_link_libraries(Instances_solution Kokkos::kokkos) diff --git a/Exercises/mdrange/Begin/CMakeLists.txt b/Exercises/mdrange/Begin/CMakeLists.txt index 9e1e883c..f84586dd 100644 --- a/Exercises/mdrange/Begin/CMakeLists.txt +++ b/Exercises/mdrange/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMdRange) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(mdrange_exercise exercise_mdrange_begin.cpp) target_link_libraries(mdrange_exercise Kokkos::kokkos) diff --git a/Exercises/mdrange/Solution/CMakeLists.txt b/Exercises/mdrange/Solution/CMakeLists.txt index 7a9508aa..9687ada7 100644 --- a/Exercises/mdrange/Solution/CMakeLists.txt +++ b/Exercises/mdrange/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMdRange) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(mdrange_Solution exercise_mdrange_solution.cpp) target_link_libraries(mdrange_Solution Kokkos::kokkos) diff --git a/Exercises/mpi_exch/CMakeLists.txt b/Exercises/mpi_exch/CMakeLists.txt index f902729e..eb5be6ec 100755 --- a/Exercises/mpi_exch/CMakeLists.txt +++ b/Exercises/mpi_exch/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(mpi_exch) # Add a custom module path for find_package(Kokkos) -include(../cmake/SetUpKokkos.cmake) +include(../SetUpKokkos.cmake) find_package(MPI REQUIRED) diff --git a/Exercises/mpi_heat_conduction/Solution/CMakeLists.txt b/Exercises/mpi_heat_conduction/Solution/CMakeLists.txt index de81b06e..9b8eaa8c 100755 --- a/Exercises/mpi_heat_conduction/Solution/CMakeLists.txt +++ b/Exercises/mpi_heat_conduction/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(heat3d) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) find_package(MPI REQUIRED) diff --git a/Exercises/mpi_pack_unpack/Begin/CMakeLists.txt b/Exercises/mpi_pack_unpack/Begin/CMakeLists.txt index f0a55b09..33198dfb 100644 --- a/Exercises/mpi_pack_unpack/Begin/CMakeLists.txt +++ b/Exercises/mpi_pack_unpack/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMPIPackUnpack) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(MPIPackUnpack mpi_pack_unpack_begin.cpp) target_link_libraries(MPIPackUnpack Kokkos::kokkos) diff --git a/Exercises/mpi_pack_unpack/Solution/CMakeLists.txt b/Exercises/mpi_pack_unpack/Solution/CMakeLists.txt index a3be340d..f73da47b 100644 --- a/Exercises/mpi_pack_unpack/Solution/CMakeLists.txt +++ b/Exercises/mpi_pack_unpack/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMPIPackUnpack) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(MPIPackUnpack mpi_pack_unpack_solution.cpp) target_link_libraries(MPIPackUnpack Kokkos::kokkos) diff --git a/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt b/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt index dd9ee552..54c0037e 100644 --- a/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt +++ b/Exercises/multi_gpu_cuda/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMultiGpuCuda) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) if (NOT Kokkos_ENABLE_CUDA) message(WARNING "This example requires CUDA, enable with -DKokkos_ENABLE_CUDA=ON") diff --git a/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt b/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt index 21638215..ad8fe5e7 100644 --- a/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt +++ b/Exercises/multi_gpu_cuda/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialMultiGpuCuda) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) if (NOT Kokkos_ENABLE_CUDA) message(WARNING "This example requires CUDA, enable with -DKokkos_ENABLE_CUDA=ON") diff --git a/Exercises/parallel_scan/Begin/CMakeLists.txt b/Exercises/parallel_scan/Begin/CMakeLists.txt index f2df32b3..812feba4 100644 --- a/Exercises/parallel_scan/Begin/CMakeLists.txt +++ b/Exercises/parallel_scan/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialParallelScan) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(ParallelScan parallel_scan.cpp) target_link_libraries(ParallelScan Kokkos::kokkos) diff --git a/Exercises/parallel_scan/Solution/CMakeLists.txt b/Exercises/parallel_scan/Solution/CMakeLists.txt index b1a5ade5..c9d3dae4 100644 --- a/Exercises/parallel_scan/Solution/CMakeLists.txt +++ b/Exercises/parallel_scan/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialParallelScan) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(ParallelScan_Solution parallel_scan.cpp) target_link_libraries(ParallelScan_Solution Kokkos::kokkos) diff --git a/Exercises/random_number/Begin/CMakeLists.txt b/Exercises/random_number/Begin/CMakeLists.txt index 4766b03b..0c6a4c75 100644 --- a/Exercises/random_number/Begin/CMakeLists.txt +++ b/Exercises/random_number/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialRNG) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(random_number_exercise MC_DartSampler.cpp) target_link_libraries(random_number_exercise Kokkos::kokkos) diff --git a/Exercises/random_number/Solution/CMakeLists.txt b/Exercises/random_number/Solution/CMakeLists.txt index 39a3657e..3750bd8a 100644 --- a/Exercises/random_number/Solution/CMakeLists.txt +++ b/Exercises/random_number/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialRNG) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(random_number_solution MC_DartSampler.cpp) target_link_libraries(random_number_solution Kokkos::kokkos) diff --git a/Exercises/scatter_view/Begin/CMakeLists.txt b/Exercises/scatter_view/Begin/CMakeLists.txt index 02da0585..f5d4ca30 100644 --- a/Exercises/scatter_view/Begin/CMakeLists.txt +++ b/Exercises/scatter_view/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialScatterView) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(scatterview scatter_view.cpp) target_link_libraries(scatterview Kokkos::kokkos) diff --git a/Exercises/scatter_view/Solution/CMakeLists.txt b/Exercises/scatter_view/Solution/CMakeLists.txt index 98f0a9a9..3ac54e5d 100644 --- a/Exercises/scatter_view/Solution/CMakeLists.txt +++ b/Exercises/scatter_view/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialScatterView) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(scatterview_Solution scatter_view.cpp) target_link_libraries(scatterview_Solution Kokkos::kokkos) diff --git a/Exercises/scatter_view/Usage/CMakeLists.txt b/Exercises/scatter_view/Usage/CMakeLists.txt index 54cd8b2d..124196ed 100644 --- a/Exercises/scatter_view/Usage/CMakeLists.txt +++ b/Exercises/scatter_view/Usage/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialScatterView) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(scatterview_usage usage.cpp) target_link_libraries(scatterview_usage Kokkos::kokkos) diff --git a/Exercises/simd/Begin/CMakeLists.txt b/Exercises/simd/Begin/CMakeLists.txt index a2bfade8..9974c453 100644 --- a/Exercises/simd/Begin/CMakeLists.txt +++ b/Exercises/simd/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSIMD) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(SIMD simd_begin.cpp) target_link_libraries(SIMD Kokkos::kokkos) diff --git a/Exercises/simd/Solution/CMakeLists.txt b/Exercises/simd/Solution/CMakeLists.txt index 038b4dcf..892c5a8a 100644 --- a/Exercises/simd/Solution/CMakeLists.txt +++ b/Exercises/simd/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSIMD) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(SIMD_Solution simd_solution.cpp) target_link_libraries(SIMD_Solution Kokkos::kokkos) diff --git a/Exercises/simd_warp/Begin/CMakeLists.txt b/Exercises/simd_warp/Begin/CMakeLists.txt index 8f161a02..6d90c712 100644 --- a/Exercises/simd_warp/Begin/CMakeLists.txt +++ b/Exercises/simd_warp/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSIMDWarp) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(SIMDWarp simd_warp_begin.cpp) target_link_libraries(SIMDWarp Kokkos::kokkos) diff --git a/Exercises/simd_warp/Solution/CMakeLists.txt b/Exercises/simd_warp/Solution/CMakeLists.txt index 1d63a598..9d551cd4 100644 --- a/Exercises/simd_warp/Solution/CMakeLists.txt +++ b/Exercises/simd_warp/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSIMDWarp) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(SIMDWarp_Solution simd_warp_solution.cpp) target_link_libraries(SIMDWarp_Solution Kokkos::kokkos) diff --git a/Exercises/subview/Begin/CMakeLists.txt b/Exercises/subview/Begin/CMakeLists.txt index bd327420..7f0bd7a7 100644 --- a/Exercises/subview/Begin/CMakeLists.txt +++ b/Exercises/subview/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSubview) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(subview_exercise exercise_subview_begin.cpp) target_link_libraries(subview_exercise Kokkos::kokkos) diff --git a/Exercises/subview/Solution/CMakeLists.txt b/Exercises/subview/Solution/CMakeLists.txt index 9d84aca4..bcd499d8 100644 --- a/Exercises/subview/Solution/CMakeLists.txt +++ b/Exercises/subview/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialSubview) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(subview_Solution exercise_subview_solution.cpp) target_link_libraries(subview_Solution Kokkos::kokkos) diff --git a/Exercises/tasking/Begin/CMakeLists.txt b/Exercises/tasking/Begin/CMakeLists.txt index 5e283f14..64b30de3 100644 --- a/Exercises/tasking/Begin/CMakeLists.txt +++ b/Exercises/tasking/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTasking) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(Tasking tasking_begin.cpp) target_link_libraries(Tasking Kokkos::kokkos) diff --git a/Exercises/tasking/Solution/CMakeLists.txt b/Exercises/tasking/Solution/CMakeLists.txt index a7310cc2..a240342f 100644 --- a/Exercises/tasking/Solution/CMakeLists.txt +++ b/Exercises/tasking/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTasking) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(Tasking_Solution tasking_solution.cpp) target_link_libraries(Tasking_Solution Kokkos::kokkos) diff --git a/Exercises/team_policy/Begin/CMakeLists.txt b/Exercises/team_policy/Begin/CMakeLists.txt index 589de7ba..68db5016 100644 --- a/Exercises/team_policy/Begin/CMakeLists.txt +++ b/Exercises/team_policy/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamPolicy) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(TeamPolicy team_policy_begin.cpp) target_link_libraries(TeamPolicy Kokkos::kokkos) diff --git a/Exercises/team_policy/Solution/CMakeLists.txt b/Exercises/team_policy/Solution/CMakeLists.txt index 1688f376..14ea9f18 100644 --- a/Exercises/team_policy/Solution/CMakeLists.txt +++ b/Exercises/team_policy/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamPolicy) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(TeamPolicy_Solution team_policy_solution.cpp) target_link_libraries(TeamPolicy_Solution Kokkos::kokkos) diff --git a/Exercises/team_scratch_memory/Begin/CMakeLists.txt b/Exercises/team_scratch_memory/Begin/CMakeLists.txt index 1e1d15c1..ebefee7a 100644 --- a/Exercises/team_scratch_memory/Begin/CMakeLists.txt +++ b/Exercises/team_scratch_memory/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamScratchMemory) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(TeamScratchMemory team_scratch_memory_begin.cpp) target_link_libraries(TeamScratchMemory Kokkos::kokkos) diff --git a/Exercises/team_scratch_memory/Solution/CMakeLists.txt b/Exercises/team_scratch_memory/Solution/CMakeLists.txt index b241587f..4a9def20 100644 --- a/Exercises/team_scratch_memory/Solution/CMakeLists.txt +++ b/Exercises/team_scratch_memory/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamScratchMemory) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(TeamScratchMemory_Solution team_scratch_memory_solution.cpp) target_link_libraries(TeamScratchMemory_Solution Kokkos::kokkos) diff --git a/Exercises/team_vector_loop/Begin/CMakeLists.txt b/Exercises/team_vector_loop/Begin/CMakeLists.txt index d41ee68c..9998b394 100644 --- a/Exercises/team_vector_loop/Begin/CMakeLists.txt +++ b/Exercises/team_vector_loop/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamVectorLoop) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(TeamVectorLoop team_vector_loop_begin.cpp) target_link_libraries(TeamVectorLoop Kokkos::kokkos) diff --git a/Exercises/team_vector_loop/Solution/CMakeLists.txt b/Exercises/team_vector_loop/Solution/CMakeLists.txt index aebf9828..9cde8392 100644 --- a/Exercises/team_vector_loop/Solution/CMakeLists.txt +++ b/Exercises/team_vector_loop/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTeamVectorLoop) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(TeamVectorLoop_Solution team_vector_loop_solution.cpp) target_link_libraries(TeamVectorLoop_Solution Kokkos::kokkos) diff --git a/Exercises/tools_minimd/CMakeLists.txt b/Exercises/tools_minimd/CMakeLists.txt index 55196e83..32d82284 100644 --- a/Exercises/tools_minimd/CMakeLists.txt +++ b/Exercises/tools_minimd/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialTools) # Add a custom module path for find_package(Kokkos) -include(../cmake/SetUpKokkos.cmake) +include(../SetUpKokkos.cmake) option(ENABLE_MPI OFF "Whether to enable the Message Passing Interface (MPI)") diff --git a/Exercises/unique_token/Begin/CMakeLists.txt b/Exercises/unique_token/Begin/CMakeLists.txt index 446b17e0..93b2205e 100644 --- a/Exercises/unique_token/Begin/CMakeLists.txt +++ b/Exercises/unique_token/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialUniqueToken) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) if (NOT Kokkos_ENABLE_OPENMP) message(WARNING "This exercise requires OpenMP, enable with -DKokkos_ENABLE_OPENMP=ON") diff --git a/Exercises/unique_token/Solution/CMakeLists.txt b/Exercises/unique_token/Solution/CMakeLists.txt index cc2bdaab..fd7696aa 100644 --- a/Exercises/unique_token/Solution/CMakeLists.txt +++ b/Exercises/unique_token/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialUniqueToken) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(uniquetoken_solution unique_token.cpp) target_link_libraries(uniquetoken_solution Kokkos::kokkos) diff --git a/Exercises/unordered_map/Begin/CMakeLists.txt b/Exercises/unordered_map/Begin/CMakeLists.txt index 89f37791..b7c749f2 100644 --- a/Exercises/unordered_map/Begin/CMakeLists.txt +++ b/Exercises/unordered_map/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialUnorderedMap) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(unordered_map_exercise unordered_map.cpp) target_link_libraries(unordered_map_exercise Kokkos::kokkos) diff --git a/Exercises/unordered_map/Solution/CMakeLists.txt b/Exercises/unordered_map/Solution/CMakeLists.txt index 5290ebc1..a417766d 100644 --- a/Exercises/unordered_map/Solution/CMakeLists.txt +++ b/Exercises/unordered_map/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialUnorderedMap) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(unordered_map_solution unordered_map.cpp) target_link_libraries(unordered_map_solution Kokkos::kokkos) diff --git a/Exercises/virtualfunction/Begin/CMakeLists.txt b/Exercises/virtualfunction/Begin/CMakeLists.txt index 815287af..f62e9416 100644 --- a/Exercises/virtualfunction/Begin/CMakeLists.txt +++ b/Exercises/virtualfunction/Begin/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialVirtualFunction) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(virtual_function virtual_function.cpp classes.cpp) target_link_libraries(virtual_function Kokkos::kokkos) diff --git a/Exercises/virtualfunction/Solution/CMakeLists.txt b/Exercises/virtualfunction/Solution/CMakeLists.txt index 8ec2cd6c..640da0fb 100644 --- a/Exercises/virtualfunction/Solution/CMakeLists.txt +++ b/Exercises/virtualfunction/Solution/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(KokkosTutorialVirtualFunction) # Add a custom module path for find_package(Kokkos) -include(../../cmake/SetUpKokkos.cmake) +include(../../SetUpKokkos.cmake) add_executable(virtual_function_solution virtual_function.cpp classes.cpp) target_link_libraries(virtual_function_solution Kokkos::kokkos) From cdb445f6e968c8e58c60eb54b820b785db52770c Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Thu, 3 Apr 2025 17:01:13 +0200 Subject: [PATCH 51/59] Fix cmake policy for downloading Kokkos Core --- Exercises/SetUpKokkos.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exercises/SetUpKokkos.cmake b/Exercises/SetUpKokkos.cmake index 6679bf60..2ed3b0c2 100644 --- a/Exercises/SetUpKokkos.cmake +++ b/Exercises/SetUpKokkos.cmake @@ -36,7 +36,7 @@ else () if (EXISTS ${KokkosTutorials_KOKKOS_SOURCE_DIR}) add_subdirectory(${KokkosTutorials_KOKKOS_SOURCE_DIR} Kokkos) else () - cmake_policy(CMP0135 NEW) # Use extract timestamp for fetch content + cmake_policy(VERSION 3.24) # Use extract timestamp for fetch content include(FetchContent) FetchContent_Declare( Kokkos From b148a85238296ef74a3d8ad857f4eb63892f0e6b Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Fri, 25 Jul 2025 15:02:56 +0200 Subject: [PATCH 52/59] Download Kokkos in Exercises/dep --- .gitignore | 6 +----- Exercises/SetUpKokkos.cmake | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 22721c9d..45ed7cd4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,4 @@ - -spack-build/ -spack-build-env.txt -spack-build-out.txt -cmake_install.cmake +Exercises/dep *.o *.host *.cuda diff --git a/Exercises/SetUpKokkos.cmake b/Exercises/SetUpKokkos.cmake index 2ed3b0c2..01ad665b 100644 --- a/Exercises/SetUpKokkos.cmake +++ b/Exercises/SetUpKokkos.cmake @@ -26,7 +26,7 @@ endif () # the default directory is inside the source tree. # This might break if the default in source directory is called from multiple cmake instances at the same time. -set(KokkosTutorials_KOKKOS_SOURCE_DIR "dep/kokkos" CACHE PATH "Description for KokkosTutorials_KOKKOS_SOURCE_DIR") +set(KokkosTutorials_KOKKOS_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/dep/kokkos" CACHE PATH "Description for KokkosTutorials_KOKKOS_SOURCE_DIR") find_package(Kokkos CONFIG) From c47a017b7ba05f7c17a3bb50cae2dad57b394816 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Fri, 25 Jul 2025 17:42:56 +0200 Subject: [PATCH 53/59] Remove references to tasking example --- CMakeLists.txt | 1 - Exercises/tasking/CMakeLists.txt | 5 ----- 2 files changed, 6 deletions(-) delete mode 100644 Exercises/tasking/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e8f923f..e00c197b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,6 @@ add_subdirectory(Exercises/team_scratch_memory) add_subdirectory(Exercises/simd) # FIXME update the code # add_subdirectory(Exercises/simd_warp) -# add_subdirectory(Exercises/tasking) add_subdirectory(Exercises/advanced_reductions) add_subdirectory(Exercises/instances) diff --git a/Exercises/tasking/CMakeLists.txt b/Exercises/tasking/CMakeLists.txt deleted file mode 100644 index 0af10cfc..00000000 --- a/Exercises/tasking/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 3.16) -project(KokkosTutorialTasking) - -add_subdirectory(Begin) -add_subdirectory(Solution) From 21baf0d43e6517ae69af3e70301e3f7f6ca54b7a Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Fri, 25 Jul 2025 17:45:52 +0200 Subject: [PATCH 54/59] Follow @pzehner advice to fix time stamping Does not require CMake 3.14 anymore. --- Exercises/SetUpKokkos.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exercises/SetUpKokkos.cmake b/Exercises/SetUpKokkos.cmake index 01ad665b..d726e6b6 100644 --- a/Exercises/SetUpKokkos.cmake +++ b/Exercises/SetUpKokkos.cmake @@ -36,13 +36,13 @@ else () if (EXISTS ${KokkosTutorials_KOKKOS_SOURCE_DIR}) add_subdirectory(${KokkosTutorials_KOKKOS_SOURCE_DIR} Kokkos) else () - cmake_policy(VERSION 3.24) # Use extract timestamp for fetch content include(FetchContent) FetchContent_Declare( Kokkos URL https://github.com/kokkos/kokkos/releases/download/4.5.01/kokkos-4.5.01.tar.gz URL_HASH SHA256=52d003ffbbe05f30c89966e4009c017efb1662b02b2b73190670d3418719564c SOURCE_DIR ${KokkosTutorials_KOKKOS_SOURCE_DIR} + DOWNLOAD_EXTRACT_TIMESTAMP ON ) FetchContent_MakeAvailable(Kokkos) endif () From 1bafe0e1787745258049dff1d5065cf75c6c9e3b Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Fri, 25 Jul 2025 17:49:35 +0200 Subject: [PATCH 55/59] Add diagnostic messages for Kokkos location --- Exercises/SetUpKokkos.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Exercises/SetUpKokkos.cmake b/Exercises/SetUpKokkos.cmake index d726e6b6..da4cc231 100644 --- a/Exercises/SetUpKokkos.cmake +++ b/Exercises/SetUpKokkos.cmake @@ -26,7 +26,7 @@ endif () # the default directory is inside the source tree. # This might break if the default in source directory is called from multiple cmake instances at the same time. -set(KokkosTutorials_KOKKOS_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/dep/kokkos" CACHE PATH "Description for KokkosTutorials_KOKKOS_SOURCE_DIR") +set(KokkosTutorials_KOKKOS_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/dep/kokkos" CACHE PATH "Where Kokkos sources are located") find_package(Kokkos CONFIG) @@ -34,8 +34,10 @@ if (Kokkos_FOUND) message(STATUS "Found Kokkos: ${Kokkos_DIR} (version \"${Kokkos_VERSION}\")") else () if (EXISTS ${KokkosTutorials_KOKKOS_SOURCE_DIR}) + message(STATUS "Using Kokkos from ${KokkosTutorials_KOKKOS_SOURCE_DIR}") add_subdirectory(${KokkosTutorials_KOKKOS_SOURCE_DIR} Kokkos) else () + message(STATUS "Downloading Kokkos to ${KokkosTutorials_KOKKOS_SOURCE_DIR}") include(FetchContent) FetchContent_Declare( Kokkos From 9e1041787f3a6b0e25b43dc9bddc0a048e79c952 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Fri, 25 Jul 2025 17:55:50 +0200 Subject: [PATCH 56/59] Upgrade to Kokkos 4.6.02 --- Exercises/SetUpKokkos.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Exercises/SetUpKokkos.cmake b/Exercises/SetUpKokkos.cmake index da4cc231..4a8c02d4 100644 --- a/Exercises/SetUpKokkos.cmake +++ b/Exercises/SetUpKokkos.cmake @@ -41,8 +41,8 @@ else () include(FetchContent) FetchContent_Declare( Kokkos - URL https://github.com/kokkos/kokkos/releases/download/4.5.01/kokkos-4.5.01.tar.gz - URL_HASH SHA256=52d003ffbbe05f30c89966e4009c017efb1662b02b2b73190670d3418719564c + URL https://github.com/kokkos/kokkos/releases/download/4.6.02/kokkos-4.6.02.tar.gz + URL_HASH SHA256=baf1ebbe67abe2bbb8bb6aed81b4247d53ae98ab8475e516d9c87e87fa2422ce SOURCE_DIR ${KokkosTutorials_KOKKOS_SOURCE_DIR} DOWNLOAD_EXTRACT_TIMESTAMP ON ) From e6e1c665247fd945960c1fa3045a2464db953410 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Fri, 25 Jul 2025 17:56:15 +0200 Subject: [PATCH 57/59] Add an example with a custom Kokkos source directory --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 62fc068e..afc1a910 100644 --- a/README.md +++ b/README.md @@ -93,3 +93,9 @@ cmake --build build_dir For specific use-cases, like when an internet connection is not available, the `KokkosTutorials_KOKKOS_SOURCE_DIR` can be used to point to a local Kokkos source directory. +For example, + +```shell +cmake -B build_dir -DKokkos_ENABLE_THREADS=ON -DCMAKE_DISABLE_FIND_PACKAGE_Kokkos=ON \ + -DKokkosTutorials_KOKKOS_SOURCE_DIR= +``` From 0e4b265ee1e8e595ecabc323f4681f5d8d55f05a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Chevalier?= Date: Mon, 28 Jul 2025 15:09:22 +0200 Subject: [PATCH 58/59] Remove a confusing warning Co-authored-by: Paul Zehner --- Exercises/SetUpKokkos.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exercises/SetUpKokkos.cmake b/Exercises/SetUpKokkos.cmake index 4a8c02d4..7f936782 100644 --- a/Exercises/SetUpKokkos.cmake +++ b/Exercises/SetUpKokkos.cmake @@ -28,7 +28,7 @@ endif () set(KokkosTutorials_KOKKOS_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/dep/kokkos" CACHE PATH "Where Kokkos sources are located") -find_package(Kokkos CONFIG) +find_package(Kokkos QUIET) if (Kokkos_FOUND) message(STATUS "Found Kokkos: ${Kokkos_DIR} (version \"${Kokkos_VERSION}\")") From 84c657b374ea2e34b607bd669e9d6335ca0d159d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Chevalier?= Date: Mon, 28 Jul 2025 15:11:49 +0200 Subject: [PATCH 59/59] Simplify README.md Co-authored-by: Paul Zehner --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index afc1a910..6e225cb5 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ test against an already installed Kokkos. ```shell # Download and build Kokkos and the tutorials, forcing the use of the internal Kokkos -cmake -B build_dir -DCMAKE_DISABLE_FIND_PACKAGE_Kokkos=ON # -DKokkos_* options +cmake -B build_dir -DCMAKE_DISABLE_FIND_PACKAGE_Kokkos=ON cmake --build build_dir ```