|
| 1 | +#include "cpp_c10d_extension.hpp" |
| 2 | + |
| 3 | +#include <map> |
| 4 | + |
| 5 | +namespace c10d { |
| 6 | + |
| 7 | +ProcessGroupTest::WorkTest::~WorkTest() {} |
| 8 | + |
| 9 | +bool ProcessGroupTest::WorkTest::isCompleted() { |
| 10 | + return true; |
| 11 | +} |
| 12 | + |
| 13 | +bool ProcessGroupTest::WorkTest::isSuccess() const { |
| 14 | + return true; |
| 15 | +} |
| 16 | + |
| 17 | +bool ProcessGroupTest::WorkTest::wait() { |
| 18 | + return true; |
| 19 | +} |
| 20 | + |
| 21 | +ProcessGroupTest::ProcessGroupTest(int rank, int size) |
| 22 | + : ProcessGroup(rank, size) {} |
| 23 | + |
| 24 | +ProcessGroupTest::~ProcessGroupTest() {} |
| 25 | + |
| 26 | +std::shared_ptr<ProcessGroup::Work> ProcessGroupTest::broadcast( |
| 27 | + std::vector<at::Tensor>& tensors, |
| 28 | + const BroadcastOptions& opts) { |
| 29 | + return std::make_shared<ProcessGroupTest::WorkTest>(); |
| 30 | +} |
| 31 | + |
| 32 | +std::shared_ptr<ProcessGroup::Work> ProcessGroupTest::allreduce( |
| 33 | + std::vector<at::Tensor>& tensors, |
| 34 | + const AllreduceOptions& opts) { |
| 35 | + return std::make_shared<ProcessGroupTest::WorkTest>(); |
| 36 | +} |
| 37 | + |
| 38 | +std::shared_ptr<ProcessGroup::Work> ProcessGroupTest::allreduce_coalesced( |
| 39 | + std::vector<at::Tensor>& tensors, |
| 40 | + const AllreduceCoalescedOptions& opts) { |
| 41 | + throw std::runtime_error("ProcessGroupTest does not support allreduce_coalesced"); |
| 42 | +} |
| 43 | + |
| 44 | +std::shared_ptr<ProcessGroup::Work> ProcessGroupTest::reduce( |
| 45 | + std::vector<at::Tensor>& tensors, |
| 46 | + const ReduceOptions& opts) { |
| 47 | + throw std::runtime_error("ProcessGroupTest does not support reduce"); |
| 48 | +} |
| 49 | + |
| 50 | +std::shared_ptr<ProcessGroup::Work> ProcessGroupTest::allgather( |
| 51 | + std::vector<std::vector<at::Tensor>>& outputTensors, |
| 52 | + std::vector<at::Tensor>& inputTensors, |
| 53 | + const AllgatherOptions& opts) { |
| 54 | + throw std::runtime_error("ProcessGroupTest does not support allgather"); |
| 55 | +} |
| 56 | + |
| 57 | +std::shared_ptr<ProcessGroup::Work> ProcessGroupTest::allgather_base( |
| 58 | + at::Tensor& outputBuffer, |
| 59 | + at::Tensor& inputBuffer, |
| 60 | + const AllgatherOptions& opts) { |
| 61 | + throw std::runtime_error("ProcessGroupTest does not support allgather_base"); |
| 62 | +} |
| 63 | + |
| 64 | +std::shared_ptr<ProcessGroup::Work> ProcessGroupTest::barrier( |
| 65 | + const BarrierOptions& opts) { |
| 66 | + throw std::runtime_error("ProcessGroupTest does not support barrier"); |
| 67 | +} |
| 68 | + |
| 69 | +std::shared_ptr<ProcessGroup::Work> ProcessGroupTest::gather( |
| 70 | + std::vector<std::vector<at::Tensor>>& outputTensors, |
| 71 | + std::vector<at::Tensor>& inputTensors, |
| 72 | + const GatherOptions& opts) { |
| 73 | + throw std::runtime_error("ProcessGroupTest does not support gather"); |
| 74 | +} |
| 75 | + |
| 76 | +std::shared_ptr<ProcessGroup::Work> ProcessGroupTest::scatter( |
| 77 | + std::vector<at::Tensor>& outputTensors, |
| 78 | + std::vector<std::vector<at::Tensor>>& inputTensors, |
| 79 | + const ScatterOptions& opts) { |
| 80 | + throw std::runtime_error("ProcessGroupTest does not support scatter"); |
| 81 | +} |
| 82 | + |
| 83 | +std::shared_ptr<ProcessGroup::Work> ProcessGroupTest::reduce_scatter( |
| 84 | + std::vector<at::Tensor>& outputTensors, |
| 85 | + std::vector<std::vector<at::Tensor>>& inputTensors, |
| 86 | + const ReduceScatterOptions& opts) { |
| 87 | + throw std::runtime_error("ProcessGroupTest does not support reduce_scatter"); |
| 88 | +} |
| 89 | + |
| 90 | +std::shared_ptr<ProcessGroup::Work> ProcessGroupTest::send( |
| 91 | + std::vector<at::Tensor>& tensors, |
| 92 | + int dstRank, |
| 93 | + int tag) { |
| 94 | + throw std::runtime_error("ProcessGroupTest does not support send"); |
| 95 | +} |
| 96 | + |
| 97 | +std::shared_ptr<ProcessGroup::Work> ProcessGroupTest::recv( |
| 98 | + std::vector<at::Tensor>& tensors, |
| 99 | + int srcRank, |
| 100 | + int tag) { |
| 101 | + throw std::runtime_error("ProcessGroupTest does not support recv"); |
| 102 | +} |
| 103 | + |
| 104 | +std::shared_ptr<ProcessGroup::Work> ProcessGroupTest::recvAnysource( |
| 105 | + std::vector<at::Tensor>& tensor, |
| 106 | + int tag) { |
| 107 | + throw std::runtime_error("ProcessGroupTest does not support recvAnysource"); |
| 108 | +} |
| 109 | + |
| 110 | +std::shared_ptr<ProcessGroup> ProcessGroupTest::createProcessGroupTest( |
| 111 | + const std::shared_ptr<::c10d::Store>& store, |
| 112 | + int rank, |
| 113 | + int size, |
| 114 | + const std::chrono::duration<float>& timeout) { |
| 115 | + return std::make_shared<ProcessGroupTest>(rank, size); |
| 116 | +} |
| 117 | + |
| 118 | +PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { |
| 119 | + m.def("createProcessGroupTest", &ProcessGroupTest::createProcessGroupTest); |
| 120 | +} |
| 121 | + |
| 122 | +} // namespace c10d |
0 commit comments