Skip to content

Add section to let CMake manage the Kokkos dependency #41

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

Open
wants to merge 6 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
108 changes: 77 additions & 31 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 @@ -40,17 +40,31 @@ 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
## How to integrate Kokkos

### As an external dependency

#### Configure, build and install Kokkos

```sh
git clone -b x.y.zz https://github.com/kokkos/kokkos.git
cd kokkos
cmake -B build \
-DCMAKE_CXX_COMPILER=<your C++ compiler> \
-DCMAKE_INSTALL_PREFIX=path/to/kokkos/install \
<Kokkos compile options>
cmake --build build
cmake --install build
```

### As part of your application
#### Setup, and configure your code

```cmake
add_subdirectory(path/to/kokkos)
find_package(Kokkos x.y.z REQUIRED)
target_link_libraries(
my-app
Kokkos::kokkos
Expand All @@ -61,52 +75,84 @@ target_link_libraries(
cd path/to/your/code
cmake -B build \
-DCMAKE_CXX_COMPILER=<your C++ compiler> \
<Kokkos compile options>
-DKokkos_ROOT=path/to/kokkos/install
```

<!--#ifndef PRINT-->
<img title="Code" alt="Code" src="./images/code_txt.svg" height="25"> Code example:

- https://github.com/kokkos/kokkos/tree/master/example/build_cmake_in_tree
<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 library
### As an internal dependency

#### Configure, build and install Kokkos
#### Setup with a Git submodule

```sh
cd path/to/kokkos
cmake -B build \
-DCMAKE_CXX_COMPILER=<your C++ compiler> \
-DCMAKE_INSTALL_PREFIX=path/to/kokkos/install \
<Kokkos compile options>
cmake --build build
cmake --install build
git submodule add -b x.y.zz https://github.com/kokkos/kokkos.git tpls/kokkos
```

```cmake
add_subdirectory(path/to/kokkos)
target_link_libraries(
my-app
Kokkos::kokkos
)
```

<!--#ifndef PRINT-->
<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/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
<img title="Doc" alt="Doc" src="./images/doc_txt.svg" height="25"> https://git-scm.com/book/en/v2/Git-Tools-Submodules
<!--#endif-->

#### Use in your code
#### Setup with FetchContent

```cmake
find_package(Kokkos REQUIRED)
include(FetchContent)
FetchContent_Declare(
kokkos
URL https://github.com/kokkos/kokkos/releases/download/x.y.zz/kokkos-x.y.zz.tar.gz
URL_HASH SHA256=<hash for x.y.z archive>
)
FetchContent_MakeAvailable(kokkos)
target_link_libraries(
my-app
Kokkos::kokkos
)
```

#### Configure your code

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

You may combine the external/internal dependency approaches.

<!--#ifndef PRINT-->
<img title="Doc" alt="Doc" src="./images/doc_txt.svg" height="25"> https://cmake.org/cmake/help/latest/guide/tutorial/index.html
<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-->

<!--#ifndef PRINT-->

### As an external or internal 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 ...")
# with either a Git submodule or FetchContent
endif()
```

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

<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#supporting-both-external-and-embedded-kokkos
<!--#endif-->

<!--#ifndef PRINT-->
Expand All @@ -115,7 +161,7 @@ cmake -B build \

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 @@ -165,7 +211,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 @@ -346,7 +392,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 All @@ -373,7 +419,7 @@ cmake \
-DKokkos_ARCH_AMD_GFX942_APU=ON
```

Environment variable is required to access host allocations from the device.
The environment variable is required to access host allocations from the device.

#### AMD MI250 GPU with HIP

Expand All @@ -398,7 +444,7 @@ cmake \
-DCMAKE_CXX_FLAGS="-fp-model=precise"
```

Last option is for math operators precision.
The last option is required for math operators precision.

#### NVIDIA H100 GPU with CUDA

Expand Down
44 changes: 30 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-04-29 15:05:59.861833564 +0200
+++ install.tex 2025-04-29 15:09:46.159589195 +0200
@@ -591,7 +591,7 @@
\KeywordTok{include}\NormalTok{(FetchContent)}
\FunctionTok{FetchContent\_Declare}\NormalTok{(}
\NormalTok{ kokkos}
-\NormalTok{ URL https://github.com/kokkos/kokkos/releases/download/x.y.zz/kokkos{-}x.y.zz.tar.gz}
+\NormalTok{ URL https://github.com/kokkos/kokkos/releases/download/x.y.zz\break{}/kokkos{-}x.y.zz.tar.gz}
\NormalTok{ URL\_HASH SHA256=\textless{}hash for x.y.z archive\textgreater{}}
\NormalTok{)}
\FunctionTok{FetchContent\_MakeAvailable}\NormalTok{(kokkos)}
@@ -709,7 +709,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 \\
@@ -752,7 +752,7 @@
\begin{tabularx}{\linewidth}{lllX}
\toprule

Expand All @@ -18,12 +27,19 @@
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}

@@ -766,6 +766,15 @@
\texttt{-DKokkos\_ARCH\_VOLTA70=ON} & Volta & 7.0 & V100 \\
\texttt{-DKokkos\_ARCH\_PASCAL61=ON} & Pascal & 6.1 & P6, P40, P4 \\
\texttt{-DKokkos\_ARCH\_PASCAL60=ON} & Pascal & 6.0 & P100 \\
+\bottomrule
+\end{tabularx}
+
+\begin{tabularx}{\linewidth}{lllX}
+\toprule
+
+\tblhead{Option} & \tblhead{Arch.} & \tblhead{CC} & \tblhead{Associated
+cards} \\ \midrule
+
\texttt{-DKokkos\_ARCH\_MAXWELL53=ON} & Maxwell & 5.3 & \\
\texttt{-DKokkos\_ARCH\_MAXWELL52=ON} & Maxwell & 5.2 & M6, M60, M4,
M40 \\