-
Notifications
You must be signed in to change notification settings - Fork 104
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
Global CMake for tutorials #91
base: main
Are you sure you want to change the base?
Conversation
One difficulty is that the first 3-4 exercises are not perfect Kokkos code and can have issue when a Kokkos device backend is enabled. |
This way, the CMakeLists.txt is almost standard. Remove old common.cmake
advanced_reductions.cpp and parallel_scan.cpp cannot compile due to missing code (the exercise).
Use "" for include instead of <> to avoid adding `-I.` flag.
Still have to check on a Cuda computer.
This allows to not pollute the source directory.
I will add Kokkos-Kernels tutorials before merge, but I want to know other thoughts before continuing. A lot of files are touched, but their modifications are pretty similar. |
KokkosTutorials_KOKKOS_SOURCE_DIR can be used to point to Kokkos source and avoid downloading.
I think this was a good improvement for the maintenance of the tutorials. It's sad to see this PR stalled. Could the current improvements be incorporated, and the moot points be tackled down by another PR? By the way, we used a very similar approach for the CExA Kokkos tutorials and it serves our needs just right. |
The conflicts would need to be resolved. |
The current The new Note that the download directory can be set instead. To re-use the already downloaded sources, we can either use a directory somewhere in the source tree that makes sense (and would be in |
Exercises/.cmake/FindKokkos.cmake
Outdated
endif () | ||
|
||
# Where to find Kokkos' source code. This might be set by the user. | ||
set(KokkosTutorials_KOKKOS_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/dep/kokkos" CACHE PATH "Description for KokkosTutorials_KOKKOS_SOURCE_DIR") |
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.
This line should be changed to use a unique directory not in the build tree.
I will update against the current |
…r19/cmake # Conflicts: # Exercises/common.cmake # Exercises/fortran-kokkosinterface/Begin/CMakeLists.txt # Exercises/fortran-kokkosinterface/Solution/CMakeLists.txt # Exercises/instances/CMakeLists.txt # Exercises/scatter_view/Begin/CMakeLists.txt # Exercises/subview/Begin/exercise_subview_begin.cpp # Exercises/subview/Solution/exercise_subview_solution.cpp # Exercises/virtualfunction/Begin/Makefile # Exercises/virtualfunction/Solution/Makefile
Before this commit, we had a fake "find_package(Kokkos)" to make tutorial CMakeLists.txt minimal. However, using builtin CMake features like `CMAKE_DISABLE_FIND_PACKAGE_<>` or `CMAKE_REQUIRE_FIND_PACKAGE_<>` was not working properly. This commit use a simple `include(../cmake/SetUpKokkos.cmake)`, and it is this file that can be a fine example of how to integrate Kokkos in a project.
This way we can promote the use of SHA256
@JBludau and @dalg24, I finally decided to follow your advice and I've factorized the code checking for a gpu. Furthermore, to apply the good practice described in the documentation to use either I can update the CI to use the new global CMake but I think it is better to leave it to a separate PR, this one being already too large. I do not understand the issue with Windows but it looks similar to the one of #107. |
Exercises/cmake/SetUpKokkos.cmake
Outdated
else () | ||
if (EXISTS ${KokkosTutorials_KOKKOS_SOURCE_DIR}) | ||
add_subdirectory(${KokkosTutorials_KOKKOS_SOURCE_DIR} Kokkos) | ||
else () |
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.
Leave early here too?
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.
Not blocking but do you know how does that play with multi-config generators?
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 will test and report it.
So, creating a custom |
Exercises/cmake/SetUpKokkos.cmake
Outdated
else () | ||
if (EXISTS ${KokkosTutorials_KOKKOS_SOURCE_DIR}) | ||
add_subdirectory(${KokkosTutorials_KOKKOS_SOURCE_DIR} Kokkos) | ||
else () |
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.
Not blocking but do you know how does that play with multi-config generators?
Co-authored-by: Paul Zehner <[email protected]>
Co-authored-by: Paul Zehner <[email protected]>
Co-authored-by: Paul Zehner <[email protected]>
…r19/cmake # Conflicts: # Exercises/tasking/Begin/CMakeLists.txt # Exercises/tasking/Solution/CMakeLists.txt
The goal is to provide a joint built for all exercises (and their solutions).
This way, compilation is straightforward for IDE users.
Currently, most of the exercises are built using the top-level CMake.
However, not all builds make sense, as CUDA builds are wrong for the first exercises. I have put configuration warnings when Kokkos is not configured correctly, as explaining why it is not working is still valuable.
I have also refactored the
fetch_content
implementation:it is now called in an overloaded.find_package
to keepCMakeLists.txt
as standard as possibleThe user can set three CMake variables to control the build system:
KokkosTutorials_KOKKOS_SOURCE_PATH
: to specify a Kokkos source directory and by-passfetch_content
when building a custom Kokkos.I can improve the global CMake by usingexternal_project
for the first exercises to "sandbox" their builds and allow a custom Kokkos.