Files
pytorch/test/cpp/c10d/ProcessGroupUCCTest.cpp
Xiang Gao a4a55f5ea6 New TORCH_UCC_BLOCKING_WAIT env variable (#81791)
Cherry-pick of https://github.com/facebookresearch/torch_ucc/pull/95.

I recommend waiting until https://github.com/pytorch/pytorch/pull/81583 is merged first, so the CI is checking if this PR compiles correctly.

Marking this as a draft for now, will change to "ready for review" once https://github.com/pytorch/pytorch/pull/81583 merged.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/81791
Approved by: https://github.com/kwen2501
2022-08-25 21:33:17 +00:00

36 lines
921 B
C++

#include <gtest/gtest.h>
#include <torch/csrc/distributed/c10d/UCCUtils.hpp>
#include <utility>
#include <vector>
using namespace c10d;
TEST(ProcessGroupUCCTest, testTrim) {
std::vector<std::pair<std::string, std::string>> tests = {
{" allreduce ", "allreduce"},
{"\tallgather", "allgather"},
{"send\n", "send"},
};
for (auto entry : tests) {
ASSERT_EQ(trim(entry.first), entry.second);
}
}
TEST(ProcessGroupUCCTest, testToLower) {
std::vector<std::pair<std::string, std::string>> tests = {
{"AllReduce", "allreduce"},
{"ALLGATHER", "allgather"},
{"send", "send"},
};
for (auto entry : tests) {
ASSERT_EQ(tolower(entry.first), entry.second);
}
}
TEST(ProcessGroupUCCTest, testParseList) {
std::string input = "\tAllReduce, ALLGATHER, send\n";
std::vector<std::string> expect{"allreduce", "allgather", "send"};
ASSERT_EQ(parse_list(input), expect);
}