Skip to content

Commit

Permalink
#883: callback: Remove 'include sender' part from callback broadcast …
Browse files Browse the repository at this point in the history
…since now sender will always execute the handler
  • Loading branch information
JacobDomagala committed Jan 21, 2021
1 parent 13a449e commit 67c5b6f
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 114 deletions.
3 changes: 0 additions & 3 deletions examples/collection/transpose.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,6 @@ struct Block : vt::Collection<Block, vt::Index1D> {
auto proxy = this->getCollectionProxy();
auto proxy_msg = vt::makeMessage<ProxyMsg>(proxy.getProxy());
vt::theMsg()->broadcastMsg<SetupGroup,ProxyMsg>(proxy_msg);
// Invoke it locally: broadcast sends to all other nodes
// auto proxy_msg_local = vt::makeMessage<ProxyMsg>(proxy.getProxy());
// SetupGroup()(proxy_msg_local.get());
}
}

Expand Down
19 changes: 0 additions & 19 deletions src/vt/pipe/callback/callback_handler_bcast.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,29 +61,10 @@ struct CallbackBcast : CallbackBase<signal::Signal<MsgT>> {
using SignalDataType = typename SignalType::DataType;
using MessageType = MsgT;

explicit CallbackBcast(bool const in_include_root = false)
: include_root_(in_include_root)
{ }

template <typename SerializerT>
void serialize(SerializerT& s) {
CallbackBase<SignalBaseType>::serializer(s);
s | include_root_;
}

private:
void trigger_(SignalDataType* data) override {
fmt::print("{}: trigger_ include_root_={}\n", include_root_)
theMsg()->broadcastMsg<MsgT,f>(data);
assert(include_root_);
if (include_root_) {
auto nmsg = makeMessage<SignalDataType*>(*data);
//f(nmsg.get());
}
}

private:
bool include_root_ = false;
};

}}} /* end namespace vt::pipe::callback */
Expand Down
4 changes: 2 additions & 2 deletions src/vt/pipe/callback/cb_union/cb_raw.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ struct SendMsgCB : CallbackSendTypeless {
struct BcastMsgCB : CallbackBcastTypeless {
BcastMsgCB() = default;
BcastMsgCB(
HandlerType const in_handler, bool const& in_include
) : CallbackBcastTypeless(in_handler, in_include)
HandlerType const in_handler
) : CallbackBcastTypeless(in_handler)
{ }
};

Expand Down
5 changes: 2 additions & 3 deletions src/vt/pipe/callback/cb_union/cb_raw_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ CallbackRawBaseSingle::CallbackRawBaseSingle(
{ }

CallbackRawBaseSingle::CallbackRawBaseSingle(
RawBcastMsgTagType, PipeType const& in_pipe, HandlerType const in_handler,
bool const& in_inc
) : pipe_(in_pipe), cb_(BcastMsgCB{in_handler,in_inc})
RawBcastMsgTagType, PipeType const& in_pipe, HandlerType const in_handler
) : pipe_(in_pipe), cb_(BcastMsgCB{in_handler})
{ }

