2020-04-02 15:44:40 -07:00
|
|
|
#include "cpp_c10d_extension.hpp"
|
|
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
|
|
namespace c10d {
|
|
|
|
|
|
|
|
|
|
ProcessGroupTest::WorkTest::~WorkTest() {}
|
|
|
|
|
|
|
|
|
|
bool ProcessGroupTest::WorkTest::isCompleted() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ProcessGroupTest::WorkTest::isSuccess() const {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-16 10:54:27 -07:00
|
|
|
bool ProcessGroupTest::WorkTest::wait(std::chrono::milliseconds /* unused */) {
|
2020-04-02 15:44:40 -07:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProcessGroupTest::ProcessGroupTest(int rank, int size)
|
|
|
|
|
: ProcessGroup(rank, size) {}
|
|
|
|
|
|
|
|
|
|
ProcessGroupTest::~ProcessGroupTest() {}
|
|
|
|
|
|
2022-09-13 12:07:22 -07:00
|
|
|
c10::intrusive_ptr<Work> ProcessGroupTest::broadcast(
|
2020-04-02 15:44:40 -07:00
|
|
|
std::vector<at::Tensor>& tensors,
|
|
|
|
|
const BroadcastOptions& opts) {
|
2020-11-11 22:49:06 -08:00
|
|
|
return c10::make_intrusive<ProcessGroupTest::WorkTest>();
|
2020-04-02 15:44:40 -07:00
|
|
|
}
|
|
|
|
|
|
2022-09-13 12:07:22 -07:00
|
|
|
c10::intrusive_ptr<Work> ProcessGroupTest::allreduce(
|
2020-04-02 15:44:40 -07:00
|
|
|
std::vector<at::Tensor>& tensors,
|
|
|
|
|
const AllreduceOptions& opts) {
|
2020-11-11 22:49:06 -08:00
|
|
|
return c10::make_intrusive<ProcessGroupTest::WorkTest>();
|
2020-04-02 15:44:40 -07:00
|
|
|
}
|
|
|
|
|
|
2022-09-13 12:07:22 -07:00
|
|
|
c10::intrusive_ptr<Work> ProcessGroupTest::allreduce_coalesced(
|
2020-04-02 15:44:40 -07:00
|
|
|
std::vector<at::Tensor>& tensors,
|
|
|
|
|
const AllreduceCoalescedOptions& opts) {
|
|
|
|
|
throw std::runtime_error("ProcessGroupTest does not support allreduce_coalesced");
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-13 12:07:22 -07:00
|
|
|
c10::intrusive_ptr<Work> ProcessGroupTest::reduce(
|
2020-04-02 15:44:40 -07:00
|
|
|
std::vector<at::Tensor>& tensors,
|
|
|
|
|
const ReduceOptions& opts) {
|
|
|
|
|
throw std::runtime_error("ProcessGroupTest does not support reduce");
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-13 12:07:22 -07:00
|
|
|
c10::intrusive_ptr<Work> ProcessGroupTest::allgather(
|
2020-04-02 15:44:40 -07:00
|
|
|
std::vector<std::vector<at::Tensor>>& outputTensors,
|
|
|
|
|
std::vector<at::Tensor>& inputTensors,
|
|
|
|
|
const AllgatherOptions& opts) {
|
|
|
|
|
throw std::runtime_error("ProcessGroupTest does not support allgather");
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-13 12:07:22 -07:00
|
|
|
c10::intrusive_ptr<Work> ProcessGroupTest::_allgather_base(
|
2020-04-02 15:44:40 -07:00
|
|
|
at::Tensor& outputBuffer,
|
|
|
|
|
at::Tensor& inputBuffer,
|
|
|
|
|
const AllgatherOptions& opts) {
|
2021-04-23 14:11:09 -07:00
|
|
|
throw std::runtime_error("ProcessGroupTest does not support _allgather_base");
|
2020-04-02 15:44:40 -07:00
|
|
|
}
|
|
|
|
|
|
2022-09-13 12:07:22 -07:00
|
|
|
c10::intrusive_ptr<Work> ProcessGroupTest::barrier(
|
2020-04-02 15:44:40 -07:00
|
|
|
const BarrierOptions& opts) {
|
2020-11-11 22:49:06 -08:00
|
|
|
return c10::make_intrusive<ProcessGroupTest::WorkTest>();
|
2020-04-02 15:44:40 -07:00
|
|
|
}
|
|
|
|
|
|
2022-09-13 12:07:22 -07:00
|
|
|
c10::intrusive_ptr<Work> ProcessGroupTest::gather(
|
2020-04-02 15:44:40 -07:00
|
|
|
std::vector<std::vector<at::Tensor>>& outputTensors,
|
|
|
|
|
std::vector<at::Tensor>& inputTensors,
|
|
|
|
|
const GatherOptions& opts) {
|
|
|
|
|
throw std::runtime_error("ProcessGroupTest does not support gather");
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-13 12:07:22 -07:00
|
|
|
c10::intrusive_ptr<Work> ProcessGroupTest::scatter(
|
2020-04-02 15:44:40 -07:00
|
|
|
std::vector<at::Tensor>& outputTensors,
|
|
|
|
|
std::vector<std::vector<at::Tensor>>& inputTensors,
|
|
|
|
|
const ScatterOptions& opts) {
|
|
|
|
|
throw std::runtime_error("ProcessGroupTest does not support scatter");
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-13 12:07:22 -07:00
|
|
|
c10::intrusive_ptr<Work> ProcessGroupTest::reduce_scatter(
|
2020-04-02 15:44:40 -07:00
|
|
|
std::vector<at::Tensor>& outputTensors,
|
|
|
|
|
std::vector<std::vector<at::Tensor>>& inputTensors,
|
|
|
|
|
const ReduceScatterOptions& opts) {
|
|
|
|
|
throw std::runtime_error("ProcessGroupTest does not support reduce_scatter");
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-13 12:07:22 -07:00
|
|
|
c10::intrusive_ptr<Work> ProcessGroupTest::send(
|
2020-04-02 15:44:40 -07:00
|
|
|
std::vector<at::Tensor>& tensors,
|
|
|
|
|
int dstRank,
|
|
|
|
|
int tag) {
|
|
|
|
|
throw std::runtime_error("ProcessGroupTest does not support send");
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-13 12:07:22 -07:00
|
|
|
c10::intrusive_ptr<Work> ProcessGroupTest::recv(
|
2020-04-02 15:44:40 -07:00
|
|
|
std::vector<at::Tensor>& tensors,
|
|
|
|
|
int srcRank,
|
|
|
|
|
int tag) {
|
|
|
|
|
throw std::runtime_error("ProcessGroupTest does not support recv");
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-13 12:07:22 -07:00
|
|
|
c10::intrusive_ptr<Work> ProcessGroupTest::recvAnysource(
|
2020-04-02 15:44:40 -07:00
|
|
|
std::vector<at::Tensor>& tensor,
|
|
|
|
|
int tag) {
|
|
|
|
|
throw std::runtime_error("ProcessGroupTest does not support recvAnysource");
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-12 07:34:13 -08:00
|
|
|
c10::intrusive_ptr<ProcessGroup> ProcessGroupTest::createProcessGroupTest(
|
2020-11-11 22:49:06 -08:00
|
|
|
const c10::intrusive_ptr<::c10d::Store>& store,
|
2020-04-02 15:44:40 -07:00
|
|
|
int rank,
|
|
|
|
|
int size,
|
|
|
|
|
const std::chrono::duration<float>& timeout) {
|
2020-11-12 07:34:13 -08:00
|
|
|
return c10::make_intrusive<ProcessGroupTest>(rank, size);
|
2020-04-02 15:44:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
|
|
|
|
|
m.def("createProcessGroupTest", &ProcessGroupTest::createProcessGroupTest);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace c10d
|