Skip to content
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

Add section to let CMake manage the Kokkos dependency #41

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

pzehner
Copy link
Member

@pzehner pzehner commented Feb 21, 2025

Warning: this currently destroys the page layout.

@pzehner pzehner added the enhancement New feature or request label Feb 21, 2025
@pzehner pzehner self-assigned this Feb 21, 2025
install.md Outdated
### As a dependency managed by CMake

```cmake
find_package(Kokkos CONFIG)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor questions:

  • Do you think it is a good practice to explicitly set CONFIG ?
  • If we allow find_package to fail, should we put it in QUIET ?

I am still skeptical with this mixed approach though. If Kokkos is found, the options are already set. On the other hand, if it is not found, the user is responsible to select the options. We use a similar approach in DDC, with submodules instead, and I don't know if we should advertise about it.

Copy link
Member Author

@pzehner pzehner Feb 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about CONFIG, to be honest. I started using it blindly when I saw it somewhere. So I tried the different options:

  • find_package(Kokkos)
    • Kokkos installed:
      -- Enabled Kokkos devices: SERIAL;CUDA
      -- kokkos_launch_compiler is enabled globally. C++ compiler commands with -DKOKKOS_DEPENDENCE will be redirected to the appropriate compiler for Kokkos
      
    • Kokkos not installed:
      CMake Warning at CMakeLists.txt:8 (find_package):
      By not providing "FindKokkos.cmake" in CMAKE_MODULE_PATH this project has
      asked CMake to find a package configuration file provided by "Kokkos", but
      CMake did not find one.
      
      Could not find a package configuration file provided by "Kokkos" (requested
      version 4.3.1) with any of the following names:
      
        KokkosConfig.cmake
        kokkos-config.cmake
      
      Add the installation prefix of "Kokkos" to CMAKE_PREFIX_PATH or set
      "Kokkos_DIR" to a directory containing one of the above files.  If "Kokkos"
      provides a separate development package or SDK, be sure it has been
      installed.
      -- Setting default Kokkos CXX standard to 17
      -- Kokkos version: 4.3.1
      <snip>
      
      The bunch of warnings is not helpful;
  • find_package(Kokkos CONFIG)
    • Kokkos installed:
      -- Enabled Kokkos devices: SERIAL;CUDA
      -- kokkos_launch_compiler is enabled globally. C++ compiler commands with -DKOKKOS_DEPENDENCE will be redirected to the appropriate compiler for Kokkos
      
    • Kokkos not installed:
      -- Could NOT find Kokkos (missing: Kokkos_DIR)
      -- Setting default Kokkos CXX standard to 17
      -- Kokkos version: 4.3.1
      <snip>
      
      I saw tutorial attendants being confused about the first line;
  • find_package(Kokkos QUIET)
    • Kokkos installed:
      -- Enabled Kokkos devices: SERIAL;CUDA
      -- kokkos_launch_compiler is enabled globally. C++ compiler commands with -DKOKKOS_DEPENDENCE will be redirected to the appropriate compiler for Kokkos
      
    • Kokkos not installed:
      -- Setting default Kokkos CXX standard to 17
      -- Kokkos version: 4.3.1
      <snip>
      

So, QUIET seems to be more appropriate.

I see your point. The subdirectory (aka submodule) approach already in the cheat sheet does not provide the "find package otherwise use a subdirectory" approach.

Initially, I wanted to give a flexible solution. Note that this is what Daniel advised Keigo Nitadori (during the last Kokkos Café) to do when using CMake. But this is not the most flexible solution, which would be too long for this cheat sheet.

Eventually, I think I can limit the section to just using FetchContent, but I feel something would be missing. I would add a specific "Mixed approach" section which also warns about what you just said.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually, the Kokkos documentation proposes the 3 + 1 approaches altogether: https://kokkos.org/kokkos-core-wiki/get-started/integrating-kokkos-into-your-cmake-project.html

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I used the approach of the documentation.

Copy link
Member

@tpadioleau tpadioleau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the end I don't think we should go into the details of how to use FetchContent etc. This is largely opinionated. I would rather describe the package name, the targets and the components available. Similar to the Targets tab in https://conan.io/center/recipes/ginkgo. We can also mention that Kokkos supports being added as a subdirectory, this implies for example that Kokkos::kokkos also exists which is not obvious.

@pzehner
Copy link
Member Author

pzehner commented Mar 11, 2025

I don't know, I think it gives practical directions about "how to include Kokkos as a dependency to my project," which is unfortunately not trivial at this time.

You cannot simply do:

conan install kokkos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants