Skip to content

Commit

Permalink
#1554: example: hack in test NOMERGE
Browse files Browse the repository at this point in the history
  • Loading branch information
lifflander committed Oct 4, 2021
1 parent c667ee4 commit 37b16ad
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions examples/hello_world/hello_world.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,29 @@
*/

#include <vt/transport.h>
#include <vt/datarep/dr.h>

struct HelloMsg : vt::Message {
HelloMsg(vt::NodeType in_from) : from(in_from) { }
HelloMsg(vt::NodeType in_from, vt::DataRepIDType handle_id)
: from(in_from),
handle_id_(handle_id)
{ }

vt::NodeType from = 0;
vt::DataRepIDType handle_id_ = vt::no_datarep;
};

static void hello_world(HelloMsg* msg) {
vt::NodeType this_node = vt::theContext()->getNode();
fmt::print("{}: Hello from node {} (start)\n", this_node, msg->from);
auto han_id = msg->handle_id_;
vt::datarep::Reader<std::vector<double>> my_reader{han_id};
my_reader.fetch();
vt::theSched()->runSchedulerWhile([&]{ return not my_reader.isReady(); });
auto const& vec = my_reader.get();
for (auto&& elm : vec) {
vt_print(gen, "elm={}\n", elm);
}
fmt::print("{}: Hello from node {}\n", this_node, msg->from);
}

Expand All @@ -65,7 +79,12 @@ int main(int argc, char** argv) {
}

if (this_node == 0) {
auto msg = vt::makeMessage<HelloMsg>(this_node);
std::vector<double> my_vec;
for (int i = 0; i < 10; i++) {
my_vec.push_back(i*10);
}
auto my_dr = vt::theDR()->makeHandle(std::move(my_vec));
auto msg = vt::makeMessage<HelloMsg>(this_node, my_dr.getHandleID());
vt::theMsg()->broadcastMsg<HelloMsg, hello_world>(msg);
}

Expand Down

0 comments on commit 37b16ad

Please sign in to comment.