summaryrefslogtreecommitdiffstats
path: root/Source/CTest/cmCTestMultiProcessHandler.cxx
diff options
context:
space:
mode:
authorZach Mullen <zach.mullen@kitware.com>2009-09-07 14:26:17 (GMT)
committerZach Mullen <zach.mullen@kitware.com>2009-09-07 14:26:17 (GMT)
commit5fb958fde950f8a8f9b1629399f0457c46224640 (patch)
treece1e1dd09388f892b6cc0135240c292519c148ab /Source/CTest/cmCTestMultiProcessHandler.cxx
parent4e16813f63bae65dd3eeec0a326e9a4926aff1c5 (diff)
downloadCMake-5fb958fde950f8a8f9b1629399f0457c46224640.zip
CMake-5fb958fde950f8a8f9b1629399f0457c46224640.tar.gz
CMake-5fb958fde950f8a8f9b1629399f0457c46224640.tar.bz2
ENH: Added ctest test options PROCESSORS and RUN_SERIAL. These allow specification of resource allocation for given tests running with the ctest -j N option. RUN_SERIAL ensures that a given test does not run in parallel with any other test. Also forced appending of "..." to the longest test name in ctest.
Diffstat (limited to 'Source/CTest/cmCTestMultiProcessHandler.cxx')
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.cxx33
1 files changed, 27 insertions, 6 deletions
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index 07af804..fadf164 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -25,6 +25,7 @@ cmCTestMultiProcessHandler::cmCTestMultiProcessHandler()
{
this->ParallelLevel = 1;
this->Completed = 0;
+ this->RunningCount = 0;
}
// Set the tests
void
@@ -112,10 +113,27 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test)
else
{
this->Completed++;
+ this->RunningCount -= GetProcessorsUsed(test);
testRun->EndTest(this->Completed, this->Total, false);
}
}
+inline size_t cmCTestMultiProcessHandler::GetProcessorsUsed(int test)
+{
+ size_t processors =
+ static_cast<int>(this->Properties[test]->Processors);
+ //If this is set to run serially, it must run alone.
+ //Also, if processors setting is set higher than the -j
+ //setting, we default to using all of the process slots.
+ if(this->Properties[test]->RunSerial
+ || processors > this->ParallelLevel)
+ {
+ processors = this->ParallelLevel;
+ }
+
+ return processors;
+}
+
bool cmCTestMultiProcessHandler::StartTest(int test)
{
// copy the depend tests locally because when
@@ -160,7 +178,7 @@ bool cmCTestMultiProcessHandler::StartTest(int test)
void cmCTestMultiProcessHandler::StartNextTests()
{
- size_t numToStart = this->ParallelLevel - this->RunningTests.size();
+ size_t numToStart = this->ParallelLevel - this->RunningCount;
if(numToStart == 0)
{
return;
@@ -171,13 +189,16 @@ void cmCTestMultiProcessHandler::StartNextTests()
for(TestMap::iterator i = tests.begin();
i != tests.end(); ++i)
{
- //int processors = this->Properties[i->first]->Processors;
-
-// if(processors > )
+ size_t processors = GetProcessorsUsed(i->first);
+ if(processors > numToStart)
+ {
+ return;
+ }
// start test should start only one test
if(this->StartTest(i->first))
{
- numToStart--;
+ numToStart -= processors;
+ this->RunningCount += processors;
}
else
{
@@ -241,7 +262,7 @@ bool cmCTestMultiProcessHandler::CheckOutput()
this->TestRunningMap[test] = false;
this->RunningTests.erase(p);
this->WriteCheckpoint(test);
-
+ this->RunningCount -= GetProcessorsUsed(test);
delete p;
}
return true;