diff --git a/CMakeLists.txt b/CMakeLists.txt index 0435c46a3fe..f341af91ee7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,7 +66,6 @@ option(GINKGO_FORCE_GPU_AWARE_MPI "Assert that the MPI library is GPU aware. Thi catastrophically in case the MPI implementation is not GPU Aware, and GPU aware functionality has been forced" OFF) set(GINKGO_CI_TEST_OMP_PARALLELISM "4" CACHE STRING "The number of OpenMP threads to use for a test binary during CTest resource file-constrained test.") -option(GINKGO_EXTENSION_KOKKOS "Enables the Kokkos extension in Ginkgo. A Kokkos installation is required in the ON case." OFF) option(GINKGO_EXTENSION_KOKKOS_CHECK_TYPE_ALIGNMENT "Enables mapping to Kokkos types to check the alignment of the source and target type." ON) gko_rename_cache(GINKGO_COMPILER_FLAGS CMAKE_CXX_FLAGS BOOL "Flags used by the CXX compiler during all build types.") gko_rename_cache(GINKGO_CUDA_COMPILER_FLAGS CMAKE_CUDA_FLAGS BOOL "Flags used by the CUDA compiler during all build types.") @@ -282,6 +281,10 @@ else() endif() configure_file(${Ginkgo_SOURCE_DIR}/include/ginkgo/config.hpp.in ${Ginkgo_BINARY_DIR}/include/ginkgo/config.hpp @ONLY) +configure_file(${Ginkgo_SOURCE_DIR}/include/ginkgo/extensions/kokkos/config.hpp.in + ${Ginkgo_BINARY_DIR}/include/ginkgo/extensions/kokkos/config.hpp + @ONLY +) # Ginkgo core libraries # Needs to be first in order for `CMAKE_CUDA_DEVICE_LINK_EXECUTABLE` to be diff --git a/INSTALL.md b/INSTALL.md index db846f66c82..9719bdfb920 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -118,11 +118,6 @@ Ginkgo adds the following additional switches to control what is being built: this option see the [`ARCHITECTURES` specification list](https://github.com/ginkgo-project/CudaArchitectureSelector/blob/master/CudaArchitectureSelector.cmake#L58) section in the documentation of the CudaArchitectureSelector CMake module. -* `-DGINKGO_EXTENSION_KOKKOS={ON, OFF}` enables an extension that can map simple Ginkgo - types (`gko::array`, `gko::matrix::Dense`) to equivalent native Kokkos types. `OFF` by - default. Requires Kokkos to be installed if set to `ON`. To use the mapping it is - required to additionally link against `Ginkgo::ext::kokkos` (or `Ginkgo::ext` for short). - More details on the usage of this extension can be found in the example `kokkos-assembly`. Additionally, the following CMake options have effect on the build process: diff --git a/cmake/GinkgoConfig.cmake.in b/cmake/GinkgoConfig.cmake.in index 4d7ad9fca7f..23b1d25adc1 100644 --- a/cmake/GinkgoConfig.cmake.in +++ b/cmake/GinkgoConfig.cmake.in @@ -82,9 +82,6 @@ set(GINKGO_HAVE_HWLOC @GINKGO_HAVE_HWLOC@) set(GINKGO_HAVE_ROCTX @GINKGO_HAVE_ROCTX@) -# Ginkgo extensions -set(GINKGO_EXTENSION_KOKKOS @GINKGO_EXTENSION_KOKKOS@) - # Ginkgo compiler information set(GINKGO_CXX_COMPILER "@CMAKE_CXX_COMPILER@") set(GINKGO_CXX_COMPILER_SHORT "@CMAKE_CXX_COMPILER_ID@:@CMAKE_CXX_COMPILER_VERSION@") @@ -199,10 +196,6 @@ if((NOT GINKGO_BUILD_SHARED_LIBS) AND GINKGO_HAVE_TAU) find_dependency(PerfStubs) endif() -if(GINKGO_EXTENSION_KOKKOS) - find_dependency(Kokkos 4.1) -endif() - # Check that the same compilers as for Ginkgo are used function(_ginkgo_check_compiler lang) if(DEFINED CMAKE_${lang}_COMPILER AND (NOT "${CMAKE_${lang}_COMPILER}" STREQUAL "${GINKGO_${lang}_COMPILER}")) diff --git a/cmake/get_info.cmake b/cmake/get_info.cmake index f524763db05..63f43c645f0 100644 --- a/cmake/get_info.cmake +++ b/cmake/get_info.cmake @@ -206,15 +206,8 @@ if(TARGET hwloc) endif() ginkgo_print_module_footer(${detailed_log} "") -set(Kokkos_VERSION ${GINKGO_Kokkos_VERSION}) -set(Kokkos_DEVICES ${GINKGO_Kokkos_DEVICES}) -ginkgo_print_generic_header(${minimal_log} " Extensions:") ginkgo_print_generic_header(${detailed_log} " Extensions:") -ginkgo_print_variable(${minimal_log} "GINKGO_EXTENSION_KOKKOS") -ginkgo_print_variable(${detailed_log} "GINKGO_EXTENSION_KOKKOS") ginkgo_print_variable(${detailed_log} "GINKGO_EXTENSION_KOKKOS_CHECK_TYPE_ALIGNMENT") -ginkgo_print_variable(${detailed_log} "Kokkos_VERSION") -ginkgo_print_variable(${detailed_log} "Kokkos_DEVICES") _minimal( " diff --git a/cmake/install_helpers.cmake b/cmake/install_helpers.cmake index ef64f80cb19..7165cad0c2b 100644 --- a/cmake/install_helpers.cmake +++ b/cmake/install_helpers.cmake @@ -82,12 +82,12 @@ function(ginkgo_install) DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" COMPONENT Ginkgo_Development FILES_MATCHING PATTERN "*.hpp" - PATTERN "extensions" EXCLUDE ) - install(FILES "${Ginkgo_BINARY_DIR}/include/ginkgo/config.hpp" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/ginkgo" - COMPONENT Ginkgo_Development - ) + install(DIRECTORY "${Ginkgo_BINARY_DIR}/include/" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + COMPONENT Ginkgo_Development + FILES_MATCHING PATTERN "*.hpp" + ) if (GINKGO_HAVE_HWLOC AND NOT HWLOC_FOUND) get_filename_component(HWLOC_LIB_PATH ${HWLOC_LIBRARIES} DIRECTORY) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 5ac3d71f436..653d52a1e88 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -56,7 +56,8 @@ if(GINKGO_BUILD_MPI) list(APPEND EXAMPLES_LIST distributed-solver) endif() -if(GINKGO_EXTENSION_KOKKOS) +find_package(Kokkos 4.1.00 QUIET) +if(Kokkos_FOUND) list(APPEND EXAMPLES_LIST kokkos-assembly) else() message(STATUS "No Kokkos found, disabling examples with Kokkos assembly.") diff --git a/examples/kokkos-assembly/CMakeLists.txt b/examples/kokkos-assembly/CMakeLists.txt index 53fa4546e8c..39c4cabd57b 100644 --- a/examples/kokkos-assembly/CMakeLists.txt +++ b/examples/kokkos-assembly/CMakeLists.txt @@ -5,12 +5,10 @@ project(kokkos-assembly CXX) if(NOT GINKGO_BUILD_EXAMPLES) find_package(Ginkgo 1.8.0 REQUIRED) endif() -if(NOT GINKGO_EXTENSION_KOKKOS) - message(FATAL_ERROR "The Kokkos examples requires that GINKGO_EXTENSION_KOKKOS=ON is set.") -endif() +find_package(Kokkos 4.1.00 REQUIRED) # Kokkos doesn't handle any compiler launcher well, so it's disable it unset(CMAKE_CXX_COMPILER_LAUNCHER) add_executable(kokkos-assembly kokkos-assembly.cpp) -target_link_libraries(kokkos-assembly Ginkgo::ginkgo Ginkgo::ext::kokkos) +target_link_libraries(kokkos-assembly Ginkgo::ginkgo Kokkos::kokkos) diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index 986b9216f6f..9c935a74270 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -1,34 +1,3 @@ -if (GINKGO_EXTENSION_KOKKOS) - find_package(Kokkos 4.1 REQUIRED) - - set(GINKGO_Kokkos_VERSION ${Kokkos_VERSION} PARENT_SCOPE) - set(GINKGO_Kokkos_DEVICES ${Kokkos_DEVICES} PARENT_SCOPE) - - add_library(ginkgo_ext_kokkos INTERFACE) - add_library(Ginkgo::ext::kokkos ALIAS ginkgo_ext_kokkos) - set_property(TARGET ginkgo_ext_kokkos PROPERTY EXPORT_NAME ext::kokkos) - - target_link_libraries(ginkgo_ext_kokkos INTERFACE Kokkos::kokkos) - target_compile_features(ginkgo_ext_kokkos INTERFACE cxx_std_17) - - configure_file("${Ginkgo_SOURCE_DIR}/include/ginkgo/extensions/kokkos/config.hpp.in" - "${Ginkgo_BINARY_DIR}/include/ginkgo/extensions/kokkos/config.hpp" - @ONLY - ) - - ginkgo_install_library(ginkgo_ext_kokkos) - install(FILES "${Ginkgo_BINARY_DIR}/include/ginkgo/extensions/kokkos/config.hpp" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/ginkgo/extensions/kokkos" - ) - install(DIRECTORY "${Ginkgo_SOURCE_DIR}/include/ginkgo/extensions/kokkos" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/ginkgo/extensions" - FILES_MATCHING PATTERN "*.hpp" - ) - install(FILES "${Ginkgo_SOURCE_DIR}/include/ginkgo/extensions/kokkos.hpp" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/ginkgo/extensions" - ) -endif () - if (GINKGO_BUILD_TESTS) add_subdirectory(test) endif () diff --git a/extensions/test/CMakeLists.txt b/extensions/test/CMakeLists.txt index 382af2ff030..a729661d909 100644 --- a/extensions/test/CMakeLists.txt +++ b/extensions/test/CMakeLists.txt @@ -1,5 +1,6 @@ include(${PROJECT_SOURCE_DIR}/cmake/create_test.cmake) -if (GINKGO_EXTENSION_KOKKOS) +find_package(Kokkos 4.1.00 QUIET) +if (Kokkos_FOUND) add_subdirectory(kokkos) endif () diff --git a/extensions/test/kokkos/CMakeLists.txt b/extensions/test/kokkos/CMakeLists.txt index 9f40b991c3e..47b5e24ca0c 100644 --- a/extensions/test/kokkos/CMakeLists.txt +++ b/extensions/test/kokkos/CMakeLists.txt @@ -32,14 +32,14 @@ endif() function(create_gtest_main_kokkos) add_library(ginkgo_gtest_main_kokkos STATIC kokkos_main.cpp ${PROJECT_SOURCE_DIR}/core/test/gtest/resources.cpp) - target_link_libraries(ginkgo_gtest_main_kokkos PUBLIC Ginkgo::ginkgo GTest::GTest Ginkgo::ext::kokkos) + target_link_libraries(ginkgo_gtest_main_kokkos PUBLIC Ginkgo::ginkgo GTest::GTest Kokkos::kokkos) target_compile_definitions(ginkgo_gtest_main_kokkos PRIVATE ${definitions}) ginkgo_compile_features(ginkgo_gtest_main_kokkos) endfunction() create_gtest_main_kokkos() function(ginkgo_create_test_kokkos test_name) - ginkgo_create_test(${test_name} NO_GTEST_MAIN RESOURCE_TYPE ${resource_type} ADDITIONAL_LIBRARIES Ginkgo::ext::kokkos ginkgo_gtest_main_kokkos ${ARGN}) + ginkgo_create_test(${test_name} NO_GTEST_MAIN RESOURCE_TYPE ${resource_type} ADDITIONAL_LIBRARIES Kokkos::kokkos ginkgo_gtest_main_kokkos ${ARGN}) endfunction() ginkgo_create_test_kokkos(types)