CallbackRawBaseSingle::CallbackRawBaseSingle(
Expand Down
8 changes: 3 additions & 5 deletions src/vt/pipe/callback/cb_union/cb_raw_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ struct CallbackRawBaseSingle {
NodeType const& in_node
);
CallbackRawBaseSingle(
RawBcastMsgTagType, PipeType const& in_pipe, HandlerType const in_handler,
bool const& in_inc
RawBcastMsgTagType, PipeType const& in_pipe, HandlerType const in_handler
);
CallbackRawBaseSingle(RawAnonTagType, PipeType const& in_pipe);
CallbackRawBaseSingle(RawSendColMsgTagType, PipeType const& in_pipe);
Expand Down Expand Up @@ -172,9 +171,8 @@ struct CallbackTyped : CallbackRawBaseSingle {
) : CallbackRawBaseSingle(RawSendMsgTag,in_pipe,in_handler,in_node)
{ }
CallbackTyped(
RawBcastMsgTagType, PipeType const& in_pipe, HandlerType const in_handler,
bool const& in_inc
) : CallbackRawBaseSingle(RawBcastMsgTag,in_pipe,in_handler,in_inc)
RawBcastMsgTagType, PipeType const& in_pipe, HandlerType const in_handler
) : CallbackRawBaseSingle(RawBcastMsgTag,in_pipe,in_handler)
{ }
CallbackTyped(RawAnonTagType, PipeType const& in_pipe)
: CallbackRawBaseSingle(RawAnonTag,in_pipe)
Expand Down
16 changes: 5 additions & 11 deletions src/vt/pipe/callback/handler_bcast/callback_bcast_tl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,17 @@
namespace vt { namespace pipe { namespace callback {

CallbackBcastTypeless::CallbackBcastTypeless(
HandlerType const in_handler, bool const& in_include
) : handler_(in_handler), include_sender_(in_include)
HandlerType const in_handler
) : handler_(in_handler)
{ }

void CallbackBcastTypeless::triggerVoid(PipeType const& pipe) {
auto const& this_node = theContext()->getNode();
fmt::print(
"CallbackBcast: (void) trigger_: pipe={:x}, this_node={}, "
"include_sender_={}\n",
pipe, this_node, include_sender_
);
vt_debug_print(
pipe, node, "CallbackBcast: (void) trigger_: pipe={:x}, this_node={}\n",
pipe, this_node);
auto msg = makeMessage<CallbackMsg>(pipe);
theMsg()->broadcastMsg<CallbackMsg>(handler_, msg);
assert(include_sender_);
if (include_sender_) {
//runnable::RunnableVoid::run(handler_,this_node);
}
}

}}} /* end namespace vt::pipe::callback */
8 changes: 2 additions & 6 deletions src/vt/pipe/callback/handler_bcast/callback_bcast_tl.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,16 @@ struct CallbackBcastTypeless : CallbackBaseTL<CallbackBcastTypeless> {
CallbackBcastTypeless& operator=(CallbackBcastTypeless const&) = default;

CallbackBcastTypeless(
HandlerType const in_handler, bool const& in_include
HandlerType const in_handler
);

HandlerType getHandler() const { return handler_; }
bool getIncSender() const { return include_sender_; }

template <typename SerializerT>
void serialize(SerializerT& s);

bool operator==(CallbackBcastTypeless const& other) const {
return
other.include_sender_ == include_sender_ &&
other.handler_ == handler_;
return other.handler_ == handler_;
}

public:
Expand All @@ -82,7 +79,6 @@ struct CallbackBcastTypeless : CallbackBaseTL<CallbackBcastTypeless> {

private:
HandlerType handler_ = uninitialized_handler;
bool include_sender_ = false;
};

}}} /* end namespace vt::pipe::callback */
Expand Down
5 changes: 2 additions & 3 deletions src/vt/pipe/callback/handler_bcast/callback_bcast_tl.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ namespace vt { namespace pipe { namespace callback {

template <typename SerializerT>
void CallbackBcastTypeless::serialize(SerializerT& s) {
s | include_sender_;
s | handler_;
}

Expand All @@ -68,8 +67,8 @@ void CallbackBcastTypeless::trigger(MsgT* msg, PipeType const& pipe) {

vt_debug_print(
pipe, node,
"CallbackBcast: trigger_: pipe={:x}, this_node={}, include_sender_={}\n",
pipe, this_node, include_sender_
"CallbackBcast: trigger_: pipe={:x}, this_node={}\n",
pipe, this_node
);

auto pmsg = promoteMsg(msg);
Expand Down
6 changes: 3 additions & 3 deletions src/vt/pipe/pipe_manager.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,17 @@ Callback<MsgT> PipeManager::makeSend(objgroup::proxy::ProxyElm<ObjT> proxy) {

template <typename MsgT, ActiveTypedFnType<MsgT>* f>
Callback<MsgT> PipeManager::makeBcast() {
return makeCallbackSingleBcast<MsgT,f>(true);
return makeCallbackSingleBcast<MsgT,f>();
}

template <typename FunctorT, typename MsgT>
Callback<MsgT> PipeManager::makeBcast() {
return makeCallbackFunctorBcast<FunctorT,MsgT>(true);
return makeCallbackFunctorBcast<FunctorT,MsgT>();
}

template <typename FunctorT, typename not_used_>
Callback<PipeManager::Void> PipeManager::makeBcast() {
return makeCallbackFunctorBcastVoid<FunctorT>(true);
return makeCallbackFunctorBcastVoid<FunctorT>();
}

template <typename ColT, typename MsgT, PipeManager::ColHanType<ColT,MsgT>* f>
Expand Down
10 changes: 5 additions & 5 deletions src/vt/pipe/pipe_manager_tl.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ struct PipeManagerTL : virtual PipeManagerBase {
CbkT makeCallbackSingleSend(NodeType const& node);

template <typename T, FnType<T>* f, typename CbkT = DefType<T>>
CbkT makeCallbackSingleBcast(bool const& inc);
CbkT makeCallbackSingleBcast();

// Single active message functor-handler
template <
Expand All @@ -113,14 +113,14 @@ struct PipeManagerTL : virtual PipeManagerBase {
typename T = typename util::FunctorExtractor<FunctorT>::MessageType,
typename CbkT = DefType<T>
>
CbkT makeCallbackFunctorBcast(bool const& inc);
CbkT makeCallbackFunctorBcast();

// Single active message functor-handler void param
template <typename FunctorT, typename CbkT = DefType<V>>
CbkT makeCallbackFunctorSendVoid(NodeType const& node);

template <typename FunctorT, typename CbkT = DefType<V>>
CbkT makeCallbackFunctorBcastVoid(bool const& inc);
CbkT makeCallbackFunctorBcastVoid();

// Single active message anon func-handler
template <typename CbkT = DefType<V>>
Expand Down Expand Up @@ -188,7 +188,7 @@ struct PipeManagerTL : virtual PipeManagerBase {
void addListener(CbkT const& cb, NodeType const& node);

template <typename T, ActiveTypedFnType<T>* f, typename CbkT = DefType<T>>
void addListenerBcast(CbkT const& cb, bool const& inc);
void addListenerBcast(CbkT const& cb);

template <
typename FunctorT,
Expand All @@ -205,7 +205,7 @@ struct PipeManagerTL : virtual PipeManagerBase {
typename T = typename util::FunctorExtractor<FunctorT>::MessageType,
typename CbkT = DefType<T>
>
void addListenerFunctorBcast(CbkT const& cb, bool const& inc);
void addListenerFunctorBcast(CbkT const& cb);
};

}} /* end namespace vt::pipe */
Expand Down
20 changes: 10 additions & 10 deletions src/vt/pipe/pipe_manager_tl.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ void PipeManagerTL::addListener(CallbackT const& cb, NodeType const& node) {
}

template <typename MsgT, ActiveTypedFnType<MsgT>* f, typename CallbackT>
void PipeManagerTL::addListenerBcast(CallbackT const& cb, bool const& inc) {
void PipeManagerTL::addListenerBcast(CallbackT const& cb) {
auto const& han = auto_registry::makeAutoHandler<MsgT,f>();
addListenerAny<MsgT>(
cb.getPipe(), std::make_unique<callback::CallbackBcast<MsgT>>(han,inc)
cb.getPipe(), std::make_unique<callback::CallbackBcast<MsgT>>(han)
);
}

Expand Down Expand Up @@ -127,12 +127,12 @@ void PipeManagerTL::addListenerFunctorVoid(

template <typename FunctorT, typename T, typename CallbackT>
void PipeManagerTL::addListenerFunctorBcast(
CallbackT const& cb, bool const& inc
CallbackT const& cb
) {
using MsgT = typename util::FunctorExtractor<FunctorT>::MessageType;
auto const& han = auto_registry::makeAutoHandlerFunctor<FunctorT,true,MsgT*>();
addListenerAny<MsgT>(
cb.getPipe(), std::make_unique<callback::CallbackBcast<MsgT>>(han,inc)
cb.getPipe(), std::make_unique<callback::CallbackBcast<MsgT>>(han)
);
}

Expand Down Expand Up @@ -297,11 +297,11 @@ CallbackT

template <typename MsgT, ActiveTypedFnType<MsgT>* f, typename CallbackT>
CallbackT
PipeManagerTL::makeCallbackSingleBcast(bool const& inc) {
PipeManagerTL::makeCallbackSingleBcast() {
auto const& new_pipe_id = makePipeID(true,false);
auto const& handler = auto_registry::makeAutoHandler<MsgT,f>();
auto cb = CallbackT(
callback::cbunion::RawBcastMsgTag,new_pipe_id,handler,inc
callback::cbunion::RawBcastMsgTag,new_pipe_id,handler
);
return cb;
}
Expand Down Expand Up @@ -392,13 +392,13 @@ PipeManagerTL::makeCallbackFunctorSend(NodeType const& send_to_node) {

template <typename FunctorT, typename T, typename CallbackT>
CallbackT
PipeManagerTL::makeCallbackFunctorBcast(bool const& inc) {
PipeManagerTL::makeCallbackFunctorBcast() {
using MsgT = typename util::FunctorExtractor<FunctorT>::MessageType;
auto const& new_pipe_id = makePipeID(true,false);
auto const& handler =
auto_registry::makeAutoHandlerFunctor<FunctorT,true,MsgT*>();
auto cb = CallbackT(
callback::cbunion::RawBcastMsgTag,new_pipe_id,handler,inc
callback::cbunion::RawBcastMsgTag,new_pipe_id,handler
);
return cb;
}
Expand All @@ -416,11 +416,11 @@ PipeManagerTL::makeCallbackFunctorSendVoid(NodeType const& send_to_node) {

template <typename FunctorT, typename CallbackT>
CallbackT
PipeManagerTL::makeCallbackFunctorBcastVoid(bool const& inc) {
PipeManagerTL::makeCallbackFunctorBcastVoid() {
auto const& new_pipe_id = makePipeID(true,false);
auto const& handler = auto_registry::makeAutoHandlerFunctor<FunctorT,true>();
auto cb = CallbackT(
callback::cbunion::RawBcastMsgTag,new_pipe_id,handler,inc
callback::cbunion::RawBcastMsgTag,new_pipe_id,handler
);
return cb;
}
Expand Down
Loading

0 comments on commit 67c5b6f

Please sign in to comment.