-
Notifications
You must be signed in to change notification settings - Fork 39
Enable Kokkos Kernels with host and GPU dependency configuration #601
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ee95002
Enable Kokkos Kernels with host and GPU dependency configuration
aaadelmann 3a0eab5
Add source-build fallback for LAPACKE
aaadelmann f694ba0
I fixed FindTPLLAPACKE.cmake
aaadelmann e0412bf
LAPACKE headers are now system includes
aaadelmann 45083e8
default Kokkos Kernels are OFF
aaadelmann 274fa5e
Document Kokkos Kernels configuration options
aaadelmann f49c6ac
Merge branch 'master' into enable-kokkos-kernels
aaadelmann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # Bootstrap the host library at configure time so the normal link/runtime probes | ||
| # still validate a real library on the first configure. Subsequent builds reuse it. | ||
| function(ippl_fetch_host_lapack) | ||
| if(CMAKE_CROSSCOMPILING AND NOT IPPL_LAPACKE_TOOLCHAIN_FILE) | ||
| message(FATAL_ERROR "LAPACKE fallback in a cross build needs IPPL_LAPACKE_TOOLCHAIN_FILE for the target CPU, or an installed LAPACKE provider.") | ||
| endif() | ||
| set(IPPL_LAPACKE_BUILD_JOBS 4 CACHE STRING "Parallel jobs for reference LAPACK bootstrap") | ||
| set(IPPL_LAPACKE_TOOLCHAIN_FILE "" CACHE FILEPATH "Optional host LAPACK C/Fortran toolchain") | ||
| FetchContent_Declare(ippl_reference_lapack | ||
| URL https://codeload.github.com/Reference-LAPACK/lapack/tar.gz/refs/tags/v3.12.1 | ||
| URL_HASH SHA256=2ca6407a001a474d4d4d35f3a61550156050c48016d949f0da0529c0aa052422 | ||
| DOWNLOAD_EXTRACT_TIMESTAMP TRUE | ||
| SOURCE_SUBDIR ippl-bootstrap-only) | ||
| FetchContent_MakeAvailable(ippl_reference_lapack) | ||
| set(_build "${FETCHCONTENT_BASE_DIR}/ippl-host-lapack-${IPPL_LAPACK_INTEGER_BYTES}-build") | ||
| set(_prefix "${FETCHCONTENT_BASE_DIR}/ippl-host-lapack-${IPPL_LAPACK_INTEGER_BYTES}-install") | ||
| set(_options) | ||
| # Let the host project discover C independently (or use CC/the toolchain). | ||
| # IPPL may enable C only later through a dependency, so forwarding its C | ||
| # compiler would change the bootstrap compiler on the second configure. | ||
| foreach(_variable CMAKE_Fortran_COMPILER CMAKE_OSX_ARCHITECTURES CMAKE_OSX_SYSROOT CMAKE_OSX_DEPLOYMENT_TARGET) | ||
| if(DEFINED ${_variable} AND NOT "${${_variable}}" STREQUAL "") | ||
| if(_variable MATCHES "_COMPILER$") | ||
| list(APPEND _options "-D${_variable}:FILEPATH=${${_variable}}") | ||
| else() | ||
| list(APPEND _options "-D${_variable}:STRING=${${_variable}}") | ||
| endif() | ||
| endif() | ||
| endforeach() | ||
| if(IPPL_LAPACKE_TOOLCHAIN_FILE) | ||
| list(APPEND _options "-DCMAKE_TOOLCHAIN_FILE=${IPPL_LAPACKE_TOOLCHAIN_FILE}") | ||
| endif() | ||
| message(STATUS "Host LAPACKE not found: building reference LAPACK 3.12.1 (C/Fortran); logs in ${_build}") | ||
| file(MAKE_DIRECTORY "${_build}") | ||
| execute_process(COMMAND "${CMAKE_COMMAND}" | ||
| -S "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/lapack-bootstrap" -B "${_build}" | ||
| "-DIPPL_REFERENCE_LAPACK_SOURCE_DIR=${ippl_reference_lapack_SOURCE_DIR}" | ||
| "-DIPPL_LAPACK_INTEGER_BYTES=${IPPL_LAPACK_INTEGER_BYTES}" | ||
| "-DCMAKE_INSTALL_PREFIX=${_prefix}" -DCMAKE_BUILD_TYPE=Release ${_options} | ||
| RESULT_VARIABLE _result OUTPUT_FILE "${_build}/configure.log" ERROR_FILE "${_build}/configure.log") | ||
| if(NOT _result EQUAL 0) | ||
| message(FATAL_ERROR "Host LAPACKE bootstrap configure failed. A host C and Fortran compiler (e.g. gfortran) is required. See ${_build}/configure.log") | ||
| endif() | ||
| execute_process(COMMAND "${CMAKE_COMMAND}" --build "${_build}" --config Release | ||
| --parallel "${IPPL_LAPACKE_BUILD_JOBS}" | ||
| RESULT_VARIABLE _result OUTPUT_FILE "${_build}/build.log" ERROR_FILE "${_build}/build.log") | ||
| if(NOT _result EQUAL 0) | ||
| message(FATAL_ERROR "Host LAPACKE bootstrap build failed; see ${_build}/build.log") | ||
| endif() | ||
| execute_process(COMMAND "${CMAKE_COMMAND}" --install "${_build}" --config Release | ||
| RESULT_VARIABLE _result OUTPUT_FILE "${_build}/install.log" ERROR_FILE "${_build}/install.log") | ||
| if(NOT _result EQUAL 0) | ||
| message(FATAL_ERROR "Host LAPACKE bootstrap install failed; see ${_build}/install.log") | ||
| endif() | ||
| # Use this exact bootstrap, including after a change of integer ABI. | ||
| set(IPPLHostLapack_DIR "${_prefix}/lib/cmake/IPPLHostLapack") | ||
| find_package(IPPLHostLapack CONFIG REQUIRED NO_DEFAULT_PATH PATHS "${IPPLHostLapack_DIR}") | ||
| # Imported targets created inside a function retain their directory visibility. | ||
| # Bundle only the private archives, public headers and our relocatable package; | ||
| # upstream pkg-config files contain the bootstrap prefix and are not exported. | ||
| install(DIRECTORY "${_prefix}/include/ippl-lapack" DESTINATION include) | ||
| install(DIRECTORY "${_prefix}/lib/ippl-lapack/" DESTINATION lib/ippl-lapack | ||
| FILES_MATCHING PATTERN "*.a" PATTERN "*.lib" | ||
| PATTERN "cmake" EXCLUDE PATTERN "pkgconfig" EXCLUDE) | ||
| install(FILES "${_prefix}/lib/cmake/IPPLHostLapack/IPPLHostLapackConfig.cmake" | ||
| DESTINATION lib/cmake/IPPLHostLapack) | ||
| install(FILES "${_prefix}/share/ippl/LAPACK-LICENSE" DESTINATION share/ippl) | ||
| set(LAPACKE_INCLUDE_DIRS "${_prefix}/include/ippl-lapack" PARENT_SCOPE) | ||
| set(LAPACKE_LIBRARIES IPPLHostLapack::lapacke PARENT_SCOPE) | ||
| set(IPPL_HOST_LAPACK_PREFIX "${_prefix}" PARENT_SCOPE) | ||
| set(IPPL_HOST_LAPACK_FETCHED ON PARENT_SCOPE) | ||
| endfunction() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # IPPL has already resolved the complete host link line. Preserve absolute paths | ||
| # and static transitive dependencies; upstream 5.2's finder treats them as names. | ||
| include(FindPackageHandleStandardArgs) | ||
| find_package_handle_standard_args(TPLLAPACKE REQUIRED_VARS LAPACKE_INCLUDE_DIRS LAPACKE_LIBRARIES) | ||
| set(_lapackeResolved) | ||
| foreach(_library IN LISTS LAPACKE_LIBRARIES) | ||
| if(TARGET "${_library}") | ||
| list(APPEND _lapackeResolved "${_library}") | ||
| elseif(_library MATCHES "^-") | ||
| # CMake LAPACK providers may return linker items such as -lm or -pthread. | ||
| # Preserve them verbatim instead of treating them as find_library names. | ||
| list(APPEND _lapackeResolved "${_library}") | ||
| elseif(IS_ABSOLUTE "${_library}") | ||
| if(NOT EXISTS "${_library}") | ||
| message(FATAL_ERROR "LAPACKE dependency does not exist: ${_library}") | ||
| endif() | ||
| list(APPEND _lapackeResolved "${_library}") | ||
| else() | ||
| unset(_lapackeLibrary CACHE) | ||
| find_library(_lapackeLibrary NAMES ${_library} HINTS ${LAPACKE_LIBRARY_DIRS} REQUIRED) | ||
| list(APPEND _lapackeResolved "${_lapackeLibrary}") | ||
| endif() | ||
| endforeach() | ||
| set(_lapackeIncludes "${LAPACKE_INCLUDE_DIRS}") | ||
| if(IPPL_HOST_LAPACK_FETCHED) | ||
| # The imported host target carries relocatable include directories itself. | ||
| set(_lapackeIncludes) | ||
| endif() | ||
| kokkoskernels_create_imported_tpl(LAPACKE INTERFACE | ||
| LINK_LIBRARIES "${_lapackeResolved}") | ||
| if(_lapackeIncludes) | ||
| # Environment views may also contain an incompatible desul installation. | ||
| # Keep their broad include directory behind Kokkos's bundled TPL headers. | ||
| target_include_directories(LAPACKE SYSTEM INTERFACE ${_lapackeIncludes}) | ||
| endif() | ||
|
|
||
| if(IPPL_HOST_LAPACK_FETCHED) | ||
| # Also make the Kernels package usable directly, including in a fresh IPPL | ||
| # build that finds this Kernels installation instead of fetching its sources. | ||
| kokkoskernels_append_config_line("include(CMakeFindDependencyMacro)") | ||
| kokkoskernels_append_config_line( | ||
| "find_dependency(IPPLHostLapack CONFIG HINTS \"\\\${PACKAGE_PREFIX_DIR}\" \"${IPPL_HOST_LAPACK_PREFIX}\")") | ||
| endif() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.