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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 54 additions & 16 deletions install.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ title: Installation cheat sheet for Kokkos

# Kokkos install cheat sheet

<img title="Doc" alt="Doc" src="./images/doc_txt.svg" height="25"> https://kokkos.org/kokkos-core-wiki/ProgrammingGuide/Compiling.html
<img title="Doc" alt="Doc" src="./images/doc_txt.svg" height="25"> https://kokkos.org/kokkos-core-wiki/get-started/quick-start.html

<img title="Doc" alt="Doc" src="./images/doc_txt.svg" height="25"> https://kokkos.org/kokkos-core-wiki/building.html
<img title="Doc" alt="Doc" src="./images/doc_txt.svg" height="25"> https://kokkos.org/kokkos-core-wiki/ProgrammingGuide/Compiling.html

<img title="Doc" alt="Doc" src="./images/tutorial_txt.svg" height="25"> https://github.com/kokkos/kokkos-tutorials/blob/main/LectureSeries/KokkosTutorial_01_Introduction.pdf

Expand Down Expand Up @@ -41,14 +41,13 @@ title: Installation cheat sheet for Kokkos
| CMake | 3.18 | For better Fortran linking |
| CMake | 3.16 | |


<!--#ifndef PRINT-->
<img title="Doc" alt="Doc" src="./images/doc_txt.svg" height="25"> https://kokkos.org/kokkos-core-wiki/requirements.html
<img title="Doc" alt="Doc" src="./images/doc_txt.svg" height="25"> https://kokkos.org/kokkos-core-wiki/get-started/requirements.html
<!--#endif-->

## How to build Kokkos

### As part of your application
### As a sub-directory dependency

```cmake
add_subdirectory(path/to/kokkos)
Expand All @@ -65,13 +64,41 @@ cmake -B build \
<Kokkos compile options>
```

You may want to provide Kokkos as a Git submodule.

<!--#ifndef PRINT-->
<img title="Code" alt="Code" src="./images/code_txt.svg" height="25"> Code example:
<img title="Doc" alt="Doc" src="./images/doc_txt.svg" height="25"> https://kokkos.org/kokkos-core-wiki/get-started/integrating-kokkos-into-your-cmake-project.html#embedded-kokkos-via-add-subdirectory-and-git-submodules
<img title="Doc" alt="Doc" src="./images/doc_txt.svg" height="25"> https://cmake.org/cmake/help/latest/command/add_subdirectory.html#command:add_subdirectory
<!--#endif-->

### As an online dependency

```cmake
include(FetchContent)
FetchContent_Declare(
kokkos
URL https://github.com/kokkos/kokkos/releases/download/x.y.z/kokkos-x.y.z.zip
)
FetchContent_MakeAvailable(kokkos)
target_link_libraries(
my-app
Kokkos::kokkos
)
```

```sh
cd path/to/your/code
cmake -B build \
-DCMAKE_CXX_COMPILER=<your C++ compiler> \
<Kokkos compile options>
```

- https://github.com/kokkos/kokkos/tree/master/example/build_cmake_in_tree
<!--#ifndef PRINT-->
<img title="Doc" alt="Doc" src="./images/doc_txt.svg" height="25"> https://kokkos.org/kokkos-core-wiki/get-started/integrating-kokkos-into-your-cmake-project.html#embedded-kokkos-via-fetchcontent
<img title="Doc" alt="Doc" src="./images/doc_txt.svg" height="25"> https://cmake.org/cmake/help/latest/module/FetchContent.html
<!--#endif-->

### As an external library
### As an external dependency

#### Configure, build and install Kokkos

