diff --git a/INSTALL.md b/INSTALL.md index 928eba7fa8..edadd009d9 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -424,7 +424,7 @@ support may be added. ## Expert configure options: * `TA_EXPERT` -- Set to `ON` to disable automatic installation of prerequisites. Useful for experts, hence the name. [Default=OFF]. -* `TA_ASSERT_POLICY` -- Set to `TA_ASSERT_IGNORE` to disable `TA_ASSERT` assertions, `TA_ASSERT_THROW` to cause `TA_ASSERT` assertions to throw, `TA_ASSERT_ABORT` to cause `TA_ASSERT` assertions to abort. The default is `TA_ASSERT_IGNORE` if CMake uses a single-configuration generator and`CMAKE_BUILD_TYPE` is set to `Release` or `MinSizeRel`, else the default is `TA_ASSERT_THROW`. +* `TA_ASSERT_POLICY` -- Set to `TA_ASSERT_IGNORE` to disable `TA_ASSERT` assertions, `TA_ASSERT_THROW` to cause `TA_ASSERT` assertions to throw, `TA_ASSERT_ABORT` to cause `TA_ASSERT` assertions to abort. The default is `TA_ASSERT_IGNORE` if CMake uses a single-configuration generator and`CMAKE_BUILD_TYPE` is set to `Release` or `MinSizeRel`, else the default is `TA_ASSERT_THROW`. This is also forwarded to BTAS, as `BTAS_ASSERT_POLICY` (`TA_ASSERT_THROW`/`TA_ASSERT_ABORT`/`TA_ASSERT_IGNORE` map onto `BTAS_ASSERT_THROW`/`BTAS_ASSERT_ABORT`/`BTAS_ASSERT_IGNORE`), when BTAS is built from source. An explicit `BTAS_ASSERT_POLICY` is honored and turns `TA_BTAS_ASSERT_POLICY_FOLLOWS_TA` (default `ON`) `OFF`, after which BTAS no longer follows TA; since CMake cannot distinguish an explicit `-DBTAS_ASSERT_POLICY=` from a cache entry that already holds ``, pin BTAS to a value TA derived on an earlier configure by also passing `-DTA_BTAS_ASSERT_POLICY_FOLLOWS_TA=OFF`. * `BUILD_TESTING` -- Set of `OFF` to disable building unit tests. The default is `ON`. * `TA_TRACE_TASKS` -- Set to `ON` to enable tracing of MADNESS tasks using custom task tracer. Note that standard profilers/tracers are generally useless (except in the trivial cases) with MADWorld-based programs since the submission context of tasks is not captured by standard tracing tools; this makes it impossible in a nontrivial program to attribute tasks to source code. WARNING: task tracing his will greatly increase the memory requirements. [Default=OFF]. * `TA_TTG` -- Set to `ON` to find or fetch the TTG library. [Default=OFF]. diff --git a/cmake/modules/FindOrFetchBTAS.cmake b/cmake/modules/FindOrFetchBTAS.cmake index 9071c11158..2a22516dfa 100644 --- a/cmake/modules/FindOrFetchBTAS.cmake +++ b/cmake/modules/FindOrFetchBTAS.cmake @@ -28,6 +28,36 @@ if (NOT TARGET BTAS::BTAS) set(gpu_backend none CACHE STRING "The device backend to use for Linalg++") endif() + # forward TA's assertion policy to BTAS, else BTAS picks its own default + # (BTAS_ASSERT_THROW whenever BUILD_TESTING=ON, no matter what TA_ASSERT does). + # BTAS_ASSERT_POLICY has the same three modes as TA_ASSERT_POLICY, and + # like it is not affected by NDEBUG. + # TA_BTAS_ASSERT_POLICY_FOLLOWS_TA is the opt-out: while ON, BTAS_ASSERT_POLICY + # is (re)derived from TA_ASSERT_POLICY on every configure; an explicit + # BTAS_ASSERT_POLICY that differs from the value TA last acknowledged + # (recorded in TA_BTAS_ASSERT_POLICY_SEEN) is honored and turns the option OFF. + # N.B. CMake cannot tell an explicit -DBTAS_ASSERT_POLICY= from a cache + # entry that already holds X, so to pin BTAS to the value TA derived on + # an earlier configure pass -DTA_BTAS_ASSERT_POLICY_FOLLOWS_TA=OFF as well + set(_ta_btas_follow_doc "Derive BTAS_ASSERT_POLICY from TA_ASSERT_POLICY when BTAS is built from source; OFF leaves BTAS_ASSERT_POLICY to the user (or to BTAS's default)") + option(TA_BTAS_ASSERT_POLICY_FOLLOWS_TA "${_ta_btas_follow_doc}" ON) + if (TA_BTAS_ASSERT_POLICY_FOLLOWS_TA) + if (DEFINED BTAS_ASSERT_POLICY AND NOT (DEFINED TA_BTAS_ASSERT_POLICY_SEEN AND BTAS_ASSERT_POLICY STREQUAL TA_BTAS_ASSERT_POLICY_SEEN)) + # explicit user value (on the first configure, or changed since TA last saw it): honor it, stop following + set(TA_BTAS_ASSERT_POLICY_FOLLOWS_TA OFF CACHE BOOL "${_ta_btas_follow_doc}" FORCE) + message(STATUS "BTAS_ASSERT_POLICY=${BTAS_ASSERT_POLICY} was set explicitly: TA_BTAS_ASSERT_POLICY_FOLLOWS_TA turned OFF, BTAS_ASSERT_POLICY will no longer follow TA_ASSERT_POLICY") + else() + if (TA_ASSERT_POLICY STREQUAL TA_ASSERT_THROW) + set(BTAS_ASSERT_POLICY BTAS_ASSERT_THROW CACHE STRING "Controls the behavior of BTAS_ASSERT" FORCE) + elseif (TA_ASSERT_POLICY STREQUAL TA_ASSERT_ABORT) + set(BTAS_ASSERT_POLICY BTAS_ASSERT_ABORT CACHE STRING "Controls the behavior of BTAS_ASSERT" FORCE) + else () + set(BTAS_ASSERT_POLICY BTAS_ASSERT_IGNORE CACHE STRING "Controls the behavior of BTAS_ASSERT" FORCE) + endif() + endif() + endif() + unset(_ta_btas_follow_doc) + include(FetchContent) FetchContent_Declare( BTAS @@ -35,6 +65,14 @@ if (NOT TARGET BTAS::BTAS) GIT_TAG ${TA_TRACKED_BTAS_TAG} ) FetchContent_MakeAvailable(BTAS) + + # record the BTAS_ASSERT_POLICY value TA acknowledged (derived, explicit, or + # BTAS's own default when following is OFF): turning + # TA_BTAS_ASSERT_POLICY_FOLLOWS_TA back ON with this value still in the cache + # resumes following. Done after BTAS has been configured so that the entry + # exists even on a first configure with following OFF and no explicit value. + # N.B. INTERNAL implies FORCE; spelled out for clarity + set(TA_BTAS_ASSERT_POLICY_SEEN ${BTAS_ASSERT_POLICY} CACHE INTERNAL "BTAS_ASSERT_POLICY last acknowledged by TiledArray" FORCE) FetchContent_GetProperties(BTAS SOURCE_DIR BTAS_SOURCE_DIR BINARY_DIR BTAS_BINARY_DIR diff --git a/external/versions.cmake b/external/versions.cmake index f5565d299c..8b7920a100 100644 --- a/external/versions.cmake +++ b/external/versions.cmake @@ -17,8 +17,8 @@ set(TA_TRACKED_MADNESS_PREVIOUS_TAG f7aa1401e) set(TA_TRACKED_MADNESS_VERSION 0.10.1) set(TA_TRACKED_MADNESS_PREVIOUS_VERSION 0.10.1) -set(TA_TRACKED_BTAS_TAG 245e49f117981d6124e0f1aa0d1ae72f1c16318b) -set(TA_TRACKED_BTAS_PREVIOUS_TAG 7e64fbad97c76f316f313f4c8ed3fca5445da15f) +set(TA_TRACKED_BTAS_TAG 52aadfe54ee48874f6926da5932482e0f5cef85c) +set(TA_TRACKED_BTAS_PREVIOUS_TAG 245e49f117981d6124e0f1aa0d1ae72f1c16318b) set(TA_TRACKED_LIBRETT_TAG 6eed30d4dd2a5aa58840fe895dcffd80be7fbece) set(TA_TRACKED_LIBRETT_PREVIOUS_TAG 354e0ccee54aeb2f191c3ce2c617ebf437e49d83)