mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-25 01:28:50 -05:00
cmCTestMultiProcessHandler: Manage affinity assignments with other resources
This commit is contained in:
@@ -164,18 +164,7 @@ void cmCTestMultiProcessHandler::RunTests()
|
|||||||
|
|
||||||
void cmCTestMultiProcessHandler::StartTestProcess(int test)
|
void cmCTestMultiProcessHandler::StartTestProcess(int test)
|
||||||
{
|
{
|
||||||
if (this->HaveAffinity && this->Properties[test]->WantAffinity) {
|
this->LockResources(test);
|
||||||
size_t needProcessors = this->GetProcessorsUsed(test);
|
|
||||||
assert(needProcessors <= this->ProcessorsAvailable.size());
|
|
||||||
std::vector<size_t> affinity;
|
|
||||||
affinity.reserve(needProcessors);
|
|
||||||
for (size_t i = 0; i < needProcessors; ++i) {
|
|
||||||
auto p = this->ProcessorsAvailable.begin();
|
|
||||||
affinity.push_back(*p);
|
|
||||||
this->ProcessorsAvailable.erase(p);
|
|
||||||
}
|
|
||||||
this->Properties[test]->Affinity = std::move(affinity);
|
|
||||||
}
|
|
||||||
|
|
||||||
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
||||||
"test " << test << "\n", this->Quiet);
|
"test " << test << "\n", this->Quiet);
|
||||||
@@ -202,10 +191,6 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always lock the resources we'll be using, even if we fail to set the
|
|
||||||
// working directory because FinishTestProcess() will try to unlock them
|
|
||||||
this->LockResources(test);
|
|
||||||
|
|
||||||
if (!this->ResourceAvailabilityErrors[test].empty()) {
|
if (!this->ResourceAvailabilityErrors[test].empty()) {
|
||||||
std::ostringstream e;
|
std::ostringstream e;
|
||||||
e << "Insufficient resources for test " << this->Properties[test]->Name
|
e << "Insufficient resources for test " << this->Properties[test]->Name
|
||||||
@@ -414,19 +399,41 @@ void cmCTestMultiProcessHandler::SetStopTimePassed()
|
|||||||
void cmCTestMultiProcessHandler::LockResources(int index)
|
void cmCTestMultiProcessHandler::LockResources(int index)
|
||||||
{
|
{
|
||||||
auto* properties = this->Properties[index];
|
auto* properties = this->Properties[index];
|
||||||
|
|
||||||
this->ProjectResourcesLocked.insert(properties->ProjectResources.begin(),
|
this->ProjectResourcesLocked.insert(properties->ProjectResources.begin(),
|
||||||
properties->ProjectResources.end());
|
properties->ProjectResources.end());
|
||||||
|
|
||||||
if (properties->RunSerial) {
|
if (properties->RunSerial) {
|
||||||
this->SerialTestRunning = true;
|
this->SerialTestRunning = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->HaveAffinity && properties->WantAffinity) {
|
||||||
|
size_t needProcessors = this->GetProcessorsUsed(index);
|
||||||
|
assert(needProcessors <= this->ProcessorsAvailable.size());
|
||||||
|
std::vector<size_t> affinity;
|
||||||
|
affinity.reserve(needProcessors);
|
||||||
|
for (size_t i = 0; i < needProcessors; ++i) {
|
||||||
|
auto p = this->ProcessorsAvailable.begin();
|
||||||
|
affinity.push_back(*p);
|
||||||
|
this->ProcessorsAvailable.erase(p);
|
||||||
|
}
|
||||||
|
properties->Affinity = std::move(affinity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmCTestMultiProcessHandler::UnlockResources(int index)
|
void cmCTestMultiProcessHandler::UnlockResources(int index)
|
||||||
{
|
{
|
||||||
auto* properties = this->Properties[index];
|
auto* properties = this->Properties[index];
|
||||||
|
|
||||||
|
for (auto p : properties->Affinity) {
|
||||||
|
this->ProcessorsAvailable.insert(p);
|
||||||
|
}
|
||||||
|
properties->Affinity.clear();
|
||||||
|
|
||||||
for (std::string const& i : properties->ProjectResources) {
|
for (std::string const& i : properties->ProjectResources) {
|
||||||
this->ProjectResourcesLocked.erase(i);
|
this->ProjectResourcesLocked.erase(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties->RunSerial) {
|
if (properties->RunSerial) {
|
||||||
this->SerialTestRunning = false;
|
this->SerialTestRunning = false;
|
||||||
}
|
}
|
||||||
@@ -686,11 +693,6 @@ void cmCTestMultiProcessHandler::FinishTestProcess(
|
|||||||
this->UnlockResources(test);
|
this->UnlockResources(test);
|
||||||
this->RunningCount -= this->GetProcessorsUsed(test);
|
this->RunningCount -= this->GetProcessorsUsed(test);
|
||||||
|
|
||||||
for (auto p : properties->Affinity) {
|
|
||||||
this->ProcessorsAvailable.insert(p);
|
|
||||||
}
|
|
||||||
properties->Affinity.clear();
|
|
||||||
|
|
||||||
runner.reset();
|
runner.reset();
|
||||||
|
|
||||||
this->StartNextTestsOnIdle();
|
this->StartNextTestsOnIdle();
|
||||||
|
|||||||
Reference in New Issue
Block a user