Expand All @@ -85,14 +112,10 @@ cmake --build build
cmake --install build
```

<!--#ifndef PRINT-->
<img title="Doc" alt="Doc" src="./images/doc_txt.svg" height="25"> https://kokkos.org/kokkos-core-wiki/building.html
<!--#endif-->

#### Use in your code

```cmake
find_package(Kokkos REQUIRED)
find_package(Kokkos x.y.z REQUIRED)
target_link_libraries(
my-app
Kokkos::kokkos
Expand All @@ -107,16 +130,31 @@ cmake -B build \
```

<!--#ifndef PRINT-->
<img title="Doc" alt="Doc" src="./images/doc_txt.svg" height="25"> https://kokkos.org/kokkos-core-wiki/get-started/integrating-kokkos-into-your-cmake-project.html#external-kokkos-recommended-for-most-users
<img title="Doc" alt="Doc" src="./images/doc_txt.svg" height="25"> https://cmake.org/cmake/help/latest/guide/tutorial/index.html
<!--#endif-->

### As an external or sub-directory/online dependency

```cmake
find_package(Kokkos x.y.z QUIET)
if(Kokkos_FOUND)
message(STATUS "Using installed Kokkos in ${Kokkos_DIR}")
else()
message(STATUS "Using Kokkos from ...")
# use either the sub-directory or the online dependency approach
endif()
```

Depending if Kokkos is already installed, you may have to call CMake with `-DKokkos_ROOT`, or with Kokkos compile options.

<!--#ifndef PRINT-->

### As a Spack package

TODO finish this part

<img title="Doc" alt="Doc" src="./images/doc_txt.svg" height="25"> See https://kokkos.org/kokkos-core-wiki/building.html#spack
<img title="Doc" alt="Doc" src="./images/doc_txt.svg" height="25"> https://kokkos.org/kokkos-core-wiki/get-started/package-managers.html?highlight=spack#spack-https-spack-io

<!--#endif-->

Expand Down Expand Up @@ -166,7 +204,7 @@ See [architecture-specific options](#architecture-specific-options).

</details>

<img title="Doc" alt="Doc" src="./images/doc_txt.svg" height="25"> For more, see https://kokkos.org/kokkos-core-wiki/keywords.html
<img title="Doc" alt="Doc" src="./images/doc_txt.svg" height="25"> https://kokkos.org/kokkos-core-wiki/get-started/configuration-guide.html
<!--#endif-->

### Architecture-specific options
Expand Down Expand Up @@ -350,7 +388,7 @@ They can be deduced from the device if present at CMake configuration time.
<!--#ifndef PRINT-->
### Third-party Libraries (TPLs)

<img title="Doc" alt="Doc" src="./images/doc_txt.svg" height="25"> See https://kokkos.org/kokkos-core-wiki/keywords.html#third-party-libraries-tpls
<img title="Doc" alt="Doc" src="./images/doc_txt.svg" height="25"> https://kokkos.org/kokkos-core-wiki/get-started/configuration-guide.html#keywords-tpls
<!--#endif-->

### Examples for the most common architectures
Expand Down
28 changes: 14 additions & 14 deletions patches/print/install.tex.diff
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
--- .install.tex 2024-06-11 16:45:25.798270906 +0200
+++ install.tex 2024-06-11 16:45:51.158407213 +0200
@@ -497,7 +497,7 @@
--- .install.tex 2025-02-28 15:37:52.208429178 +0100
+++ install.tex 2025-02-28 15:38:14.746538842 +0100
@@ -471,7 +471,7 @@
\KeywordTok{include}\NormalTok{(FetchContent)}
\FunctionTok{FetchContent\_Declare}\NormalTok{(}
\NormalTok{ kokkos}
-\NormalTok{ URL https://github.com/kokkos/kokkos/releases/download/x.y.z/kokkos{-}x.y.z.zip}
+\NormalTok{ URL https://github.com/kokkos/kokkos/releases/download/x.y.z/\break{}kokkos{-}x.y.z.zip}
\NormalTok{)}
\FunctionTok{FetchContent\_MakeAvailable}\NormalTok{(kokkos)}
\KeywordTok{target\_link\_libraries}\NormalTok{(}
@@ -645,7 +645,7 @@
\begin{tabularx}{\linewidth}{llX}
\toprule

-\tblhead{Option} & \tblhead{Architecture} & \tblhead{Associated
+\tblhead{Option} & \tblhead{Arch.} & \tblhead{Associated
cards} \\ \midrule

\texttt{-DKokkos\_ARCH\_AMD\_GFX942=ON} & GFX942 & MI300A, MI300X \\
@@ -537,7 +537,7 @@
\texttt{-DKokkos\_ARCH\_AMD\_GFX942\_APU=ON} & GFX942 APU & MI300A \\
@@ -688,7 +688,7 @@
\begin{tabularx}{\linewidth}{lllX}
\toprule

Expand All @@ -18,12 +27,3 @@
cards} \\ \midrule

\texttt{-DKokkos\_ARCH\_HOPPER90=ON} & Hopper & 9.0 & H200, H100 \\
@@ -639,7 +639,7 @@
\ExtensionTok{{-}DKokkos\_ENABLE\_SYCL}\NormalTok{=ON }\KeywordTok{\textbackslash{}}
\ExtensionTok{{-}DKokkos\_ARCH\_INTEL\_PVC}\NormalTok{=ON }\KeywordTok{\textbackslash{}}
\ExtensionTok{{-}DKokkos\_ENABLE\_OPENMP}\NormalTok{=ON }\KeywordTok{\textbackslash{}}
- \ExtensionTok{{-}DCMAKE\_CXX\_FLAGS}\NormalTok{=}\StringTok{"{-}fp{-}model=precise"}\NormalTok{ \# for math precision}
+ \ExtensionTok{{-}DCMAKE\_CXX\_FLAGS}\NormalTok{=}\StringTok{"{-}fp{-}model=precise"}\CommentTok{ \# for math precision}
\end{Highlighting}
\end{Shaded}