diff --git a/.github/workflows/macosx-clang-mpich.yml b/.github/workflows/macosx-clang-mpich.yml index 73001e9d18..470dd6849f 100644 --- a/.github/workflows/macosx-clang-mpich.yml +++ b/.github/workflows/macosx-clang-mpich.yml @@ -27,7 +27,7 @@ jobs: VT_LB_ENABLED: 1 VT_TRACE_ENABLED: 1 VT_WERROR: 1 - CMAKE_CXX_STANDARD: 17 + CMAKE_CXX_STANDARD: 20 CMAKE_GENERATOR: "Unix Makefiles" CMAKE_BUILD_PARALLEL_LEVEL: 4 diff --git a/.github/workflows/spawn-extended-tests-label.yml b/.github/workflows/spawn-extended-tests-label.yml index c4b6055133..630df7daba 100644 --- a/.github/workflows/spawn-extended-tests-label.yml +++ b/.github/workflows/spawn-extended-tests-label.yml @@ -19,8 +19,7 @@ jobs: fail-fast: false matrix: target: - - vt-build-amd64-ubuntu-20-04-gcc-9-cuda-11-4-3-cpp - - vt-build-amd64-ubuntu-20-04-gcc-9-cuda-12-2-0-cpp + - vt-build-amd64-ubuntu-24-04-gcc-13-cuda-12-9-0-cpp - vt-build-amd64-ubuntu-24-04-icpx-cpp steps: diff --git a/.gitignore b/.gitignore index b80ef85489..0fe13e568f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ build transport lib/*-build lib/checkpoint +lib/loc lib/googletest lib/kokkos lib/vt-tv diff --git a/CMakeLists.txt b/CMakeLists.txt index 12483d0d80..6af48bff27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,10 @@ file(READ "VERSION" _vt_version_str) string(STRIP "${_vt_version_str}" _vt_version_str) project(vt VERSION ${_vt_version_str}) +# VT does not use C++ modules. Disable CMake's automatic C++20 module +# dependency scanning so builds do not require clang-scan-deps. +set(CMAKE_CXX_SCAN_FOR_MODULES OFF) + # To generate output file with compilation errors and warnings # CMake generator needs to be known set(USED_CMAKE_GENERATOR "${CMAKE_GENERATOR}" CACHE STRING "Expose CMAKE_GENERATOR" FORCE) @@ -41,7 +45,7 @@ set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD_REQUIRED ON) if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 17 CACHE STRING "The C++ standard to use") + set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard to use") endif() message(STATUS "CMAKE_CXX_STANDARD: ${CMAKE_CXX_STANDARD}") @@ -70,6 +74,7 @@ include(cmake/check_compiler.cmake) include(cmake/nvcc_no_deprecated_gpu_targets.cmake) include(cmake/load_bundled_libraries.cmake) include(cmake/load_local_packages.cmake) +include(cmake/load_loc_repositories.cmake) # Primary VT build add_subdirectory(src) diff --git a/ci/add_spack_loc_resource.py b/ci/add_spack_loc_resource.py new file mode 100644 index 0000000000..f1dddbf3a1 --- /dev/null +++ b/ci/add_spack_loc_resource.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 + +"""Add the loc source resource needed by a VT pull-request version.""" + +import re +import sys +from pathlib import Path + + +LOC_BRANCH = "develop" + + +if len(sys.argv) != 3 or not sys.argv[2].strip(): + sys.exit( + "usage: add_spack_loc_resource.py " + ) + +package_file = Path(sys.argv[1]) +version = sys.argv[2] +text = package_file.read_text() + +resource = f''' resource( + name="loc", + git="https://github.com/DARMA-tasking/loc.git", + branch="{LOC_BRANCH}", + destination="lib", + placement="loc", + when="@{version}", + ) +''' + +if resource not in text: + version_pattern = re.compile( + rf'^\s*version\(["\']{re.escape(version)}["\'].*$', + re.MULTILINE, + ) + version_match = version_pattern.search(text) + if version_match is None: + sys.exit(f"version {version!r} was not found in {package_file}") + + insertion_point = text.find("\n", version_match.end()) + 1 + text = text[:insertion_point] + "\n" + resource + text[insertion_point:] + package_file.write_text(text) diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index d7c9d89140..e1369a6348 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -11,6 +11,7 @@ env | sort # Dependency versions, when fetched via git. checkpoint_rev=develop +loc_rev=develop if [ -z ${4} ]; then dashj="" @@ -98,6 +99,14 @@ else fi fi +if test -d "${source_dir}/lib/loc" +then + { echo "loc already in lib... not downloading"; } 2>/dev/null +else + cd "${source_dir}/lib" + git clone -b "${loc_rev}" --depth 1 https://github.com/DARMA-tasking/loc.git +fi + if test "${VT_TV_ENABLED}" -eq 1 then if test -d "${source_dir}/lib/vt-tv" @@ -176,7 +185,7 @@ cmake -G "${CMAKE_GENERATOR:-Ninja}" \ -Dfmt_DIR="${FMT_DIR}" \ -Dlibunwind_ROOT="${LIBUNWIND_ROOT:-/usr}" \ -Dvt_no_color_enabled="${VT_NO_COLOR_ENABLED:-0}" \ - -DCMAKE_CXX_STANDARD="${CMAKE_CXX_STANDARD:-17}" \ + -DCMAKE_CXX_STANDARD="${CMAKE_CXX_STANDARD:-20}" \ -DBUILD_SHARED_LIBS="${BUILD_SHARED_LIBS:-0}" \ "$VT" cmake_conf_ret=$? diff --git a/ci/build_vt_sample.sh b/ci/build_vt_sample.sh index fdbff08af5..54f75f45e8 100755 --- a/ci/build_vt_sample.sh +++ b/ci/build_vt_sample.sh @@ -49,7 +49,7 @@ then -Dvt_build_examples="0" \ -Dvt_build_tests="0" \ -Dvt_external_fmt="${VT_EXTERNAL_FMT:-0}" \ - -DCMAKE_CXX_STANDARD="${CMAKE_CXX_STANDARD:-17}" \ + -DCMAKE_CXX_STANDARD="${CMAKE_CXX_STANDARD:-20}" \ -DCMAKE_EXPORT_COMPILE_COMMANDS=1 \ -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" \ -DCMAKE_CXX_COMPILER="${CXX:-c++}" \ diff --git a/ci/ctest_build_all.sh b/ci/ctest_build_all.sh index 9605c7a94a..f4959b1842 100755 --- a/ci/ctest_build_all.sh +++ b/ci/ctest_build_all.sh @@ -7,6 +7,7 @@ build_dir=${2} # Dependency versions, when fetched via git. checkpoint_rev=develop +loc_rev=develop export parallel_level=4 if [ -z ${4} ]; then @@ -61,6 +62,14 @@ else fi fi +if test -d "${source_dir}/lib/loc" +then + { echo "loc already in lib... not downloading"; } 2>/dev/null +else + cd "${source_dir}/lib" + git clone -b "${loc_rev}" --depth 1 https://github.com/DARMA-tasking/loc.git +fi + if test "${VT_ZOLTAN_ENABLED:-0}" -eq 1 then export Zoltan_DIR=${ZOLTAN_DIR:-""} diff --git a/ci/docker/vt.dockerfile b/ci/docker/vt.dockerfile index 6205cf8313..188064d4ae 100644 --- a/ci/docker/vt.dockerfile +++ b/ci/docker/vt.dockerfile @@ -69,6 +69,10 @@ RUN --mount=type=cache,id=${CACHE_ID},target=/build/ccache \ --mount=type=cache,id=BUILD-${CACHE_ID},target=/build/vt \ --mount=type=secret,id=GITHUB_TOKEN,env=GITHUB_TOKEN \ --mount=target=/vt,rw \ + if [ "${VT_TV_ENABLED}" = "1" ]; then \ + apt-get update -y -q && \ + apt-get install -y -q --no-install-recommends nlohmann-json3-dev; \ + fi && \ if [ "${VT_TEST_SPACK}" = "1" ]; then \ apt update -y -q && apt install -y -q libssl-dev unzip && \ /vt/ci/test_spack_package.sh; \ diff --git a/ci/test_spack_package.sh b/ci/test_spack_package.sh index 600e34366b..2457387794 100755 --- a/ci/test_spack_package.sh +++ b/ci/test_spack_package.sh @@ -4,12 +4,15 @@ set -exo pipefail cur_path=$(pwd) vt_spack_package="$cur_path/spack-package" +script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd) git clone --branch v1.2.2 --depth=2 https://github.com/spack/spack.git . spack/share/spack/setup-env.sh git clone -b master https://github.com/DARMA-tasking/spack-package.git python3 spack-package/ci/add_vt_branch.py "${GIT_BRANCH}" +python3 "${script_dir}/add_spack_loc_resource.py" \ + spack-package/packages/darma-vt/package.py "${GIT_BRANCH}" declare -A variables_map variables_map["lb_enabled"]="${VT_LB_ENABLED:-0}" @@ -35,7 +38,8 @@ do done install_cmd=$(printf " %s" "${cmd_vars[@]}") -install_cmd="spack install darma-vt@${GIT_BRANCH} build_type=Release ${install_cmd:1} ^openmpi@4.0.4" +# Match VT/loc's fmt headers, including when Spack has not listed this release. +install_cmd="spack install darma-vt@${GIT_BRANCH} build_type=Release ${install_cmd:1} ^openmpi@4.0.4 ^fmt@git.12.2.0=12.2.0" mkdir -p ~/.spack cat >> ~/.spack/packages.yaml <<'EOF' diff --git a/cmake/check_compiler.cmake b/cmake/check_compiler.cmake index 3212345d8f..11f9c09790 100644 --- a/cmake/check_compiler.cmake +++ b/cmake/check_compiler.cmake @@ -12,7 +12,7 @@ function(check_cc_quirk VAR CC_FILE) ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cc_tests/${CC_FILE} OUTPUT_VARIABLE check_cc_quirk_output - CXX_STANDARD 17 + CXX_STANDARD 20 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF ) diff --git a/cmake/load_bundled_libraries.cmake b/cmake/load_bundled_libraries.cmake index c555e63150..700ff47ebd 100644 --- a/cmake/load_bundled_libraries.cmake +++ b/cmake/load_bundled_libraries.cmake @@ -21,33 +21,23 @@ endif() add_subdirectory(${PROJECT_LIB_DIR}/CLI) # Use an external fmt package or configure VT's shared DARMA fmt provider. -if(${vt_external_fmt}) - # user should provide 'fmt_DIR' or 'fmt_ROOT' to CMake (unless fmt is installed in system libs) - if(fmt_ROOT) - message(STATUS "vt_external_fmt = ON. Using fmt located at ${fmt_ROOT}") - elseif(fmt_DIR) - message(STATUS "vt_external_fmt = ON. Using fmt located at ${fmt_DIR}") - else() - message(STATUS "vt_external_fmt = ON but neither fmt_DIR nor fmt_ROOT is provided!") - endif() - find_package(fmt 10.2.1 REQUIRED) - set(FMT_LIBRARY "") - set(FMT_LINK_TARGET fmt::fmt) +include(setup_fmt) +if(vt_external_fmt AND NOT TARGET fmt::fmt) + find_package(fmt 12.2.0 EXACT CONFIG REQUIRED) + # Record the verified package version for setup_fmt's existing reuse check. + set_property(TARGET fmt::fmt PROPERTY INTERFACE_DARMA_FMT_VERSION 120200) +endif() +darma_setup_fmt( + SOURCE_DIR "${PROJECT_LIB_DIR}/fmt" + VENDORED_TARGET fmt + OUT_LIBRARY FMT_LIBRARY + OUT_LINK_TARGET FMT_LINK_TARGET + POST_ADD_COMMAND set_darma_compiler_flags +) +if(FMT_LIBRARY OR vt_external_fmt) set(vt_uses_parent_fmt 0) else() - include(setup_fmt) - darma_setup_fmt( - SOURCE_DIR "${PROJECT_LIB_DIR}/fmt" - VENDORED_TARGET fmt - OUT_LIBRARY FMT_LIBRARY - OUT_LINK_TARGET FMT_LINK_TARGET - POST_ADD_COMMAND set_darma_compiler_flags - ) - if(FMT_LIBRARY) - set(vt_uses_parent_fmt 0) - else() - set(vt_uses_parent_fmt 1) - endif() + set(vt_uses_parent_fmt 1) endif() # yaml-cpp always included in the build diff --git a/cmake/load_loc_repositories.cmake b/cmake/load_loc_repositories.cmake new file mode 100644 index 0000000000..e53ea9e0bb --- /dev/null +++ b/cmake/load_loc_repositories.cmake @@ -0,0 +1,23 @@ +if (EXISTS "${PROJECT_LIB_DIR}/loc") + # loc detects that it is embedded and disables its standalone comm/MPI + # backend, examples, tests, and documentation. VT supplies LocCommunicator. + add_subdirectory(${PROJECT_LIB_DIR}/loc) +else() + message( + FATAL_ERROR + "DARMA/loc was not found. Clone https://github.com/DARMA-tasking/loc.git " + "into ${PROJECT_LIB_DIR}/loc before configuring VT." + ) +endif() + +get_target_property( + VT_LOC_INCLUDE_DIRECTORIES loc::loc INTERFACE_INCLUDE_DIRECTORIES +) + +# loc is header-only and does not currently define install rules. Install its +# public headers with VT so installed VT packages do not need the source tree. +install( + DIRECTORY "${PROJECT_LIB_DIR}/loc/src/loc" + DESTINATION include + FILES_MATCHING PATTERN "*.h" +) diff --git a/docker-bake.hcl b/docker-bake.hcl index 3193c9fac3..d421af63f6 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -191,7 +191,7 @@ function "vt_ldms" { function "vt_cmake_cxx_standard" { params = [item] - result = lookup(item, "vt_cmake_cxx_standard", 17) + result = lookup(item, "vt_cmake_cxx_standard", 20) } function "vt_find_mpi" { @@ -294,14 +294,16 @@ target "vt-build-all" { vt_production_build = 1 }, { - image = "amd64-ubuntu-20.04-clang-10-cpp" + image = "amd64-ubuntu-22.04-clang-14-cpp" + variant = "ubsan" vt_tests_num_nodes = 8 vt_ubsan = 1 #FIXME ubsan_options = "print_stacktrace=1" }, { - image = "amd64-ubuntu-20.04-clang-9-cpp" + image = "amd64-ubuntu-22.04-clang-15-cpp" + variant = "shared-ext-lib" vt_build_shared_libs = 1 vt_inclusion = "EXT_LIB" vt_werror = 0 @@ -322,19 +324,7 @@ target "vt-build-all" { variant = "spack" }, { - image = "amd64-ubuntu-20.04-gcc-9-cpp" - }, - { - image = "amd64-ubuntu-20.04-gcc-9-cuda-11.4.3-cpp" - vt_diagnostics = 0 - vt_extended_tests = 0 - vt_external_fmt = 1 - vt_pool = 0 - vt_tests_num_nodes = 8 - vt_trace = 1 - }, - { - image = "amd64-ubuntu-20.04-gcc-9-cuda-12.2.0-cpp" + image = "amd64-ubuntu-24.04-gcc-13-cuda-12.9.0-cpp" vt_debug_verbose = 1 vt_diagnostics = 0 vt_extended_tests = 0 @@ -350,7 +340,8 @@ target "vt-build-all" { vt_trace = 1 }, { - image = "amd64-ubuntu-22.04-clang-11-cpp" + image = "amd64-ubuntu-22.04-clang-13-cpp" + variant = "fcontext" vt_fcontext = 1 }, { @@ -364,12 +355,13 @@ target "vt-build-all" { }, { image = "amd64-ubuntu-22.04-clang-14-cpp" + variant = "trace-debug" vt_trace = 1 vt_debug_verbose = 1 }, { image = "amd64-ubuntu-22.04-clang-15-cpp" - variant = "cxx20" + variant = "debug" vt_cmake_cxx_standard = 20 vt_debug_verbose = 1 vt_production_build = 0 @@ -427,7 +419,7 @@ target "vt-build-all" { variant = "docs" }, { - image = "amd64-ubuntu-20.04-gcc-9-ldms-cpp" + image = "amd64-ubuntu-20.04-gcc-10-ldms-cpp" vt_ldms = 1 vt_lb = 0 vt_trace = 0 diff --git a/docker-compose.yml b/docker-compose.yml index 1f43d8f2b2..7a818c0b3b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -82,7 +82,7 @@ x-ccache: &ccache x-vtopts: &vtopts BUILD_SHARED_LIBS: ${VT_BUILD_SHARED_LIBS:-0} CMAKE_BUILD_TYPE: ${BUILD_TYPE:-release} - CMAKE_CXX_STANDARD: ${CMAKE_CXX_STANDARD:-17} + CMAKE_CXX_STANDARD: ${CMAKE_CXX_STANDARD:-20} CODECOV_TOKEN: ${CODECOV_TOKEN:-} http_proxy: ${PROXY-} https_proxy: ${PROXY-} diff --git a/docs/Doxyfile.in-mcss b/docs/Doxyfile.in-mcss index 8d1fd5803e..28f1e0dbd6 100644 --- a/docs/Doxyfile.in-mcss +++ b/docs/Doxyfile.in-mcss @@ -6,7 +6,7 @@ M_SHOW_UNDOCUMENTED = YES EXTRACT_ALL = YES M_LINKS_NAVBAR1 = \ - "introduction context active-messenger collection collective group location objgroup pipe pool rdmahandle registry scheduler term trace trace-only" \ + "introduction context active-messenger collection collective group objgroup pipe pool rdmahandle registry scheduler term trace trace-only" \ "learn vt-build tutorial examples ckpt_learn_serialize" \ "pages" \ "namespaces namespacevt namespacevt_1_1collective namespacevt_1_1debug namespacevt_1_1group namespacevt_1_1location namespacevt_1_1messaging namespacevt_1_1objgroup namespacevt_1_1pipe namespacevt_1_1rdma namespacevt_1_1runtime namespacevt_1_1term namespacevt_1_1vrt" diff --git a/docs/md/building.md b/docs/md/building.md index 91a720edc7..5a5999234e 100644 --- a/docs/md/building.md +++ b/docs/md/building.md @@ -10,18 +10,20 @@ To build \vt, one must obtain the following dependencies: \subsection required-deps Required - checkpoint, (*vt* ecosystem) + - loc, (*vt* ecosystem) - MPI (mpich/openmpi/mvapich/IBM Spectrum MPI/Cray MPICH/etc.) \subsection automatic-build-deps Automatically build dependencies -Assuming MPI is installed and accessible via CC/CXX, the only other dependency -that is required is checkpoint. The easiest way to get these -built are to clone it inside `vt/lib`: +Assuming MPI is installed and accessible via CC/CXX, the other required +dependencies are checkpoint and loc. The easiest way to build them is to clone +them inside `vt/lib`: ```bash $ git clone git@github.com:DARMA-tasking/vt $ cd vt/lib $ git clone git@github.com:DARMA-tasking/checkpoint +$ git clone git@github.com:DARMA-tasking/loc ``` With these in `vt/lib`, cmake will automatically build them and stitch them into @@ -29,10 +31,10 @@ With these in `vt/lib`, cmake will automatically build them and stitch them into \subsection use-cmake-directly-vars Using cmake directly -One may use `cmake` as normal on *vt*, with checkpoint cloned in -`vt/lib` to compile them all together as explained above. The following are some -custom configuration build options that can be provided to `cmake` to change the -build configuration: +One may use `cmake` as normal on *vt*, with checkpoint and loc cloned in +`vt/lib` to compile them all together as explained above. The following are +some custom configuration build options that can be provided to `cmake` to +change the build configuration: | CMake Variable | Default Value | Description | | -------------------------------- | --------------- | -------------------------------------------------------------------------------------------------- | diff --git a/docs/md/location.md b/docs/md/location.md deleted file mode 100644 index d9d57915db..0000000000 --- a/docs/md/location.md +++ /dev/null @@ -1,38 +0,0 @@ -\page location Location Manager -\brief Virtual entity location management - -The location manager component `vt::location::LocationManager`, accessed via -`vt::theLocMan()` manages the location of arbitrary virtual entities in the -system. It holds a set of live `vt::location::EntityLocationCoord` across the -distributed system which allow users to register/unregister entities and inform -the system when migrations occur. With the entities registered, the location -coordinator can route messages to them even in the presence of migrations that -may occur at any time. The location coordinator maintains a cache of locations -for entities registered off-node and forwards messages using a communication -protocol that depends on the size of the message. - -Every entity in the system has a "home node", which is the node that is -ultimately responsible for knowing the location of the entity. When an entity -migrates, it informs the home node of its new location in the system. Nodes that -try to route messages to that entity will inquire the home node unless the -location is already in cache. - -\section comm-protocol Eager vs. Rendezvous Routing Protocol - -The variable `vt::location::small_msg_max_size` controls whether a message is -routed with an eager or rendezvous protocol. If the message is under that size -limit, the message is routed eagerly---forwarded to the "home node" for -resolution if the location is not in the cache. - -If the size of the message is greater than `vt::location::small_msg_max_size`, -the location coordinator will inquire with a control message to resolve the -location before the large message is actually sent. This reduces the number of -hops required to send large messages. - -\section location-migrations Entity Migrations - -When migrations occur at any time, it's always possible for the message to -arrive on a node where the entity *used to be*. In this case, the location -coordinator knows to follow the breadcrumb to get the message delivered properly -where the entity exists now. If the entity continues to move, the message will -"chase" it until it catches up. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6f81975a8d..798c38d1d8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -64,10 +64,7 @@ set( rdma/channel rdma/collection rdma/group rdma/state rdmahandle topos/location - topos/location/cache topos/location/message topos/location/record - topos/location/utility - topos/location/directory - topos/location/lookup + topos/location/message topos/location/utility topos/index topos/index/dense topos/index/traits topos/index/printer topos/mapping @@ -138,6 +135,7 @@ install( DESTINATION ${VT_INSTALL_DESTINATION} CONFIGURATIONS ${build_type_list} ) + file( GLOB HEADER_FILES @@ -213,7 +211,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/../cmake/build_git_info.cmake) target_compile_features( ${VIRTUAL_TRANSPORT_LIBRARY} PUBLIC - cxx_std_17 + cxx_std_20 ) include(turn_on_warnings) @@ -263,6 +261,7 @@ include(../cmake/define_build_types.cmake) target_include_directories( ${VIRTUAL_TRANSPORT_LIBRARY} PUBLIC $ + $ $ ) diff --git a/src/vt/rdma/collection/rdma_collection_info.h b/src/vt/rdma/collection/rdma_collection_info.h index fd9a6936fc..a13767f2eb 100644 --- a/src/vt/rdma/collection/rdma_collection_info.h +++ b/src/vt/rdma/collection/rdma_collection_info.h @@ -45,12 +45,12 @@ #define INCLUDED_VT_RDMA_COLLECTION_RDMA_COLLECTION_INFO_H #include "vt/config.h" -#include "vt/topos/location/cache/cache.h" -#include "vt/topos/location/record/record.h" +#include +#include namespace vt { namespace rdma { -namespace loc = ::vt::location; +namespace loc = ::loc; struct CollectionInfo { using ElmType = RDMA_ElmType; diff --git a/src/vt/topos/location/cache/cache.h b/src/vt/topos/location/cache/cache.h deleted file mode 100644 index 4002deaff6..0000000000 --- a/src/vt/topos/location/cache/cache.h +++ /dev/null @@ -1,99 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// cache.h -// DARMA/vt => Virtual Transport -// -// Copyright 2019-2024 National Technology & Engineering Solutions of Sandia, LLC -// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. -// Government retains certain rights in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact darma@sandia.gov -// -// ***************************************************************************** -//@HEADER -*/ - -#if !defined INCLUDED_VT_TOPOS_LOCATION_CACHE_CACHE_H -#define INCLUDED_VT_TOPOS_LOCATION_CACHE_CACHE_H - -#include "vt/config.h" -#include "vt/topos/location/location_common.h" -#include "vt/context/context.h" - -#include -#include -#include - -namespace vt { namespace location { - -template -struct LocationCache { - using LookupType = std::tuple; - using CacheOrderedType = std::list; - using ValueIter = typename CacheOrderedType::iterator; - using LookupContainerType = std::unordered_map; - - explicit LocationCache(LocationSizeType const& in_max_size); - - LocationCache(LocationCache const&) = delete; - LocationCache(LocationCache&&) = default; - LocationCache& operator=(LocationCache const&) = default; - - bool exists(KeyT const& key) const; - LocationSizeType getSize() const; - ValueT const& get(KeyT const& key); - void remove(KeyT const& key); - void insert(KeyT const& key, ValueT const& value); - void printCache() const; - - template - void serialize(Serializer& s) { - s | cache_ - | max_size_ - | lookup_; - } - - private: - // container for quick lookup - LookupContainerType lookup_; - - // the location records sorted in LRU cache - CacheOrderedType cache_; - - // the maximum size the cache is allowed to grow - LocationSizeType max_size_; -}; - -}} // end namespace vt::location - -#include "vt/topos/location/cache/cache.impl.h" - -#endif /*INCLUDED_VT_TOPOS_LOCATION_CACHE_CACHE_H*/ diff --git a/src/vt/topos/location/cache/cache.impl.h b/src/vt/topos/location/cache/cache.impl.h deleted file mode 100644 index acd0d2177e..0000000000 --- a/src/vt/topos/location/cache/cache.impl.h +++ /dev/null @@ -1,155 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// cache.impl.h -// DARMA/vt => Virtual Transport -// -// Copyright 2019-2024 National Technology & Engineering Solutions of Sandia, LLC -// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. -// Government retains certain rights in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact darma@sandia.gov -// -// ***************************************************************************** -//@HEADER -*/ - -#if !defined INCLUDED_VT_TOPOS_LOCATION_CACHE_CACHE_IMPL_H -#define INCLUDED_VT_TOPOS_LOCATION_CACHE_CACHE_IMPL_H - -#include "vt/config.h" -#include "vt/topos/location/location_common.h" -#include "vt/topos/location/cache/cache.h" -#include "vt/context/context.h" - -#include -#include -#include -#include -#include -#include -#include - -namespace vt { namespace location { - -template -LocationCache::LocationCache(LocationSizeType const& in_max_size) - : max_size_(in_max_size) -{ } - -template -bool LocationCache::exists(KeyT const& key) const { - auto iter = lookup_.find(key); - return iter != lookup_.end(); -} - -template -ValueT const& LocationCache::get(KeyT const& key) { - auto iter = lookup_.find(key); - - vtAssert(iter != lookup_.end(), "Key must exist in cache"); - - cache_.splice(cache_.begin(), cache_, iter->second); - - return std::get<1>(*iter->second); -} - -template -LocationSizeType LocationCache::getSize() const { - return max_size_; -} - -template -void LocationCache::remove(KeyT const& key) { - auto iter = lookup_.find(key); - if (iter != lookup_.end()) { - cache_.erase(iter->second); - lookup_.erase(iter); - } -} - -template -void LocationCache::insert(KeyT const& key, ValueT const& value) { - auto iter = lookup_.find(key); - - vt_debug_print( - verbose, location, - "location cache: insert: found={}, size={}\n", - print_bool(iter != lookup_.end()), lookup_.size() - ); - - if (iter == lookup_.end()) { - if (lookup_.size() + 1 > max_size_) { - auto last_iter = cache_.crbegin(); - lookup_.erase(std::get<0>(*last_iter)); - cache_.pop_back(); - } - - cache_.push_front(std::make_tuple(key, value)); - - lookup_.emplace( - std::piecewise_construct, - std::forward_as_tuple(key), - std::forward_as_tuple(cache_.begin()) - ); - } else { - std::get<1>(*iter->second) = value; - cache_.splice(cache_.cbegin(), cache_, iter->second); - } -} - -template -void LocationCache::printCache() const { - std::stringstream stream; - - stream << "lookup_.size=" << lookup_.size() << ", " - << "cache_.size=" << cache_.size() - << "\n"; - - for (auto&& elm : lookup_) { - stream << "\t lookup val: entity=" << std::get<0>(elm) << "\n"; - } - - for (auto&& elm : cache_) { - stream << "\t cache val: " - << "entity=" << std::get<0>(elm) << ", " - << "val=" << std::get<1>(elm) - << "\n"; - } - - vt_debug_print( - normal, location, - "printing cache: {}", stream.str().c_str() - ); -} - -}} // end namespace vt::location - -#endif /*INCLUDED_VT_TOPOS_LOCATION_CACHE_CACHE_IMPL_H*/ diff --git a/src/vt/topos/location/directory/directory.h b/src/vt/topos/location/directory/directory.h deleted file mode 100644 index c802e9ba8b..0000000000 --- a/src/vt/topos/location/directory/directory.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// directory.h -// DARMA/vt => Virtual Transport -// -// Copyright 2019-2024 National Technology & Engineering Solutions of Sandia, LLC -// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. -// Government retains certain rights in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact darma@sandia.gov -// -// ***************************************************************************** -//@HEADER -*/ - -#if !defined INCLUDED_VT_TOPOS_LOCATION_DIRECTORY_DIRECTORY_H -#define INCLUDED_VT_TOPOS_LOCATION_DIRECTORY_DIRECTORY_H - -#include "vt/config.h" - -#include - -namespace vt { namespace location { - -template -struct Directory { - using DirectoryMapType = std::unordered_map; - - Directory() = default; - - bool exists(KeyT const& key) const; - std::size_t getSize() const; - ValueT const& get(KeyT const& key); - typename DirectoryMapType::iterator getIter(KeyT const& key); - typename DirectoryMapType::iterator getIterEnd(); - void remove(KeyT const& key); - void insert(KeyT const& key, ValueT const& value); - - /** - * \brief Get the whole directory map - * - * \return the directory map - */ - auto const& getMap() const { return dir_; } - - template - void serialize(Serializer& s) { - s | dir_; - } - -private: - DirectoryMapType dir_; -}; - -}} /* end namespace vt::location */ - -#include "vt/topos/location/directory/directory.impl.h" - -#endif /*INCLUDED_VT_TOPOS_LOCATION_DIRECTORY_DIRECTORY_H*/ diff --git a/src/vt/topos/location/directory/directory.impl.h b/src/vt/topos/location/directory/directory.impl.h deleted file mode 100644 index 298652c8cd..0000000000 --- a/src/vt/topos/location/directory/directory.impl.h +++ /dev/null @@ -1,108 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// directory.impl.h -// DARMA/vt => Virtual Transport -// -// Copyright 2019-2024 National Technology & Engineering Solutions of Sandia, LLC -// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. -// Government retains certain rights in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact darma@sandia.gov -// -// ***************************************************************************** -//@HEADER -*/ - -#if !defined INCLUDED_VT_TOPOS_LOCATION_DIRECTORY_DIRECTORY_IMPL_H -#define INCLUDED_VT_TOPOS_LOCATION_DIRECTORY_DIRECTORY_IMPL_H - -#include "vt/config.h" - -namespace vt { namespace location { - -template -bool Directory::exists(KeyT const& key) const { - auto iter = dir_.find(key); - return iter != dir_.end(); -} - -template -ValueT const& Directory::get(KeyT const& key) { - auto iter = dir_.find(key); - - vtAssert(iter != dir_.end(), "Key must exist in directory"); - - return iter->second; -} - -template -typename Directory::DirectoryMapType::iterator -Directory::getIter(KeyT const& key) { - return dir_.find(key); -} - -template -typename Directory::DirectoryMapType::iterator -Directory::getIterEnd() { - return dir_.end(); -} - -template -LocationSizeType Directory::getSize() const { - return dir_.size(); -} - -template -void Directory::remove(KeyT const& key) { - auto iter = dir_.find(key); - if (iter != dir_.end()) { - dir_.erase(iter); - } -} - -template -void Directory::insert(KeyT const& key, ValueT const& value) { - auto iter = dir_.find(key); - - if (iter == dir_.end()) { - dir_.emplace( - std::piecewise_construct, - std::forward_as_tuple(key), - std::forward_as_tuple(value) - ); - } else { - iter->second = value; - } -} - -}} /* end namespace vt::location */ - -#endif /*INCLUDED_VT_TOPOS_LOCATION_DIRECTORY_DIRECTORY_IMPL_H*/ diff --git a/src/vt/topos/location/location.h b/src/vt/topos/location/location.h index 5e9b3ab381..706eba2d08 100644 --- a/src/vt/topos/location/location.h +++ b/src/vt/topos/location/location.h @@ -47,29 +47,61 @@ #include "vt/config.h" #include "vt/topos/location/location_common.h" #include "vt/topos/location/location.fwd.h" -#include "vt/topos/location/utility/pending.h" #include "vt/topos/location/utility/entity.h" -#include "vt/topos/location/utility/coord.h" #include "vt/topos/location/message/msg.h" -#include "vt/topos/location/lookup/lookup.h" -#include "vt/topos/location/record/record.h" -#include "vt/topos/location/record/state.h" #include "vt/context/context.h" #include "vt/activefn/activefn.h" #include "vt/vrt/vrt_common.h" #include "vt/objgroup/manager.h" +#include + #include #include #include -#include #include #include +#include +#include namespace vt { namespace location { struct collection_lm_tag_t {}; +template +struct EntityLocationCoord; + +/** + * \brief Adapter satisfying loc::Communicator with VT objgroup messaging. + * + * The containing EntityLocationCoord is already a collectively-created + * objgroup, so its proxy is also the collective instance handle expected by + * loc. Control-plane RPCs are dispatched to the embedded loc coordinator. + */ +template +struct LocCommunicator { + using OwnerType = EntityLocationCoord; + + template + using HandleType = objgroup::proxy::Proxy; + + explicit LocCommunicator(OwnerType* in_owner) : owner_(in_owner) { } + + int getRank() const; + + template + HandleType registerInstanceCollective(Instance* instance); + + template + void send( + ::loc::NodeType node, objgroup::proxy::Proxy handle, + Args&&... args + ); + +private: + OwnerType* owner_ = nullptr; +}; + /** * \struct EntityLocationCoord * @@ -77,12 +109,10 @@ struct collection_lm_tag_t {}; * virtual entities. * * Allows general registration of an \c EntityID that is tracked across the - * system as it migrates. Routes messages to the appropriate node by inheriting - * from \c EntityMsg and sending it through the routing algorithm. Manages a - * distributed table of entities and their location allowing an entity to be - * found anywhere in the system. Caches locations to speed up resolution once a - * location is known. Allows migration of an entity at any time; forwards - * messages if they miss in the cache. + * system as it migrates. DARMA/loc owns the distributed directory, resolution, + * and cache-coherence protocol through \c ResolverType. VT retains the entity + * message delivery, handler dispatch, and termination-epoch integration layered + * on top of the resolved node. * * The \c registerEntity method allows an external component to locally register * an entity as existing on this node. If the entity is deleted, \c @@ -93,20 +123,15 @@ struct collection_lm_tag_t {}; * */ template -struct EntityLocationCoord : LocationCoord { +struct EntityLocationCoord { using ThisType = EntityLocationCoord; - using LocRecType = LocRecord; - using LocCacheType = LocLookup; + using ResolverCommType = LocCommunicator; + using ResolverType = ::loc::Coordinator; using LocEntityMsg = LocEntity; using LocalRegisteredContType = std::unordered_set; using LocalRegisteredMsgContType = std::unordered_map; using ActionListType = std::vector; - using ExistsListType = std::vector; - using PendingType = PendingLocationLookup; using PendingLocLookupsType = std::unordered_map; - using PendingExistsLocType = std::unordered_map; - using ActionContainerType = std::unordered_map; - using LocAsksType = std::unordered_map>; template using EntityMsgType = EntityMsg; @@ -114,9 +139,7 @@ struct EntityLocationCoord : LocationCoord { /** * \brief Construct a new location manager with defaults */ - EntityLocationCoord() - : recs_(default_max_cache_size, theContext()->getNode()) - { } + EntityLocationCoord() : resolver_comm_(this) { } /** * \brief Construct with parameters @@ -127,10 +150,11 @@ struct EntityLocationCoord : LocationCoord { */ explicit EntityLocationCoord( bool in_anytime_migration, bool in_keep_cache_updated, - std::size_t in_max_cache_size = default_max_cache_size - ) : recs_(in_max_cache_size, theContext()->getNode()), + std::size_t in_max_cache_size = ::loc::default_max_cache_size + ) : resolver_comm_(this), anytime_migration_(in_anytime_migration), - keep_cache_updated_(in_keep_cache_updated) + keep_cache_updated_(in_keep_cache_updated), + max_cache_size_(in_max_cache_size) { } @@ -332,17 +356,6 @@ struct EntityLocationCoord : LocationCoord { EntityID const& id, NodeType const& home_node, ActionNodeType action ); - /** - * \internal \brief Update location - * - * \param[in] id the entity ID - * \param[in] resolved_node the node reported to have the entity - * \param[in] home_node the home node for the entity - */ - void updatePendingRequest( - EntityID const& id, NodeType const& resolved_node, NodeType const& home_node - ); - /** * \internal \brief Output the current cache state */ @@ -363,37 +376,11 @@ struct EntityLocationCoord : LocationCoord { void clearCache(); /** - * \internal \brief Send back an eager update on a discovered location - * - * \param[in] id the entity ID - * \param[in] ask_node the asking node - * \param[in] home_node the home node - * \param[in] deliver_node the node discovered which delivered the message - */ - void sendEagerUpdate( - EntityID const& id, NodeType ask_node, NodeType home_node, - NodeType deliver_node - ); - - /** - * \internal \brief Update cache on eager update received - * - * \param[in] id the entity ID - * \param[in] home_node the home node - * \param[in] deliver_node the node discovered which delivered the message - */ - void handleEagerUpdate( - EntityID const& id, NodeType home_node, NodeType deliver_node - ); - - /** - * \internal \brief Check if the eager or rendezvous protocol should be used + * \internal \brief Classify the legacy eager/rendezvous message size * - * The eager protocol, typically used for small messages, forwards the message - * even if the location is stale or unknown (to the home node). The rendezvous - * protocol, typically used for large messages, will send a control message to - * determine the location of the entity before sending the actual data. The - * threshold between these two modes is controlled by \c small_msg_max_size + * Kept for source compatibility and diagnostics. The loc-backed coordinator + * resolves both sizes before VT delivers them; the threshold remains \c + * small_msg_max_size. * * \param[in] msg the message to check * @@ -409,6 +396,13 @@ struct EntityLocationCoord : LocationCoord { */ void setProxy(objgroup::proxy::Proxy> proxy) { proxy_ = proxy; + resolver_ = std::make_unique(resolver_comm_, max_cache_size_); + } + + template + void locControlHandler(Args... args) { + vtAssert(resolver_ != nullptr, "loc resolver must be initialized"); + std::invoke(Handler, resolver_.get(), std::move(args)...); } /** @@ -428,6 +422,8 @@ struct EntityLocationCoord : LocationCoord { std::unordered_map buildGlobalMap(); private: + friend struct LocCommunicator; + /** * \brief \internal The global map handler for the all-reduce to collect up * entity location @@ -446,76 +442,6 @@ struct EntityLocationCoord : LocationCoord { template void routedHandler(MessageT *msg); - /** - * \internal \brief Request location handler from this node - * - * \param[in] id entity id - * \param[in] home_node the home node for the entity - * \param[in] cb the callback to trigger - */ - void getLocationRequest( - EntityID id, NodeType home_node, Callback cb - ); - - /** - * \brief Check if entity exists - * - * \param[in] id the entity ID - * \param[in] home_node the home node - * \param[in] cb callback to invoke - */ - void entityExistsRequest( - EntityID id, NodeType home_node, - Callback cb - ); - - /** - * \brief Response callback when entity exists request comes back with the - * answer - * - * \param[in] id the entity ID - * \param[in] exists whether it exists - * \param[in] answer the rank it exists on - * \param[in] home_node the home node for the entity - */ - void entityExistsResponse( - EntityID const& id, bool exists, NodeType answer, NodeType home_node - ); - - /** - * \internal \brief Update the location on this node - * - * \param[in] id entity id - * \param[in] answer the answer of where the entity is location - * \param[in] home_node the home node for the entity - */ - void updateLocation(EntityID const& id, NodeType answer, NodeType home_node); - - /** - * \internal \brief Update the location on this node - * - * \param[in] id entity id - * \param[in] exists whether it exists - * \param[in] answer the answer of where the entity is location - * \param[in] home_node the home node for the entity - */ - void entityExistsAnswer( - EntityID const& id, bool exists, NodeType answer, NodeType home_node - ); - - /** - * \internal \brief Route a message to destination with eager protocol - * - * \param[in] id the entity ID - * \param[in] home_node the home node - * \param[in] msg the message to route - */ - template - void routeMsgEager( - EntityID const& id, NodeType const& home_node, - MsgSharedPtr const& msg - ); - /** * \internal \brief Route a message to destination with rendezvous protocol * @@ -548,25 +474,16 @@ struct EntityLocationCoord : LocationCoord { /// registered entities LocalRegisteredContType local_registered_; - /// the cached location records - LocCacheType recs_; - - /// hold pending actions that this location manager is waiting on - ActionContainerType pending_actions_; - - /// pending lookup requests where this manager is the home node + /// routed deliveries waiting for local entity registration PendingLocLookupsType pending_lookups_; - /// Pending lookup requests for existence, does not buffer if it doesn't find - /// the entity - PendingExistsLocType pending_exists_lookups_; - - /// List of nodes that inquire about an entity that require an update - LocAsksType loc_asks_; - /// the location manager's objgroup proxy objgroup::proxy::Proxy> proxy_; + /// VT transport adapter and the backend-neutral resolver from DARMA/loc + ResolverCommType resolver_comm_; + std::unique_ptr resolver_; + /// Whether anytime migration can happen for this LM bool anytime_migration_ = true; @@ -579,6 +496,9 @@ struct EntityLocationCoord : LocationCoord { /// Whether to keep the cache up-to-date at all times bool keep_cache_updated_ = false; + /// Maximum number of non-home records cached by loc + std::size_t max_cache_size_ = ::loc::default_max_cache_size; + /// Temporary storage for global map while reducing std::unordered_map global_map_temp_; }; diff --git a/src/vt/topos/location/location.impl.h b/src/vt/topos/location/location.impl.h index 618a7f9796..0d78792c48 100644 --- a/src/vt/topos/location/location.impl.h +++ b/src/vt/topos/location/location.impl.h @@ -61,12 +61,41 @@ namespace vt { namespace location { +template +int LocCommunicator::getRank() const { + return theContext()->getNode(); +} + +template +template +auto LocCommunicator::registerInstanceCollective(Instance* instance) + -> HandleType +{ + static_assert(std::is_same_v); + vtAssert(owner_ != nullptr, "loc communicator must have an owner"); + vtAssert(instance != nullptr, "loc coordinator must be valid"); + return owner_->proxy_; +} + +template +template +void LocCommunicator::send( + ::loc::NodeType node, objgroup::proxy::Proxy handle, + Args&&... args +) { + using Owner = OwnerType; + handle[node].template send< + &Owner::template locControlHandler...> + >( + MsgProps().asLocationMsg(), std::forward(args)... + ); +} + template void EntityLocationCoord::registerEntity( EntityID const& id, NodeType const& home, LocMsgActionType msg_action, bool const& migrated ) { - auto const& this_node = theContext()->getNode(); auto reg_iter = local_registered_.find(id); vtAssert( @@ -83,8 +112,6 @@ void EntityLocationCoord::registerEntity( local_registered_.insert(id); - recs_.insert(id, home, LocRecType{id, eLocState::Local, this_node}); - if (msg_action != nullptr) { // vtAssert( // local_registered_msg_han_.find(id) == local_registered_msg_han_.end(), @@ -117,25 +144,9 @@ void EntityLocationCoord::registerEntity( } } - /* - * This is either the case where the entity is *not* migrated here - * but gets constructed in an alternative non-default location or - * it is migrated here and it's not the home. Thus, we need to - * inform the home so that messages can be forwarded. - */ vtAssert(home != uninitialized_destination, "Must have home node info"); - if (home != this_node) { - vt_debug_print( - normal, location, - "EntityLocationCoord: registerEntity: updating id={}, home={}, " - "migrated={}\n", - id, home, migrated - ); - - proxy_[home].template send<&ThisType::updateLocation>( - MsgProps().asLocationMsg(), id, this_node, home - ); - } + vtAssert(resolver_ != nullptr, "loc resolver must be initialized"); + resolver_->registerEntity(id, home); } template @@ -159,7 +170,8 @@ void EntityLocationCoord::registerEntityRemote( auto const this_node = theContext()->getNode(); vtAssert(home == this_node, "Must be registered on home node"); - recs_.insert(id, home, LocRecType{id, eLocState::Remote, create_node}); + vtAssert(resolver_ != nullptr, "loc resolver must be initialized"); + resolver_->updateHome(id, create_node); if (msg_action != nullptr) { local_registered_msg_han_.emplace(id, LocEntityMsg{id, msg_action}); @@ -182,10 +194,8 @@ void EntityLocationCoord::unregisterEntity(EntityID const& id) { local_registered_.erase(reg_iter); - bool const& rec_exists = recs_.exists(id); - if (rec_exists) { - recs_.remove(id); - } + vtAssert(resolver_ != nullptr, "loc resolver must be initialized"); + resolver_->unregisterEntity(id); auto reg_msg_han_iter = local_registered_msg_han_.find(id); if (reg_msg_han_iter != local_registered_msg_han_.end()) { @@ -218,52 +228,8 @@ void EntityLocationCoord::entityExists( EntityID const& id, NodeType const& home_node, ExistsNodeActionType const& action ) { - auto const this_node = theContext()->getNode(); - if (entityExistsLocal(id)) { - // Update cache - recs_.insert(id, home_node, LocRecType{id, eLocState::Local, this_node}); - - // Trigger action true as it exists here - action(true, this_node); - } else { - bool const rec_exists = recs_.exists(id); - if (rec_exists) { - auto const& rec = recs_.get(id); - if (rec.isLocal()) { - vtAssert(false, "Should be registered if this is the case!"); - } else if (rec.isRemote()) { - action(true, rec.getRemoteNode()); - } else { - vtAssert(false, "Should not be able to reach this case"); - } - } else { - if (home_node == this_node) { - // if the home node is this node, it does not exist - action(false, -1); - } else { - // Go to home node - auto cb = theCB()->makeSend<&ThisType::entityExistsResponse>( - proxy_[this_node] - ); - proxy_[home_node].template send<&ThisType::entityExistsRequest>( - MsgProps().asLocationMsg(), id, home_node, cb - ); - - pending_exists_lookups_[id].push_back(action); - } - } - } -} - -template -void EntityLocationCoord::entityExistsRequest( - EntityID id, NodeType home_node, - Callback cb -) { - entityExists(id, home_node, [=](bool exists, NodeType node) mutable { - auto props = MsgProps().asLocationMsg(); - cb.send(props, id, exists, node, home_node); - }); + vtAssert(resolver_ != nullptr, "loc resolver must be initialized"); + resolver_->entityExists(id, home_node, action); } template @@ -285,8 +251,8 @@ void EntityLocationCoord::entityEmigrated( if (reg_iter != local_registered_.end()) { local_registered_.erase(reg_iter); } - - recs_.update(id, LocRecType{id, eLocState::Remote, new_node}); + vtAssert(resolver_ != nullptr, "loc resolver must be initialized"); + resolver_->entityEmigrated(id, new_node); } template @@ -305,12 +271,14 @@ void EntityLocationCoord::entityImmigrated( template bool EntityLocationCoord::isCached(EntityID const& id) const { - return recs_.exists(id); + vtAssert(resolver_ != nullptr, "loc resolver must be initialized"); + return resolver_->isCached(id); } template void EntityLocationCoord::clearCache() { - recs_.clearCache(); + vtAssert(resolver_ != nullptr, "loc resolver must be initialized"); + resolver_->clearCache(); } namespace detail { @@ -359,198 +327,12 @@ void EntityLocationCoord::insertPendingEntityAction( pending_lookups_[id].push_back(action); } -template -template -void EntityLocationCoord::routeMsgEager( - EntityID const& id, NodeType const& home_node, - MsgSharedPtr const& msg -) { - auto const& this_node = theContext()->getNode(); - NodeType route_to_node = uninitialized_destination; - - auto reg_iter = local_registered_.find(id); - bool const found = reg_iter != local_registered_.end(); - - vt_debug_print( - normal, location, - "EntityLocationCoord: routeMsgEager: found={}, home_node={}, " - "route_to_node={}, id={}\n", - found, home_node, route_to_node, id - ); - - if (found) { - recs_.insert(id, home_node, LocRecType{id, eLocState::Local, this_node}); - route_to_node = this_node; - } else { - bool const& rec_exists = recs_.exists(id); - - if (not rec_exists) { - if (home_node != this_node) { - route_to_node = home_node; - } else { - route_to_node = this_node; - } - } else { - auto const& rec = recs_.get(id); - - if (rec.isLocal()) { - route_to_node = this_node; - } else if (rec.isRemote()) { - route_to_node = rec.getRemoteNode(); - } - } - } - - vtAssert( - route_to_node != uninitialized_destination, - "Node to route to must be set by this point" - ); - - vt_debug_print( - normal, location, - "EntityLocationCoord: routeMsgEager: home_node={}, route_node={}, " - "id={}\n", - home_node, route_to_node, id - ); - - return routeMsgNode(id, home_node, route_to_node, msg); -} - -template -void EntityLocationCoord::getLocationRequest( - EntityID id, NodeType home_node, - Callback cb -) { - getLocation(id, home_node, [=](NodeType n) mutable { - auto props = MsgProps().asLocationMsg(); - cb.send(props, id, n, home_node); - }); -} - -template -void EntityLocationCoord::updateLocation( - EntityID const& id, NodeType answer, NodeType home_node -) { - updatePendingRequest(id, answer, home_node); -} - -template -void EntityLocationCoord::entityExistsResponse( - EntityID const& id, bool exists, NodeType answer, NodeType home_node -) { - // Update the cache - if (exists) { - recs_.insert(id, home_node, LocRecType{id, eLocState::Remote, answer}); - } - - // trigger any pending actions upon registration - if (auto lookups = pending_exists_lookups_.extract(id); lookups) { - for (auto&& action : lookups.mapped()) { - action(exists, answer); - } - } -} - template void EntityLocationCoord::getLocation( EntityID const& id, NodeType const& home_node, NodeActionType const& action ) { - auto const& this_node = theContext()->getNode(); - - auto reg_iter = local_registered_.find(id); - - if (reg_iter != local_registered_.end()) { - vt_debug_print( - normal, location, - "EntityLocationCoord: getLocation: entity is local\n" - ); - - recs_.insert(id, home_node, LocRecType{id, eLocState::Local, this_node}); - action(this_node); - return; - } else { - bool const rec_exists = recs_.exists(id); - - vt_debug_print( - normal, location, - "EntityLocationCoord: getLocation: home_node={}, rec_exists={}\n", - home_node, print_bool(rec_exists) - ); - - if (not rec_exists) { - if (home_node != this_node) { - auto cb = theCB()->makeSend<&ThisType::updateLocation>( - proxy_[this_node] - ); - proxy_[home_node].template send<&ThisType::getLocationRequest>( - MsgProps().asLocationMsg(), id, home_node, cb - ); - } - - pending_lookups_[id].push_back(action); - } else { - auto const& rec = recs_.get(id); - - if (rec.isLocal()) { - vtAssert(false, "Should be registered if this is the case!"); - action(this_node); - } else if (rec.isRemote()) { - vt_debug_print( - normal, location, - "EntityLocationCoord: getLocation: entity is remote\n" - ); - - action(rec.getRemoteNode()); - } - } - } -} - -template -void EntityLocationCoord::handleEagerUpdate( - EntityID const& id, NodeType home_node, NodeType deliver_node -) { - auto this_node = theContext()->getNode(); - vtAssert(this_node != deliver_node, "This should have been a forwarding node"); - vtAssert(home_node != uninitialized_destination, "Home node should be valid"); - vtAssert(home_node < theContext()->getNumNodes(), "Home node should be valid"); - - vt_debug_print( - normal, location, - "handleEagerUpdate: id={}, home_node={}, deliver_node={}\n", - id, home_node, deliver_node - ); - - // Insert a new entry in the cache for the updated location - recs_.insert(id, home_node, LocRecType{id, eLocState::Remote, deliver_node}); - - auto ask_iter = loc_asks_.find(id); - if (ask_iter != loc_asks_.end()) { - for (auto&& ask_node : ask_iter->second) { - sendEagerUpdate(id, ask_node, home_node, deliver_node); - } - loc_asks_.erase(ask_iter); - } -} - -template -void EntityLocationCoord::sendEagerUpdate( - EntityID const& id, NodeType ask_node, NodeType home_node, - NodeType deliver_node -) { - vt_debug_print( - normal, location, - "sendEagerUpdate: id={}, ask_node={}, home_node={}, deliver_node={}\n", - id, ask_node, home_node, deliver_node - ); - - auto this_node = theContext()->getNode(); - if (ask_node != this_node and ask_node != deliver_node) { - vtAssert(ask_node != uninitialized_destination, "Ask node must be valid"); - proxy_[ask_node].template send<&ThisType::handleEagerUpdate>( - MsgProps().asLocationMsg(), id, home_node, deliver_node - ); - } + vtAssert(resolver_ != nullptr, "loc resolver must be initialized"); + resolver_->getLocation(id, home_node, action); } template @@ -574,16 +356,6 @@ void EntityLocationCoord::routeMsgNode( theMsg()->markAsLocationMessage(msg); if (to_node != this_node) { - // Get the current ask node, which is the from node for the first hop - auto prev_ask = msg->getAskNode(); - if (prev_ask != uninitialized_destination) { - // Record previous asker for cascaded updates - loc_asks_[id].insert(prev_ask); - } else { - // Set initial ask node to the sender for direct eager update later - msg->setAskNode(this_node); - } - auto m = msg; //copy for msg thief // send to the node discovered by the location manager proxy_[to_node].template sendMsg<&ThisType::routedHandler>(m); @@ -598,7 +370,7 @@ void EntityLocationCoord::routeMsgNode( theTerm()->produce(epoch); - auto trigger_msg_handler_action = [this, msg, home_node](EntityID const& hid) { + auto trigger_msg_handler_action = [this, msg](EntityID const& hid) { bool const& has_handler = msg->hasHandler(); auto const& from = msg->getLocFromNode(); if (has_handler) { @@ -627,26 +399,10 @@ void EntityLocationCoord::routeMsgNode( reg_han_iter->second.applyRegisteredActionMsg(msg.get()); } - auto ask_node = msg->getAskNode(); auto const route_epoch = msg->getRouteEpoch(); - if (ask_node != uninitialized_destination) { - auto delivered_node = theContext()->getNode(); - // Tie the eager update to the same epoch as the routed message. Prefer - // the epoch explicitly carried in the message (set at origination for - // messages that cannot hold an epoch in their envelope); otherwise fall - // back to the envelope-derived epoch used by epoch-carrying messages. - auto epoch_local = route_epoch != no_epoch ? - route_epoch : theMsg()->getEpochContextMsg(msg); - theMsg()->pushEpoch(epoch_local); - sendEagerUpdate(hid, ask_node, home_node, delivered_node); - theMsg()->popEpoch(epoch_local); - } - // Release the caller's epoch that was manually held at origination for a - // message that could not carry it in its envelope. The eager update above - // is produced on this same epoch before the consume below, so the epoch - // stays alive until the origin processes the cache update. + // message whose envelope could not carry it across the routing hop. if (route_epoch != no_epoch) { theTerm()->consume(route_epoch); } @@ -785,10 +541,9 @@ void EntityLocationCoord::routePreparedMsg( // caller's epoch as soon as they hop to another node: getEpochContextMsg // collapses to the "any epoch" sentinel even when the caller is inside a real // collective epoch. Detect that case at origination and manually hold the - // caller's epoch across the whole route (including the eager cache update that - // comes back to the origin), releasing it at final delivery. This keeps the - // routed message and its cache update enclosed by the caller's epoch, exactly - // as an epoch-carrying (long) message already is via its envelope. + // caller's epoch across the whole route, releasing it at final delivery. + // This keeps the routed message enclosed by the caller's epoch exactly as an + // epoch-carrying (long) message already is via its envelope. if (msg->getRouteEpoch() == no_epoch and epoch == term::any_epoch_sentinel) { auto const cur_epoch = theMsg()->getEpoch(); if (cur_epoch != term::any_epoch_sentinel and cur_epoch != no_epoch) { @@ -806,22 +561,18 @@ void EntityLocationCoord::routePreparedMsg( epoch ); - if (use_eager) { - theMsg()->pushEpoch(epoch); - routeMsgEager(msg->getEntity(), msg->getHomeNode(), msg); - theMsg()->popEpoch(epoch); - } else { - theTerm()->produce(epoch); - // non-eager protocol: get location first then send message after resolution - getLocation(msg->getEntity(), msg->getHomeNode(), [this, epoch, msg](NodeType node){ + // loc is a resolver rather than a forwarding router. Resolve first for both + // message sizes, then keep VT's existing delivery and epoch semantics. + theTerm()->produce(epoch); + getLocation( + msg->getEntity(), msg->getHomeNode(), + [this, epoch, msg](NodeType node) { theMsg()->pushEpoch(epoch); - routeMsgNode( - msg->getEntity(), msg->getHomeNode(), node, msg - ); + routeMsgNode(msg->getEntity(), msg->getHomeNode(), node, msg); theMsg()->popEpoch(epoch); theTerm()->consume(epoch); - }); - } + } + ); } template @@ -843,29 +594,11 @@ void EntityLocationCoord::routeMsg( } template -void EntityLocationCoord::updatePendingRequest( - EntityID const& id, NodeType const& node, NodeType const& home_node -) { - +void EntityLocationCoord::printCurrentCache() const { vt_debug_print( normal, location, - "EntityLocationCoord: updatePendingRequest: node={}\n", - node + "EntityLocationCoord: cache is managed by DARMA/loc\n" ); - - recs_.insert(id, home_node, LocRecType{id, eLocState::Remote, node}); - - // trigger any pending actions upon registration - if (auto lookups = pending_lookups_.extract(id); lookups) { - for (auto&& action : lookups.mapped()) { - action(node); - } - } -} - -template -void EntityLocationCoord::printCurrentCache() const { - recs_.printCache(); } template @@ -910,11 +643,8 @@ std::unordered_map EntityLocationCoord::buildGlobalMap() { std::unordered_map local_map; - auto const& dir = recs_.getDirectory().getMap(); - for (auto const& [key, value] : dir) { - if (value.isLocal()) { - local_map[key] = theContext()->getNode(); - } + for (auto const& key : local_registered_) { + local_map[key] = theContext()->getNode(); } waiting_global_map_handler_ = true; diff --git a/src/vt/topos/location/location_common.h b/src/vt/topos/location/location_common.h index c03218fca3..8642860f5e 100644 --- a/src/vt/topos/location/location_common.h +++ b/src/vt/topos/location/location_common.h @@ -55,24 +55,8 @@ namespace vt { namespace location { using NodeActionType = std::function; using ExistsNodeActionType = std::function; using LocMsgActionType = std::function; -using LocEventID = int64_t; - -static constexpr LocEventID const no_location_event_id = -1; - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-variable" -static LocEventID fst_location_event_id = 0; -#pragma GCC diagnostic pop - -using LocationSizeType = size_t; -static constexpr LocationSizeType const default_max_cache_size = 4096; - static constexpr ByteType const small_msg_max_size = 256; -using LocInstType = int64_t; - -static constexpr LocInstType const no_loc_inst = -1; - }} // end namespace vt::location #endif /*INCLUDED_VT_TOPOS_LOCATION_LOCATION_COMMON_H*/ diff --git a/src/vt/topos/location/lookup/lookup.h b/src/vt/topos/location/lookup/lookup.h deleted file mode 100644 index 467900f76f..0000000000 --- a/src/vt/topos/location/lookup/lookup.h +++ /dev/null @@ -1,98 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// lookup.h -// DARMA/vt => Virtual Transport -// -// Copyright 2019-2024 National Technology & Engineering Solutions of Sandia, LLC -// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. -// Government retains certain rights in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact darma@sandia.gov -// -// ***************************************************************************** -//@HEADER -*/ - -#if !defined INCLUDED_VT_TOPOS_LOCATION_LOOKUP_LOOKUP_H -#define INCLUDED_VT_TOPOS_LOCATION_LOOKUP_LOOKUP_H - -#include "vt/config.h" -#include "vt/topos/location/location_common.h" -#include "vt/topos/location/cache/cache.h" -#include "vt/topos/location/directory/directory.h" - -namespace vt { namespace location { - -template -struct LocLookup { - - LocLookup(LocationSizeType const& in_max_cache_size, NodeType in_this_node) - : max_cache_size_(in_max_cache_size), - cache_(in_max_cache_size), - this_node_(in_this_node) - { } - - bool exists(KeyT const& key) const; - LocationSizeType getCacheSize() const; - ValueT const& get(KeyT const& key); - void remove(KeyT const& key); - void insert(KeyT const& key, NodeType const home, ValueT const& value); - void update(KeyT const& key, ValueT const& value); - void clearCache(); - void printCache() const; - - /** - * \brief Get the whole directory - * - * \return the directory - */ - auto const& getDirectory() const { return directory_; } - - template - void serialize(Serializer& s) { - s | max_cache_size_ - | directory_ - | cache_ - | this_node_; - } - -private: - LocationSizeType max_cache_size_ = 0; - Directory directory_; - LocationCache cache_; - NodeType this_node_ = uninitialized_destination; -}; - -}} /* end namespace vt::location */ - -#include "vt/topos/location/lookup/lookup.impl.h" - -#endif /*INCLUDED_VT_TOPOS_LOCATION_LOOKUP_LOOKUP_H*/ diff --git a/src/vt/topos/location/lookup/lookup.impl.h b/src/vt/topos/location/lookup/lookup.impl.h deleted file mode 100644 index 1629d72422..0000000000 --- a/src/vt/topos/location/lookup/lookup.impl.h +++ /dev/null @@ -1,111 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// lookup.impl.h -// DARMA/vt => Virtual Transport -// -// Copyright 2019-2024 National Technology & Engineering Solutions of Sandia, LLC -// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. -// Government retains certain rights in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact darma@sandia.gov -// -// ***************************************************************************** -//@HEADER -*/ - -#if !defined INCLUDED_VT_TOPOS_LOCATION_LOOKUP_LOOKUP_IMPL_H -#define INCLUDED_VT_TOPOS_LOCATION_LOOKUP_LOOKUP_IMPL_H - -#include "vt/config.h" - -namespace vt { namespace location { - -template -bool LocLookup::exists(KeyT const& key) const { - return directory_.exists(key) or cache_.exists(key); -} - -template -ValueT const& LocLookup::get(KeyT const& key) { - auto dir_iter = directory_.getIter(key); - if (dir_iter != directory_.getIterEnd()) { - return dir_iter->second; - } - return cache_.get(key); -} - -template -LocationSizeType LocLookup::getCacheSize() const { - return cache_.getSize(); -} - -template -void LocLookup::remove(KeyT const& key) { - directory_.remove(key); - cache_.remove(key); -} - -template -void LocLookup::insert( - KeyT const& key, NodeType const home, ValueT const& value -) { - // If this node is the home, maintain location in permanent directory, - // otherwise, insert/update in local cache of locations - if (this_node_ == home) { - directory_.insert(key, value); - } else { - cache_.insert(key, value); - } -} - -template -void LocLookup::update(KeyT const& key, ValueT const& value) { - auto dir_iter = directory_.getIter(key); - if (dir_iter != directory_.getIterEnd()) { - dir_iter->second = value; - } else { - cache_.insert(key, value); - } -} - -template -void LocLookup::clearCache() { - cache_ = LocationCache{max_cache_size_}; -} - -template -void LocLookup::printCache() const { - cache_.printCache(); -} - -}} /* end namespace vt::location */ - -#endif /*INCLUDED_VT_TOPOS_LOCATION_LOOKUP_LOOKUP_IMPL_H*/ diff --git a/src/vt/topos/location/manager.h b/src/vt/topos/location/manager.h index 716a210215..f7444fd222 100644 --- a/src/vt/topos/location/manager.h +++ b/src/vt/topos/location/manager.h @@ -48,7 +48,6 @@ #include "vt/topos/location/location_common.h" #include "vt/topos/location/location.fwd.h" #include "vt/topos/location/manager.fwd.h" -#include "vt/topos/location/utility/coord.h" #include "vt/vrt/vrt_common.h" #include "vt/vrt/collection/proxy.h" #include "vt/objgroup/proxy/proxy_objgroup.h" @@ -78,8 +77,6 @@ namespace vt { namespace location { struct LocationManager : runtime::component::Component { template using PtrType = LocType*; - using LocCoordPtrType = LocationCoord*; - using LocInstContainerType = std::unordered_map; using VrtLocType = EntityLocationCoord; using VrtLocProxyType = EntityLocationCoord; diff --git a/src/vt/topos/location/record/record.h b/src/vt/topos/location/record/record.h deleted file mode 100644 index 4260540835..0000000000 --- a/src/vt/topos/location/record/record.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// record.h -// DARMA/vt => Virtual Transport -// -// Copyright 2019-2024 National Technology & Engineering Solutions of Sandia, LLC -// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. -// Government retains certain rights in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact darma@sandia.gov -// -// ***************************************************************************** -//@HEADER -*/ - -#if !defined INCLUDED_VT_TOPOS_LOCATION_RECORD_RECORD_H -#define INCLUDED_VT_TOPOS_LOCATION_RECORD_RECORD_H - -#include "vt/config.h" -#include "vt/topos/location/record/state.h" - -#include - -namespace vt { namespace location { - -template -struct LocRecord { - using LocStateType = eLocState; - - LocRecord( - EntityID const& in_id, LocStateType const& in_state, - NodeType const& in_node - ); - void updateNode(NodeType const& new_node); - - bool isLocal() const; - bool isRemote() const; - NodeType getRemoteNode() const; - EntityID getEntityID() const; - - template - friend std::ostream& operator<<(std::ostream& os, LocRecord const& rec); - - template - void serialize(Serializer& s) { - s | id_ - | state_ - | cur_node_; - } - -private: - EntityID id_; - LocStateType state_ = eLocState::Invalid; - NodeType cur_node_ = uninitialized_destination; -}; - -}} // end namespace vt::location - -#include "vt/topos/location/record/record.impl.h" - -#endif /*INCLUDED_VT_TOPOS_LOCATION_RECORD_RECORD_H*/ diff --git a/src/vt/topos/location/record/record.impl.h b/src/vt/topos/location/record/record.impl.h deleted file mode 100644 index eb4898ba9d..0000000000 --- a/src/vt/topos/location/record/record.impl.h +++ /dev/null @@ -1,93 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// record.impl.h -// DARMA/vt => Virtual Transport -// -// Copyright 2019-2024 National Technology & Engineering Solutions of Sandia, LLC -// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. -// Government retains certain rights in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact darma@sandia.gov -// -// ***************************************************************************** -//@HEADER -*/ - -#if !defined INCLUDED_VT_TOPOS_LOCATION_RECORD_RECORD_IMPL_H -#define INCLUDED_VT_TOPOS_LOCATION_RECORD_RECORD_IMPL_H - -#include "vt/config.h" -#include "vt/topos/location/record/record.h" -#include "vt/topos/location/record/state_printer.h" - -namespace vt { namespace location { - -template -LocRecord::LocRecord( - EntityID const& in_id, LocStateType const& in_state, - NodeType const& in_node -) : id_(in_id), state_(in_state), cur_node_(in_node) -{ } - -template -void LocRecord::updateNode(NodeType const& new_node) { - if (new_node == theContext()->getNode()) { - state_ = eLocState::Local; - } else { - state_ = eLocState::Remote; - } - - cur_node_ = new_node; -} - -template -bool LocRecord::isLocal() const { - return state_ == eLocState::Local; -} - -template -bool LocRecord::isRemote() const { - return state_ == eLocState::Remote; -} - -template -NodeType LocRecord::getRemoteNode() const { - return cur_node_; -} - -template -EntityID LocRecord::getEntityID() const { - return id_; -} - -}} // end namespace vt::location - -#endif /*INCLUDED_VT_TOPOS_LOCATION_RECORD_RECORD_IMPL_H*/ diff --git a/src/vt/topos/location/record/state.h b/src/vt/topos/location/record/state.h deleted file mode 100644 index ab8bf1462a..0000000000 --- a/src/vt/topos/location/record/state.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// state.h -// DARMA/vt => Virtual Transport -// -// Copyright 2019-2024 National Technology & Engineering Solutions of Sandia, LLC -// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. -// Government retains certain rights in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact darma@sandia.gov -// -// ***************************************************************************** -//@HEADER -*/ - -#if !defined INCLUDED_VT_TOPOS_LOCATION_RECORD_STATE_H -#define INCLUDED_VT_TOPOS_LOCATION_RECORD_STATE_H - -#include "vt/config.h" -#include "vt/context/context.h" - -#include -#include - -namespace vt { namespace location { - -enum class eLocState : int32_t { - Local = 1, - Remote = 2, - Invalid = -1 -}; - -}} // end namespace vt::location - -#endif /*INCLUDED_VT_TOPOS_LOCATION_RECORD_STATE_H*/ diff --git a/src/vt/topos/location/record/state_printer.h b/src/vt/topos/location/record/state_printer.h deleted file mode 100644 index 49c1fb2b8b..0000000000 --- a/src/vt/topos/location/record/state_printer.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// state_printer.h -// DARMA/vt => Virtual Transport -// -// Copyright 2019-2024 National Technology & Engineering Solutions of Sandia, LLC -// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. -// Government retains certain rights in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact darma@sandia.gov -// -// ***************************************************************************** -//@HEADER -*/ - -#if !defined INCLUDED_VT_TOPOS_LOCATION_RECORD_STATE_PRINTER_H -#define INCLUDED_VT_TOPOS_LOCATION_RECORD_STATE_PRINTER_H - -#include "vt/config.h" -#include "vt/topos/location/record/state.h" -#include "vt/topos/location/record/state_stringize.h" - -#include -#include -#include - -namespace vt { namespace location { - -template -std::ostream& operator<<(std::ostream& os, LocRecord const& rec) { - auto state_val = (int32_t) rec.state_; - os << "id=" << rec.id_ << ", " - << "state=" << rec.state_ << ", " - << "state=" << state_val << ", " - << "cur_node_=" << rec.cur_node_; - return os; -} - -inline std::ostream& operator<<(std::ostream& os, eLocState const& state) { - os << print_location_record_state(state); - return os; -} - -}} // end namespace vt::location - -#endif /*INCLUDED_VT_TOPOS_LOCATION_RECORD_STATE_PRINTER_H*/ diff --git a/src/vt/topos/location/record/state_stringize.h b/src/vt/topos/location/record/state_stringize.h deleted file mode 100644 index f496013b69..0000000000 --- a/src/vt/topos/location/record/state_stringize.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// state_stringize.h -// DARMA/vt => Virtual Transport -// -// Copyright 2019-2024 National Technology & Engineering Solutions of Sandia, LLC -// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. -// Government retains certain rights in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact darma@sandia.gov -// -// ***************************************************************************** -//@HEADER -*/ - -#if !defined INCLUDED_VT_TOPOS_LOCATION_RECORD_STATE_STRINGIZE_H -#define INCLUDED_VT_TOPOS_LOCATION_RECORD_STATE_STRINGIZE_H - -#include "vt/config.h" -#include "vt/topos/location/record/state.h" - -#define print_location_record_state(state) ( \ - (state) == eLocState::Local ? "eLocState::Local" : ( \ - (state) == eLocState::Remote ? "eLocState::Remote" : ( \ - (state) == eLocState::Invalid ? "eLocState::Invalid" : ( \ - "Unknown eLocState!" \ - ) \ - ) \ - ) \ - ) - -#endif /*INCLUDED_VT_TOPOS_LOCATION_RECORD_STATE_STRINGIZE_H*/ diff --git a/src/vt/topos/location/utility/coord.h b/src/vt/topos/location/utility/coord.h deleted file mode 100644 index 8859edacc2..0000000000 --- a/src/vt/topos/location/utility/coord.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// coord.h -// DARMA/vt => Virtual Transport -// -// Copyright 2019-2024 National Technology & Engineering Solutions of Sandia, LLC -// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. -// Government retains certain rights in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact darma@sandia.gov -// -// ***************************************************************************** -//@HEADER -*/ - -#if !defined INCLUDED_VT_TOPOS_LOCATION_UTILITY_COORD_H -#define INCLUDED_VT_TOPOS_LOCATION_UTILITY_COORD_H - -#include "vt/config.h" -#include "vt/topos/location/location_common.h" - -namespace vt { namespace location { - -// General base class for the location coords to erase templated types -struct LocationCoord { - int data; - - template - void serialize(Serializer& s) { - s | data; - } -}; - -}} // end namespace vt::location - -#endif /*INCLUDED_VT_TOPOS_LOCATION_UTILITY_COORD_H*/ diff --git a/src/vt/topos/location/utility/pending.h b/src/vt/topos/location/utility/pending.h deleted file mode 100644 index 2038c28c87..0000000000 --- a/src/vt/topos/location/utility/pending.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// pending.h -// DARMA/vt => Virtual Transport -// -// Copyright 2019-2024 National Technology & Engineering Solutions of Sandia, LLC -// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. -// Government retains certain rights in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact darma@sandia.gov -// -// ***************************************************************************** -//@HEADER -*/ - -#if !defined INCLUDED_VT_TOPOS_LOCATION_UTILITY_PENDING_H -#define INCLUDED_VT_TOPOS_LOCATION_UTILITY_PENDING_H - -#include "vt/config.h" -#include "vt/topos/location/location_common.h" -#include "vt/topos/location/location.fwd.h" - -namespace vt { namespace location { - -template -struct PendingLocationLookup { - PendingLocationLookup(EntityID const& in_entity, NodeActionType const& in_act) - : entity_(in_entity), action_(in_act) - { } - - void applyNodeAction(NodeType const& node) { - action_(node); - } - - friend struct EntityLocationCoord; - - template - void serialize(Serializer& s) { - s | entity_ - | action_; - } - -private: - EntityID entity_; - NodeActionType action_ = nullptr; -}; - -}} // end namespace vt::location - -#endif /*INCLUDED_VT_TOPOS_LOCATION_UTILITY_PENDING_H*/ diff --git a/src/vt/trace/trace_lite.cc b/src/vt/trace/trace_lite.cc index 0e4b093436..aedc74a152 100644 --- a/src/vt/trace/trace_lite.cc +++ b/src/vt/trace/trace_lite.cc @@ -218,7 +218,7 @@ void TraceLite::setupNames([[maybe_unused]] std::string const& in_prog_name) { auto const trace_name = tc[tc.size() - 1]; auto const prog_name = pc[pc.size() - 1]; - auto const node_str = "." + std::to_string(node) + ".log.gz"; + auto const node_str = std::string{"."} + std::to_string(node) + ".log.gz"; if (theConfig()->vt_trace_file.empty()) { full_trace_name_ = full_dir_name_ + trace_name; full_sts_name_ = full_dir_name_ + prog_name + ".sts"; diff --git a/src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc b/src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc index 9d91894a35..769583ac81 100644 --- a/src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc +++ b/src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc @@ -488,8 +488,6 @@ void LBManager::fatalError() { #if vt_check_enabled(tv) struct GatherTVInfo { - GatherTVInfo() = default; - std::unordered_map rank_map; std::unordered_map info; PhaseType phase = 0; diff --git a/tests/unit/lb/test_temperedlb.cc b/tests/unit/lb/test_temperedlb.cc index 5f32e428e7..e76b153114 100644 --- a/tests/unit/lb/test_temperedlb.cc +++ b/tests/unit/lb/test_temperedlb.cc @@ -61,7 +61,11 @@ std::string writeTemperedLBConfig( auto config_file = getUniqueFilename(); if (this_node == 0) { std::ofstream cfg_file_{config_file.c_str(), std::ofstream::out | std::ofstream::trunc}; - cfg_file_ << "0 TemperedLB converge_tolerance=0.001 iters=10 trials=3 transfer=" << transfer_strategy << + // These tests assert exact solutions, so use synchronous informs and avoid + // random propagation or transfer choices producing a different optimum. + cfg_file_ << "0 TemperedLB converge_tolerance=0.001 iters=10 trials=3 " + "inform=SyncInform ordering=ElmID deterministic=true transfer=" << + transfer_strategy << " alpha=" << alpha << " beta=" << beta << " gamma=" << gamma << diff --git a/tests/unit/utils/test_demangler_utils.nompi.cc b/tests/unit/utils/test_demangler_utils.nompi.cc index 775a3bca29..b599a0f8f6 100644 --- a/tests/unit/utils/test_demangler_utils.nompi.cc +++ b/tests/unit/utils/test_demangler_utils.nompi.cc @@ -43,6 +43,10 @@ #include +#include +#include +#include + #include "vt/utils/demangle/demangle.h" #include "test_harness.h" @@ -95,52 +99,49 @@ struct TestDemanglerUtils : TestHarness { using TE = vt::util::demangle::TemplateExtract; TEST_F(TestDemanglerUtils, test_getVoidFuncStrArgs) { - std::vector> data; - data.emplace_back("", ""); - data.emplace_back("not-starting-void", "not-starting-void"); - data.emplace_back("void(with-extra-at)end", "void(with-extra-at)end"); - data.emplace_back("void ()", ""); - data.emplace_back("void (foo)", "foo"); - data.emplace_back("void(foo)", "foo"); - data.emplace_back("void (dontcare-unbalanced))", "dontcare-unbalanced)"); - data.emplace_back("void (fn())", "fn()"); - data.emplace_back("void (fn(a))", "fn(a)"); - data.emplace_back("void (fn(*)(a,b,c,d))", "fn(*)(a,b,c,d)"); - - for (auto& t : data) { - std::string& given = std::get<0>(t); - std::string& expected = std::get<1>(t); + std::array, 10> const data = {{ + {"", ""}, + {"not-starting-void", "not-starting-void"}, + {"void(with-extra-at)end", "void(with-extra-at)end"}, + {"void ()", ""}, + {"void (foo)", "foo"}, + {"void(foo)", "foo"}, + {"void (dontcare-unbalanced))", "dontcare-unbalanced)"}, + {"void (fn())", "fn()"}, + {"void (fn(a))", "fn(a)"}, + {"void (fn(*)(a,b,c,d))", "fn(*)(a,b,c,d)"} + }}; + + for (auto const& [given, expected] : data) { EXPECT_EQ(TE::getVoidFuncStrArgs(given), expected); } } TEST_F(TestDemanglerUtils, test_getNamespace) { - std::vector> data; - data.emplace_back("", ""); - data.emplace_back("aa", ""); - data.emplace_back("aa::bb", "aa"); - data.emplace_back("&aa::bb", "aa"); - data.emplace_back("aa::dd>::bare", "aa::dd>"); - data.emplace_back("aa::dd::bare", "aa::dd"); - - for (auto& t : data) { - std::string& given = std::get<0>(t); - std::string& expected = std::get<1>(t); + std::array, 6> const data = {{ + {"", ""}, + {"aa", ""}, + {"aa::bb", "aa"}, + {"&aa::bb", "aa"}, + {"aa::dd>::bare", "aa::dd>"}, + {"aa::dd::bare", "aa::dd"} + }}; + + for (auto const& [given, expected] : data) { EXPECT_EQ(TE::getNamespace(given), expected); } } TEST_F(TestDemanglerUtils, test_getBarename) { - std::vector> data; - data.emplace_back("", ""); - data.emplace_back("aa", "aa"); - data.emplace_back("aa::bb", "bb"); - data.emplace_back("aa::dd>::bare", "bare"); - data.emplace_back("aa::dd::bare", "bare"); - - for (auto& t : data) { - std::string& given = std::get<0>(t); - std::string& expected = std::get<1>(t); + std::array, 5> const data = {{ + {"", ""}, + {"aa", "aa"}, + {"aa::bb", "bb"}, + {"aa::dd>::bare", "bare"}, + {"aa::dd::bare", "bare"} + }}; + + for (auto const& [given, expected] : data) { EXPECT_EQ(TE::getBarename(given), expected); } } @@ -157,20 +158,18 @@ void someFunc_2(A, B) { } } // namespace helpers TEST_F(TestDemanglerUtils, test_lastNamedPfType) { - std::vector> data; - data.emplace_back("", ""); - data.emplace_back(__PRETTY_FUNCTION__, ""); - data.emplace_back(TestFunctor{}()); - data.emplace_back(TestFunctor{}()); - data.emplace_back(TestFunctor>{}()); - data.emplace_back(SecondTestFunctor{}()); - data.emplace_back(SecondTestFunctor{}()); - data.emplace_back( - SecondTestFunctor>{}()); - - for (auto& t : data) { - std::string& spf = std::get<0>(t); - std::string& expected = std::get<1>(t); + std::array, 8> const data = {{ + {"", ""}, + {std::string{__PRETTY_FUNCTION__}, std::string{}}, + TestFunctor{}(), + TestFunctor{}(), + TestFunctor>{}(), + SecondTestFunctor{}(), + SecondTestFunctor{}(), + SecondTestFunctor>{}() + }}; + + for (auto const& [spf, expected] : data) { EXPECT_EQ(TE::lastNamedPfType(spf, "PF_VALUE_NAME"), expected) << "spf: " << spf << std::endl; }