Skip to content

Commit

Permalink
#872: add encoding member bits in handler field
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Strzebonski committed Oct 16, 2020
1 parent e6df66e commit 745fb81
Show file tree
Hide file tree
Showing 22 changed files with 184 additions and 240 deletions.
21 changes: 16 additions & 5 deletions src/vt/handler/handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@
namespace vt {

/*static*/ HandlerType HandlerManager::makeHandler(
bool is_auto, bool is_functor, HandlerIdentifierType id, bool is_objgroup,
HandlerControlType control, bool is_trace
bool is_auto, bool is_functor, HandlerIdentifierType id, bool is_member,
bool is_objgroup, HandlerControlType control, bool is_trace
) {
HandlerType new_han = blank_handler;
HandlerManager::setHandlerAuto(new_han, is_auto);
HandlerManager::setHandlerObjGroup(new_han, is_objgroup);
HandlerManager::setHandlerFunctor(new_han, is_functor);
HandlerManager::setHandlerMember(new_han, is_member);
HandlerManager::setHandlerIdentifier(new_han, id);

#if vt_check_enabled(trace_enabled)
Expand All @@ -68,8 +69,9 @@ namespace vt {
vt_debug_print(
handler, node,
"HandlerManager::makeHandler: is_functor={}, is_auto={}, is_objgroup={},"
" id={:x}, control={:x}, han={:x}, is_trace={}\n",
is_functor, is_auto, is_objgroup, id, control, new_han, is_trace
"is_memer={} id={:x}, control={:x}, han={:x}, is_trace={}\n",
is_functor, is_auto, is_objgroup, is_member, id, control, new_han,
is_trace
);

return new_han;
Expand Down Expand Up @@ -123,6 +125,12 @@ namespace vt {
BitPackerType::boolSetField<HandlerBitsType::Functor>(han, is_functor);
}

/*static*/ void HandlerManager::setHandlerMember(
HandlerType& han, bool is_member
) {
BitPackerType::boolSetField<HandlerBitsType::Member>(han, is_member);
}

/*static*/ bool HandlerManager::isHandlerAuto(HandlerType han) {
return BitPackerType::boolGetField<HandlerBitsType::Auto>(han);
}
Expand All @@ -135,6 +143,10 @@ namespace vt {
return BitPackerType::boolGetField<HandlerBitsType::ObjGroup>(han);
}

/*static*/ bool HandlerManager::isHandlerMember(HandlerType han) {
return BitPackerType::boolGetField<HandlerBitsType::Member>(han);
}

#if vt_check_enabled(trace_enabled)
/*static*/ bool HandlerManager::isHandlerTrace(HandlerType han) {
return BitPackerType::boolGetField<HandlerBitsType::Trace>(han);
Expand All @@ -148,4 +160,3 @@ namespace vt {
#endif

} // end namespace vt

19 changes: 12 additions & 7 deletions src/vt/handler/handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,27 @@ static constexpr BitCountType const functor_num_bits = 1;
static constexpr BitCountType const objgroup_num_bits = 1;
static constexpr BitCountType const trace_num_bits = 1;
static constexpr BitCountType const control_num_bits = 20;
static constexpr BitCountType const member_num_bits = 1;
static constexpr BitCountType const handler_id_num_bits =
BitCounterType<HandlerType>::value - (
auto_num_bits
+ functor_num_bits
+ objgroup_num_bits
+ control_num_bits
+ trace_num_bits
+ member_num_bits
);

// eHandlerBits::ObjGroup identifies the handler as targeting an objgroup; the
// control bits are an extensible field used for module-specific sub-handlers
enum eHandlerBits {
ObjGroup = 0,
Auto = eHandlerBits::ObjGroup + objgroup_num_bits,
Functor = eHandlerBits::Auto + auto_num_bits,
Trace = eHandlerBits::Functor + functor_num_bits,
Control = eHandlerBits::Trace + trace_num_bits,
Identifier = eHandlerBits::Control + control_num_bits
Auto = eHandlerBits::ObjGroup + objgroup_num_bits,
Functor = eHandlerBits::Auto + auto_num_bits,
Trace = eHandlerBits::Functor + functor_num_bits,
Control = eHandlerBits::Trace + trace_num_bits,
Member = eHandlerBits::Control + control_num_bits,
Identifier = eHandlerBits::Member + member_num_bits,
};

struct HandlerManager {
Expand All @@ -97,8 +100,8 @@ struct HandlerManager {

static HandlerType makeHandler(
bool is_auto, bool is_functor, HandlerIdentifierType id,
bool is_objgroup = false, HandlerControlType control = 0,
bool is_trace = true
bool is_member = false, bool is_objgroup = false,
HandlerControlType control = 0, bool is_trace = true
);
static void setHandlerIdentifier(HandlerType& han, HandlerIdentifierType id);
static void setHandlerControl(HandlerType& han, HandlerControlType control);
Expand All @@ -108,9 +111,11 @@ struct HandlerManager {
static void setHandlerAuto(HandlerType& han, bool is_auto);
static void setHandlerFunctor(HandlerType& han, bool is_functor);
static void setHandlerObjGroup(HandlerType& han, bool is_objgroup);
static void setHandlerMember(HandlerType& han, bool is_member);
static bool isHandlerAuto(HandlerType han);
static bool isHandlerFunctor(HandlerType han);
static bool isHandlerObjGroup(HandlerType han);
static bool isHandlerMember(HandlerType han);
#if vt_check_enabled(trace_enabled)
static void setHandlerTrace(HandlerType& han, bool is_trace);
static bool isHandlerTrace(HandlerType han);
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 @@ -91,8 +91,8 @@ struct BcastColDirCB : CallbackProxyBcastDirect {
BcastColDirCB(
HandlerType const& in_handler,
CallbackProxyBcastDirect::AutoHandlerType const& in_vrt_handler,
bool const& in_member, VirtualProxyType const& in_proxy
) : CallbackProxyBcastDirect(in_handler, in_vrt_handler, in_member, in_proxy)
VirtualProxyType const& in_proxy
) : CallbackProxyBcastDirect(in_handler, in_vrt_handler, in_proxy)
{ }
};

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

CallbackRawBaseSingle::CallbackRawBaseSingle(
RawBcastColDirTagType, PipeType const& in_pipe,
HandlerType const& in_handler, AutoHandlerType const& in_vrt,
bool const& in_member, VirtualProxyType const& in_proxy
) : pipe_(in_pipe), cb_(BcastColDirCB{in_handler,in_vrt,in_member,in_proxy})
RawBcastColDirTagType, PipeType const& in_pipe, HandlerType const& in_handler,
AutoHandlerType const& in_vrt, VirtualProxyType const& in_proxy
) : pipe_(in_pipe), cb_(BcastColDirCB{in_handler, in_vrt, in_proxy})
{ }

CallbackRawBaseSingle::CallbackRawBaseSingle(
Expand Down
6 changes: 3 additions & 3 deletions src/vt/pipe/callback/cb_union/cb_raw_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ struct CallbackRawBaseSingle {
CallbackRawBaseSingle(
RawBcastColDirTagType, PipeType const& in_pipe,
HandlerType const& in_handler, AutoHandlerType const& in_vrt,
bool const& in_member, VirtualProxyType const& in_proxy
VirtualProxyType const& in_proxy
);
CallbackRawBaseSingle(
RawSendColDirTagType, PipeType const& in_pipe,
Expand Down Expand Up @@ -182,9 +182,9 @@ struct CallbackTyped : CallbackRawBaseSingle {
CallbackTyped(
RawBcastColDirTagType, PipeType const& in_pipe,
HandlerType const& in_handler, AutoHandlerType const& in_vrt,
bool const& in_member, VirtualProxyType const& in_proxy
VirtualProxyType const& in_proxy
) : CallbackRawBaseSingle(
RawBcastColDirTag,in_pipe,in_handler,in_vrt,in_member,in_proxy
RawBcastColDirTag, in_pipe, in_handler, in_vrt, in_proxy
)
{ }
CallbackTyped(
Expand Down
7 changes: 2 additions & 5 deletions src/vt/pipe/callback/proxy_bcast/callback_proxy_bcast.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ struct CallbackProxyBcast : CallbackBase<signal::Signal<MsgT>> {
CallbackProxyBcast(CallbackProxyBcast const&) = default;
CallbackProxyBcast(CallbackProxyBcast&&) = default;

CallbackProxyBcast(
HandlerType const& in_handler, ProxyType const& in_proxy,
bool const& in_member
) : proxy_(in_proxy), handler_(in_handler), member_(in_member)
CallbackProxyBcast(HandlerType const& in_handler, ProxyType const& in_proxy)
: proxy_(in_proxy), handler_(in_handler)
{ }

template <typename SerializerT>
Expand All @@ -83,7 +81,6 @@ struct CallbackProxyBcast : CallbackBase<signal::Signal<MsgT>> {
private:
ProxyType proxy_ = {};
HandlerType handler_ = uninitialized_handler;
bool member_ = false;
};

}}} /* end namespace vt::pipe::callback */
Expand Down
3 changes: 1 addition & 2 deletions src/vt/pipe/callback/proxy_bcast/callback_proxy_bcast.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,11 @@ void CallbackProxyBcast<ColT,MsgT>::serialize(SerializerT& s) {
CallbackBase<SignalBaseType>::serializer(s);
s | proxy_;
s | handler_;
s | member_;
}

template <typename ColT, typename MsgT>
void CallbackProxyBcast<ColT,MsgT>::trigger_(SignalDataType* data) {
theCollection()->broadcastMsgWithHan(proxy_,data,handler_,member_,true);
theCollection()->broadcastMsgWithHan(proxy_, data, handler_, true);
}

}}} /* end namespace vt::pipe::callback */
Expand Down
9 changes: 3 additions & 6 deletions src/vt/pipe/callback/proxy_bcast/callback_proxy_bcast_tl.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ struct CallbackProxyBcastDirect : CallbackBaseTL<CallbackProxyBcastDirect> {
CallbackProxyBcastDirect() = default;
CallbackProxyBcastDirect(
HandlerType const& in_han, AutoHandlerType const& in_vrt,
bool const& in_member, VirtualProxyType const& in_proxy
) : vrt_dispatch_han_(in_vrt), handler_(in_han), proxy_(in_proxy),
member_(in_member)
VirtualProxyType const& in_proxy
) : vrt_dispatch_han_(in_vrt), handler_(in_han), proxy_(in_proxy)
{ }

template <typename SerializerT>
Expand All @@ -89,8 +88,7 @@ struct CallbackProxyBcastDirect : CallbackBaseTL<CallbackProxyBcastDirect> {
return
other.handler_ == handler_ &&
other.vrt_dispatch_han_ == vrt_dispatch_han_ &&
other.proxy_ == proxy_ &&
other.member_ == member_;
other.proxy_ == proxy_;
}

public:
Expand All @@ -105,7 +103,6 @@ struct CallbackProxyBcastDirect : CallbackBaseTL<CallbackProxyBcastDirect> {
AutoHandlerType vrt_dispatch_han_ = uninitialized_handler;
HandlerType handler_ = uninitialized_handler;
VirtualProxyType proxy_ = no_vrt_proxy;
bool member_ = false;
};

}}} /* end namespace vt::pipe::callback */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ template <typename SerializerT>
void CallbackProxyBcastDirect::serialize(SerializerT& s) {
s | handler_;
s | vrt_dispatch_han_;
s | member_;
s | proxy_;
}

Expand All @@ -108,7 +107,7 @@ void CallbackProxyBcastDirect::trigger(MsgT* msg, PipeType const& pipe) {

auto dispatcher = vrt::collection::getDispatcher(vrt_dispatch_han_);
auto const& proxy = proxy_;
dispatcher->broadcast(proxy,msg,handler_,member_);
dispatcher->broadcast(proxy, msg, handler_);
}

}}} /* end namespace vt::pipe::callback */
Expand Down
11 changes: 4 additions & 7 deletions src/vt/pipe/callback/proxy_send/callback_proxy_send.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,15 @@ struct CallbackProxySend : CallbackBase<signal::Signal<MsgT>> {
using MessageType = MsgT;

CallbackProxySend(
HandlerType const& in_handler, IndexedProxyType const& in_proxy,
bool const& in_member
HandlerType const& in_handler, IndexedProxyType const& in_proxy
) : proxy_(in_proxy.getCollectionProxy()),
idx_(in_proxy.getElementProxy().getIndex()),
handler_(in_handler), member_(in_member)
idx_(in_proxy.getElementProxy().getIndex()), handler_(in_handler)
{ }

CallbackProxySend(
HandlerType const& in_handler, ProxyType const& in_proxy,
IndexType const& in_idx, bool const& in_member
) : proxy_(in_proxy), idx_(in_idx), handler_(in_handler), member_(in_member)
IndexType const& in_idx
) : proxy_(in_proxy), idx_(in_idx), handler_(in_handler)
{ }

