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

Set Kokkos_DEVICES and Kokkos_ARCH variables in exported CMake configuration #2193

Closed
dalg24 opened this issue Jun 26, 2019 · 9 comments
Closed
Assignees
Labels
Enhancement Improve existing capability; will potentially require voting

Comments

@dalg24
Copy link
Member

dalg24 commented Jun 26, 2019

On a related note, we need to make sure downstream code that do find_package(Kokkos) will be able to deduce the list of devices that where enabled at the time Kokkos was built.
c.f. arborx/ArborX#73 (comment)

Originally posted by @dalg24 in #2175 (comment)

@dalg24
Copy link
Member Author

dalg24 commented Jun 26, 2019

Current version of #2104 would break Cabana and ArborX. Both projects have some logic to instantiate code or enable examples/tests that rely on knowing at configuration time what devices were enabled at the time Kokkos was built.
See:
https://github.com/ECP-copa/Cabana/blob/b27a54c8c2df2f8b46d93f15d3e6992ee05041d3/CMakeLists.txt#L47-L49
and
https://github.com/arborx/ArborX/blob/857bcb6e06a984ca2363174ed7c989cdfb90f0e8/cmake/FindKokkos.cmake#L81-L82

CC: @junghans

@dalg24
Copy link
Member Author

dalg24 commented Jun 26, 2019

Adding a reference to the helper function I had proposed at the user meeting (see also #2064) which let the user code assert that a backend has been enabled.

# This function makes sure that kokkos was built with the requested backends
# and target architectures and generates a fatal error if it was not.
#
# kokkos_check_requested(
# [DEVICES <devices>...] # Set of backends (e.g. "OpenMP" and/or "Cuda")
# [ARCH <archs>...] # Target architectures (e.g. "Power9" and/or "Volta70")
# )
function(kokkos_check_requested)
cmake_parse_arguments(_KOKKOS_REQUESTED "" "" "DEVICES;ARCH" ${ARGN})
set(_KOKKOS_REQUESTED_ARGS)
foreach(_X DEVICES ARCH)
if(_KOKKOS_REQUESTED_${_X})
list(APPEND _KOKKOS_REQUESTED_ARGS ${_X})
endif()
endforeach()
set(_KOKKOS_CHECK_REQUESTED_SUCCESS TRUE)
foreach(_X ${_KOKKOS_REQUESTED_ARGS})
foreach(_requested ${_KOKKOS_REQUESTED_${_X}})
foreach(_provided ${KOKKOS_${_X}})
if(_requested STREQUAL _provided)
string(REPLACE ";" " " ${_requested} "${_KOKKOS_REQUESTED_${_X}}")
endif()
endforeach()
endforeach()
find_package_handle_standard_args("KOKKOS_${_X}" DEFAULT_MSG ${_KOKKOS_REQUESTED_${_X}})
if(NOT KOKKOS_${_X}_FOUND)
set(_KOKKOS_CHECK_REQUESTED_SUCCESS FALSE)
endif()
endforeach()
if(NOT _KOKKOS_CHECK_REQUESTED_SUCCESS)
message(FATAL_ERROR "Kokkos does NOT provide all backends and/or architectures requested")
endif()
endfunction()

@junghans
Copy link
Contributor

junghans commented Aug 1, 2019

I agree, exporting devices would be very useful.

@ipdemes
Copy link

ipdemes commented Aug 2, 2019

We need this for FLeCSI too

@junghans
Copy link
Contributor

junghans commented Aug 2, 2019

@crtrott

@junghans
Copy link
Contributor

junghans commented Aug 2, 2019

Another option would be to set the these as properties in kokkos-config.cmake, e.g.:

set_target_properties(Kokkos::kokkos PROPERTIES ARCH "@KOKKOS_ARCH@")

then we could process them in Cabana and FleCSI with:

get_target_property(KOKKOS_ARCH Kokkos::kokkos ARCH)

and everything is transparently attached to the Kokkos::kokkos target.

@ipdemes
Copy link

ipdemes commented Aug 16, 2019

@crtrott : any update on this?

@dalg24
Copy link
Member Author

dalg24 commented Aug 16, 2019

@jjwilke has added Kokkos_ARCH and Kokkos_DEVICES in the latest revision of #2104.

@ipdemes
Copy link

ipdemes commented Aug 16, 2019

@dalg24 : Great! Thank you

@crtrott crtrott added the Enhancement Improve existing capability; will potentially require voting label Aug 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Improve existing capability; will potentially require voting
Projects
None yet
Development

No branches or pull requests

6 participants