summaryrefslogtreecommitdiffstats
path: root/Source/CTest/cmProcess.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-03-01 15:38:15 (GMT)
committerBrad King <brad.king@kitware.com>2018-03-05 14:21:32 (GMT)
commit6be53c6695e8d82d3633681f893b79db1de466f0 (patch)
tree753efcf002e0af8545df663288627d142a299f80 /Source/CTest/cmProcess.cxx
parentc5428d8db2aebb215b418d72eae99f4a106a82b0 (diff)
downloadCMake-6be53c6695e8d82d3633681f893b79db1de466f0.zip
CMake-6be53c6695e8d82d3633681f893b79db1de466f0.tar.gz
CMake-6be53c6695e8d82d3633681f893b79db1de466f0.tar.bz2
CTest: Add options to control test process affinity to CPUs
In commit v2.8.0~170 (ENH: Added ctest test options PROCESSORS and RUN_SERIAL, 2009-09-07) CTest learned to track the number of processors allocated to running tests in order to balance it against the desired level of parallelism. Extend this idea by introducing a new `PROCESSOR_AFFINITY` test property to ask that CTest run a test with the CPU affinity mask set. This will allow a set of tests that are running concurrently to use disjoint CPU resources.
Diffstat (limited to 'Source/CTest/cmProcess.cxx')
-rw-r--r--Source/CTest/cmProcess.cxx18
1 files changed, 17 insertions, 1 deletions
diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx
index 09ed0a9..5c9b169 100644
--- a/Source/CTest/cmProcess.cxx
+++ b/Source/CTest/cmProcess.cxx
@@ -83,7 +83,7 @@ void cmProcess::SetCommandArguments(std::vector<std::string> const& args)
this->Arguments = args;
}
-bool cmProcess::StartProcess(uv_loop_t& loop)
+bool cmProcess::StartProcess(uv_loop_t& loop, std::vector<size_t>* affinity)
{
this->ProcessState = cmProcess::State::Error;
if (this->Command.empty()) {
@@ -138,6 +138,22 @@ bool cmProcess::StartProcess(uv_loop_t& loop)
options.stdio_count = 3; // in, out and err
options.exit_cb = &cmProcess::OnExitCB;
options.stdio = stdio;
+#if !defined(CMAKE_USE_SYSTEM_LIBUV)
+ std::vector<char> cpumask;
+ if (affinity && !affinity->empty()) {
+ cpumask.resize(static_cast<size_t>(uv_cpumask_size()), 0);
+ for (auto p : *affinity) {
+ cpumask[p] = 1;
+ }
+ options.cpumask = cpumask.data();
+ options.cpumask_size = cpumask.size();
+ } else {
+ options.cpumask = nullptr;
+ options.cpumask_size = 0;
+ }
+#else
+ static_cast<void>(affinity);
+#endif
status =
uv_read_start(pipe_reader, &cmProcess::OnAllocateCB, &cmProcess::OnReadCB);