From 9e9007a03120f4abd09ae264a48f1f4668b62595 Mon Sep 17 00:00:00 2001 From: JBludau Date: Sat, 27 Jul 2024 00:08:25 +0200 Subject: [PATCH 1/3] added section about separation of compilation --- docs/source/building.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/source/building.md b/docs/source/building.md index 0d6ad9bd9..82a7ada0f 100644 --- a/docs/source/building.md +++ b/docs/source/building.md @@ -49,6 +49,20 @@ There are numerous device backends, options, and architecture-specific optimizat ```` which activates the OpenMP backend. All the options controlling device backends, options, architectures, and third-party libraries (TPLs) are given in [CMake Keywords](../keywords). +## Separate Compilation via CMake Language + +Kokkos supports separating the compilation of source files using Kokkos from others. This is controlled similar to a CMake language. The feature requires Kokkos to be compiled with the keyword `Kokkos_ENABLE_COMPILE_AS_CMAKE_LANGUAGE=ON`. The availability of the feature can be checked via `find_package(Kokkos COMPONENTS separable_compilation)`. +The `kokkos_compilation` CMake function marks files in the application's source that contain Kokkos code to be compiled with the correct compiler and flags. +````cmake +# this function is provided to easily select which files use the same compiler as Kokkos +# GLOBAL --> all files +# TARGET --> all files in a target +# SOURCE --> specific source files +# DIRECTORY --> all files in directory +# PROJECT --> all files/targets in a project/subproject +kokkos_compilation(SOURCE example.cpp) +```` +The example in `examples/cmake_build_installed_kk_as_language` can help get you started. ## Known Issues @@ -61,6 +75,9 @@ which activates the OpenMP backend. All the options controlling device backends, * In a mixed C++/Fortran code, CMake will use the C++ linker by default. If you override this behavior and use Fortran as the link language, the link may break because Kokkos adds linker flags expecting the linker to be C++. Prior to CMake 3.18, Kokkos has no way of detecting in downstream projects that the linker was changed to Fortran. From CMake 3.18, Kokkos can use generator expressions to avoid adding flags when the linker is not C++. Note: Kokkos will not add any linker flags in this Fortran case. The user will be entirely on their own to add the appropriate linker flags. +### MSVC +* Building an application that uses Kokkos with Microsoft Visual Studio and the `Cuda` backend enabled, requires the use of the CMake language feature, see [Separate Compilation](#separate-compilation-via-cmake-language). + ## Raw Makefile Raw Makefiles are only supported via inline builds. See below. From e0b1f07518a801b4ee43d08618a7482b1099524c Mon Sep 17 00:00:00 2001 From: JBludau Date: Sat, 27 Jul 2024 00:08:55 +0200 Subject: [PATCH 2/3] added COMPILE_AS_CMAKE_LANGUAGE to cmake keywords --- docs/source/keywords.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/source/keywords.rst b/docs/source/keywords.rst index 96a1dbc4d..24b5024af 100644 --- a/docs/source/keywords.rst +++ b/docs/source/keywords.rst @@ -151,6 +151,10 @@ General options * Aggressively vectorize loops * ``OFF`` + * * ``Kokkos_ENABLE_COMPILE_AS_CMAKE_LANGUAGE`` + * Enables Kokkos behaving like a CMake language, see `Separate Compilation `_. + * ``OFF`` + Debugging --------- .. list-table:: From 5c04488b3d37a90db47e5ff3cede6648b462c873 Mon Sep 17 00:00:00 2001 From: JBludau <104908666+JBludau@users.noreply.github.com> Date: Thu, 1 Aug 2024 17:35:33 +0200 Subject: [PATCH 3/3] wording changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cédric Chevalier --- docs/source/building.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/building.md b/docs/source/building.md index 82a7ada0f..97648dbcd 100644 --- a/docs/source/building.md +++ b/docs/source/building.md @@ -51,7 +51,7 @@ which activates the OpenMP backend. All the options controlling device backends, ## Separate Compilation via CMake Language -Kokkos supports separating the compilation of source files using Kokkos from others. This is controlled similar to a CMake language. The feature requires Kokkos to be compiled with the keyword `Kokkos_ENABLE_COMPILE_AS_CMAKE_LANGUAGE=ON`. The availability of the feature can be checked via `find_package(Kokkos COMPONENTS separable_compilation)`. +Kokkos supports separating the compilation of source files using Kokkos from others. This is controlled similarly to a CMake language. The feature requires Kokkos to be compiled with the keyword `Kokkos_ENABLE_COMPILE_AS_CMAKE_LANGUAGE=ON`. The availability of the feature can be requested via `find_package(Kokkos COMPONENTS separable_compilation)`. The `kokkos_compilation` CMake function marks files in the application's source that contain Kokkos code to be compiled with the correct compiler and flags. ````cmake # this function is provided to easily select which files use the same compiler as Kokkos