template <typename SerializerT>
Expand All @@ -91,7 +89,6 @@ struct CallbackProxySend : CallbackBase<signal::Signal<MsgT>> {
ProxyType proxy_ = {};
IndexType idx_ = {};
HandlerType handler_ = uninitialized_handler;
bool member_ = false;
};

}}} /* end namespace vt::pipe::callback */
Expand Down
5 changes: 2 additions & 3 deletions src/vt/pipe/callback/proxy_send/callback_proxy_send.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,11 @@ void CallbackProxySend<ColT,MsgT>::serialize(SerializerT& s) {
CallbackBase<SignalBaseType>::serializer(s);
s | proxy_ | idx_;
s | handler_;
s | member_;
}

template <typename ColT, typename MsgT>
void CallbackProxySend<ColT,MsgT>::trigger_(SignalDataType* data) {
theCollection()->sendMsgWithHan(proxy_.index(idx_),data,handler_,member_);
void CallbackProxySend<ColT, MsgT>::trigger_(SignalDataType* data) {
theCollection()->sendMsgWithHan(proxy_.index(idx_), data, handler_);
}

}}} /* end namespace vt::pipe::callback */
Expand Down
16 changes: 4 additions & 12 deletions src/vt/pipe/pipe_manager_tl.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,9 @@ PipeManagerTL::makeCallbackSingleProxySend(typename ColT::ProxyType proxy) {
newPipeState(pipe_id,persist,dispatch,-1,-1,0);
auto cb = CallbackT(callback::cbunion::RawSendColMsgTag,pipe_id);
auto const& handler = auto_registry::makeAutoHandlerCollection<ColT,MsgT,f>();
bool member = false;
addListenerAny<MsgT>(
cb.getPipe(),
std::make_unique<callback::CallbackProxySend<ColT,MsgT>>(
handler,proxy,member
)
std::make_unique<callback::CallbackProxySend<ColT, MsgT>>(handler, proxy)
);
return cb;
}
Expand All @@ -173,12 +170,9 @@ PipeManagerTL::makeCallbackSingleProxySend(typename ColT::ProxyType proxy) {
auto cb = CallbackT(callback::cbunion::RawSendColMsgTag,pipe_id);
auto const& handler =
auto_registry::makeAutoHandlerCollectionMem<ColT,MsgT,f>();
bool member = true;
addListenerAny<MsgT>(
cb.getPipe(),
std::make_unique<callback::CallbackProxySend<ColT,MsgT>>(
handler,proxy,member
)
std::make_unique<callback::CallbackProxySend<ColT, MsgT>>(handler, proxy)
);
return cb;
}
Expand Down Expand Up @@ -253,9 +247,8 @@ PipeManagerTL::makeCallbackSingleProxyBcastDirect(ColProxyType<ColT> proxy) {
auto const& pipe_id = makePipeID(persist,send_back);
auto const& handler = auto_registry::makeAutoHandlerCollection<ColT,MsgT,f>();
auto const& vrt_handler = vrt::collection::makeVrtDispatch<MsgT,ColT>();
bool const member = false;
auto cb = CallbackT(
callback::cbunion::RawBcastColDirTag,pipe_id,handler,vrt_handler,member,
callback::cbunion::RawBcastColDirTag, pipe_id, handler, vrt_handler,
proxy.getProxy()
);
return cb;
Expand All @@ -273,9 +266,8 @@ PipeManagerTL::makeCallbackSingleProxyBcastDirect(ColProxyType<ColT> proxy) {
auto const& handler =
auto_registry::makeAutoHandlerCollectionMem<ColT,MsgT,f>();
auto const& vrt_handler = vrt::collection::makeVrtDispatch<MsgT,ColT>();
bool const member = true;
auto cb = CallbackT(
callback::cbunion::RawBcastColDirTag,pipe_id,handler,vrt_handler,member,
callback::cbunion::RawBcastColDirTag, pipe_id, handler, vrt_handler,
proxy.getProxy()
);
return cb;
Expand Down
10 changes: 8 additions & 2 deletions src/vt/registry/auto/collection/auto_registry_collection.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ inline HandlerType makeAutoHandlerCollection() {
using ContainerType = AutoActiveCollectionContainerType;
using RegInfoType = AutoRegInfoType<AutoActiveCollectionType>;
using FuncType = ActiveColFnPtrType;
return RunnableGen<FunctorT, ContainerType, RegInfoType, FuncType>::idx;

auto han = RunnableGen<FunctorT, ContainerType, RegInfoType, FuncType>::idx;
HandlerManager::setHandlerMember(han, false);
return han;
}

inline AutoActiveCollectionMemType getAutoHandlerCollectionMem(
Expand All @@ -81,7 +84,10 @@ inline HandlerType makeAutoHandlerCollectionMem() {
using ContainerType = AutoActiveCollectionMemContainerType;
using RegInfoType = AutoRegInfoType<AutoActiveCollectionMemType>;
using FuncType = ActiveColMemberFnPtrType;
return RunnableGen<FunctorT, ContainerType, RegInfoType, FuncType>::idx;

auto han = RunnableGen<FunctorT, ContainerType, RegInfoType, FuncType>::idx;
HandlerManager::setHandlerMember(han, true);
return han;
}

template <typename ColT, typename MsgT, ActiveColTypedFnType<MsgT, ColT>* f>
Expand Down
1 change: 0 additions & 1 deletion src/vt/runnable/collection.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ template <typename MsgT, typename ElementT>
struct RunnableCollection {
static void run(
HandlerType handler, MsgT* msg, ElementT* elm, NodeType from_node,
bool member,
uint64_t idx1 = 0, uint64_t idx2 = 0, uint64_t idx3 = 0, uint64_t idx4 = 0,
trace::TraceEventIDType in_trace_event = trace::no_trace_event
);
Expand Down
8 changes: 5 additions & 3 deletions src/vt/runnable/collection.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@
namespace vt { namespace runnable {

template <typename MsgT, typename ElementT>
/*static*/ void RunnableCollection<MsgT,ElementT>::run(
HandlerType handler, MsgT* msg, ElementT* elm, NodeType from,
bool member, uint64_t idx1, uint64_t idx2, uint64_t idx3, uint64_t idx4,
/*static*/ void RunnableCollection<MsgT, ElementT>::run(
HandlerType handler, MsgT* msg, ElementT* elm, NodeType from, uint64_t idx1,
uint64_t idx2, uint64_t idx3, uint64_t idx4,
trace::TraceEventIDType in_trace_event
) {
auto const member = HandlerManager::isHandlerMember(handler);

#if vt_check_enabled(trace_enabled)
trace::TraceProcessingTag processing_tag;
{
Expand Down
Loading

0 comments on commit 745fb81

Please sign in to comment.