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

#1668: initialize collection stats phase #2185

Merged
merged 8 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 15 additions & 8 deletions src/vt/elm/elm_lb_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,28 @@ void ElementLBData::addTime(LoadType const timeLoad) {
);
}

void ElementLBData::setPhase(PhaseType const& new_phase) {
cur_phase_ = new_phase;

// Access all table entries for current phase, to ensure presence even
// if they're left empty
if ( cur_phase_ != 0 )
{
phase_timings_[cur_phase_];
subphase_timings_[cur_phase_];
phase_comm_[cur_phase_];
subphase_comm_[cur_phase_];
}
thearusable marked this conversation as resolved.
Show resolved Hide resolved
}

void ElementLBData::updatePhase(PhaseType const& inc) {
vt_debug_print(
verbose, lb,
"ElementLBData: updatePhase: cur_phase_={}, inc={}\n",
cur_phase_, inc
);

cur_phase_ += inc;

// Access all table entries for current phase, to ensure presence even
// if they're left empty
phase_timings_[cur_phase_];
subphase_timings_[cur_phase_];
phase_comm_[cur_phase_];
subphase_comm_[cur_phase_];
setPhase(cur_phase_ + inc);
}

void ElementLBData::resetPhase() {
Expand Down
1 change: 1 addition & 0 deletions src/vt/elm/elm_lb_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ struct ElementLBData {
NodeType to, ElementIDStruct from_perm,
double bytes, bool bcast
);
void setPhase(PhaseType const& new_phase);
void updatePhase(PhaseType const& inc = 1);
void resetPhase();
PhaseType getPhase() const;
Expand Down
7 changes: 3 additions & 4 deletions src/vt/vrt/collection/manager.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,9 @@ bool CollectionManager::insertCollectionElement(
listener::ElementEventEnum::ElementMigratedIn, idx, home_node
);
} else {
auto raw_ptr = elm_holder->lookup(idx).getRawPtr();
raw_ptr->getLBData().setPhase(thePhase()->getCurrentPhase());

theLocMan()->getCollectionLM<IndexT>(proxy)->registerEntity(
idx, home_node,
CollectionManager::collectionMsgHandler<ColT, IndexT>
Expand Down Expand Up @@ -1681,10 +1684,6 @@ void CollectionManager::insert(
if (insert_node == this_node and proceed_with_insertion) {
auto cons_fn = detail::InsertMsgDispatcher<MsgT, ColT>::makeCons(insert_msg);
makeCollectionElement<ColT>(untyped_proxy, idx, mapped_node, cons_fn);

auto elm_holder = findElmHolder<IndexType>(untyped_proxy);
auto raw_ptr = elm_holder->lookup(idx).getRawPtr();
raw_ptr->getLBData().updatePhase(thePhase()->getCurrentPhase());
} else if (insert_node != this_node) {
auto msg = makeMessage<InsertMsg<ColT, MsgT>>(
proxy, idx, insert_node, mapped_node, modify_epoch, insert_msg
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/collection/test_lb_data_retention.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include <vt/vrt/collection/balance/lb_invoke/lb_manager.h>
#include <vt/vrt/collection/types/type_aliases.h>
#include <vt/vrt/collection/manager.h>
#include <vt/phase/phase_manager.h>

#include <gtest/gtest.h>

Expand All @@ -58,7 +59,7 @@
namespace vt { namespace tests { namespace unit {

struct TestCol : vt::Collection<TestCol,vt::Index1D> {
unsigned int prev_calls_ = 0;
unsigned int prev_calls_ = thePhase()->getCurrentPhase();

unsigned int prevCalls() { return prev_calls_++; }

Expand Down
35 changes: 35 additions & 0 deletions tests/unit/collection/test_lb_lite.extended.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,41 @@ TEST_F(TestLB, test_lb_1) {
}
}

TEST_F(TestLB, test_lb_phase_stats) {
auto const& this_node = theContext()->getNode();
auto const& range = Index1D(32);
auto proxy = theCollection()->constructCollective<LBTest>(
range, "test_lb_phases_stats"
);

for (int i = 0; i < num_iter; i++) {
auto cur_time = vt::timing::getCurrentTime();

vt::runInEpochCollective([=]{
proxy.broadcastCollective<IterMsg,&LBTest::iterWork>(i);
});

auto total_time = vt::timing::getCurrentTime() - cur_time;
if (this_node == 0) {
fmt::print("iteration: iter={},time={}\n", i, total_time);
}

vt::thePhase()->nextPhaseCollective();
}

auto proxy2 = theCollection()->constructCollective<LBTest>(
range, "test_lb_phases_stats_2"
);

for (int i = 0; i < num_iter; i++) {
vt::runInEpochCollective([=]{
proxy2.broadcastCollective<IterMsg,&LBTest::iterWork>(i);
});

vt::thePhase()->nextPhaseCollective();
thearusable marked this conversation as resolved.
Show resolved Hide resolved
}
}

// TEST_F(TestLB, test_lb_multi_1) {
// auto const& this_node = theContext()->getNode();
// if (this_node == 0) {
Expand Down