Skip to content

Commit

Permalink
1974: add constructor to PhaseOffset since it isn't aggregate initial…
Browse files Browse the repository at this point in the history
…izable anymore; add explicit `this` to lambda captures, replace `std::is_pod` with `std::is_standard_layout && std::is_trivial`, and remove `std::iterator`
  • Loading branch information
nmm0 committed Sep 22, 2022
1 parent 13c86c5 commit a4212f8
Show file tree
Hide file tree
Showing 16 changed files with 47 additions and 45 deletions.
2 changes: 1 addition & 1 deletion src/vt/collective/reduce/reduce.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Reduce::PendingSendType Reduce::reduce(
ReduceNumType num_contrib
) {
auto msg_ptr = promoteMsg(msg);
return PendingSendType{theMsg()->getEpochContextMsg(msg_ptr), [=](){
return PendingSendType{theMsg()->getEpochContextMsg(msg_ptr), [=, this](){
reduceImmediate<MsgT, f>(root, msg_ptr.get(), id, num_contrib);
} };
}
Expand Down
2 changes: 1 addition & 1 deletion src/vt/messaging/active.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ void ActiveMessenger::finishPendingActiveMsgAsyncRecv(InProgressIRecv* irecv) {
} else {
/*bool const put_delivered = */recvDataMsg(
1, put_tag, sender,
[=](PtrLenPairType ptr, ActionType deleter){
[=, this](PtrLenPairType ptr, ActionType deleter){
envelopeSetPutPtr(base->env, std::get<0>(ptr), std::get<1>(ptr));
processActiveMsg(base, sender, true, deleter);
}
Expand Down
2 changes: 1 addition & 1 deletion src/vt/messaging/collection_chain_set.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ CollectionChainSet<Index>::CollectionChainSet(
auto const this_node = theContext()->getNode();
auto const proxy_bits = proxy.getProxy();

ListenerType l = [=](ElementEventEnum event, IndexT idx, NodeType home) {
ListenerType l = [=, this](ElementEventEnum event, IndexT idx, NodeType home) {
switch (event) {
case ElementEventEnum::ElementCreated:
case ElementEventEnum::ElementMigratedIn:
Expand Down
3 changes: 1 addition & 2 deletions src/vt/messaging/envelope/envelope_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ namespace vt {

using Envelope = messaging::ActiveEnvelope;

static_assert(std::is_pod<Envelope>(), "Envelope must be POD");
static_assert(std::is_trivially_destructible<Envelope>(), "Envelope must be trivially destructible");
static_assert(std::is_standard_layout<Envelope>::value && std::is_trivial<Envelope>::value, "Envelope must be standard layout and trivial");

} /* end namespace vt */

Expand Down
12 changes: 6 additions & 6 deletions src/vt/messaging/envelope/envelope_extended.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,19 @@ using EpochEnvelope = messaging::EpochActiveEnvelope;
using TagEnvelope = messaging::TagActiveEnvelope;
using EpochTagEnvelope = messaging::EpochTagActiveEnvelope;

static_assert(std::is_pod<EpochEnvelope>(), "EpochEnvelope must be POD");
static_assert(std::is_pod<TagEnvelope>(), "TagEnvelope must be POD");
static_assert(std::is_pod<EpochTagEnvelope>(), "EpochTagEnvelope must be POD");
static_assert(std::is_standard_layout<EpochEnvelope>::value, "EpochEnvelope must be standard layout");
static_assert(std::is_standard_layout<TagEnvelope>::value, "TagEnvelope must be standard layout");
static_assert(std::is_standard_layout<EpochTagEnvelope>::value, "EpochTagEnvelope must be standard layout");
static_assert(
std::is_trivially_destructible<EpochEnvelope>(),
std::is_trivial<EpochEnvelope>::value,
"EpochEnvelope must be trivial"
);
static_assert(
std::is_trivially_destructible<TagEnvelope>(),
std::is_trivial<TagEnvelope>::value,
"TagEnvelope must be trivial"
);
static_assert(
std::is_trivially_destructible<EpochTagEnvelope>(),
std::is_trivial<EpochTagEnvelope>::value,
"EpochTagEnvelope must be trivial"
);

Expand Down
2 changes: 1 addition & 1 deletion src/vt/messaging/envelope/payload_envelope.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ inline void envelopeInitEmpty(PutShortEnvelope& env) {
env.put_data_tag_ = no_tag;
}

static_assert(std::is_pod<PutShortEnvelope>(), "PutShortEnvelope must be POD");
static_assert(std::is_standard_layout<PutShortEnvelope>::value, "PutShortEnvelope must be POD");

/**
* \brief Get the put pointer
Expand Down
4 changes: 2 additions & 2 deletions src/vt/rdma/rdma.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ void RDMAManager::createDirectChannelInternal(
);

auto cb = theCB()->makeFunc<GetInfoChannel>(
pipe::LifetimeEnum::Once, [=](GetInfoChannel* msg){
pipe::LifetimeEnum::Once, [=, this](GetInfoChannel* msg){
auto const& my_num_bytes = msg->num_bytes;
createDirectChannelFinish(
type, han, non_target, action, unique_channel_tag, is_target, my_num_bytes,
Expand Down Expand Up @@ -1321,7 +1321,7 @@ void RDMAManager::removeDirectChannel(
auto const target = getTarget(han, override_target);

if (this_node != target) {
auto cb = theCB()->makeFunc(pipe::LifetimeEnum::Once, [=]{
auto cb = theCB()->makeFunc(pipe::LifetimeEnum::Once, [=, this]{
auto iter = channels_.find(
makeChannelLookup(han,RDMA_TypeType::Put,target,this_node)
);
Expand Down
6 changes: 3 additions & 3 deletions src/vt/rdmahandle/holder.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ RequestHolder Holder<T,E>::rget(
auto mpi_type_str = TypeMPI<T>::getTypeStr();
RequestHolder r;
if (mpi2_) {
r.add([=]{
r.add([=, this]{
LockMPI _scope_lock(l, node, data_window_);
vt_debug_print(
verbose, rdma,
Expand Down Expand Up @@ -188,7 +188,7 @@ RequestHolder Holder<T,E>::rput(
auto mpi_type_str = TypeMPI<T>::getTypeStr();
RequestHolder r;
if (mpi2_) {
r.add([=]{
r.add([=, this]{
LockMPI _scope_lock(l, node, data_window_);
vt_debug_print(
verbose, rdma,
Expand Down Expand Up @@ -245,7 +245,7 @@ RequestHolder Holder<T,E>::raccum(
auto mpi_type_str = TypeMPI<T>::getTypeStr();
RequestHolder r;
if (mpi2_) {
r.add([=]{
r.add([=, this]{
LockMPI _scope_lock(l, node, data_window_);
vt_debug_print(
verbose, rdma,
Expand Down
20 changes: 10 additions & 10 deletions src/vt/runnable/runnable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void RunnableNew::setupHandler(HandlerType handler, bool is_void, TagType tag) {

if (not is_void) {
if (is_obj) {
task_ = [=] { objgroup::dispatchObjGroup(msg_, handler); };
task_ = [=, this] { objgroup::dispatchObjGroup(msg_, handler); };
return;
} else {
bool const is_auto = HandlerManagerType::isHandlerAuto(handler);
Expand All @@ -69,9 +69,9 @@ void RunnableNew::setupHandler(HandlerType handler, bool is_void, TagType tag) {
auto const& func = auto_registry::getAutoHandlerFunctor(handler);
auto const num_args = auto_registry::getAutoHandlerFunctorArgs(handler);
if (num_args == 0) {
task_ = [=, &func] { func->dispatch(nullptr, nullptr); };
task_ = [&func] { func->dispatch(nullptr, nullptr); };
} else {
task_ = [=, &func] { func->dispatch(msg_.get(), nullptr); };
task_ = [this, &func] { func->dispatch(msg_.get(), nullptr); };
}

return;
Expand All @@ -80,16 +80,16 @@ void RunnableNew::setupHandler(HandlerType handler, bool is_void, TagType tag) {
HandlerManagerType::isHandlerBaseMsgDerived(handler);
if (is_base_msg_derived) {
auto const& func = auto_registry::getAutoHandler(handler);
task_ = [=, &func] { func->dispatch(msg_.get(), nullptr); };
task_ = [this, &func] { func->dispatch(msg_.get(), nullptr); };
return;
}

auto const& func = auto_registry::getScatterAutoHandler(handler);
task_ = [=, &func] { func->dispatch(msg_.get(), nullptr); };
task_ = [this, &func] { func->dispatch(msg_.get(), nullptr); };
return;
} else {
auto typed_func = theRegistry()->getHandler(handler, tag);
task_ = [=] { typed_func(msg_.get()); };
task_ = [typed_func, this] { typed_func(msg_.get()); };
return;
}
}
Expand All @@ -106,12 +106,12 @@ void RunnableNew::setupHandler(HandlerType handler, bool is_void, TagType tag) {
HandlerManagerType::isHandlerBaseMsgDerived(handler);
if (is_base_msg_derived) {
auto const& func = auto_registry::getAutoHandler(handler);
task_ = [=, &func] { func->dispatch(msg_.get(), nullptr); };
task_ = [this, &func] { func->dispatch(msg_.get(), nullptr); };
return;
}

auto const& func = auto_registry::getScatterAutoHandler(handler);
task_ = [=, &func] { func->dispatch(msg_.get(), nullptr); };
task_ = [this, &func] { func->dispatch(msg_.get(), nullptr); };
return;
} else {
vtAbort("Must be auto/functor for a void handler");
Expand All @@ -126,14 +126,14 @@ void RunnableNew::setupHandlerElement(
auto const& func = member ?
auto_registry::getAutoHandlerCollectionMem(handler) :
auto_registry::getAutoHandlerCollection(handler);
task_ = [=, &func] { func->dispatch(msg_.get(), elm); };
task_ = [this, elm, &func] { func->dispatch(msg_.get(), elm); };
}

void RunnableNew::setupHandlerElement(
vrt::VirtualContext* elm, HandlerType handler
) {
auto const& func = auto_registry::getAutoHandlerVC(handler);
task_ = [=, &func] { func->dispatch(msg_.get(), elm); };
task_ = [this, elm, &func] { func->dispatch(msg_.get(), elm); };
}

void RunnableNew::run() {
Expand Down
3 changes: 1 addition & 2 deletions src/vt/termination/interval/integral_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,7 @@ struct IntegralSetBase {
// using reference = DomainT&;

template <typename Impl>
struct IntervalSetIter :
std::iterator<std::bidirectional_iterator_tag, DomainT, DomainT>
struct IntervalSetIter
{
using Iter = IntervalSetIter;
using iterator_category = std::bidirectional_iterator_tag;
Expand Down
6 changes: 3 additions & 3 deletions src/vt/topos/location/location.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ void EntityLocationCoord<EntityID>::routeMsgNode(

theTerm()->produce(epoch);

auto trigger_msg_handler_action = [=](EntityID const& hid) {
auto trigger_msg_handler_action = [=, this](EntityID const& hid) {
bool const& has_handler = msg->hasHandler();
auto const& from = msg->getLocFromNode();
if (has_handler) {
Expand Down Expand Up @@ -590,7 +590,7 @@ void EntityLocationCoord<EntityID>::routeMsgNode(

EntityID id_ = id;
// buffer the message here, the entity will be registered in the future
insertPendingEntityAction(id_, [=](NodeType resolved) {
insertPendingEntityAction(id_, [=, this](NodeType resolved) {
auto const& my_node = theContext()->getNode();

vt_debug_print(
Expand Down Expand Up @@ -712,7 +712,7 @@ void EntityLocationCoord<EntityID>::routeMsg(
} else {
theTerm()->produce(epoch);
// non-eager protocol: get location first then send message after resolution
getLocation(id, home_node, [=](NodeType node) {
getLocation(id, home_node, [=, this](NodeType node) {
theMsg()->pushEpoch(epoch);
routeMsgNode<MessageT>(serialize_msg, id, home_node, node, msg);
theMsg()->popEpoch(epoch);
Expand Down
4 changes: 2 additions & 2 deletions src/vt/vrt/collection/balance/lb_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ LoadSummary getObjectLoads(
) {
LoadSummary ret;
ret.whole_phase_load =
model->getModeledLoad(object, {when.phases, PhaseOffset::WHOLE_PHASE});
model->getModeledLoad(object, PhaseOffset{when.phases, PhaseOffset::WHOLE_PHASE});

unsigned int subphases = model->getNumSubphases();
for (unsigned int i = 0; i < subphases; ++i)
ret.subphase_loads.push_back(
model->getModeledLoad(object, {when.phases, i})
model->getModeledLoad(object, PhaseOffset{when.phases, i})
);

return ret;
Expand Down
4 changes: 4 additions & 0 deletions src/vt/vrt/collection/balance/lb_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ static constexpr ElementIDType const no_element_id = elm::no_element_id;
struct PhaseOffset {
PhaseOffset() = delete;

PhaseOffset(int ph, unsigned int sub)
: phases(ph), subphase(sub)
{}

int phases;
static constexpr unsigned int NEXT_PHASE = 0;

Expand Down
10 changes: 5 additions & 5 deletions src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void LBManager::defaultPostLBWork(ReassignmentMsg* msg) {
auto phase = msg->phase;
auto proposed = std::make_shared<ProposedReassignment>(model_, reassignment);

runInEpochCollective("LBManager::runLB -> computeStats", [=] {
runInEpochCollective("LBManager::runLB -> computeStats", [=, this] {
auto stats_cb = vt::theCB()->makeBcast<
LBManager, StatsMsgType, &LBManager::statsHandler
>(proxy_);
Expand Down Expand Up @@ -218,7 +218,7 @@ void
LBManager::runLB(
LBProxyType base_proxy, PhaseType phase, vt::Callback<ReassignmentMsg> cb
) {
runInEpochCollective("LBManager::runLB -> updateLoads", [=] {
runInEpochCollective("LBManager::runLB -> updateLoads", [=, this] {
model_->updateLoads(phase);
});

Expand All @@ -231,7 +231,7 @@ LBManager::runLB(
);
}

runInEpochCollective("LBManager::runLB -> computeStats", [=] {
runInEpochCollective("LBManager::runLB -> computeStats", [=, this] {
auto stats_cb = vt::theCB()->makeBcast<
LBManager, StatsMsgType, &LBManager::statsHandler
>(proxy_);
Expand Down Expand Up @@ -301,11 +301,11 @@ void LBManager::startLB(
last_phase_info_->migration_count = 0;
last_phase_info_->ran_lb = false;

runInEpochCollective("LBManager::noLB -> updateLoads", [=] {
runInEpochCollective("LBManager::noLB -> updateLoads", [=, this] {
model_->updateLoads(phase);
});

runInEpochCollective("LBManager::noLB -> computeStats", [=] {
runInEpochCollective("LBManager::noLB -> computeStats", [=, this] {
before_lb_stats_ = true;
auto stats_cb = vt::theCB()->makeBcast<
LBManager, StatsMsgType, &LBManager::statsHandler
Expand Down
6 changes: 3 additions & 3 deletions src/vt/vrt/collection/balance/temperedlb/temperedlb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ void TemperedLB::doLBStages(TimeType start_imb) {
);

if (rollback_ || theConfig()->vt_debug_temperedlb || (iter_ == num_iters_ - 1)) {
runInEpochCollective("TemperedLB::doLBStages -> Rank_load_modeled", [=] {
runInEpochCollective("TemperedLB::doLBStages -> Rank_load_modeled", [=, this] {
using ReduceOp = collective::PlusOp<std::vector<balance::LoadData>>;
auto cb = vt::theCB()->makeBcast<
TemperedLB, StatsMsgType, &TemperedLB::loadStatsHandler
Expand Down Expand Up @@ -1312,7 +1312,7 @@ void TemperedLB::decide() {

if (theConfig()->vt_debug_temperedlb) {
// compute rejection rate because it will be printed
runInEpochCollective("TemperedLB::decide -> compute rejection", [=] {
runInEpochCollective("TemperedLB::decide -> compute rejection", [=, this] {
using ReduceOp = collective::PlusOp<balance::RejectionStats>;
auto cb = vt::theCB()->makeBcast<
TemperedLB, RejectionMsgType, &TemperedLB::rejectionStatsHandler
Expand Down Expand Up @@ -1363,7 +1363,7 @@ void TemperedLB::migrate() {

TimeType TemperedLB::getModeledWork(const elm::ElementIDStruct& obj) {
return load_model_->getModeledLoad(
obj, {balance::PhaseOffset::NEXT_PHASE, balance::PhaseOffset::WHOLE_PHASE}
obj, balance::PhaseOffset{balance::PhaseOffset::NEXT_PHASE, balance::PhaseOffset::WHOLE_PHASE}
);
}

Expand Down
6 changes: 3 additions & 3 deletions src/vt/vrt/collection/manager.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ CollectionManager::runConstructor(Args&&... args) {

template <typename ColT>
void CollectionManager::addCleanupFn(VirtualProxyType proxy) {
cleanup_fns_[proxy].push_back([=]{
cleanup_fns_[proxy].push_back([=, this]{
CollectionProxyWrapType<ColT> typed_proxy(proxy);
destroyMatching(typed_proxy);
});
Expand Down Expand Up @@ -1833,7 +1833,7 @@ MigrateStatus CollectionManager::migrate(

auto const epoch = theMsg()->getEpoch();
theTerm()->produce(epoch);
schedule([=]{
schedule([=, this]{
theMsg()->pushEpoch(epoch);
migrateOut<ColT,IndexT>(col_proxy, idx, dest);
theMsg()->popEpoch(epoch);
Expand Down Expand Up @@ -2380,7 +2380,7 @@ messaging::PendingSend CollectionManager::schedule(
MsgT msg, bool execute_now, EpochType cur_epoch, ActionType action
) {
theTerm()->produce(cur_epoch);
return messaging::PendingSend(msg, [=](MsgVirtualPtr<BaseMsgType> inner_msg){
return messaging::PendingSend(msg, [=, this](MsgVirtualPtr<BaseMsgType> inner_msg){
auto fn = [=]{
theMsg()->pushEpoch(cur_epoch);
action();
Expand Down

0 comments on commit a4212f8

Please sign in to comment.