Skip to content

Commit

Permalink
#2099: Make public API work as before
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobDomagala committed Jan 18, 2024
1 parent f34d636 commit b8e2123
Show file tree
Hide file tree
Showing 141 changed files with 480 additions and 556 deletions.
4 changes: 2 additions & 2 deletions examples/callback/callback_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ int main(int argc, char** argv) {

auto this_node = vt::theContext()->getNode();

if (this_node == vt::NodeT{0}) {
if (this_node == 0) {
my_global_ctx.x = 1283;

// Make a callback that triggers the callback with a context
Expand All @@ -114,7 +114,7 @@ int main(int argc, char** argv) {
);

auto const default_proxy = vt::theObjGroup()->getDefault();
default_proxy[vt::NodeT{1}].send<CallbackMsg, handler>(cb);
default_proxy[1].send<CallbackMsg, handler>(cb);
}

vt::finalize();
Expand Down
2 changes: 1 addition & 1 deletion examples/collection/migrate_collection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static void doWork(Hello* col) {
static void migrateToNext(Hello* col) {
auto this_node = vt::theContext()->getNode();
auto num_nodes = vt::theContext()->getNumNodes();
vt::NodeT next_node = (this_node + vt::NodeT{1}) % num_nodes;
auto next_node = (this_node + 1) % num_nodes;

fmt::print("{}: migrateToNext: idx={}\n", this_node, col->getIndex());
col->migrate(next_node);
Expand Down
6 changes: 3 additions & 3 deletions examples/collection/polymorphic_collection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void Hello::doWork() {
static void migrateToNext(Hello* col) {
auto this_node = vt::theContext()->getNode();
auto num_nodes = vt::theContext()->getNumNodes();
vt::NodeT next_node = (this_node + vt::NodeT{1}) % num_nodes;
auto const next_node = (this_node + 1) % num_nodes;

fmt::print("{}: migrateToNext: idx={}\n", this_node, col->getIndex());
col->migrate(next_node);
Expand All @@ -165,12 +165,12 @@ int main(int argc, char** argv) {
vtAbortIf(num_elms % num_nodes != 0, "Must be even number of elements per rank");
auto const num_per = num_elms / num_nodes;
if (this_node % 2 == 0) {
for (int i = this_node.get()*num_per; i < (this_node.get()+1)*num_per; i++) {
for (int i = this_node*num_per; i < (this_node+1)*num_per; i++) {
vt::Index1D idx{i};
elms.emplace_back(idx, std::make_unique<HelloTyped<int>>(InitialConsTag{}));
}
} else if (this_node % 2 == 1) {
for (int i = this_node.get()*num_per; i < (this_node.get()+1)*num_per; i++) {
for (int i = this_node*num_per; i < (this_node+1)*num_per; i++) {
vt::Index1D idx{i};
elms.emplace_back(idx, std::make_unique<HelloTyped<double>>(InitialConsTag{}));
}
Expand Down
3 changes: 2 additions & 1 deletion examples/collection/transpose.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
//@HEADER
*/

#include "vt/configs/types/types_node.h"
#include <vt/transport.h>

#include <vector>
Expand Down Expand Up @@ -284,7 +285,7 @@ vt::NodeT my_map(IndexT* idx, IndexT* max_idx, vt::NodeT num_nodes) {
}
}

static void solveGroupSetup(vt::NodeT this_node, vt::VirtualProxyType coll_proxy) {
static void solveGroupSetup(vt::BaseNodeType this_node, vt::VirtualProxyType coll_proxy) {
auto const& is_even_node = this_node % 2 == 0;

// This is how you would explicitly create/get a new communicator for this
Expand Down
4 changes: 2 additions & 2 deletions examples/hello_world/hello_reduce.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ void reduceResult(int result, double result2) {
int main(int argc, char** argv) {
vt::initialize(argc, argv);

vt::NodeType const root = 0;
vt::NodeT const root(0);

auto r = vt::theCollective()->global();
r->reduce<reduceResult, vt::collective::PlusOp>(vt::Node{root}, 50, 52.334);
r->reduce<reduceResult, vt::collective::PlusOp>(root, 50, 52.334);

vt::finalize();
return 0;
Expand Down
8 changes: 4 additions & 4 deletions examples/hello_world/objgroup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ int main(int argc, char** argv) {

vt::theCollective()->barrier();

if (this_node == vt::NodeT{0}) {
proxy[vt::NodeT{0}].send<&MyObjGroup::handler>(5,10);
if (this_node == 0) {
proxy[0].send<&MyObjGroup::handler>(5,10);
if (num_nodes > 1) {
proxy[vt::NodeT{1}].send<&MyObjGroup::handler>(10,20);
proxy[1].send<&MyObjGroup::handler>(10,20);
}

// Broadcast to all nodes
Expand All @@ -83,7 +83,7 @@ int main(int argc, char** argv) {

// Create list of nodes and multicast to them
List::ListType range;
for (vt::NodeType node = 0; node < num_nodes; ++node) {
for (int32_t node = 0; node < num_nodes; ++node) {
if (node % 2 == 0) {
range.push_back(node);
}
Expand Down
4 changes: 2 additions & 2 deletions sketches/test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ using namespace vt;
struct ParticleCollection : vt::VirtualCollectionContext {
std::vector<Particle> particles;

NodeType initial_map_to_node(index i) {
NodeT initial_map_to_node(index i) {

}
};

Expand Down
4 changes: 2 additions & 2 deletions sketches/test_program1.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

using namespace vt;

NodeType this_node = -1;
NodeType num_nodes = -1;
NodeT this_node = -1;
NodeT num_nodes = -1;
HandlerType test_msg_han = 0;
HandlerType test_msg_han2 = 0;
EpochType test_epoch = -1;
Expand Down
2 changes: 1 addition & 1 deletion src/vt/collective/barrier/barrier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ BarrierType Barrier::newNamedCollectiveBarrier() {

BarrierType Barrier::newNamedBarrier() {
BarrierType const next_barrier = cur_named_barrier_++;
NodeT const cur_node = theContext()->getNode();
NodeT const cur_node = theContext()->getNodeStrong();
BarrierType const cur_node_shift = static_cast<BarrierType>(cur_node) << 32;
BarrierType const barrier_name = next_barrier | cur_node_shift;
return barrier_name;
Expand Down
2 changes: 1 addition & 1 deletion src/vt/collective/collective_alg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static void broadcastConsensus(

reenter_counter_++;

auto const this_node = theContext()->getNode();
auto const this_node = theContext()->getNodeStrong();
TagType consensus_scope = no_tag;
TagType consensus_tag = no_tag;
bool consensus_is_user_tag = false;
Expand Down
2 changes: 1 addition & 1 deletion src/vt/collective/collective_ops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ RuntimePtrType CollectiveAnyOps<instance>::initialize(

// If appConfig is not nullptr, compare CLI arguments with user-defined ones,
// and report overwritten ones.
if (appConfig && theContext()->getNode() == 0) {
if (appConfig && theContext()->getNodeStrong() == 0) {
printOverwrittens(*rt->getAppConfig(), *appConfig);
}

Expand Down
4 changes: 2 additions & 2 deletions src/vt/collective/reduce/reduce.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ struct Reduce : virtual collective::tree::Tree {
template <typename Arg> class Op = NoneOp,
typename... Params
>
PendingSendType reduce(Node root, Params&&... params);
PendingSendType reduce(NodeT root, Params&&... params);

template <typename Op, auto f, typename... Params>
PendingSendType reduce(Node root, Params&&... params);
PendingSendType reduce(NodeT root, Params&&... params);

/**
* \brief Reduce a message up the tree
Expand Down
6 changes: 3 additions & 3 deletions src/vt/collective/reduce/reduce.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ template <
template <typename Arg> class Op,
typename... Params
>
Reduce::PendingSendType Reduce::reduce(Node root, Params&&... params) {
Reduce::PendingSendType Reduce::reduce(NodeT root, Params&&... params) {
using Tuple = typename FuncTraits<decltype(f)>::TupleType;
using OpT = Op<Tuple>;
return reduce<OpT, f>(root, std::forward<Params>(params)...);
}

template <typename Op, auto f, typename... Params>
Reduce::PendingSendType Reduce::reduce(Node root, Params&&... params) {
Reduce::PendingSendType Reduce::reduce(NodeT root, Params&&... params) {
using Tuple = typename FuncTraits<decltype(f)>::TupleType;
using MsgT = ReduceTMsg<Tuple>;
using GetReduceStamp = collective::reduce::GetReduceStamp<void, Params...>;
Expand Down Expand Up @@ -299,7 +299,7 @@ void Reduce::startReduce(detail::ReduceStamp id, bool use_num_contrib) {
state_.erase(lookup);

if (isRoot()) {
auto const& this_node = theContext()->getNode();
auto const& this_node = theContext()->getNodeStrong();
if (root != this_node) {
vt_debug_print(
normal, reduce,
Expand Down
4 changes: 2 additions & 2 deletions src/vt/collective/scatter/scatter.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void Scatter::scatter(
std::size_t const& total_size, std::size_t const& max_proc_size,
FuncSizeType size_fn, FuncDataType data_fn
) {
auto const num_nodes = theContext()->getNumNodes();
auto const num_nodes = theContext()->getNumNodesStrong();
auto const elm_size = max_proc_size;
auto const combined_size = static_cast<size_t>(num_nodes * elm_size);
auto scatter_msg =
Expand Down Expand Up @@ -90,7 +90,7 @@ void Scatter::scatter(
);
vtAssert(nptr == ptr + combined_size, "nptr must match size");
auto const& handler = auto_registry::makeScatterHandler<MessageT, f>();
auto const& this_node = theContext()->getNode();
auto const& this_node = theContext()->getNodeStrong();
scatter_msg->user_han = handler;
if (this_node != root_node) {
theMsg()->sendMsg<scatterHandler>(
Expand Down
10 changes: 5 additions & 5 deletions src/vt/collective/tree/tree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ bool Tree::isRoot() const {
}

Tree::NodeListType Tree::getChildren(NodeT node) const {
auto const& num_nodes = theContext()->getNumNodes();
auto const& num_nodes = theContext()->getNumNodesStrong();
auto const& c1_ = node * 2 + 1;
auto const& c2_ = node * 2 + 2;
NodeListType children;
Expand Down Expand Up @@ -133,8 +133,8 @@ void Tree::foreachChild(NumLevelsType level, OperationType op) const {

void Tree::setupTree() {
if (not set_up_tree_) {
auto const& this_node_ = theContext()->getNode();
auto const& num_nodes_ = theContext()->getNumNodes();
auto const& this_node_ = theContext()->getNodeStrong();
auto const& num_nodes_ = theContext()->getNumNodesStrong();

auto const& c1_ = this_node_ * 2 + 1;
auto const& c2_ = this_node_ * 2 + 2;
Expand All @@ -157,8 +157,8 @@ void Tree::setupTree() {
}

Tree::NumLevelsType Tree::numLevels() const {
auto const& num_nodes = theContext()->getNumNodes();
auto const& levels = std::log2(num_nodes.get());
auto const num_nodes = theContext()->getNumNodesStrong();
auto const levels = std::log2(num_nodes.get());
return levels;
}

Expand Down
2 changes: 1 addition & 1 deletion src/vt/configs/arguments/args.cc
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ namespace {
static std::string buildRankFile(std::string const& file) {
std::string name = file;
std::size_t rank = name.find("%p");
auto str_rank = std::to_string(theContext()->getNode());
auto str_rank = std::to_string(theContext()->getNodeStrong());
if (rank == std::string::npos) {
name = name + str_rank;
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/vt/configs/error/stack_out.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ std::string prettyPrintStack(DumpStackType const& stack) {
auto magenta = ::vt::debug::magenta();
auto yellow = ::vt::debug::yellow();
auto vt_pre = ::vt::debug::vtPre();
auto node = ::vt::theContext()->getNode();
auto node_str = ::vt::debug::proc(node);
auto node = ::vt::theContext()->getNodeStrong();
auto node_str = ::vt::debug::proc(NodeT{node});
auto prefix = vt_pre + node_str + " ";
auto separator = fmt::format("{}{}{:-^120}{}\n", prefix, yellow, "", reset);
auto title_node = fmt::format("on Node {}", node);
Expand Down
10 changes: 5 additions & 5 deletions src/vt/context/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ NodeT Context::getFromNodeCurrentTask() const {
}
}
#endif
return getNode();
return getNodeStrong();
}

#if vt_check_enabled(trace_enabled)
Expand All @@ -133,19 +133,19 @@ namespace vt { namespace debug {
NodeT preNode() {
#if !vt_check_enabled(trace_only)
return ::vt::curRT != nullptr and ::vt::curRT->isLive() ?
theContext()->getNode() :
theContext()->getNodeStrong() :
NodeT{-1};
#else
return theContext() ? theContext()->getNode() : NodeT{-1};
return theContext() ? theContext()->getNodeStrong() : NodeT{-1};
#endif
}
NodeT preNodes() {
#if !vt_check_enabled(trace_only)
return ::vt::curRT != nullptr and ::vt::curRT->isLive() ?
theContext()->getNumNodes() :
theContext()->getNumNodesStrong() :
NodeT{-1};
#else
return theContext() ? theContext()->getNode() : NodeT{-1};
return theContext() ? theContext()->getNodeStrong() : NodeT{-1};
#endif
}

Expand Down
5 changes: 4 additions & 1 deletion src/vt/context/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ struct Context : runtime::component::Component<Context> {
*/
inline BaseNodeType getNode() const { return thisNode_; }

inline NodeT getNodeStrong() const { return thisNode_; }

/**
* \brief Get the number of nodes (analogous to MPI's num ranks) being used
*
Expand All @@ -111,6 +113,7 @@ struct Context : runtime::component::Component<Context> {
*/
inline BaseNodeType getNumNodes() const { return numNodes_; }

inline NodeT getNumNodesStrong() const { return numNodes_; }
/**
* \brief Get the MPI communicator being used by VT in a given runtime
* instance
Expand Down Expand Up @@ -143,7 +146,7 @@ struct Context : runtime::component::Component<Context> {
* the node that sent the message to trigger the current runnable.
*
* \note If a task is not currently running, this will return the this node
* ---equivalent to \c theContext()->getNode()
* ---equivalent to \c theContext()->getNodeStrong()
*
* For the current task that is executing, get the node that sent the message
* that caused this runnable to execute. Note, for collection handlers this
Expand Down
4 changes: 2 additions & 2 deletions src/vt/elm/elm_id_bits.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace vt { namespace elm {
bool migratable, NodeT curr_node
) {
auto const seq_id = theNodeLBData()->getNextElm();
auto const home_node = theContext()->getNode();
auto const home_node = theContext()->getNodeStrong();
return createCollectionImpl(migratable, seq_id, home_node, curr_node);
}

Expand All @@ -70,7 +70,7 @@ namespace vt { namespace elm {
) {
ElementIDType ret = 0;
setObjGroup(ret, proxy, node);
auto const this_node = theContext()->getNode();
auto const this_node = theContext()->getNodeStrong();
return ElementIDStruct{ret, this_node};
}

Expand Down
4 changes: 2 additions & 2 deletions src/vt/epoch/epoch_manip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ EpochManip::EpochManip()
/*static*/ EpochType EpochManip::generateRootedEpoch(
eEpochCategory const& category
) {
auto const root_node = theContext()->getNode();
auto const root_node = theContext()->getNodeStrong();
return generateEpoch(true,root_node,category);
}

Expand All @@ -103,7 +103,7 @@ EpochType EpochManip::getNextCollectiveEpoch(
EpochType EpochManip::getNextRootedEpoch(
eEpochCategory const& category
) {
auto const root_node = theContext()->getNode();
auto const root_node = theContext()->getNodeStrong();
auto const arch_epoch = getNextRootedEpoch(category, root_node);
return getTerminatedWindow(arch_epoch)->allocateNewEpoch();
}
Expand Down
Loading

0 comments on commit b8e2123

Please sign in to comment.