Skip to content

Commit

Permalink
#476 add LB migrating to the same node
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Strzebonski committed Apr 8, 2022
1 parent 74c2e0c commit 1677943
Show file tree
Hide file tree
Showing 7 changed files with 201 additions and 25 deletions.
51 changes: 26 additions & 25 deletions docs/md/lb-manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -250,6 +251,7 @@ void LBManager::startLB(PhaseType phase, LBType lb) {
# if vt_check_enabled(zoltan)
case LBType::ZoltanLB: lb_instances_["chosen"] = makeLB<lb::ZoltanLB>(); break;
# endif
case LBType::SerdeTestLB: lb_instances_["chosen"] = makeLB<lb::SerdeTestLB>(); break;
case LBType::NoLB:
vtAssert(false, "LBType::NoLB is not a valid LB for collectiveImpl");
break;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/vt/vrt/collection/balance/lb_type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ static std::unordered_map<LBType,std::string> 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<LBType, std::string>& get_lb_names() {
Expand Down
1 change: 1 addition & 0 deletions src/vt/vrt/collection/balance/lb_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ enum struct LBType : int8_t {
, ZoltanLB = 6
# endif
, RandomLB = 7
, SerdeTestLB = 8
};

}}}} /* end namespace vt::vrt::collection::balance */
Expand Down
89 changes: 89 additions & 0 deletions src/vt/vrt/collection/balance/serdetestlb/serdetestlb.cc
Original file line number Diff line number Diff line change
@@ -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 [email protected]
//
// *****************************************************************************
//@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 <memory>

namespace vt { namespace vrt { namespace collection { namespace lb {

/*static*/ std::unordered_map<std::string, std::string>
SerdeTestLB::getInputKeysWithHelp() {
return std::unordered_map<std::string, std::string>{};
}

void SerdeTestLB::init(objgroup::proxy::Proxy<SerdeTestLB>) { }

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 */
78 changes: 78 additions & 0 deletions src/vt/vrt/collection/balance/serdetestlb/serdetestlb.h
Original file line number Diff line number Diff line change
@@ -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 [email protected]
//
// *****************************************************************************
//@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 <memory>
#include <list>
#include <map>
#include <cstdlib>
#include <unordered_map>

namespace vt { namespace vrt { namespace collection { namespace lb {

struct SerdeTestLB : BaseLB {

SerdeTestLB() = default;
virtual ~SerdeTestLB() {}

void init(objgroup::proxy::Proxy<SerdeTestLB> in_proxy);
void runLB(TimeType) override;
void inputParams(balance::SpecEntry* spec) override;

static std::unordered_map<std::string, std::string> getInputKeysWithHelp();

private:
objgroup::proxy::Proxy<SerdeTestLB> proxy = {};
};

}}}} /* end namespace vt::vrt::collection::lb */

#endif /*INCLUDED_VT_VRT_COLLECTION_BALANCE_SERDETESTLB_SERDETESTLB_H*/

0 comments on commit 1677943

Please sign in to comment.