From cc02fc6ff916b2a8636ebdf3607b372b36376087 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Wed, 25 Aug 2021 09:58:01 -0400 Subject: [PATCH 1/8] Build MADworld, if not found, via FetchContent --- CMakeLists.txt | 15 +- cmake/modules/FindOrFetchBTAS.cmake | 17 +- cmake/modules/FindOrFetchBoost.cmake | 15 +- cmake/modules/FindOrFetchMADWorld.cmake | 62 ++++ cmake/modules/FindOrFetchRangeV3.cmake | 16 +- external/madness.cmake | 415 ------------------------ 6 files changed, 105 insertions(+), 435 deletions(-) create mode 100644 cmake/modules/FindOrFetchMADWorld.cmake delete mode 100644 external/madness.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 61cb87fdad..addd6ff71c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,14 +33,19 @@ include(external/versions.cmake) # Bring ValeevGroup cmake toolkit ############################################################################### include(FetchContent) +if (DEFINED PROJECT_BINARY_DIR) + set(VG_CMAKE_KIT_PREFIX_DIR PROJECT_BINARY_DIR) +else () + set(VG_CMAKE_KIT_PREFIX_DIR CMAKE_CURRENT_BINARY_DIR) +endif() FetchContent_Declare( vg_cmake_kit QUIET GIT_REPOSITORY https://github.com/ValeevGroup/kit-cmake.git GIT_TAG ${TA_TRACKED_VGCMAKEKIT_TAG} - SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/cmake/vg - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/cmake/vg-build - SUBBUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/cmake/vg-subbuild + SOURCE_DIR ${${VG_CMAKE_KIT_PREFIX_DIR}}/cmake/vg + BINARY_DIR ${${VG_CMAKE_KIT_PREFIX_DIR}}/cmake/vg-build + SUBBUILD_DIR ${${VG_CMAKE_KIT_PREFIX_DIR}}/cmake/vg-subbuild ) FetchContent_GetProperties(vg_cmake_kit) if (NOT vg_cmake_kit_POPULATED) @@ -261,7 +266,7 @@ if (CMAKE_CXX_STANDARD EQUAL 20 AND CMAKE_VERSION VERSION_LESS 3.12.0) cmake_minimum_required (VERSION 3.12.0) endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF CACHE BOOL "Whether to use extensions of C++ ISO Standard version") +set(CMAKE_CXX_EXTENSIONS OFF CACHE BOOL "Whether to use extensions of C++ ISO Standard version") # Check type support include(CheckTypeSize) check_type_size("long double" TILEDARRAY_HAS_LONG_DOUBLE LANGUAGE CXX) @@ -301,7 +306,7 @@ add_custom_target(External-tiledarray) if(ENABLE_CUDA) include(external/cuda.cmake) endif() -include(external/madness.cmake) +include(FindOrFetchMADWorld) detect_MADNESS_configuration() include(external/eigen.cmake) include(external/umpire.cmake) diff --git a/cmake/modules/FindOrFetchBTAS.cmake b/cmake/modules/FindOrFetchBTAS.cmake index ee8d2e110a..9abf776279 100644 --- a/cmake/modules/FindOrFetchBTAS.cmake +++ b/cmake/modules/FindOrFetchBTAS.cmake @@ -1,14 +1,21 @@ -find_package(BTAS 1.0.0 QUIET CONFIG) +# try find_package +if (NOT TARGET BTAS::BTAS) + include (FindPackageRegimport) + find_package_regimport(BTAS 1.0.0 QUIET CONFIG) + if (TARGET BTAS::BTAS) + message(STATUS "Found BTAS CONFIG at ${BTAS_CONFIG}") + endif (TARGET BTAS::BTAS) +endif (NOT TARGET BTAS::BTAS) -if (TARGET BTAS::BTAS) - message(STATUS "Found BTAS CONFIG at ${BTAS_CONFIG}") -else (TARGET BTAS::BTAS) +# if not found, build via FetchContent +if (NOT TARGET BTAS::BTAS) if (NOT TILEDARRAY_HAS_CUDA) # tell BLAS++/LAPACK++ to ignore CUDA set(use_cuda FALSE CACHE BOOL "Whether to look for CUDA-enabled libs in BLAS++/LAPACK++") endif() + include(FetchContent) FetchContent_Declare( BTAS GIT_REPOSITORY https://github.com/BTAS/btas.git @@ -28,7 +35,7 @@ else (TARGET BTAS::BTAS) # set BTAS_CONFIG to the install location so that we know where to find it set(BTAS_CONFIG ${CMAKE_INSTALL_PREFIX}/${BTAS_INSTALL_CMAKEDIR}/btas-config.cmake) -endif(TARGET BTAS::BTAS) +endif(NOT TARGET BTAS::BTAS) # postcond check if (NOT TARGET BTAS::BTAS) diff --git a/cmake/modules/FindOrFetchBoost.cmake b/cmake/modules/FindOrFetchBoost.cmake index 7c82b4f736..263b7a8d6a 100644 --- a/cmake/modules/FindOrFetchBoost.cmake +++ b/cmake/modules/FindOrFetchBoost.cmake @@ -3,12 +3,17 @@ if (BOOST_ROOT OR BOOST_INCLUDEDIR) set(Boost_NO_SYSTEM_PATHS TRUE) endif() -# Check for Boost -find_package(Boost ${TA_TRACKED_BOOST_VERSION} QUIET) +# try find_package +if (NOT TARGET Boost::boost) + include(FindPackageRegimport) + find_package_regimport(Boost ${TA_TRACKED_BOOST_VERSION} QUIET) + if (TARGET Boost::boost) + message(STATUS "Found Boost ${Boost_VERSION}: ${Boost_INCLUDE_DIRS}") + endif(TARGET Boost::boost) +endif (NOT TARGET Boost::boost) -if (TARGET Boost::boost) - message(STATUS "Found Boost ${Boost_VERSION}: ${Boost_INCLUDE_DIRS}") -else (TARGET Boost::boost) +# if not found, build via FetchContent +if (NOT TARGET Boost::boost) include (FetchContent) cmake_minimum_required (VERSION 3.14.0) # for FetchContent_MakeAvailable diff --git a/cmake/modules/FindOrFetchMADWorld.cmake b/cmake/modules/FindOrFetchMADWorld.cmake new file mode 100644 index 0000000000..1275829e1d --- /dev/null +++ b/cmake/modules/FindOrFetchMADWorld.cmake @@ -0,0 +1,62 @@ +# first try find_package +if (NOT TARGET MADworld) + include (FindPackageRegimport) + find_package_regimport(MADNESS ${TA_TRACKED_MADNESS_VERSION} CONFIG QUIET COMPONENTS world HINTS "${MADNESS_ROOT_DIR}") + if (TARGET MADworld) + message(STATUS "Found MADNESS CONFIG at ${MADNESS_CONFIG}") + endif (TARGET MADworld) +endif (NOT TARGET MADworld) + +# if not found, build via FetchContent +if (NOT TARGET MADworld) + + # TA-specific configuration + set(MADNESS_BUILD_MADWORLD_ONLY ON CACHE BOOL "Whether to build MADNESS runtime only") + set(ENABLE_PARSEC OFF CACHE BOOL "Whether to use PaRSEC as the task backend of MADWorld") + set(MPI_THREAD "multiple" CACHE INTERNAL "MADNESS requires MPI_THREAD_MULTIPLE") + set(MADNESS_ASSUMES_ASLR_DISABLED ${TA_ASSUMES_ASLR_DISABLED} CACHE BOOL "Whether MADNESS assumes ASLR to be disabled") + set(MPI_CXX_SKIP_MPICXX ON CACHE BOOL "Whether to disable search for C++ MPI-2 bindings") + set(DISABLE_WORLD_GET_DEFAULT ON CACHE INTERNAL "Whether to disable madness::World::get_default()") + set(ENABLE_MEM_PROFILE ON CACHE INTERNAL "Whether to enable instrumented memory profiling in MADNESS") + set(ENABLE_TASK_DEBUG_TRACE ${TILEDARRAY_ENABLE_TASK_DEBUG_TRACE} CACHE INTERNAL "Whether to enable task profiling in MADNESS") + + # Set error handling method (for TA_ASSERT_POLICY allowed values see top-level CMakeLists.txt) + if(TA_ASSERT_POLICY STREQUAL TA_ASSERT_IGNORE) + set(_MAD_ASSERT_TYPE disable) + elseif(TA_ASSERT_POLICY STREQUAL TA_ASSERT_THROW) + set(_MAD_ASSERT_TYPE throw) + elseif(TA_ASSERT_POLICY STREQUAL TA_ASSERT_ABORT) + set(_MAD_ASSERT_TYPE abort) + endif() + set(MAD_ASSERT_TYPE ${_MAD_ASSERT_TYPE} CACHE INTERNAL "MADNESS assert type") + set(ASSERTION_TYPE "${MAD_ASSERT_TYPE}" CACHE INTERNAL "MADNESS assert type") + + # look for C and MPI here to make troubleshooting easier and be able to override defaults for MADNESS + enable_language(C) + find_package(MPI REQUIRED COMPONENTS C CXX) + + include(FetchContent) + FetchContent_Declare( + MADNESS + GIT_REPOSITORY https://github.com/m-a-d-n-e-s-s/madness.git + GIT_TAG ${TA_TRACKED_MADNESS_TAG} + ) + FetchContent_MakeAvailable(MADNESS) + FetchContent_GetProperties(MADNESS + SOURCE_DIR MADNESS_SOURCE_DIR + BINARY_DIR MADNESS_BINARY_DIR + ) + set_property(DIRECTORY ${MADNESS_SOURCE_DIR} PROPERTY EXCLUDE_FROM_ALL TRUE) + # making madness targets EXCLUDE_FROM_ALL via the above makes its install statement "UB": https://cmake.org/cmake/help/latest/command/install.html#installing-targets + # force 'all' target to build madness and MADworld using this dummy target + add_custom_target(tiledarray-force-all-to-build-madness-target ALL DEPENDS madness MADworld) + + # add MADworld target to the tiledarray export set + install(TARGETS MADworld EXPORT tiledarray) + +endif(NOT TARGET MADworld) + +# postcond check +if (NOT TARGET MADworld) + message(FATAL_ERROR "FindOrFetchMADNESS could not make MADworld target available") +endif(NOT TARGET MADworld) diff --git a/cmake/modules/FindOrFetchRangeV3.cmake b/cmake/modules/FindOrFetchRangeV3.cmake index 6a6805614b..942a734925 100644 --- a/cmake/modules/FindOrFetchRangeV3.cmake +++ b/cmake/modules/FindOrFetchRangeV3.cmake @@ -1,8 +1,14 @@ -find_package(range-v3 QUIET CONFIG) - -if (TARGET range-v3::range-v3) +# try find_package +if (NOT TARGET range-v3::range-v3) + include (FindPackageRegimport) + find_package_regimport(range-v3 QUIET CONFIG) + if (TARGET range-v3::range-v3) message(STATUS "Found Range-V3 CONFIG at ${range-v3_CONFIG}") -else (TARGET range-v3::range-v3) + endif (TARGET range-v3::range-v3) +endif (NOT TARGET range-v3::range-v3) + +# if not found, build via FetchContent +if (NOT TARGET range-v3::range-v3) include(FetchContent) FetchContent_Declare( @@ -19,7 +25,7 @@ else (TARGET range-v3::range-v3) # set range-v3_CONFIG to the install location so that we know where to find it set(range-v3_CONFIG ${CMAKE_INSTALL_PREFIX}/lib/cmake/range-v3/range-v3-config.cmake) -endif(TARGET range-v3::range-v3) +endif(NOT TARGET range-v3::range-v3) # postcond check if (NOT TARGET range-v3::range-v3) diff --git a/external/madness.cmake b/external/madness.cmake deleted file mode 100644 index 9ab766f7e6..0000000000 --- a/external/madness.cmake +++ /dev/null @@ -1,415 +0,0 @@ -# -*- mode: cmake -*- - -################### -# Find MADNESS -################### - -# extra compiler flags that MADNESS needs from TiledArray -set(MADNESS_EXTRA_CXX_FLAGS "") - -include(ExternalProject) -include(ConvertIncludesListToCompilerArgs) -include(ConvertLibrariesListToCompilerArgs) - -# user specified madness -set(MADNESS_TAG "" CACHE STRING "Revision hash or tag to use when building MADNESS") -mark_as_advanced(FORCE MADNESS_TAG) - -set(_madness_tag ${TA_TRACKED_MADNESS_TAG}) - -if (MADNESS_TAG) - set(_madness_tag ${MADNESS_TAG}) -endif() - -find_package_regimport(MADNESS ${TA_TRACKED_MADNESS_VERSION} CONFIG QUIET COMPONENTS world HINTS ${MADNESS_ROOT_DIR}) - -macro(replace_mad_targets_with_libnames _mad_libraries _mad_config_libs) - set(${_mad_config_libs} ) - foreach (_lib ${${_mad_libraries}}) - if (${_lib} MATCHES "MAD*") - set(${_mad_config_libs} "${${_mad_config_libs}} -l${_lib}") - else () - set(${_mad_config_libs} "${${_mad_config_libs}} ${_lib}") - endif() - endforeach() -endmacro() - -# if found, make sure the MADNESS tag matches exactly -if (MADNESS_FOUND AND NOT TILEDARRAY_DOWNLOADED_MADNESS) - set(TILEDARRAY_DOWNLOADED_MADNESS OFF CACHE BOOL "Whether TA downloaded MADNESS") - mark_as_advanced(TILEDARRAY_DOWNLOADED_MADNESS) - - set(CONFIG_H_PATH "${MADNESS_DIR}/../../../include/madness/config.h") # if MADNESS were installed - if (NOT EXISTS "${CONFIG_H_PATH}") - set(CONFIG_H_PATH "${MADNESS_DIR}/src/madness/config.h") # if MADNESS were used from build tree - if (NOT EXISTS "${CONFIG_H_PATH}") - message(FATAL_ERROR "did not find MADNESS' config.h") - endif() - endif() - file(STRINGS "${CONFIG_H_PATH}" MADNESS_REVISION_LINE REGEX "define MADNESS_REVISION") - if (MADNESS_REVISION_LINE) # MADNESS_REVISION found? make sure it matches the required tag exactly - string(REGEX REPLACE ".*define[ \t]+MADNESS_REVISION[ \t]+\"([a-z0-9]+)\"" "\\1" MADNESS_REVISION "${MADNESS_REVISION_LINE}") - if ("${MADNESS_REVISION}" STREQUAL "${_madness_tag}") - message(STATUS "Found MADNESS with required revision ${MADNESS_REQUIRED_TAG}") - else() - message(FATAL_ERROR "Found MADNESS with revision ${MADNESS_REVISION}, but ${MADNESS_REQUIRED_TAG} is required; if MADNESS was built by TiledArray, remove the TiledArray install directory, else build the required revision of MADNESS") - endif() - else (MADNESS_REVISION_LINE) # MADNESS_REVISION not found? MADNESS is not recent enough, reinstall - message(FATAL_ERROR "Found MADNESS, but it is not recent enough; either provide MADNESS with revision ${TA_TRACKED_MADNESS_TAG} or let TiledArray built it") - endif(MADNESS_REVISION_LINE) - - if ((NOT TA_ASSUMES_ASLR_DISABLED AND MADNESS_ASSUMES_ASLR_DISABLED) OR (TA_ASSUMES_ASLR_DISABLED AND NOT MADNESS_ASSUMES_ASLR_DISABLED)) - message(FATAL_ERROR "Found MADNESS configured with MADNESS_ASSUMES_ASLR_DISABLED=${MADNESS_ASSUMES_ASLR_DISABLED} but TA is configured with TA_ASSUMES_ASLR_DISABLED=${TA_ASSUMES_ASLR_DISABLED}; MADNESS_ASSUMES_ASLR_DISABLED and TA_ASSUMES_ASLR_DISABLED should be the same") - endif() - - cmake_push_check_state() - - set(MADNESS_CONFIG_DIR ${MADNESS_DIR}) - - list(APPEND CMAKE_REQUIRED_INCLUDES ${MADNESS_INCLUDE_DIRS} ${TiledArray_CONFIG_INCLUDE_DIRS}) - list(APPEND CMAKE_REQUIRED_LIBRARIES "${MADNESS_LINKER_FLAGS}" ${MADNESS_LIBRARIES} - "${CMAKE_EXE_LINKER_FLAGS}" ${TiledArray_CONFIG_LIBRARIES}) - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${MADNESS_COMPILE_FLAGS} ${CMAKE_CXX_FLAGS} ${MADNESS_EXTRA_CXX_FLAGS}") - - # sanity check: try compiling a simple program - CHECK_CXX_SOURCE_COMPILES( - " - #include - int main(int argc, char** argv) { - madness::World& world = madness::initialize(argc, argv); - madness::finalize(); - return 0; - } - " MADNESS_COMPILES) - - if (NOT MADNESS_COMPILES) - message(FATAL_ERROR "MADNESS found, but does not compile correctly.") - endif() - - # ensure fresh MADNESS - CHECK_CXX_SOURCE_COMPILES( - " - #include - #include - int main(int argc, char** argv) { - // test 1 - madness::print_meminfo_enable(); - // test 2 - madness::World::is_default(SafeMPI::COMM_WORLD); - return 0; - } - " MADNESS_IS_FRESH) - - if (NOT MADNESS_IS_FRESH) - message(FATAL_ERROR "MADNESS is not fresh enough; update to ${_madness_tag}") - endif() - - cmake_pop_check_state() - - # Set config variables - list(APPEND TiledArray_CONFIG_INCLUDE_DIRS ${MADNESS_INCLUDE_DIRS}) - replace_mad_targets_with_libnames(MADNESS_LIBRARIES MADNESS_CONFIG_LIBRARIES) - list(APPEND TiledArray_CONFIG_LIBRARIES ${MADNESS_CONFIG_LIBRARIES}) - set(TiledArray_LIBRARIES ${MADNESS_LIBRARIES} ${TiledArray_LIBRARIES}) - - -elseif(TA_EXPERT) - - message("** MADNESS was not found or explicitly set") - message(FATAL_ERROR "** Downloading and building MADNESS is explicitly disabled in EXPERT mode") - -else() - - # look for C and MPI here to make troubleshooting easier and be able to override defaults for MADNESS - enable_language(C) - find_package(MPI REQUIRED COMPONENTS C CXX) - - find_package(Git REQUIRED) - message(STATUS "git found: ${GIT_EXECUTABLE}") - - # Create a cache entry for MADNESS build variables. - # Note: This will not overwrite user specified values. - set(MADNESS_SOURCE_DIR "${CMAKE_BINARY_DIR}/_deps/madness-src" CACHE PATH - "Path to the MADNESS source directory") - set(MADNESS_BINARY_DIR "${CMAKE_BINARY_DIR}/_deps/madness-build" CACHE PATH - "Path to the MADNESS build directory") - set(MADNESS_URL "https://github.com/m-a-d-n-e-s-s/madness.git" CACHE STRING - "Path to the MADNESS repository") - - # Setup configure variables - - # Set error handling method (for TA_ASSERT_POLICY allowed values see top-level CMakeLists.txt) - if(TA_ASSERT_POLICY STREQUAL TA_ASSERT_IGNORE) - set(_MAD_ASSERT_TYPE disable) - elseif(TA_ASSERT_POLICY STREQUAL TA_ASSERT_THROW) - set(_MAD_ASSERT_TYPE throw) - elseif(TA_ASSERT_POLICY STREQUAL TA_ASSERT_ABORT) - set(_MAD_ASSERT_TYPE abort) - endif() - set(MAD_ASSERT_TYPE ${_MAD_ASSERT_TYPE} CACHE INTERNAL "MADNESS assert type") - - # Check the MADNESS source directory to make sure it contains the source files - # If the MADNESS source directory is the default location and does not exist, - # MADNESS will be downloaded from git. - message(STATUS "Checking MADNESS source directory: ${MADNESS_SOURCE_DIR}") - if("${MADNESS_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}/_deps/madness-src") - - # Create the source directory - if(NOT EXISTS ${CMAKE_BINARY_DIR}/_deps) - set(error_code 1) - execute_process( - COMMAND "${CMAKE_COMMAND}" -E make_directory "${CMAKE_BINARY_DIR}/_deps" - RESULT_VARIABLE error_code) - if(error_code) - message(FATAL_ERROR "Failed to create directory \"${CMAKE_BINARY_DIR}/_deps\"") - endif() - endif() - - # Clone the MADNESS repository - if(NOT EXISTS ${MADNESS_SOURCE_DIR}/.git) - message(STATUS "Pulling MADNESS from: ${MADNESS_URL}") - set(error_code 1) - set(number_of_tries 0) - while(error_code AND number_of_tries LESS 3) - execute_process( - COMMAND ${GIT_EXECUTABLE} clone ${MADNESS_URL} madness-src - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/_deps - RESULT_VARIABLE error_code) - math(EXPR number_of_tries "${number_of_tries} + 1") - endwhile() - if(number_of_tries GREATER 1) - message(STATUS "Had to git clone more than once: ${number_of_tries} times.") - endif() - if(error_code) - message(FATAL_ERROR "Failed to clone repository: '${MADNESS_URL}'") - endif() - endif() - - elseif(EXISTS "${MADNESS_SOURCE_DIR}") - message(STATUS "Checking MADNESS source directory: ${MADNESS_SOURCE_DIR} - found") - else() - message(STATUS "Checking MADNESS source directory: ${MADNESS_SOURCE_DIR} - not found") - message(FATAL_ERROR "Path to MADNESS source directory does not exist.") - endif() - - if(EXISTS ${MADNESS_SOURCE_DIR}/.git) - # Checkout the correct MADNESS revision - set(error_code 1) - execute_process( - COMMAND "${GIT_EXECUTABLE}" fetch origin master - COMMAND "${GIT_EXECUTABLE}" checkout ${_madness_tag} - WORKING_DIRECTORY "${MADNESS_SOURCE_DIR}" - RESULT_VARIABLE error_code) - if(error_code) - message(FATAL_ERROR "Failed to checkout tag: '${_madness_tag}'") - endif() - - # Add update-madness target that will pull updates to the madness source - # from the git repository. This is done outside ExternalProject_add to - # prevent madness from doing a full pull, configure, and build everytime the - # project is built. - add_custom_target(update-madness - COMMAND ${GIT_EXECUTABLE} fetch origin master - COMMAND ${GIT_EXECUTABLE} checkout ${_madness_tag} - WORKING_DIRECTORY ${MADNESS_SOURCE_DIR} - COMMENT "Updating source for 'madness' from ${MADNESS_URL}") - - endif() - - # Check that the MADNESS source contains madness.h - message(STATUS "Looking for madness.h") - if(EXISTS ${MADNESS_SOURCE_DIR}/src/madness.h) - message(STATUS "Looking for madness.h - found") - else() - message(STATUS "Looking for madness.h - not found") - message("The MADNESS source was not found in ${MADNESS_SOURCE_DIR}.") - message("You can download the MADNESS source with:") - message("$ git clone https://github.com/m-a-d-n-e-s-s/madness.git madness") - message(FATAL_ERROR "MADNESS source not found.") - endif() - - # Create or clean the build directory - if(EXISTS "${MADNESS_BINARY_DIR}") - set(error_code 1) - execute_process( - COMMAND "${CMAKE_COMMAND}" -E remove -f "./*" - WORKING_DIRECTORY ${MADNESS_BINARY_DIR} - RESULT_VARIABLE error_code) - if(error_code) - message(FATAL_ERROR "Failed to delete existing files the MADNESS build directory.") - endif() - else() - set(error_code 1) - execute_process( - COMMAND "${CMAKE_COMMAND}" -E make_directory "${MADNESS_BINARY_DIR}" - RESULT_VARIABLE error_code) - if(error_code) - message(FATAL_ERROR "Failed to create the MADNESS build directory.") - endif() - endif() - - set(MADNESS_CMAKE_GENERATOR "${CMAKE_GENERATOR}" CACHE STRING "CMake generator to use for compiling MADNESS") - - # update all CMAKE_CXX_FLAGS to include extra preprocessor flags MADNESS needs - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MADNESS_EXTRA_CXX_FLAGS}") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${MADNESS_EXTRA_CXX_FLAGS}") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${MADNESS_EXTRA_CXX_FLAGS}") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${MADNESS_EXTRA_CXX_FLAGS}") - set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} ${MADNESS_EXTRA_CXX_FLAGS}") - - set(MADNESS_CMAKE_ARGS - -DMADNESS_BUILD_MADWORLD_ONLY=ON - -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} - -DMADNESS_ASSUMES_ASLR_DISABLED=${TA_ASSUMES_ASLR_DISABLED} - -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} - -DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} - "-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}" - "-DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG}" - "-DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE}" - "-DCMAKE_C_FLAGS_RELWITHDEBINFO=${CMAKE_C_FLAGS_RELWITHDEBINFO}" - "-DCMAKE_C_FLAGS_MINSIZEREL=${CMAKE_C_FLAGS_MINSIZEREL}" - -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}" - "-DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}" - "-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}" - "-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" - "-DCMAKE_CXX_FLAGS_MINSIZEREL=${CMAKE_CXX_FLAGS_MINSIZEREL}" - -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} - -DCMAKE_CXX_EXTENSIONS=${CMAKE_CXX_EXTENSIONS} - # F Fortran, assume we can link without its runtime - # -DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER} - # "-DCMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS}" - # "-DCMAKE_Fortran_FLAGS_DEBUG=${CMAKE_Fortran_FLAGS_DEBUG}" - # "-DCMAKE_Fortran_FLAGS_RELEASE=${CMAKE_Fortran_FLAGS_RELEASE}" - # "-DCMAKE_Fortran_FLAGS_RELWITHDEBINFO=${CMAKE_Fortran_FLAGS_RELWITHDEBINFO}" - # "-DCMAKE_Fortran_FLAGS_MINSIZEREL=${CMAKE_Fortran_FLAGS_MINSIZEREL}" - -DCMAKE_AR=${CMAKE_AR} - -DENABLE_MPI=${ENABLE_MPI} - -DMPI_THREAD=multiple - -DMPI_CXX_COMPILER=${MPI_CXX_COMPILER} - -DMPI_C_COMPILER=${MPI_C_COMPILER} - -DMPI_CXX_SKIP_MPICXX=ON # introduced in cmake 3.10, disables search for C++ MPI-2 bindings - -DENABLE_TBB=${ENABLE_TBB} - "-DTBB_ROOT_DIR=${TBB_ROOT_DIR}" - -DENABLE_GPERFTOOLS=${ENABLE_GPERFTOOLS} - -DENABLE_TCMALLOC_MINIMAL=${ENABLE_TCMALLOC_MINIMAL} - -DENABLE_LIBUNWIND=${ENABLE_LIBUNWIND} - -DASSERTION_TYPE=${MAD_ASSERT_TYPE} - "-DCMAKE_EXE_LINKER_FLAGS=${MAD_LDFLAGS}" - -DDISABLE_WORLD_GET_DEFAULT=ON - -DENABLE_MEM_PROFILE=ON - "-DENABLE_TASK_DEBUG_TRACE=${TILEDARRAY_ENABLE_TASK_DEBUG_TRACE}" - ${MADNESS_CMAKE_EXTRA_ARGS}) - - if (CMAKE_TOOLCHAIN_FILE) - if (IS_ABSOLUTE CMAKE_TOOLCHAIN_FILE) - set(absolute_toolchain_file_path "${CMAKE_TOOLCHAIN_FILE}") - else(IS_ABSOLUTE CMAKE_TOOLCHAIN_FILE) - # try relative to (TA) project source dir first, then to binary dir - get_filename_component(absolute_toolchain_file_path "${CMAKE_TOOLCHAIN_FILE}" ABSOLUTE - BASE_DIR "${PROJECT_SOURCE_DIR}") - if (NOT absolute_toolchain_file_path OR NOT EXISTS "${absolute_toolchain_file_path}") - get_filename_component(absolute_toolchain_file_path "${CMAKE_TOOLCHAIN_FILE}" ABSOLUTE - BASE_DIR "${PROJECT_BINARY_DIR}") - endif() - # better give up, if cannot resolve, then end up with MADNESS built with a different toolchain - if (NOT absolute_toolchain_file_path OR NOT EXISTS "${absolute_toolchain_file_path}") - message(FATAL_ERROR "could not resolve the absolute path to the toolchain file: CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}; specify the CMAKE_TOOLCHAIN_FILE as the absolute path to work around") - endif() - endif(IS_ABSOLUTE CMAKE_TOOLCHAIN_FILE) - set(MADNESS_CMAKE_ARGS "${MADNESS_CMAKE_ARGS}" - "-DCMAKE_TOOLCHAIN_FILE=${absolute_toolchain_file_path}") - endif(CMAKE_TOOLCHAIN_FILE) - - set(error_code 1) - message (STATUS "** Configuring MADNESS") - message (STATUS "MADNESS CMake generator: ${MADNESS_CMAKE_GENERATOR}") - message (STATUS "MADNESS CMake Arguments: ${MADNESS_CMAKE_ARGS}") - execute_process( - COMMAND ${CMAKE_COMMAND} - "${MADNESS_SOURCE_DIR}" - -G "${MADNESS_CMAKE_GENERATOR}" - ${MADNESS_CMAKE_ARGS} - WORKING_DIRECTORY "${MADNESS_BINARY_DIR}" - RESULT_VARIABLE error_code) - if(error_code) - message(FATAL_ERROR "The MADNESS cmake configuration failed.") - else(error_code) - message (STATUS "** Done configuring MADNESS") - endif(error_code) - - set(MADNESS_DIR ${MADNESS_BINARY_DIR}) - find_package_regimport(MADNESS ${TA_TRACKED_MADNESS_VERSION} CONFIG REQUIRED - COMPONENTS world HINTS ${MADNESS_BINARY_DIR}) - if (NOT TARGET MADworld) - message(FATAL_ERROR "Did not receive target MADworld") - endif() - if (MADNESS_CMAKE_EXTRA_ARGS MATCHES -DENABLE_PARSEC=ON) - if (NOT TARGET PaRSEC::parsec) - find_package_regimport(PaRSEC CONFIG REQUIRED COMPONENTS parsec) - endif() - endif() - set(TILEDARRAY_DOWNLOADED_MADNESS ON CACHE BOOL "Whether TA downloaded MADNESS") - mark_as_advanced(TILEDARRAY_DOWNLOADED_MADNESS) - - # TiledArray only needs MADworld library compiled to be ... - # as long as you mark dependence on it correcty its target properties - # will be used correctly (header locations, etc.) - set(MADNESS_WORLD_LIBRARY MADworld) - if (BUILD_SHARED_LIBS) - set(MADNESS_DEFAULT_LIBRARY_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX}) - set(MADNESS_EL_DEFAULT_LIBRARY_ABI_SUFFIX ".88-dev") - else(BUILD_SHARED_LIBS) - set(MADNESS_DEFAULT_LIBRARY_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX}) - set(MADNESS_EL_DEFAULT_LIBRARY_ABI_SUFFIX "") - endif(BUILD_SHARED_LIBS) - set(MADNESS_LIBRARIES ${MADNESS_WORLD_LIBRARY}) - - # custom target for building MADNESS components .. only MADworld here! - # N.B. Ninja needs spelling out the byproducts of custom targets, see https://cmake.org/cmake/help/v3.3/policy/CMP0058.html - set(MADNESS_BUILD_BYPRODUCTS "${MADNESS_BINARY_DIR}/src/madness/world/lib${MADNESS_WORLD_LIBRARY}${CMAKE_STATIC_LIBRARY_SUFFIX}") - message(STATUS "custom target build-madness is expected to build these byproducts: ${MADNESS_BUILD_BYPRODUCTS}") - add_custom_target(build-madness ALL - COMMAND ${CMAKE_COMMAND} --build . --target ${MADNESS_WORLD_LIBRARY} - WORKING_DIRECTORY ${MADNESS_BINARY_DIR} - BYPRODUCTS "${MADNESS_BUILD_BYPRODUCTS}" - COMMENT Building 'madness') - - # Add clean-madness target that will delete files generated by MADNESS build. - add_custom_target(clean-madness - COMMAND ${CMAKE_COMMAND} --build . --target clean - WORKING_DIRECTORY ${MADNESS_BINARY_DIR} - COMMENT Cleaning build directory for 'madness') - - # Since 'install-madness' target cannot be linked to the 'install' target, - # we will do it manually here. - set(INSTALL_MADNESS_SUBTARGETS install-madness-world install-madness-config install-madness-common) - foreach(INSTALL_MADNESS_SUBTARGET IN LISTS INSTALL_MADNESS_SUBTARGETS) - install(CODE - "execute_process( - COMMAND \"${CMAKE_COMMAND}\" \"--build\" \".\" \"--target\" \"${INSTALL_MADNESS_SUBTARGET}\" - WORKING_DIRECTORY \"${MADNESS_BINARY_DIR}\" - RESULT_VARIABLE error_code) - if(error_code) - message(FATAL_ERROR \"Failed to install 'madness'\") - endif() - " - ) - endforeach() - - # Set build dependencies and compiler arguments - add_dependencies(External-tiledarray build-madness) - - # Set config variables - replace_mad_targets_with_libnames(MADNESS_LIBRARIES MADNESS_CONFIG_LIBRARIES) - list(APPEND TiledArray_CONFIG_LIBRARIES ${MADNESS_CONFIG_LIBRARIES}) - -endif() - - -include_directories(${MADNESS_INCLUDE_DIRS}) -list (APPEND TiledArray_LIBRARIES ${MADNESS_LIBRARIES}) -append_flags(CMAKE_CXX_FLAGS "${MADNESS_COMPILE_FLAGS}") -append_flags(CMAKE_EXE_LINKER_FLAGS "${MADNESS_LINKER_FLAGS}") From 21c7b4405f863664fc8bbc68492e607c2eb0b6cf Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Thu, 26 Aug 2021 07:10:34 -0400 Subject: [PATCH 2/8] cleanup --- cmake/modules/FindOrFetchBoost.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/modules/FindOrFetchBoost.cmake b/cmake/modules/FindOrFetchBoost.cmake index 263b7a8d6a..4cfd9ea111 100644 --- a/cmake/modules/FindOrFetchBoost.cmake +++ b/cmake/modules/FindOrFetchBoost.cmake @@ -37,7 +37,7 @@ if (NOT TARGET Boost::boost) DESTINATION "${TILEDARRAY_INSTALL_CMAKEDIR}" COMPONENT boost-libs) -endif(TARGET Boost::boost) +endif(NOT TARGET Boost::boost) # postcond check if (NOT TARGET Boost::boost) From 34c76982007597702a018ffe6bf1bf70f3976db3 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Thu, 26 Aug 2021 07:11:34 -0400 Subject: [PATCH 3/8] bumped MADNESS tag to avoid consumption of madworld-only of MADNESS --- INSTALL.md | 2 +- cmake/modules/FindOrFetchMADWorld.cmake | 3 --- external/versions.cmake | 4 ++-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index bd72fc4d4a..844448562f 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -42,7 +42,7 @@ Both methods are supported. However, for most users we _strongly_ recommend to b - Boost.Range: header-only, *only used for unit testing* - [BTAS](http://github.com/ValeevGroup/BTAS), tag b7bddfcef89612652878854a447bacf4d3f6a5b0 . If usable BTAS installation is not found, TiledArray will download and compile BTAS from source. *This is the recommended way to compile BTAS for all users*. -- [MADNESS](https://github.com/m-a-d-n-e-s-s/madness), tag 3cebcd2adadb8365dd46629143d1915ff45fa3be . +- [MADNESS](https://github.com/m-a-d-n-e-s-s/madness), tag fb82aa568619b8ea11868e4015092dff12190f19 . Only the MADworld runtime and BLAS/LAPACK C API component of MADNESS is used by TiledArray. If usable MADNESS installation is not found, TiledArray will download and compile MADNESS from source. *This is the recommended way to compile MADNESS for all users*. diff --git a/cmake/modules/FindOrFetchMADWorld.cmake b/cmake/modules/FindOrFetchMADWorld.cmake index 1275829e1d..b129bb8248 100644 --- a/cmake/modules/FindOrFetchMADWorld.cmake +++ b/cmake/modules/FindOrFetchMADWorld.cmake @@ -51,9 +51,6 @@ if (NOT TARGET MADworld) # force 'all' target to build madness and MADworld using this dummy target add_custom_target(tiledarray-force-all-to-build-madness-target ALL DEPENDS madness MADworld) - # add MADworld target to the tiledarray export set - install(TARGETS MADworld EXPORT tiledarray) - endif(NOT TARGET MADworld) # postcond check diff --git a/external/versions.cmake b/external/versions.cmake index 41cf7cfcd5..4ca6730033 100644 --- a/external/versions.cmake +++ b/external/versions.cmake @@ -19,8 +19,8 @@ set(TA_INSTALL_EIGEN_PREVIOUS_VERSION 3.3.7) set(TA_INSTALL_EIGEN_URL_HASH b9e98a200d2455f06db9c661c5610496) set(TA_INSTALL_EIGEN_PREVIOUS_URL_HASH b9e98a200d2455f06db9c661c5610496) -set(TA_TRACKED_MADNESS_TAG 3cebcd2adadb8365dd46629143d1915ff45fa3be) -set(TA_TRACKED_MADNESS_PREVIOUS_TAG 12bd24c6cb984a639be863fc0e1364226713f7ff) +set(TA_TRACKED_MADNESS_TAG fb82aa568619b8ea11868e4015092dff12190f19) +set(TA_TRACKED_MADNESS_PREVIOUS_TAG 0be1dcea2667f5800ac1d5cc332b848e2bca60ea) set(TA_TRACKED_MADNESS_VERSION 0.10.1) set(TA_TRACKED_MADNESS_PREVIOUS_VERSION 0.10.1) From b1ba15854f551fcae2ed98f781c757d5d5f1eedd Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Thu, 26 Aug 2021 08:01:20 -0400 Subject: [PATCH 4/8] [cmake] fix building of mpi_tests --- examples/mpi_tests/CMakeLists.txt | 6 +++--- examples/mpi_tests/mpi_bandwidth.c | 3 ++- examples/mpi_tests/mpi_latency.c | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/mpi_tests/CMakeLists.txt b/examples/mpi_tests/CMakeLists.txt index 0b7894789b..a2e9829f23 100644 --- a/examples/mpi_tests/CMakeLists.txt +++ b/examples/mpi_tests/CMakeLists.txt @@ -28,16 +28,16 @@ if(NOT DISABLE_MPI) enable_language(C) # Add the mpi_bandwidth executable - add_ta_executable(mpi_bandwidth "mpi_bandwidth.c" "${MADNESS_LIBRARIES}") + add_ta_executable(mpi_bandwidth "mpi_bandwidth.c" MADworld) add_dependencies(examples-tiledarray mpi_bandwidth) # Add the mpi_latency executable - add_ta_executable(mpi_latency "mpi_latency.c" "${MADNESS_LIBRARIES}") + add_ta_executable(mpi_latency "mpi_latency.c" MADworld) add_dependencies(examples-tiledarray mpi_latency) if(CUDA_FOUND) - add_ta_executable(mpi_cuda "mpi_cuda.cpp" "${MADNESS_LIBRARIES}") + add_ta_executable(mpi_cuda "mpi_cuda.cpp" MADworld) set_source_files_properties(mpi_cuda.cpp PROPERTIES LANGUAGE CUDA) diff --git a/examples/mpi_tests/mpi_bandwidth.c b/examples/mpi_tests/mpi_bandwidth.c index 0266e8d6d5..3aa02bde28 100644 --- a/examples/mpi_tests/mpi_bandwidth.c +++ b/examples/mpi_tests/mpi_bandwidth.c @@ -6,11 +6,12 @@ * AUTHOR: Blaise Barney * LAST REVISED: 04/13/05 ****************************************************************************/ +#include #include #include #include #include -#include "mpi.h" +#include MADNESS_MPI_HEADER #define MAXTASKS 8192 /* Change the next four parameters to suit your case */ diff --git a/examples/mpi_tests/mpi_latency.c b/examples/mpi_tests/mpi_latency.c index 497dff2db4..ee7ce32e03 100644 --- a/examples/mpi_tests/mpi_latency.c +++ b/examples/mpi_tests/mpi_latency.c @@ -9,11 +9,12 @@ * AUTHOR: Blaise Barney * LAST REVISED: 04/13/05 ******************************************************************************/ +#include #include #include #include #include -#include "mpi.h" +#include MADNESS_MPI_HEADER #define NUMBER_REPS 1000 int main(int argc, char *argv[]) { From ec465d3a8ec3bc0e6499d7e5597469a956eb14d1 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Thu, 26 Aug 2021 08:39:53 -0400 Subject: [PATCH 5/8] [travis] use default install target for free-standing madness --- bin/build-madness-linux.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/build-madness-linux.sh b/bin/build-madness-linux.sh index 2c1aa45517..3e7b253937 100755 --- a/bin/build-madness-linux.sh +++ b/bin/build-madness-linux.sh @@ -73,8 +73,8 @@ if [ "$BUILD_TYPE" = "Debug" ]; then -DASSERTION_TYPE=throw \ -DDISABLE_WORLD_GET_DEFAULT=ON - # Build MADworld + LAPACK/BLAS interface - make -j2 install-madness-world install-madness-common install-madness-config VERBOSE=1 + # Build+install MADworld interface + make -j2 install VERBOSE=1 fi fi From 02daf17269ad3d6454fa828fd08728c7942e8d91 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Thu, 26 Aug 2021 11:37:03 -0400 Subject: [PATCH 6/8] bump MADNESS tag to avoid it picking up python2 --- INSTALL.md | 2 +- external/versions.cmake | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 844448562f..012938634e 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -42,7 +42,7 @@ Both methods are supported. However, for most users we _strongly_ recommend to b - Boost.Range: header-only, *only used for unit testing* - [BTAS](http://github.com/ValeevGroup/BTAS), tag b7bddfcef89612652878854a447bacf4d3f6a5b0 . If usable BTAS installation is not found, TiledArray will download and compile BTAS from source. *This is the recommended way to compile BTAS for all users*. -- [MADNESS](https://github.com/m-a-d-n-e-s-s/madness), tag fb82aa568619b8ea11868e4015092dff12190f19 . +- [MADNESS](https://github.com/m-a-d-n-e-s-s/madness), tag 0c0b41e8490f53c62508fd0c8d918fb642488fc2 . Only the MADworld runtime and BLAS/LAPACK C API component of MADNESS is used by TiledArray. If usable MADNESS installation is not found, TiledArray will download and compile MADNESS from source. *This is the recommended way to compile MADNESS for all users*. diff --git a/external/versions.cmake b/external/versions.cmake index 4ca6730033..326123d73f 100644 --- a/external/versions.cmake +++ b/external/versions.cmake @@ -19,8 +19,8 @@ set(TA_INSTALL_EIGEN_PREVIOUS_VERSION 3.3.7) set(TA_INSTALL_EIGEN_URL_HASH b9e98a200d2455f06db9c661c5610496) set(TA_INSTALL_EIGEN_PREVIOUS_URL_HASH b9e98a200d2455f06db9c661c5610496) -set(TA_TRACKED_MADNESS_TAG fb82aa568619b8ea11868e4015092dff12190f19) -set(TA_TRACKED_MADNESS_PREVIOUS_TAG 0be1dcea2667f5800ac1d5cc332b848e2bca60ea) +set(TA_TRACKED_MADNESS_TAG 0c0b41e8490f53c62508fd0c8d918fb642488fc2) +set(TA_TRACKED_MADNESS_PREVIOUS_TAG fb82aa568619b8ea11868e4015092dff12190f19) set(TA_TRACKED_MADNESS_VERSION 0.10.1) set(TA_TRACKED_MADNESS_PREVIOUS_VERSION 0.10.1) From 9c17954680f0d64c0edfe289c640dd6718c54f10 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Thu, 26 Aug 2021 14:38:26 -0400 Subject: [PATCH 7/8] [ci] use check-tiledarray target instead of check --- .github/workflows/ci.yml | 2 +- .gitlab-ci.yml | 2 +- bin/build-linux.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e75528073..663899ff1b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,4 +56,4 @@ jobs: run: | source ${{github.workspace}}/ci/openmpi.env cmake --build . --target ta_test - cmake --build . --target check + cmake --build . --target check-tiledarray diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a30fd2e9aa..a5582004ef 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,7 @@ default: variables: MAD_NUM_THREADS : 2 - TA_TARGETS : "tiledarray examples ta_test check" + TA_TARGETS : "tiledarray examples ta_test check-tiledarray" TA_CONFIG : > CMAKE_BUILD_TYPE=${BUILD_TYPE} TA_ASSERT_POLICY=TA_ASSERT_THROW diff --git a/bin/build-linux.sh b/bin/build-linux.sh index 3202896820..a6c55ed951 100755 --- a/bin/build-linux.sh +++ b/bin/build-linux.sh @@ -141,7 +141,7 @@ make -j1 ta_test VERBOSE=1 export MAD_NUM_THREADS=2 # to find dep shared libs (do we need this since El is gone?) export LD_LIBRARY_PATH=${INSTALL_PREFIX}/TA/lib:${INSTALL_PREFIX}/madness/lib:${LD_LIBRARY_PATH} -make check +make check-tiledarray # Build examples make -j2 examples VERBOSE=1 From 894fa0aaaec2a97ebe159275a965842d8e2bf2cd Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Thu, 26 Aug 2021 16:50:31 -0400 Subject: [PATCH 8/8] namespaced TA unit test names so that check-tiledarray works as intended --- CMakeLists.txt | 15 +++++++------- INSTALL.md | 6 +++--- external/versions.cmake | 8 ++++---- python/CMakeLists.txt | 44 ++++++++++++++++++++++------------------- tests/CMakeLists.txt | 20 ++++++++++++------- 5 files changed, 51 insertions(+), 42 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index addd6ff71c..a83f8b4541 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,7 +141,6 @@ endif() option(TA_TENSOR_MEM_PROFILE "Turn on instrumented profiling of TA::Tensor memory use" OFF) add_feature_info(TENSOR_MEM_PROFILE TA_TENSOR_MEM_PROFILE "instrumented profiling of TA::Tensor memory use") -option(TA_BUILD_UNITTEST "Causes building TiledArray unit tests" ON) option(TA_EXPERT "TiledArray Expert mode: disables automatically downloading or building dependencies" OFF) option(TA_SIGNED_1INDEX_TYPE "Enables the use of signed 1-index coordinate type (OFF in 1.0.0-alpha.2 and older)" ON) @@ -286,9 +285,9 @@ set_property( # if building unit tests default to throw to be able to test TA_ASSERT statements if (NOT (TA_ASSERT_POLICY STREQUAL TA_ASSERT_THROW)) - if (TA_BUILD_UNITTEST) - message(FATAL_ERROR "TA_ASSERT_POLICY=${TA_ASSERT_POLICY} requires TA_BUILD_UNITTEST=OFF") - endif(TA_BUILD_UNITTEST) + if (BUILD_TESTING) + message(FATAL_ERROR "TA_ASSERT_POLICY=${TA_ASSERT_POLICY} requires BUILD_TESTING=OFF") + endif(BUILD_TESTING) endif() ########################## @@ -371,12 +370,12 @@ add_subdirectory(doc) ########################## # checking/testing ########################## -enable_testing() -if (TA_BUILD_UNITTEST) - add_custom_target_subproject(tiledarray check USES_TERMINAL COMMAND ${CMAKE_CTEST_COMMAND} -V) +include(CTest) +if (BUILD_TESTING) + add_custom_target_subproject(tiledarray check USES_TERMINAL COMMAND ${CMAKE_CTEST_COMMAND} -V -R "tiledarray/unit") add_subdirectory(tests) else() - add_custom_target_subproject(tiledarray check USES_TERMINAL COMMAND echo "WARNING: unit testing disabled. To enable, add --unittest to configure, or give -DTA_BUILD_UNITTEST=TRUE to cmake") + add_custom_target_subproject(tiledarray check USES_TERMINAL COMMAND echo "WARNING: unit testing disabled. To enable, give -DBUILD_TESTING=ON to cmake") endif() ########################## diff --git a/INSTALL.md b/INSTALL.md index 012938634e..1672d549e0 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -40,9 +40,9 @@ Both methods are supported. However, for most users we _strongly_ recommend to b - Boost.Container: header-only - Boost.Test: header-only or (optionally) as a compiled library, *only used for unit testing* - Boost.Range: header-only, *only used for unit testing* -- [BTAS](http://github.com/ValeevGroup/BTAS), tag b7bddfcef89612652878854a447bacf4d3f6a5b0 . If usable BTAS installation is not found, TiledArray will download and compile +- [BTAS](http://github.com/ValeevGroup/BTAS), tag 0dc805fd7f2dea5e56eff94ab1c44b2b2397edd7 . If usable BTAS installation is not found, TiledArray will download and compile BTAS from source. *This is the recommended way to compile BTAS for all users*. -- [MADNESS](https://github.com/m-a-d-n-e-s-s/madness), tag 0c0b41e8490f53c62508fd0c8d918fb642488fc2 . +- [MADNESS](https://github.com/m-a-d-n-e-s-s/madness), tag 34ef8e6d6c61098d44ca559a530b4096e40b9a01 . Only the MADworld runtime and BLAS/LAPACK C API component of MADNESS is used by TiledArray. If usable MADNESS installation is not found, TiledArray will download and compile MADNESS from source. *This is the recommended way to compile MADNESS for all users*. @@ -400,7 +400,7 @@ support may be added. * `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_BUILD_UNITTEST` -- Set of `OFF` to disable building unit tests. The default is `ON`. +* `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_ENABLE_RANGEV3` -- Set to `ON` to find or fetch the Range-V3 library and enable additional tests of TA components with constructs anticipated to be supported in the future. [Default=OFF]. * `TA_SIGNED_1INDEX_TYPE` -- Set to `OFF` to use unsigned 1-index coordinate type (default for TiledArray 1.0.0-alpha.2 and older). The default is `ON`, which enables the use of negative indices in coordinates. diff --git a/external/versions.cmake b/external/versions.cmake index 326123d73f..95765bfe10 100644 --- a/external/versions.cmake +++ b/external/versions.cmake @@ -19,13 +19,13 @@ set(TA_INSTALL_EIGEN_PREVIOUS_VERSION 3.3.7) set(TA_INSTALL_EIGEN_URL_HASH b9e98a200d2455f06db9c661c5610496) set(TA_INSTALL_EIGEN_PREVIOUS_URL_HASH b9e98a200d2455f06db9c661c5610496) -set(TA_TRACKED_MADNESS_TAG 0c0b41e8490f53c62508fd0c8d918fb642488fc2) -set(TA_TRACKED_MADNESS_PREVIOUS_TAG fb82aa568619b8ea11868e4015092dff12190f19) +set(TA_TRACKED_MADNESS_TAG 34ef8e6d6c61098d44ca559a530b4096e40b9a01) +set(TA_TRACKED_MADNESS_PREVIOUS_TAG 0c0b41e8490f53c62508fd0c8d918fb642488fc2) set(TA_TRACKED_MADNESS_VERSION 0.10.1) set(TA_TRACKED_MADNESS_PREVIOUS_VERSION 0.10.1) -set(TA_TRACKED_BTAS_TAG b7bddfcef89612652878854a447bacf4d3f6a5b0) -set(TA_TRACKED_BTAS_PREVIOUS_TAG d7794799e4510cf66844081dd8f1f5b648112d33) +set(TA_TRACKED_BTAS_TAG 0dc805fd7f2dea5e56eff94ab1c44b2b2397edd7) +set(TA_TRACKED_BTAS_PREVIOUS_TAG b7bddfcef89612652878854a447bacf4d3f6a5b0) set(TA_TRACKED_CUTT_TAG 0e8685bf82910bc7435835f846e88f1b39f47f09) set(TA_TRACKED_CUTT_PREVIOUS_TAG 592198b93c93b7ca79e7900b9a9f2e79f9dafec3) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index f079c1d0ab..46ff408fa3 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -51,27 +51,31 @@ endif() target_link_libraries(python-tiledarray INTERFACE Boost::boost) -enable_testing() - -# build step -add_test(build_python "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target python-tiledarray) - -# check for presence of prerequisite modules -foreach(_mod pytest numpy) - execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import ${_mod}" +# tests +if (BUILD_TESTING) + # build step + add_test(tiledarray/unit/python/build "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target python-tiledarray) + set_tests_properties(tiledarray/unit/python/build PROPERTIES FIXTURES_SETUP TA_UNIT_TESTS_PYTHON_EXEC) + + # check for presence of prerequisite modules + foreach(_mod pytest numpy) + execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import ${_mod}" OUTPUT_QUIET ERROR_QUIET RESULTS_VARIABLE check_for_${_mod}) - if (check_for_${_mod}) - message(FATAL_ERROR "Python module \"${_mod}\" is not installed; install via \"${PYTHON_EXECUTABLE} -m pip install ${_mod}\" and rerun cmake") - endif(check_for_${_mod}) -endforeach(_mod) - -# test step -add_test( - NAME test_python - # need to use pytest to find tiledarray module properly - COMMAND ${PYTHON_EXECUTABLE} -m pytest ${PROJECT_SOURCE_DIR}/test_tiledarray.py -v - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + if (check_for_${_mod}) + message(FATAL_ERROR "Python module \"${_mod}\" is not installed; install via \"${PYTHON_EXECUTABLE} -m pip install ${_mod}\" and rerun cmake") + endif(check_for_${_mod}) + endforeach(_mod) + + # test step + add_test( + NAME tiledarray/unit/python/run + # need to use pytest to find tiledarray module properly + COMMAND ${PYTHON_EXECUTABLE} -m pytest ${PROJECT_SOURCE_DIR}/test_tiledarray.py -v + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} ) + set_tests_properties(tiledarray/unit/python/run + PROPERTIES FIXTURES_REQUIRED TA_UNIT_TESTS_PYTHON_EXEC + ENVIRONMENT MAD_NUM_THREADS=2) -set_tests_properties(test_python PROPERTIES DEPENDS build_python) +endif(BUILD_TESTING) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e16729bec0..a4b00ef92d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -154,7 +154,8 @@ if (TARGET range-v3::range-v3) endif (TARGET range-v3::range-v3) # Add targets -add_test(build_${executable} "${CMAKE_COMMAND}" --build ${PROJECT_BINARY_DIR} --target ${executable}) +add_test(tiledarray/unit/build "${CMAKE_COMMAND}" --build ${PROJECT_BINARY_DIR} --target ${executable}) +set_tests_properties(tiledarray/unit/build PROPERTIES FIXTURES_SETUP TA_UNIT_TESTS_EXEC) # Add a test(s) if(ENABLE_MPI) @@ -162,19 +163,24 @@ if(ENABLE_MPI) set (${executable}_np_2_args --run_test=!@serial) foreach(p RANGE 1 2) add_test( - NAME ${executable}-np-${p} + NAME tiledarray/unit/run-np-${p} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${p} ${MPIEXEC_PREFLAGS} $ --log_level=warning --show-progress ${${executable}_np_${p}_args} ${MPIEXEC_POSTFLAGS} ) - set_tests_properties(${executable}-np-${p} PROPERTIES DEPENDS build_${executable}) + set_tests_properties(tiledarray/unit/run-np-${p} + PROPERTIES FIXTURES_REQUIRED TA_UNIT_TESTS_EXEC + ENVIRONMENT MAD_NUM_THREADS=2) + if (p GREATER 1) - set_tests_properties(${executable}-np-${p} PROPERTIES ENVIRONMENT TA_UT_DISTRIBUTED=1) + set_tests_properties(tiledarray/unit/run-np-${p} PROPERTIES ENVIRONMENT TA_UT_DISTRIBUTED=1) endif() endforeach(p) else() - add_test(NAME ${executable} - COMMAND ${executable}) - set_tests_properties(${executable} PROPERTIES DEPENDS build_${executable}) + add_test(NAME tiledarray/unit/run-np-1 + COMMAND ${executable}) + set_tests_properties(tiledarray/unit/run-np-1 + PROPERTIES FIXTURES_REQUIRED TA_UNIT_TESTS_EXEC + ENVIRONMENT MAD_NUM_THREADS=2) endif()