add broadcast
This commit is contained in:
parent
90a8505208
commit
31a3d22af4
16
guide/broadcast.cc
Normal file
16
guide/broadcast.cc
Normal file
@ -0,0 +1,16 @@
|
||||
#include <rabit.h>
|
||||
using namespace rabit;
|
||||
const int N = 3;
|
||||
int main(int argc, char *argv[]) {
|
||||
rabit::Init(argc, argv);
|
||||
std::string s;
|
||||
if (rabit::GetRank() == 0) s = "hello world";
|
||||
printf("@node[%d] before-broadcast: s=\"%s\"\n",
|
||||
rabit::GetRank(), s.c_str());
|
||||
// broadcast s from node 0 to all other nodes
|
||||
rabit::Broadcast(&s, 0);
|
||||
printf("@node[%d] after-broadcast: s=\"%s\"\n",
|
||||
rabit::GetRank(), s.c_str());
|
||||
rabit::Finalize();
|
||||
return 0;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user