Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1596 Extend lb stats #1601

Merged
merged 34 commits into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
481d2ed
#1596: LB: fix old comment that isn't correct anymore
lifflander Nov 3, 2021
da1c265
#1596: LB: move elm ID to its own file
lifflander Nov 3, 2021
255b6e4
#1596: objgroup: remove unneeded layer for scheduling a message
lifflander Nov 3, 2021
3a88c39
#1596: runnable: refactor the ColT element template out
lifflander Nov 3, 2021
9e7c300
#1596: elm: move to top level to generalize
lifflander Nov 3, 2021
296661f
#1596: elm: add new fmt extension for formatting
lifflander Nov 3, 2021
040e3e1
#1596: elm: move all communication to new location
lifflander Nov 3, 2021
37eebf2
#1596: elm: remove all old ostream outputting
lifflander Nov 3, 2021
11860de
#1596: elm: remove old commented ostream support
lifflander Nov 4, 2021
af19968
#1596: elm: add some doxygen for ElementIDStruct
lifflander Nov 4, 2021
9be92b4
#1596: elm: abstract ElementStats and move to elm
lifflander Nov 4, 2021
16c8d6d
#1596: elm: add getter for subphase timings
lifflander Nov 4, 2021
32c8451
#1596: elm: add objgroup elements to statistics
lifflander Nov 4, 2021
2cc5381
#1596: objgroup: fix missing serialize of member
lifflander Nov 8, 2021
7372b68
#1596: temperedlb: fix access when objs are empty
lifflander Nov 8, 2021
2aea245
#1596: tests: check if object exists
lifflander Nov 8, 2021
cec7d6a
#1596: active: add LB stats to all bare handlers
lifflander Nov 8, 2021
02bc98d
#1596: objgroup: fix bug in bits of objgroup
lifflander Nov 9, 2021
3893343
#1596: elm: rewrite elm_id to use bit encodings
lifflander Nov 9, 2021
2237dc7
#1596: elm: fix tests to work with new encoding
lifflander Nov 10, 2021
0558f11
#1596: add missing file
lifflander Dec 2, 2021
49a0950
#1596: tests: update for new interface
lifflander Dec 16, 2021
2abe300
#1596: elm: add internal messages, refactor communication collection
lifflander Dec 16, 2021
c42228b
#1596: elm: implement new tests for different comm patterns
lifflander Dec 16, 2021
8fb2ec8
#1596: elm: fix some rebase problems
lifflander Dec 16, 2021
8209686
#1596: elm: remove unnecessary include
lifflander Dec 16, 2021
86dc3fc
#1596: formatting: fix blank lines
lifflander Dec 16, 2021
47fe6cd
#1596: formatting: fix spacing in license
lifflander Dec 16, 2021
976fb33
#1596: test: remove commented lines
lifflander Dec 16, 2021
9e1d32b
#1596: active: rename elm_id/stats for bare handlers
lifflander Dec 16, 2021
0573bf0
#1596: env: rename bit field to be more precise
lifflander Dec 17, 2021
8f41139
#1596: tests: diable when LB is disabled
lifflander Dec 17, 2021
5e2e655
#1596: lb: make adjustments for ZoltanLB
lifflander Dec 20, 2021
832480a
#1596: active: rename envelope flag
lifflander Dec 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
set(TOP_LEVEL_SUBDIRS
configs
collective
elm
epoch
group
messaging
Expand Down Expand Up @@ -33,6 +34,7 @@ set(
collective/scatter/
collective/reduce/
collective/reduce/operators collective/reduce/functors
elm
group/id group/region group/global group/msg group/collective group/rooted
group/base
pipe/id pipe/msg pipe/state pipe/signal pipe/interface pipe/callback
Expand Down
3 changes: 2 additions & 1 deletion src/vt/context/runnable_context/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#define INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_BASE_H

#include "vt/configs/types/types_type.h"
#include "vt/elm/elm_id.h"

namespace vt { namespace ctx {

Expand Down Expand Up @@ -95,7 +96,7 @@ struct Base {
* \param[in] size the size of the message
* \param[in] bcast whether the message is being broadcast or sent
*/
virtual void send(NodeType dest, MsgSizeType size, bool bcast) { }
virtual void send(elm::ElementIDStruct dest, MsgSizeType bytes) { }
};

}} /* end namespace vt::ctx */
Expand Down
4 changes: 2 additions & 2 deletions src/vt/context/runnable_context/lb_stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ void LBStats::end() {
}
}

void LBStats::send(NodeType dest, MsgSizeType size, bool bcast) {
stats_->recvToNode(dest, cur_elm_id_, size, bcast);
void LBStats::send(elm::ElementIDStruct dest, MsgSizeType bytes) {
stats_->sendToEntity(dest, cur_elm_id_, bytes);
}

void LBStats::suspend() {
Expand Down
18 changes: 11 additions & 7 deletions src/vt/context/runnable_context/lb_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

#include "vt/context/runnable_context/base.h"
#include "vt/vrt/collection/balance/lb_common.h"
#include "vt/vrt/collection/balance/elm_stats.fwd.h"
#include "vt/elm/elm_stats.fwd.h"

namespace vt { namespace ctx {

Expand All @@ -56,8 +56,8 @@ namespace vt { namespace ctx {
* \brief Context for collection LB statistics when a task runs
*/
struct LBStats final : Base {
using ElementIDStruct = vrt::collection::balance::ElementIDStruct;
using ElementStats = vrt::collection::balance::ElementStats;
using ElementIDStruct = elm::ElementIDStruct;
using ElementStats = elm::ElementStats;

/**
* \brief Construct a \c LBStats
Expand All @@ -71,10 +71,14 @@ struct LBStats final : Base {
/**
* \brief Construct a \c LBStats
*
* \param[in] in_elm the collection element
* \param[in] in_stats the statistics
* \param[in] in_elm_id the element ID
*/
template <typename ElmT>
explicit LBStats(ElmT* in_elm);
LBStats(ElementStats* in_stats, ElementIDStruct const& in_elm_id)
: stats_(in_stats),
cur_elm_id_(in_elm_id),
should_instrument_(true)
{ }

/**
* \brief Set the context and timing for a collection task
Expand All @@ -94,7 +98,7 @@ struct LBStats final : Base {
* \param[in] size the size of the message
* \param[in] bcast whether the message is being broadcast or sent
*/
void send(NodeType dest, MsgSizeType size, bool bcast) final override;
void send(elm::ElementIDStruct dest, MsgSizeType bytes) final override;

void suspend() final override;
void resume() final override;
Expand Down
9 changes: 1 addition & 8 deletions src/vt/context/runnable_context/lb_stats.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

#include "vt/context/runnable_context/lb_stats.h"
#include "vt/messaging/active.h"
#include "vt/vrt/collection/balance/elm_stats.h"
#include "vt/elm/elm_stats.h"
#include "vt/vrt/collection/manager.h"

#include <memory>
Expand All @@ -63,13 +63,6 @@ LBStats::LBStats(ElmT* in_elm, MsgT* msg)
theCollection()->recordStats(in_elm, msg);
}

template <typename ElmT>
LBStats::LBStats(ElmT* in_elm)
: stats_(&in_elm->getStats()),
cur_elm_id_(in_elm->getElmID()),
should_instrument_(true)
{ }

}} /* end namespace vt::ctx */

#endif /*INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_LB_STATS_IMPL_H*/
65 changes: 39 additions & 26 deletions src/vt/vrt/collection/balance/lb_comm.h → src/vt/elm/elm_comm.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//@HEADER
// *****************************************************************************
//
// lb_comm.h
// elm_comm.h
// DARMA/vt => Virtual Transport
//
// Copyright 2019-2021 National Technology & Engineering Solutions of Sandia, LLC
Expand Down Expand Up @@ -41,15 +41,14 @@
//@HEADER
*/

#if !defined INCLUDED_VT_VRT_COLLECTION_BALANCE_LB_COMM_H
#define INCLUDED_VT_VRT_COLLECTION_BALANCE_LB_COMM_H
#if !defined INCLUDED_VT_ELM_ELM_COMM_H
#define INCLUDED_VT_ELM_ELM_COMM_H

#include "vt/config.h"
#include "vt/vrt/collection/balance/lb_common.h"
#include "vt/elm/elm_id.h"

#include <unordered_map>

namespace vt { namespace vrt { namespace collection { namespace balance {
namespace vt { namespace elm {

enum struct CommCategory : int8_t {
SendRecv = 1,
Expand All @@ -66,43 +65,52 @@ inline NodeType objGetNode(ElementIDStruct const id) {
return id.curr_node;
}

struct LBCommKey {
struct CommKey {

struct SendRecvTag { };
struct CollectionTag { };
struct CollectionToNodeTag { };
struct NodeToCollectionTag { };

LBCommKey() = default;
LBCommKey(LBCommKey const&) = default;
LBCommKey(LBCommKey&&) = default;
LBCommKey& operator=(LBCommKey const&) = default;
CommKey() = default;
CommKey(CommKey const&) = default;
CommKey(CommKey&&) = default;
CommKey& operator=(CommKey const&) = default;

LBCommKey(
CommKey(
SendRecvTag,
ElementIDStruct from, ElementIDStruct to,
bool bcast
) : from_(from), to_(to),
cat_(bcast ? CommCategory::Broadcast : CommCategory::SendRecv)
{ }

CommKey(
CollectionTag,
ElementIDStruct from, ElementIDStruct to,
bool bcast
) : from_(from), to_(to),
cat_(bcast ? CommCategory::Broadcast : CommCategory::SendRecv)
{ }
LBCommKey(
CommKey(
CollectionToNodeTag,
ElementIDStruct from, NodeType to,
bool bcast
) : from_(from), nto_(to),
cat_(bcast ? CommCategory::CollectionToNodeBcast : CommCategory::CollectionToNode)
{ }
LBCommKey(
CommKey(
NodeToCollectionTag,
NodeType from, ElementIDStruct to,
bool bcast
) : to_(to), nfrom_(from),
cat_(bcast ? CommCategory::NodeToCollectionBcast : CommCategory::NodeToCollection)
{ }

ElementIDStruct from_ = { no_element_id, uninitialized_destination, uninitialized_destination };
ElementIDStruct to_ = { no_element_id, uninitialized_destination, uninitialized_destination };
ElementIDStruct from_ = {};
ElementIDStruct to_ = {};

ElementIDStruct edge_id_ = { no_element_id, uninitialized_destination, uninitialized_destination };
ElementIDStruct edge_id_ = {};
NodeType nfrom_ = uninitialized_destination;
NodeType nto_ = uninitialized_destination;
CommCategory cat_ = CommCategory::SendRecv;
Expand All @@ -127,7 +135,7 @@ struct LBCommKey {
}
bool onNode() const { return !offNode(); }

bool operator==(LBCommKey const& k) const {
bool operator==(CommKey const& k) const {
return
k.from_ == from_ and k.to_ == to_ and
k.nfrom_ == nfrom_ and k.nto_ == nto_ and
Expand All @@ -141,7 +149,7 @@ struct LBCommKey {
};

// Set the types for the communication graph
using CommKeyType = LBCommKey;
using CommKeyType = CommKey;
using CommBytesType = double;

struct CommVolume {
Expand All @@ -153,6 +161,11 @@ struct CommVolume {
bytes += b;
}

void sendMsg(double b) {
messages++;
bytes += b;
}

void operator+=(const CommVolume &rhs) {
bytes += rhs.bytes;
messages += rhs.messages;
Expand All @@ -166,13 +179,13 @@ struct CommVolume {

using CommMapType = std::unordered_map<CommKeyType,CommVolume>;

}}}} /* end namespace vt::vrt::collection::balance */
}} /* end namespace vt::elm */

namespace std {

using CommCategoryType = vt::vrt::collection::balance::CommCategory;
using LBCommKeyType = vt::vrt::collection::balance::LBCommKey;
using ElementIDStructType = vt::vrt::collection::balance::ElementIDStruct;
using CommCategoryType = vt::elm::CommCategory;
using CommKeyType = vt::elm::CommKey;
using ElementIDStructType = vt::elm::ElementIDStruct;

template <>
struct hash<CommCategoryType> {
Expand All @@ -184,8 +197,8 @@ struct hash<CommCategoryType> {
};

template <>
struct hash<LBCommKeyType> {
size_t operator()(LBCommKeyType const& in) const {
struct hash<CommKeyType> {
size_t operator()(CommKeyType const& in) const {
return std::hash<uint64_t>()(
std::hash<ElementIDStructType>()(in.from_) ^
std::hash<ElementIDStructType>()(in.to_) ^ in.nfrom_ ^ in.nto_
Expand All @@ -195,4 +208,4 @@ struct hash<LBCommKeyType> {

} /* end namespace std */

#endif /*INCLUDED_VT_VRT_COLLECTION_BALANCE_LB_COMM_H*/
#endif /*INCLUDED_VT_ELM_ELM_COMM_H*/
61 changes: 61 additions & 0 deletions src/vt/elm/elm_id.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
//@HEADER
// *****************************************************************************
//
// elm_id.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/elm/elm_id.h"
#include "vt/elm/elm_id_bits.h"

namespace vt { namespace elm {

bool ElementIDStruct::isMigratable() const {
return ElmIDBits::isMigratable(id);
}

NodeType ElementIDStruct::getHomeNode() const {
return ElmIDBits::getNode(id);
}

NodeType ElementIDStruct::getCurrNode() const {
return curr_node;
}

}} /* end namespace vt::elm */
Loading