From 1b2b56a0c2b9c586eb4cc81c72b990a2fe329505 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Sun, 12 May 2024 18:14:28 +0200 Subject: [PATCH 01/33] 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 02/33] 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 03/33] 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 04/33] 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 05/33] 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 06/33] `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 07/33] 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 08/33] 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 09/33] 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 10/33] 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 11/33] 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 12/33] 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 13/33] 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 14/33] 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 15/33] 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 16/33] 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 17/33] 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 18/33] 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 19/33] 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 20/33] 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 21/33] 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 22/33] 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 23/33] 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 24/33] 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 25/33] 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 26/33] 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 27/33] 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 28/33] 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 29/33] 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 30/33] 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 31/33] 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 32/33] 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 33/33] 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