From 84e8f729705eaa17db13b68af6cb7b801762e6c8 Mon Sep 17 00:00:00 2001 From: Jacob Domagala Date: Tue, 4 Jun 2024 14:10:53 +0200 Subject: [PATCH] #2240: Use vt_debug_print for RecursiveDoubling allreduce --- .../reduce/allreduce/recursive_doubling.h | 2 - .../allreduce/recursive_doubling.impl.h | 56 +++++++------------ 2 files changed, 21 insertions(+), 37 deletions(-) diff --git a/src/vt/collective/reduce/allreduce/recursive_doubling.h b/src/vt/collective/reduce/allreduce/recursive_doubling.h index 9cf15a5e98..08c2c69870 100644 --- a/src/vt/collective/reduce/allreduce/recursive_doubling.h +++ b/src/vt/collective/reduce/allreduce/recursive_doubling.h @@ -56,8 +56,6 @@ namespace vt::collective::reduce::allreduce { -constexpr bool isdebug = false; - template struct AllreduceDblMsg : SerializeIfNeeded, DataT> { diff --git a/src/vt/collective/reduce/allreduce/recursive_doubling.impl.h b/src/vt/collective/reduce/allreduce/recursive_doubling.impl.h index eaf414069b..ebb7b5a2c9 100644 --- a/src/vt/collective/reduce/allreduce/recursive_doubling.impl.h +++ b/src/vt/collective/reduce/allreduce/recursive_doubling.impl.h @@ -105,10 +105,10 @@ template < auto finalHandler> void RecursiveDoubling::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_); @@ -120,17 +120,6 @@ template < auto finalHandler> void RecursiveDoubling:: adjustForPowerOfTwoHandler(AllreduceDblMsg* 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()(val_, msg->val_); finished_adjustment_part_ = true; @@ -180,10 +169,11 @@ void RecursiveDoubling::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_); @@ -219,18 +209,13 @@ template < auto finalHandler> void RecursiveDoubling::reduceIterHandler( AllreduceDblMsg* 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; @@ -255,10 +240,11 @@ template < auto finalHandler> void RecursiveDoubling::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_); }