Skip to content

Commit

Permalink
#1423: introduce PipeRefType and use inside pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
stmcgovern committed Apr 13, 2022
1 parent e0a697a commit c85f1bb
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 25 deletions.
2 changes: 2 additions & 0 deletions src/vt/configs/types/types_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ using BarrierType = uint64_t;
using CollectiveAlgType = uint64_t;
/// Used to hold the reference count for messages
using RefType = uint16_t;
/// Used to hold the reference count for messages in pipes
using PipeRefType = int16_t;
/// Used to store some number of bytes
using ByteType = uint64_t;
/// Used to store the number of bits in a field
Expand Down
2 changes: 1 addition & 1 deletion src/vt/pipe/callback/anon/callback_anon_listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct AnonListener : CallbackBase<SignalT> {
AnonListener() = default;
AnonListener(AnonListener const&) = default;
AnonListener(AnonListener&&) = default;
AnonListener(CallbackFnType const& in_fn, bool is_persist, RefType refs = -1);
AnonListener(CallbackFnType const& in_fn, bool is_persist, PipeRefType refs = -1);
explicit AnonListener(CallbackFnType const& in_fn);

private:
Expand Down
2 changes: 1 addition & 1 deletion src/vt/pipe/callback/anon/callback_anon_listener.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace vt { namespace pipe { namespace callback {

template <typename SignalT>
AnonListener<SignalT>::AnonListener(
CallbackFnType const& in_fn, bool is_persist, RefType refs
CallbackFnType const& in_fn, bool is_persist, PipeRefType refs
) : CallbackBase<SignalT>(CallbackExplicitTag, is_persist, refs),
fn_(in_fn)
{ }
Expand Down
8 changes: 4 additions & 4 deletions src/vt/pipe/callback/callback_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ struct CallbackBase {
: reference_counted_(true),
refs_(1)
{ }
CallbackBase(CallbackMultiUseTagType, RefType const& in_num_refs)
CallbackBase(CallbackMultiUseTagType, PipeRefType const& in_num_refs)
: reference_counted_(true),
refs_(in_num_refs)
{ }
CallbackBase(
CallbackExplicitTagType, bool const& persist, RefType const& in_refs = -1
CallbackExplicitTagType, bool const& persist, PipeRefType const& in_refs = -1
) : reference_counted_(!persist), refs_(in_refs)
{ }

Expand Down Expand Up @@ -134,8 +134,8 @@ struct CallbackBase {

private:
bool reference_counted_ = true;
RefType triggered_ = 0;
RefType refs_ = 1;
PipeRefType triggered_ = 0;
PipeRefType refs_ = 1;
};

}}} /* end namespace vt::pipe::callback */
Expand Down
8 changes: 4 additions & 4 deletions src/vt/pipe/pipe_manager_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ namespace vt { namespace pipe {
}

void PipeManagerBase::newPipeState(
PipeType const& pipe, bool persist, bool typeless, RefType num_signals,
RefType num_listeners, RefType num_reg_listeners, DispatchFuncType fn
PipeType const& pipe, bool persist, bool typeless, PipeRefType num_signals,
PipeRefType num_listeners, PipeRefType num_reg_listeners, DispatchFuncType fn
) {
/*
* Create pipe state of `pipe' to track the state locally on this node
Expand Down Expand Up @@ -103,8 +103,8 @@ void PipeManagerBase::newPipeState(
}

PipeType PipeManagerBase::makeCallbackFuncVoid(
bool const& persist, FuncType fn, bool const& dispatch, RefType num_signals,
RefType num_listeners
bool const& persist, FuncType fn, bool const& dispatch, PipeRefType num_signals,
PipeRefType num_listeners
) {
using SignalType = signal::SignalVoid;

Expand Down
10 changes: 5 additions & 5 deletions src/vt/pipe/pipe_manager_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ struct PipeManagerBase {

PipeType makeCallbackFuncVoid(
bool const& persist, FuncType fn, bool const& dispatch = false,
RefType num_signals = -1, RefType num_listeners = 1
PipeRefType num_signals = -1, PipeRefType num_listeners = 1
);

template <typename MsgT>
PipeType makeCallbackFunc(
bool const& persist, FuncMsgType<MsgT> fn, bool const& dispatch = false,
RefType num_signals = -1, RefType num_listeners = 1
PipeRefType num_signals = -1, PipeRefType num_listeners = 1
);

template <typename MsgT>
Expand All @@ -113,7 +113,7 @@ struct PipeManagerBase {
template <typename MsgT, typename ListenerT>
PipeType makeCallbackAny(
bool const& persist, ListenerT&& fn, bool const& dispatch = false,
RefType num_signals = -1, RefType num_listeners = 1
PipeRefType num_signals = -1, PipeRefType num_listeners = 1
);

template <typename MsgT, typename ListenerT>
Expand All @@ -137,8 +137,8 @@ struct PipeManagerBase {
void triggerPipe(PipeType const& pipe);
void generalSignalTrigger(PipeType const& pipe);
void newPipeState(
PipeType const& pipe, bool persist, bool typeless, RefType num_sig,
RefType num_listeners, RefType num_reg_listeners,
PipeType const& pipe, bool persist, bool typeless, PipeRefType num_sig,
PipeRefType num_listeners, PipeRefType num_reg_listeners,
DispatchFuncType fn = nullptr
);

Expand Down
4 changes: 2 additions & 2 deletions src/vt/pipe/pipe_manager_base.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void PipeManagerBase::registerCallback(
template <typename MsgT, typename ListenerT>
PipeType PipeManagerBase::makeCallbackAny(
bool const& persist, ListenerT&& listener, bool const& dispatch,
RefType num_signals, RefType num_listeners
PipeRefType num_signals, PipeRefType num_listeners
) {
using SignalType = signal::Signal<MsgT>;

Expand Down Expand Up @@ -170,7 +170,7 @@ PipeType PipeManagerBase::makeCallbackAny(
template <typename MsgT>
PipeType PipeManagerBase::makeCallbackFunc(
bool const& persist, FuncMsgType<MsgT> fn, bool const& dispatch,
RefType num_signals, RefType num_listeners
PipeRefType num_signals, PipeRefType num_listeners
) {
using SignalType = signal::Signal<MsgT>;
vtAssert(num_listeners > 0, "Number of listeners must be positive");
Expand Down
4 changes: 2 additions & 2 deletions src/vt/pipe/state/pipe_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
namespace vt { namespace pipe {

PipeState::PipeState(
PipeType const& in_pipe, RefType const& in_signals, RefType const& in_lis,
PipeType const& in_pipe, PipeRefType const& in_signals, PipeRefType const& in_lis,
bool const& in_typeless
) : automatic_(true), typeless_(in_typeless), num_signals_expected_(in_signals),
num_listeners_expected_(in_lis), pipe_(in_pipe)
Expand Down Expand Up @@ -82,7 +82,7 @@ PipeType PipeState::getPipe() const {
return pipe_;
}

RefType PipeState::refsPerListener() const {
PipeRefType PipeState::refsPerListener() const {
return num_signals_expected_;
}

Expand Down
12 changes: 6 additions & 6 deletions src/vt/pipe/state/pipe_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct PipeState {
using DispatchFuncType = std::function<void(void*)>;

PipeState(
PipeType const& in_pipe, RefType const& in_signals, RefType const& in_lis,
PipeType const& in_pipe, PipeRefType const& in_signals, PipeRefType const& in_lis,
bool const& in_typeless = false
);

Expand All @@ -68,7 +68,7 @@ struct PipeState {
bool isPersist() const;
PipeType getPipe() const;
bool finished() const;
RefType refsPerListener() const;
PipeRefType refsPerListener() const;

bool hasDispatch() const;
void setDispatch(DispatchFuncType in_dispatch);
Expand All @@ -77,10 +77,10 @@ struct PipeState {
private:
bool automatic_ = false;
bool typeless_ = false;
RefType num_signals_expected_ = -1;
RefType num_signals_received_ = 0;
RefType num_listeners_expected_ = -1;
RefType num_listeners_received_ = 0;
PipeRefType num_signals_expected_ = -1;
PipeRefType num_signals_received_ = 0;
PipeRefType num_listeners_expected_ = -1;
PipeRefType num_listeners_received_ = 0;
PipeType pipe_ = no_pipe;
DispatchFuncType dispatch_ = nullptr;
};
Expand Down

0 comments on commit c85f1bb

Please sign in to comment.