Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`. 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=<X>` from a cache entry that already holds `<X>`, pin BTAS to a value TA derived on an earlier configure by also passing `-DTA_BTAS_ASSERT_POLICY_FOLLOWS_TA=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`. On the first configure of a build directory this also seeds `BTAS_ASSERT_POLICY` of a BTAS built from source (`TA_ASSERT_THROW`/`TA_ASSERT_ABORT`/`TA_ASSERT_IGNORE` map onto `BTAS_ASSERT_THROW`/`BTAS_ASSERT_ABORT`/`BTAS_ASSERT_IGNORE`). As with any cached option, an explicit `-DBTAS_ASSERT_POLICY=...` wins, and a later change of `TA_ASSERT_POLICY` does not re-seed it: set `BTAS_ASSERT_POLICY` explicitly, or use a fresh build directory.
* `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].
Expand Down
49 changes: 15 additions & 34 deletions cmake/modules/FindOrFetchBTAS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,23 @@ 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=<X> 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()
# Seed BTAS's assertion policy from TA's, so that the two agree by default
# (else BTAS_ASSERT throws whenever BUILD_TESTING=ON, regardless of NDEBUG);
# BTAS_ASSERT_POLICY has the same three modes as TA_ASSERT_POLICY and is
# likewise not affected by NDEBUG. Like any cached option this applies on
# the first configure of a build directory only: an explicit
# -DBTAS_ASSERT_POLICY=... (from the user or a parent project) is already in
# the cache and wins, and a later change of TA_ASSERT_POLICY does not re-seed
# it (set BTAS_ASSERT_POLICY explicitly, or use a fresh build directory).
if (NOT DEFINED CACHE{BTAS_ASSERT_POLICY})
if (TA_ASSERT_POLICY STREQUAL TA_ASSERT_THROW)
set(BTAS_ASSERT_POLICY BTAS_ASSERT_THROW CACHE STRING "Controls the behavior of BTAS_ASSERT (seeded from TA_ASSERT_POLICY)")
elseif (TA_ASSERT_POLICY STREQUAL TA_ASSERT_ABORT)
set(BTAS_ASSERT_POLICY BTAS_ASSERT_ABORT CACHE STRING "Controls the behavior of BTAS_ASSERT (seeded from TA_ASSERT_POLICY)")
else ()
set(BTAS_ASSERT_POLICY BTAS_ASSERT_IGNORE CACHE STRING "Controls the behavior of BTAS_ASSERT (seeded from TA_ASSERT_POLICY)")
endif()
endif()
unset(_ta_btas_follow_doc)

include(FetchContent)
FetchContent_Declare(
Expand All @@ -66,13 +54,6 @@ if (NOT TARGET BTAS::BTAS)
)
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
Expand Down
Loading