1 #include <c10d/FileStore.hpp> 2 #include <c10d/ProcessGroupGloo.hpp> 4 using namespace ::
c10d;
6 int main(
int argc,
char** argv) {
7 int rank = atoi(getenv(
"RANK"));
8 int size = atoi(getenv(
"SIZE"));
9 auto store = std::make_shared<FileStore>(
"/tmp/c10d_example", size);
10 ProcessGroupGloo pg(store, rank, size);
13 const auto ntensors = 10;
14 std::vector<at::Tensor> tensors;
15 for (
auto i = 0; i < ntensors; i++) {
22 std::vector<std::shared_ptr<ProcessGroup::Work>> pending;
23 for (
auto i = 0; i < ntensors; i++) {
24 std::vector<at::Tensor> tmp = {tensors[i]};
25 pending.push_back(pg.allreduce(tmp));
29 for (
auto& work : pending) {