Skip to content

Commit

Permalink
Introduce KOKKOSKERNELS_ALL_COMPONENTS_ENABLED variable
Browse files Browse the repository at this point in the history
Previously, we could have the following issue:

1. User sets KokkosKernernels_ENABLE_ALL_COMPONENTS to on
2. This enables each component
3. Invoke cmake again
4. Since components are enabled, KokkosKernels_ENABLE_ALL_COMPONENTS would be set to off
5. Things that rely on KokkosKernels_ENABLE_ALL_COMPONENTS are no longer build (e.g. tests)

Now, KOKKOSKERELS_ALL_COMPONENTS_ENABLED is used to track whether all components are enabled,
regardless of how we got there.
It's marked as advanced to hide it from GUIs, and leaves the user-facing KokkosKernels_ENABLE_ALL_COMPONENTS intact.
  • Loading branch information
cwpearson committed Feb 22, 2023
1 parent 6d73c14 commit 0576a2d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ ELSE()
IF (KokkosKernels_ENABLE_COMPONENT_SPARSE)
KOKKOSKERNELS_ADD_TEST_DIRECTORIES(sparse/unit_test)
ENDIF()
IF (KokkosKernels_ENABLE_ALL_COMPONENTS)
IF (KOKKOSKERNELS_ALL_COMPONENTS_ENABLED)
IF (KokkosKernels_ENABLE_PERFTESTS)
MESSAGE(STATUS "Enabling perf tests.")
KOKKOSKERNELS_ADD_TEST_DIRECTORIES(perf_test)
Expand All @@ -400,13 +400,13 @@ ELSE()
KOKKOSKERNELS_ADD_EXAMPLE_DIRECTORIES(example)
ENDIF ()
ELSE ()
# ENABLE_ALL_COMPONENTS is OFF, so perftests and examples can't be enabled.
# all components were not enabled, so perftests and examples can't be enabled.
# Warn if they were requested.
IF (KokkosKernels_ENABLE_PERFTESTS)
MESSAGE(WARNING "Could not enable perf tests because KokkosKernels_ENABLE_ALL_COMPONENTS=OFF")
MESSAGE(WARNING "Could not enable perf tests because not all components were enabled")
ENDIF ()
IF (KokkosKernels_ENABLE_EXAMPLES)
MESSAGE(WARNING "Could not enable examples because KokkosKernels_ENABLE_ALL_COMPONENTS=OFF")
MESSAGE(WARNING "Could not enable examples because not all components were enabled")
ENDIF ()
ENDIF ()

Expand Down
27 changes: 15 additions & 12 deletions cmake/kokkoskernels_components.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ KOKKOSKERNELS_ADD_OPTION(
"Whether to build the graph component. Default: OFF"
)

# The user requested individual components,
# the assumption is that a full build is not
# desired and ENABLE_ALL_COMPONENETS is turned
# off.
IF (KokkosKernels_ENABLE_COMPONENT_BATCHED OR KokkosKernels_ENABLE_COMPONENT_BLAS
OR KokkosKernels_ENABLE_COMPONENT_GRAPH OR KokkosKernels_ENABLE_COMPONENT_SPARSE)
SET(KokkosKernels_ENABLE_ALL_COMPONENTS OFF CACHE BOOL "" FORCE)
ENDIF()

# Graph depends on everything else because it depends
# on Sparse at the moment, breaking that dependency will
Expand All @@ -72,13 +64,24 @@ IF (KokkosKernels_ENABLE_COMPONENT_SPARSE)
SET(KokkosKernels_ENABLE_COMPONENT_GRAPH ON CACHE BOOL "" FORCE)
ENDIF()

# At this point, if ENABLE_ALL_COMPONENTS is
# still ON we need to enable all individual
# components as they are required for this
# build.
# If user requested to enable all components, enable all components
IF (KokkosKernels_ENABLE_ALL_COMPONENTS)
SET(KokkosKernels_ENABLE_COMPONENT_BATCHED ON CACHE BOOL "" FORCE)
SET(KokkosKernels_ENABLE_COMPONENT_BLAS ON CACHE BOOL "" FORCE)
SET(KokkosKernels_ENABLE_COMPONENT_SPARSE ON CACHE BOOL "" FORCE)
SET(KokkosKernels_ENABLE_COMPONENT_GRAPH ON CACHE BOOL "" FORCE)
ENDIF()

# KOKKOSKERNELS_ALL_COMPONENTS_ENABLED says whether all components are on,
# regardless of how this came to be
# this is in the cache so we can use it as a global variable,
# but marking it as advanced should hide it from GUIs
IF ( KokkosKernels_ENABLE_COMPONENT_BATCHED
AND KokkosKernels_ENABLE_COMPONENT_BLAS
AND KokkosKernels_ENABLE_COMPONENT_GRAPH
AND KokkosKernels_ENABLE_COMPONENT_SPARSE)
SET(KOKKOSKERNELS_ALL_COMPONENTS_ENABLED ON CACHE BOOL "" FORCE)
ELSE()
SET(KOKKOSKERNELS_ALL_COMPONENTS_ENABLED OFF CACHE BOOL "" FORCE)
ENDIF()
mark_as_advanced(FORCE KOKKOSKERNELS_ALL_COMPONENTS_ENABLED)

0 comments on commit 0576a2d

Please sign in to comment.