Skip to content

Commit 081570b

Browse files
committed
#2240: Use vt_debug_print for RecursiveDoubling allreduce
1 parent 918ab1b commit 081570b

File tree

2 files changed

+21
-37
lines changed

2 files changed

+21
-37
lines changed

src/vt/collective/reduce/allreduce/recursive_doubling.h

-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@
5656

5757
namespace vt::collective::reduce::allreduce {
5858

59-
constexpr bool isdebug = false;
60-
6159
template <typename DataT>
6260
struct AllreduceDblMsg
6361
: SerializeIfNeeded<vt::Message, AllreduceDblMsg<DataT>, DataT> {

src/vt/collective/reduce/allreduce/recursive_doubling.impl.h

+21-35
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ template <
105105
auto finalHandler>
106106
void RecursiveDoubling<DataT, Op, ObjT, finalHandler>::adjustForPowerOfTwo() {
107107
if (is_part_of_adjustment_group_ and not is_even_) {
108-
if constexpr (isdebug) {
109-
fmt::print(
110-
"[{}] Part1: Sending to Node {} \n", this_node_, this_node_ - 1);
111-
}
108+
vt_debug_print(
109+
terse, allreduce, "[{}] RecursiveDoubling Part1: Sending to Node {} \n", this_node_,
110+
this_node_ - 1
111+
);
112112

113113
proxy_[this_node_ - 1]
114114
.template send<&RecursiveDoubling::adjustForPowerOfTwoHandler>(val_);
@@ -120,17 +120,6 @@ template <
120120
auto finalHandler>
121121
void RecursiveDoubling<DataT, Op, ObjT, finalHandler>::
122122
adjustForPowerOfTwoHandler(AllreduceDblMsg<DataT>* msg) {
123-
if constexpr (isdebug) {
124-
std::string data(1024, 0x0);
125-
for (auto val : msg->val_) {
126-
data.append(fmt::format("{} ", val));
127-
}
128-
fmt::print(
129-
"[{}] Part1 Handler: Received data ({}) "
130-
"from {}\n",
131-
this_node_, data, theContext()->getFromNodeCurrentTask());
132-
}
133-
134123
Op<DataT>()(val_, msg->val_);
135124

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

181170
auto vdest = vrt_node_ ^ mask_;
182171
auto dest = (vdest < nprocs_rem_) ? vdest * 2 : vdest + nprocs_rem_;
183-
if constexpr (isdebug) {
184-
fmt::print(
185-
"[{}] Part2 Step {}: Sending to Node {} \n", this_node_, step_, dest);
186-
}
172+
vt_debug_print(
173+
terse, allreduce,
174+
"[{}] RecursiveDoubling Part2 (step {}): Sending to Node {} \n", this_node_,
175+
step_, dest
176+
);
187177

188178
proxy_[dest].template send<&RecursiveDoubling::reduceIterHandler>(
189179
val_, step_);
@@ -219,18 +209,13 @@ template <
219209
auto finalHandler>
220210
void RecursiveDoubling<DataT, Op, ObjT, finalHandler>::reduceIterHandler(
221211
AllreduceDblMsg<DataT>* msg) {
222-
if constexpr (isdebug) {
223-
std::string data(1024, 0x0);
224-
for (auto val : msg->val_) {
225-
data.append(fmt::format("{} ", val));
226-
}
227-
fmt::print(
228-
"[{}] Part2 Step {} mask_= {} nprocs_pof2_ = {}: "
229-
"Received data ({}) "
230-
"from {}\n",
231-
this_node_, msg->step_, mask_, nprocs_pof2_, data,
232-
theContext()->getFromNodeCurrentTask());
233-
}
212+
vt_debug_print(
213+
terse, allreduce,
214+
"[{}] RecursiveDoubling Part2 (step {}): mask_= {} nprocs_pof2_ = {}: "
215+
"from {}\n",
216+
this_node_, msg->step_, mask_, nprocs_pof2_,
217+
theContext()->getFromNodeCurrentTask()
218+
);
234219

235220
messages_.at(msg->step_) = promoteMsg(msg);
236221
steps_recv_[msg->step_] = true;
@@ -255,10 +240,11 @@ template <
255240
auto finalHandler>
256241
void RecursiveDoubling<DataT, Op, ObjT, finalHandler>::sendToExcludedNodes() {
257242
if (is_part_of_adjustment_group_ and is_even_) {
258-
if constexpr (isdebug) {
259-
fmt::print(
260-
"[{}] Part3 : Sending to Node {} \n", this_node_, this_node_ + 1);
261-
}
243+
vt_debug_print(
244+
terse, allreduce, "[{}] RecursiveDoubling Part3: Sending to Node {} \n", this_node_,
245+
this_node_ + 1
246+
);
247+
262248
proxy_[this_node_ + 1]
263249
.template send<&RecursiveDoubling::sendToExcludedNodesHandler>(val_);
264250
}

0 commit comments

Comments
 (0)