Skip to content

Commit

Permalink
#2240: Use vt_debug_print for RecursiveDoubling allreduce
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobDomagala committed Oct 10, 2024
1 parent 9d88016 commit 5d79bd0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 37 deletions.
2 changes: 0 additions & 2 deletions src/vt/collective/reduce/allreduce/recursive_doubling.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@

namespace vt::collective::reduce::allreduce {

constexpr bool isdebug = false;

template <typename DataT>
struct AllreduceDblMsg
: SerializeIfNeeded<vt::Message, AllreduceDblMsg<DataT>, DataT> {
Expand Down
56 changes: 21 additions & 35 deletions src/vt/collective/reduce/allreduce/recursive_doubling.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ template <
auto finalHandler>
void RecursiveDoubling<DataT, Op, ObjT, finalHandler>::adjustForPowerOfTwo() {
if (is_part_of_adjustment_group_ and not is_even_) {
if constexpr (isdebug) {
fmt::print(
"[{}] Part1: Sending to Node {} \n", this_node_, this_node_ - 1);
}
vt_debug_print(
terse, allreduce, "[{}] RecursiveDoubling Part1: Sending to Node {} \n", this_node_,
this_node_ - 1
);

proxy_[this_node_ - 1]
.template send<&RecursiveDoubling::adjustForPowerOfTwoHandler>(val_);
Expand All @@ -120,17 +120,6 @@ template <
auto finalHandler>
void RecursiveDoubling<DataT, Op, ObjT, finalHandler>::
adjustForPowerOfTwoHandler(AllreduceDblMsg<DataT>* msg) {
if constexpr (isdebug) {
std::string data(1024, 0x0);
for (auto val : msg->val_) {
data.append(fmt::format("{} ", val));
}
fmt::print(
"[{}] Part1 Handler: Received data ({}) "
"from {}\n",
this_node_, data, theContext()->getFromNodeCurrentTask());
}

Op<DataT>()(val_, msg->val_);

finished_adjustment_part_ = true;
Expand Down Expand Up @@ -180,10 +169,11 @@ void RecursiveDoubling<DataT, Op, ObjT, finalHandler>::reduceIter() {

auto vdest = vrt_node_ ^ mask_;
auto dest = (vdest < nprocs_rem_) ? vdest * 2 : vdest + nprocs_rem_;
if constexpr (isdebug) {
fmt::print(
"[{}] Part2 Step {}: Sending to Node {} \n", this_node_, step_, dest);
}
vt_debug_print(
terse, allreduce,
"[{}] RecursiveDoubling Part2 (step {}): Sending to Node {} \n", this_node_,
step_, dest
);

proxy_[dest].template send<&RecursiveDoubling::reduceIterHandler>(
val_, step_);
Expand Down Expand Up @@ -219,18 +209,13 @@ template <
auto finalHandler>
void RecursiveDoubling<DataT, Op, ObjT, finalHandler>::reduceIterHandler(
AllreduceDblMsg<DataT>* msg) {
if constexpr (isdebug) {
std::string data(1024, 0x0);
for (auto val : msg->val_) {
data.append(fmt::format("{} ", val));
}
fmt::print(
"[{}] Part2 Step {} mask_= {} nprocs_pof2_ = {}: "
"Received data ({}) "
"from {}\n",
this_node_, msg->step_, mask_, nprocs_pof2_, data,
theContext()->getFromNodeCurrentTask());
}
vt_debug_print(
terse, allreduce,
"[{}] RecursiveDoubling Part2 (step {}): mask_= {} nprocs_pof2_ = {}: "
"from {}\n",
this_node_, msg->step_, mask_, nprocs_pof2_,
theContext()->getFromNodeCurrentTask()
);

messages_.at(msg->step_) = promoteMsg(msg);
steps_recv_[msg->step_] = true;
Expand All @@ -255,10 +240,11 @@ template <
auto finalHandler>
void RecursiveDoubling<DataT, Op, ObjT, finalHandler>::sendToExcludedNodes() {
if (is_part_of_adjustment_group_ and is_even_) {
if constexpr (isdebug) {
fmt::print(
"[{}] Part3 : Sending to Node {} \n", this_node_, this_node_ + 1);
}
vt_debug_print(
terse, allreduce, "[{}] RecursiveDoubling Part3: Sending to Node {} \n", this_node_,
this_node_ + 1
);

proxy_[this_node_ + 1]
.template send<&RecursiveDoubling::sendToExcludedNodesHandler>(val_);
}
Expand Down

0 comments on commit 5d79bd0

Please sign in to comment.