forked from rogerpearce/ygm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello_world.cpp
More file actions
25 lines (20 loc) · 734 Bytes
/
hello_world.cpp
File metadata and controls
25 lines (20 loc) · 734 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright 2019-2021 Lawrence Livermore National Security, LLC and other YGM
// Project Developers. See the top-level COPYRIGHT file for details.
//
// SPDX-License-Identifier: MIT
#include <string>
#include <ygm/comm.hpp>
int main(int argc, char** argv) {
// Construct a communicator that sends messages when it has 32MB of used send
// buffer space
ygm::comm world(&argc, &argv, 32 * 1024 * 1024);
// Define a "hello world" lambda to execute on a remote rank
auto hello_world_lambda = [](const std::string& name) {
std::cout << "Hello " << name << std::endl;
};
// Rank 0 tells rank 1 to greet the world
if (world.rank0()) {
world.async(1, hello_world_lambda, std::string("world"));
}
return 0;
}