From 167794359024cfb95ed78e1986b3838aefe25b08 Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Wed, 26 Jan 2022 11:30:05 +0100 Subject: [PATCH] #476 add LB migrating to the same node --- docs/md/lb-manager.md | 51 +++++------ src/CMakeLists.txt | 1 + .../balance/lb_invoke/lb_manager.cc | 5 ++ src/vt/vrt/collection/balance/lb_type.cc | 1 + src/vt/vrt/collection/balance/lb_type.h | 1 + .../balance/serdetestlb/serdetestlb.cc | 89 +++++++++++++++++++ .../balance/serdetestlb/serdetestlb.h | 78 ++++++++++++++++ 7 files changed, 201 insertions(+), 25 deletions(-) create mode 100644 src/vt/vrt/collection/balance/serdetestlb/serdetestlb.cc create mode 100644 src/vt/vrt/collection/balance/serdetestlb/serdetestlb.h diff --git a/docs/md/lb-manager.md b/docs/md/lb-manager.md index 3153f218e7..7423651ecf 100644 --- a/docs/md/lb-manager.md +++ b/docs/md/lb-manager.md @@ -51,15 +51,16 @@ To print LB specification during startup, use `--vt_lb_show_spec` command line f \section load-balancers Load balancers -| Load Balancer | Type | Description | Reference | -| -------------- | ----------------------- | ---------------------------------------------- | --------- | -| RotateLB | Testing | Rotate objects in a ring | `vt::vrt::collection::lb::RotateLB` | -| RandomLB | Testing | Randomly migrate object with seed | `vt::vrt::collection::lb::RandomLB` | -| GreedyLB | Centralized | Gather to central node apply min/max heap | `vt::vrt::collection::lb::GreedyLB` | -| TemperedLB | Distributed | Inspired by epidemic algorithms | `vt::vrt::collection::lb::TemperedLB` | -| HierarchicalLB | Hierarchical | Build tree to move objects nodes | `vt::vrt::collection::lb::HierarchicalLB` | -| ZoltanLB | Hyper-graph Partitioner | Run Zoltan in hyper-graph mode to LB | `vt::vrt::collection::lb::ZoltanLB` | -| StatsMapLB | User-specified | Read file to determine mapping | `vt::vrt::collection::lb::StatsMapLB` | +| Load Balancer | Type | Description | Reference | +| -------------- | ----------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------- | +| RotateLB | Testing | Rotate objects in a ring | `vt::vrt::collection::lb::RotateLB` | +| RandomLB | Testing | Randomly migrate object with seed | `vt::vrt::collection::lb::RandomLB` | +| GreedyLB | Centralized | Gather to central node apply min/max heap | `vt::vrt::collection::lb::GreedyLB` | +| TemperedLB | Distributed | Inspired by epidemic algorithms | `vt::vrt::collection::lb::TemperedLB` | +| HierarchicalLB | Hierarchical | Build tree to move objects nodes | `vt::vrt::collection::lb::HierarchicalLB` | +| ZoltanLB | Hyper-graph Partitioner | Run Zoltan in hyper-graph mode to LB | `vt::vrt::collection::lb::ZoltanLB` | +| StatsMapLB | User-specified | Read file to determine mapping | `vt::vrt::collection::lb::StatsMapLB` | +| SerdeTestLB | Testing | Migrate objects to the same node, for testing serialization/deserialization purpose | `vt::vrt::collection::lb::SerdeTestLB` | \section load-models Object Load Models @@ -104,22 +105,22 @@ times those objects will take in all future phases. The full set of load model classes provided with \vt is as follows -| Load Model | Description | Reference | -| ------------------ | --------------------------------------------------- | --------- | -| **Utilities** | | | -| LoadModel | Pure virtual interface class, which the following implement | `vt::vrt::collection::balance::LoadModel` | -| ComposedModel | A convenience class for most implementations to inherit from, that passes unmodified calls through to an underlying model instance | `vt::vrt::collection::balance::ComposedModel` | -| RawData | Returns historical data only, from the measured times | `vt::vrt::collection::balance::RawData` | -| **Transformers** | Transforms the values computed by the composed model(s), agnostic to whether a query refers to a past or future phase | | -| Norm | When asked for a `WHOLE_PHASE` value, computes a specified l-norm over all subphases | `vt::vrt::collection::balance::Norm` | -| SelectSubphases | Filters and remaps the subphases with data present in the underlying model | `vt::vrt::collection::balance::SelectSubphases` | -| CommOverhead | Adds a specified amount of imputed 'system overhead' time to each object's work based on the number of messages received | `vt::vrt::collection::balance::CommOverhead` | -| PerCollection | Maintains a set of load models associated with different collection instances, and passes queries for an object through to the model corresponding to its collection | `vt::vrt::collection::balance::PerCollection` | -| **Predictors** | Computes values for future phase queries, and passes through past phase queries | | -| NaivePersistence | Passes through historical queries, and maps all future queries to the most recent past phase | `vt::vrt::collection::balance::NaivePersistence` | -| PersistenceMedianLastN | Similar to NaivePersistence, except that it predicts based on a median over the N most recent phases | `vt::vrt::collection::balance::PersistenceMedianLastN` | -| LinearModel | Computes a linear regression over on object's loads from a number of recent phases | `vt::vrt::collection::balance::LinearModel` | -| MultiplePhases | Computes values for future phases based on sums of the underlying model's predictions for N corresponding future phases | `vt::vrt::collection::balance::MultiplePhases` | +| Load Model | Description | Reference | +| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ | +| **Utilities** | | | +| LoadModel | Pure virtual interface class, which the following implement | `vt::vrt::collection::balance::LoadModel` | +| ComposedModel | A convenience class for most implementations to inherit from, that passes unmodified calls through to an underlying model instance | `vt::vrt::collection::balance::ComposedModel` | +| RawData | Returns historical data only, from the measured times | `vt::vrt::collection::balance::RawData` | +| **Transformers** | Transforms the values computed by the composed model(s), agnostic to whether a query refers to a past or future phase | | +| Norm | When asked for a `WHOLE_PHASE` value, computes a specified l-norm over all subphases | `vt::vrt::collection::balance::Norm` | +| SelectSubphases | Filters and remaps the subphases with data present in the underlying model | `vt::vrt::collection::balance::SelectSubphases` | +| CommOverhead | Adds a specified amount of imputed 'system overhead' time to each object's work based on the number of messages received | `vt::vrt::collection::balance::CommOverhead` | +| PerCollection | Maintains a set of load models associated with different collection instances, and passes queries for an object through to the model corresponding to its collection | `vt::vrt::collection::balance::PerCollection` | +| **Predictors** | Computes values for future phase queries, and passes through past phase queries | | +| NaivePersistence | Passes through historical queries, and maps all future queries to the most recent past phase | `vt::vrt::collection::balance::NaivePersistence` | +| PersistenceMedianLastN | Similar to NaivePersistence, except that it predicts based on a median over the N most recent phases | `vt::vrt::collection::balance::PersistenceMedianLastN` | +| LinearModel | Computes a linear regression over on object's loads from a number of recent phases | `vt::vrt::collection::balance::LinearModel` | +| MultiplePhases | Computes values for future phases based on sums of the underlying model's predictions for N corresponding future phases | `vt::vrt::collection::balance::MultiplePhases` | All of the provided load balancers described in the previous section require that the installed load model provide responses to future diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9dc38b1eba..778bb765d1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -89,6 +89,7 @@ set( vrt/collection/balance/statsmaplb vrt/collection/balance/zoltanlb vrt/collection/balance/randomlb + vrt/collection/balance/serdetestlb vrt/collection/balance/lb_invoke vrt/collection/balance/model vrt/collection/balance/proxy 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 c7420a1263..950cd1a4c3 100644 --- a/src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc +++ b/src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc @@ -58,6 +58,7 @@ #include "vt/vrt/collection/balance/stats_restart_reader.h" #include "vt/vrt/collection/balance/zoltanlb/zoltanlb.h" #include "vt/vrt/collection/balance/randomlb/randomlb.h" +#include "vt/vrt/collection/balance/serdetestlb/serdetestlb.h" #include "vt/vrt/collection/messages/system_create.h" #include "vt/vrt/collection/manager.fwd.h" #include "vt/utils/memory/memory_usage.h" @@ -250,6 +251,7 @@ void LBManager::startLB(PhaseType phase, LBType lb) { # if vt_check_enabled(zoltan) case LBType::ZoltanLB: lb_instances_["chosen"] = makeLB(); break; # endif + case LBType::SerdeTestLB: lb_instances_["chosen"] = makeLB(); break; case LBType::NoLB: vtAssert(false, "LBType::NoLB is not a valid LB for collectiveImpl"); break; @@ -300,6 +302,9 @@ void LBManager::printLBArgsHelp(LBType lb) { help = lb::ZoltanLB::getInputKeysWithHelp(); break; # endif + case LBType::SerdeTestLB: + help = lb::SerdeTestLB::getInputKeysWithHelp(); + break; case LBType::NoLB: // deliberately skip retrieving arguments break; diff --git a/src/vt/vrt/collection/balance/lb_type.cc b/src/vt/vrt/collection/balance/lb_type.cc index 262953b301..3a02255471 100644 --- a/src/vt/vrt/collection/balance/lb_type.cc +++ b/src/vt/vrt/collection/balance/lb_type.cc @@ -60,6 +60,7 @@ static std::unordered_map lb_names_ = { {LBType::TemperedLB, std::string{"TemperedLB" }}, {LBType::StatsMapLB, std::string{"StatsMapLB" }}, {LBType::RandomLB, std::string{"RandomLB" }}, + {LBType::SerdeTestLB, std::string{"SerdeTestLB" }}, }; std::unordered_map& get_lb_names() { diff --git a/src/vt/vrt/collection/balance/lb_type.h b/src/vt/vrt/collection/balance/lb_type.h index b7b72da115..c4b47c8f4a 100644 --- a/src/vt/vrt/collection/balance/lb_type.h +++ b/src/vt/vrt/collection/balance/lb_type.h @@ -63,6 +63,7 @@ enum struct LBType : int8_t { , ZoltanLB = 6 # endif , RandomLB = 7 + , SerdeTestLB = 8 }; }}}} /* end namespace vt::vrt::collection::balance */ diff --git a/src/vt/vrt/collection/balance/serdetestlb/serdetestlb.cc b/src/vt/vrt/collection/balance/serdetestlb/serdetestlb.cc new file mode 100644 index 0000000000..ab97d911ee --- /dev/null +++ b/src/vt/vrt/collection/balance/serdetestlb/serdetestlb.cc @@ -0,0 +1,89 @@ +/* +//@HEADER +// ***************************************************************************** +// +// serdetestlb.cc +// DARMA/vt => Virtual Transport +// +// Copyright 2019-2021 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 +*/ + +// #include "vt/config.h" +// #include "vt/timing/timing.h" +#include "vt/vrt/collection/balance/serdetestlb/serdetestlb.h" +#include "vt/vrt/collection/balance/model/load_model.h" +// #include "vt/vrt/collection/manager.h" + +// #include + +namespace vt { namespace vrt { namespace collection { namespace lb { + +/*static*/ std::unordered_map +SerdeTestLB::getInputKeysWithHelp() { + return std::unordered_map{}; +} + +void SerdeTestLB::init(objgroup::proxy::Proxy) { } + +void SerdeTestLB::inputParams(balance::SpecEntry*) { } + +void SerdeTestLB::runLB(TimeType) { + auto const this_node = theContext()->getNode(); + auto const next_node = this_node; + + if (this_node == 0) { + vt_print( + lb, + "SerdeTestLB: runLB: next_node={}\n", + next_node + ); + fflush(stdout); + } + + for (auto obj : *load_model_) { + TimeTypeWrapper const load = load_model_->getWork(obj, {balance::PhaseOffset::NEXT_PHASE, balance::PhaseOffset::WHOLE_PHASE}); + vt_debug_print( + terse, lb, + "\t SerdeTestLB::migrating object to: obj={}, load={}, to_node={} from_node={}\n", + obj, load, next_node, this_node + ); + if (obj.isMigratable()) { + migrateObjectTo(obj, next_node); + } + } +} + +}}}} /* end namespace vt::vrt::collection::lb */ diff --git a/src/vt/vrt/collection/balance/serdetestlb/serdetestlb.h b/src/vt/vrt/collection/balance/serdetestlb/serdetestlb.h new file mode 100644 index 0000000000..78e2fc0be4 --- /dev/null +++ b/src/vt/vrt/collection/balance/serdetestlb/serdetestlb.h @@ -0,0 +1,78 @@ +/* +//@HEADER +// ***************************************************************************** +// +// serdetestlb.h +// DARMA/vt => Virtual Transport +// +// Copyright 2019-2021 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_VRT_COLLECTION_BALANCE_SERDETESTLB_SERDETESTLB_H +#define INCLUDED_VT_VRT_COLLECTION_BALANCE_SERDETESTLB_SERDETESTLB_H + +#include "vt/config.h" +#include "vt/messaging/message.h" +#include "vt/vrt/collection/balance/lb_common.h" +#include "vt/vrt/collection/balance/baselb/baselb.h" +#include "vt/timing/timing.h" + +#include +#include +#include +#include +#include + +namespace vt { namespace vrt { namespace collection { namespace lb { + +struct SerdeTestLB : BaseLB { + + SerdeTestLB() = default; + virtual ~SerdeTestLB() {} + + void init(objgroup::proxy::Proxy in_proxy); + void runLB(TimeType) override; + void inputParams(balance::SpecEntry* spec) override; + + static std::unordered_map getInputKeysWithHelp(); + +private: + objgroup::proxy::Proxy proxy = {}; +}; + +}}}} /* end namespace vt::vrt::collection::lb */ + +#endif /*INCLUDED_VT_VRT_COLLECTION_BALANCE_SERDETESTLB_SERDETESTLB_H*/