-
Notifications
You must be signed in to change notification settings - Fork 118
Global CMake for tutorials #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
9d26afe
1b2b56a
50bf4e0
56003c8
6268211
dec987e
4f30736
f2cc0c8
9ebf652
c4451a0
1a9d282
1b1dedc
1a07316
9bce058
7c6a676
8b5cd95
5779c0f
dacde70
2bc96df
46fa1d0
d6e6530
fe583b3
5656d32
af3141e
5ccfe61
7bdf80c
bfe7e16
798effa
a451ee4
0e178f0
90f978c
40db39d
96cf66d
dba7191
b4d1484
99b1c78
93462e7
f2e44a3
a96a6e2
f1b5bff
208dcb6
263297e
1a6e198
1c404fc
0b9221a
cd94126
4ec18a0
e0ee40b
d21fe57
d3daa7f
bffe62b
5f3a382
cdb445f
e514fc7
b148a85
8a3aca6
c47a017
21baf0d
1bafe0e
9e10417
e6e1c66
0e4b265
84c657b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Exercises/dep | ||
*.o | ||
*.host | ||
*.cuda | ||
KokkosCore_config.h | ||
KokkosCore_config.tmp | ||
*.a | ||
|
||
cedricchevalier19 marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(KokkosTutorials) | ||
|
||
# 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/simd) | ||
# FIXME update the code | ||
# add_subdirectory(Exercises/simd_warp) | ||
|
||
add_subdirectory(Exercises/advanced_reductions) | ||
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) | ||
cedricchevalier19 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(KokkosTutorial01) | ||
include(../../common.cmake) | ||
|
||
# Add a custom module path for find_package(Kokkos) | ||
include(../../SetUpKokkos.cmake) | ||
|
||
KokkosTutorials_WarnGPU() | ||
|
||
add_executable(01_Exercise exercise_1_begin.cpp) | ||
target_link_libraries(01_Exercise Kokkos::kokkos) | ||
|
||
cedricchevalier19 marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(KokkosTutorial01) | ||
|
||
add_subdirectory(Begin) | ||
add_subdirectory(Solution) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(KokkosTutorial01) | ||
include(../../common.cmake) | ||
|
||
add_executable(01_Exercise exercise_1_solution.cpp) | ||
target_link_libraries(01_Exercise Kokkos::kokkos) | ||
# Add a custom module path for find_package(Kokkos) | ||
include(../../SetUpKokkos.cmake) | ||
|
||
KokkosTutorials_WarnGPU() | ||
|
||
add_executable(01_Solution exercise_1_solution.cpp) | ||
target_link_libraries(01_Solution Kokkos::kokkos) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(KokkosTutorial02) | ||
include(../../common.cmake) | ||
|
||
add_executable(02_Exercise exercise_2_begin.cpp) | ||
target_link_libraries(02_Exercise Kokkos::kokkos) | ||
# Add a custom module path for find_package(Kokkos) | ||
include(../../SetUpKokkos.cmake) | ||
|
||
KokkosTutorials_WarnGPU() | ||
|
||
add_executable(02_Exercise exercise_2_begin.cpp) | ||
target_link_libraries(02_Exercise Kokkos::kokkos) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(KokkosTutorial02) | ||
|
||
add_subdirectory(Begin) | ||
add_subdirectory(Solution) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(KokkosTutorial02) | ||
include(../../common.cmake) | ||
|
||
add_executable(02_Exercise exercise_2_solution.cpp) | ||
target_link_libraries(02_Exercise Kokkos::kokkos) | ||
# Add a custom module path for find_package(Kokkos) | ||
include(../../SetUpKokkos.cmake) | ||
|
||
KokkosTutorials_WarnGPU() | ||
|
||
add_executable(02_Solution exercise_2_solution.cpp) | ||
target_link_libraries(02_Solution Kokkos::kokkos) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(KokkosTutorial03) | ||
include(../../common.cmake) | ||
|
||
# Add a custom module path for find_package(Kokkos) | ||
include(../../SetUpKokkos.cmake) | ||
|
||
add_executable(03_Exercise exercise_3_begin.cpp) | ||
target_link_libraries(03_Exercise Kokkos::kokkos) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(KokkosTutorial03) | ||
|
||
add_subdirectory(Begin) | ||
add_subdirectory(Solution) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(KokkosTutorial03) | ||
include(../../common.cmake) | ||
|
||
add_executable(03_Exercise exercise_3_solution.cpp) | ||
target_link_libraries(03_Exercise Kokkos::kokkos) | ||
|
||
# Add a custom module path for find_package(Kokkos) | ||
include(../../SetUpKokkos.cmake) | ||
|
||
add_executable(03_Solution exercise_3_solution.cpp) | ||
target_link_libraries(03_Solution Kokkos::kokkos) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(KokkosTutorial04) | ||
include(../../common.cmake) | ||
|
||
# Add a custom module path for find_package(Kokkos) | ||
include(../../SetUpKokkos.cmake) | ||
|
||
add_executable(04_Exercise exercise_4_begin.cpp) | ||
target_link_libraries(04_Exercise Kokkos::kokkos) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(KokkosTutorial04) | ||
|
||
add_subdirectory(Begin) | ||
add_subdirectory(Solution) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(KokkosTutorial04) | ||
include(../../common.cmake) | ||
|
||
add_executable(04_Exercise exercise_4_solution.cpp) | ||
target_link_libraries(04_Exercise Kokkos::kokkos) | ||
|
||
# Add a custom module path for find_package(Kokkos) | ||
include(../../SetUpKokkos.cmake) | ||
|
||
add_executable(04_Solution exercise_4_solution.cpp) | ||
target_link_libraries(04_Solution Kokkos::kokkos) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Convenience macro to warn the user if a GPU backend is enabled | ||
macro(KokkosTutorials_WarnGPU) | ||
if (Kokkos_ENABLE_CUDA OR Kokkos_ENABLE_HIP OR Kokkos_ENABLE_SYCL OR Kokkos_ENABLE_OPENMPTARGET OR Kokkos_ENABLE_HPX) | ||
message(WARNING "cmake" | ||
"a Kokkos accelerator backend is enabled, it might cause issue with the current program" | ||
"Please recompile with only a host backend enabled (e.g. -DKokkos_ENABLE_OPENMP=ON)") | ||
endif () | ||
endmacro() | ||
|
||
# Early return if Kokkos is already set up | ||
# We do not use Kokkos_FOUND as it is not globally defined | ||
if (TARGET Kokkos::kokkos) | ||
return() | ||
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 () | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then, if Kokkos is already found, the build type is not specified for the files of the tutorial. Is it what we want? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've kept how it was working. I do not really see any added value and I am happy to remove this part. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's true that CMake always let the user choose what kind of build they want. |
||
|
||
# Where to find Kokkos' source code. This might be set by the user. | ||
# In order to automatically share the download between exercises when they are compiled individually, | ||
# the default directory is inside the source tree. | ||
# This might break if the default in source directory is called from multiple cmake instances at the same time. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you elaborate? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If several CMake instances download at the same time I am not it will always work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, maybe you can rework the sentence then. |
||
|
||
set(KokkosTutorials_KOKKOS_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/dep/kokkos" CACHE PATH "Where Kokkos sources are located") | ||
|
||
find_package(Kokkos QUIET) | ||
|
||
if (Kokkos_FOUND) | ||
message(STATUS "Found Kokkos: ${Kokkos_DIR} (version \"${Kokkos_VERSION}\")") | ||
else () | ||
if (EXISTS ${KokkosTutorials_KOKKOS_SOURCE_DIR}) | ||
message(STATUS "Using Kokkos from ${KokkosTutorials_KOKKOS_SOURCE_DIR}") | ||
add_subdirectory(${KokkosTutorials_KOKKOS_SOURCE_DIR} Kokkos) | ||
else () | ||
message(STATUS "Downloading Kokkos to ${KokkosTutorials_KOKKOS_SOURCE_DIR}") | ||
include(FetchContent) | ||
FetchContent_Declare( | ||
Kokkos | ||
URL https://github.com/kokkos/kokkos/releases/download/4.6.02/kokkos-4.6.02.tar.gz | ||
URL_HASH SHA256=baf1ebbe67abe2bbb8bb6aed81b4247d53ae98ab8475e516d9c87e87fa2422ce | ||
SOURCE_DIR ${KokkosTutorials_KOKKOS_SOURCE_DIR} | ||
DOWNLOAD_EXTRACT_TIMESTAMP ON | ||
) | ||
FetchContent_MakeAvailable(Kokkos) | ||
endif () | ||
endif () |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(KokkosTutorial01) | ||
include(../../common.cmake) | ||
project(KokkosTutorialAdvancedReductions) | ||
|
||
# Add a custom module path for find_package(Kokkos) | ||
include(../../SetUpKokkos.cmake) | ||
|
||
add_executable(AdvancedReductions advanced_reductions.cpp) | ||
target_link_libraries(AdvancedReductions Kokkos::kokkos) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,8 @@ int main(int argc, char *argv[]) { | |
n, KOKKOS_LAMBDA(int i) { view(i) = 1 + i / 10.; }); | ||
|
||
double result; | ||
Kokkos::parallel_reduce(n, GeometricMean{view}, result); | ||
// EXERCISE uncomment the following line when GeometricMean is implemented | ||
// Kokkos::parallel_reduce(n, GeometricMean{view}, result); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment here, please propose this change as its own PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change was necessary in order to compile this exercise. I will comment out the |
||
|
||
auto host_view = | ||
Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, view); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(KokkosTutorialAdvancedReductions) | ||
|
||
add_subdirectory(Begin) | ||
add_subdirectory(Solution) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(KokkosTutorial01) | ||
include(../../common.cmake) | ||
project(KokkosTutorialAdvancedReductions) | ||
|
||
add_executable(AdvancedReductions advanced_reductions.cpp) | ||
target_link_libraries(AdvancedReductions Kokkos::kokkos) | ||
# Add a custom module path for find_package(Kokkos) | ||
include(../../SetUpKokkos.cmake) | ||
|
||
add_executable(AdvancedReductions_Solution advanced_reductions.cpp) | ||
target_link_libraries(AdvancedReductions_Solution Kokkos::kokkos) |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(KokkosTutorialDualView) | ||
include(../../common.cmake) | ||
|
||
# Add a custom module path for find_package(Kokkos) | ||
include(../../SetUpKokkos.cmake) | ||
|
||
add_executable(dualview dual_view_exercise.cpp) | ||
target_link_libraries(dualview Kokkos::kokkos) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(KokkosTutorialDualView) | ||
|
||
add_subdirectory(Begin) | ||
add_subdirectory(Solution) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(KokkosTutorialDualView) | ||
include(../../common.cmake) | ||
|
||
add_executable(dualview dual_view_exercise.cpp) | ||
target_link_libraries(dualview Kokkos::kokkos) | ||
|
||
# Add a custom module path for find_package(Kokkos) | ||
include(../../SetUpKokkos.cmake) | ||
|
||
add_executable(dualview_Solution dual_view_exercise.cpp) | ||
target_link_libraries(dualview_Solution Kokkos::kokkos) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(KokkosTutorialInstances) | ||
|
||
# Add a custom module path for find_package(Kokkos) | ||
include(../../SetUpKokkos.cmake) | ||
|
||
add_executable(Instances_exercise instances_begin.cpp) | ||
target_link_libraries(Instances_exercise Kokkos::kokkos) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,4 +137,3 @@ int main( int argc, char* argv[] ) | |
|
||
return 0; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
#Todo: Add CMake build | ||
cmake_minimum_required(VERSION 3.16) | ||
project(KokkosInstances) | ||
|
||
add_subdirectory(Begin) | ||
add_subdirectory(Solution) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(KokkosTutorialInstances) | ||
|
||
# Add a custom module path for find_package(Kokkos) | ||
include(../../SetUpKokkos.cmake) | ||
|
||
add_executable(Instances_solution instances_solution.cpp) | ||
target_link_libraries(Instances_solution Kokkos::kokkos) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,4 +126,3 @@ int main( int argc, char* argv[] ) | |
|
||
return 0; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(KokkosTutorialMdRange) | ||
include(../../common.cmake) | ||
|
||
# Add a custom module path for find_package(Kokkos) | ||
include(../../SetUpKokkos.cmake) | ||
|
||
add_executable(mdrange_exercise exercise_mdrange_begin.cpp) | ||
target_link_libraries(mdrange_exercise Kokkos::kokkos) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(KokkosTutorialMDRange) | ||
|
||
add_subdirectory(Begin) | ||
add_subdirectory(Solution) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
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 a custom module path for find_package(Kokkos) | ||
include(../../SetUpKokkos.cmake) | ||
|
||
add_executable(mdrange_Solution exercise_mdrange_solution.cpp) | ||
target_link_libraries(mdrange_Solution Kokkos::kokkos) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am in general against .gitignores if possible ... I want to see what changed and I think devs should be aware of what they push ...
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think most of it can go out, besides
Exercises/dep
, since we're only relying on CMake. But I would addbuild*/
.I removed the
.gitignore
after a build to see whatgit status
gives, and it's Kokkos sources and the build directories.