summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-11-15 20:17:36 (GMT)
committerBrad King <brad.king@kitware.com>2023-11-22 12:49:04 (GMT)
commit697900da29f8905dc87047259148ce0dc8b7bdb0 (patch)
tree30f4eb999ec49c4e3edf52b9a18c12a10d268bda
parent1d963973b9517bddd5d4c988850bf9baa6ce27a8 (diff)
downloadCMake-697900da29f8905dc87047259148ce0dc8b7bdb0.zip
CMake-697900da29f8905dc87047259148ce0dc8b7bdb0.tar.gz
CMake-697900da29f8905dc87047259148ce0dc8b7bdb0.tar.bz2
cmCTestMultiProcessHandler: Manage affinity assignments with other resources
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.cxx44
1 files changed, 23 insertions, 21 deletions
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index a9930df..d9da2d8 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -164,18 +164,7 @@ void cmCTestMultiProcessHandler::RunTests()
void cmCTestMultiProcessHandler::StartTestProcess(int test)
{
- if (this->HaveAffinity && this->Properties[test]->WantAffinity) {
- 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);
- }
+ this->LockResources(test);
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"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()) {
std::ostringstream e;
e << "Insufficient resources for test " << this->Properties[test]->Name
@@ -414,19 +399,41 @@ void cmCTestMultiProcessHandler::SetStopTimePassed()
void cmCTestMultiProcessHandler::LockResources(int index)
{
auto* properties = this->Properties[index];
+
this->ProjectResourcesLocked.insert(properties->ProjectResources.begin(),
properties->ProjectResources.end());
+
if (properties->RunSerial) {
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)
{
auto* properties = this->Properties[index];
+
+ for (auto p : properties->Affinity) {
+ this->ProcessorsAvailable.insert(p);
+ }
+ properties->Affinity.clear();
+
for (std::string const& i : properties->ProjectResources) {
this->ProjectResourcesLocked.erase(i);
}
+
if (properties->RunSerial) {
this->SerialTestRunning = false;
}
@@ -686,11 +693,6 @@ void cmCTestMultiProcessHandler::FinishTestProcess(
this->UnlockResources(test);
this->RunningCount -= this->GetProcessorsUsed(test);
- for (auto p : properties->Affinity) {
- this->ProcessorsAvailable.insert(p);
- }
- properties->Affinity.clear();
-
runner.reset();
this->StartNextTestsOnIdle();