Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions llvm/unittests/Support/ThreadPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ TYPED_TEST(ThreadPoolTest, AsyncBarrier) {

std::atomic_int checked_in{0};

DefaultThreadPool Pool;
TypeParam Pool;
for (size_t i = 0; i < 5; ++i) {
Pool.async([this, &checked_in] {
this->waitForMainThread();
Expand Down Expand Up @@ -453,15 +453,19 @@ TYPED_TEST(ThreadPoolTest, AffinityMask) {
[](auto &T) { return T.getData().front() < 16UL; }) &&
"Threads ran on more CPUs than expected! The affinity mask does not "
"seem to work.");
GTEST_SKIP();
return;
}
std::string Executable =
sys::fs::getMainExecutable(TestMainArgv0, &ThreadPoolTestStringArg1);
StringRef argv[] = {Executable, "--gtest_filter=ThreadPoolTest.AffinityMask"};
const auto *TestInfo = testing::UnitTest::GetInstance()->current_test_info();
std::string Arg = (Twine("--gtest_filter=") + TestInfo->test_suite_name() +
"." + TestInfo->name())
.str();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised we're doing this kind of thing, that seems quite hacky to me.

That said your fix is just improving the status quo.

StringRef argv[] = {Executable, Arg};

// Add environment variable to the environment of the child process.
int Res = setenv("LLVM_THREADPOOL_AFFINITYMASK", "1", false);
ASSERT_EQ(Res, 0);
ASSERT_EQ(0, Res);

std::string Error;
bool ExecutionFailed;
Expand All @@ -470,6 +474,8 @@ TYPED_TEST(ThreadPoolTest, AffinityMask) {
Affinity.set(0, 4); // Use CPUs 0,1,2,3.
int Ret = sys::ExecuteAndWait(Executable, argv, {}, {}, 0, 0, &Error,
&ExecutionFailed, nullptr, &Affinity);
Res = setenv("LLVM_THREADPOOL_AFFINITYMASK", "", false);
ASSERT_EQ(0, Res);
ASSERT_EQ(0, Ret);
}

Expand Down