CMake/Tests/CMakeLib/testAffinity.cxx
Brad King 6be53c6695 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.
2018-03-05 09:21:32 -05:00

19 lines
498 B
C++

/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmAffinity.h"
#include <cstddef>
#include <iostream>
#include <set>
int main()
{
std::set<size_t> cpus = cmAffinity::GetProcessorsAvailable();
if (!cpus.empty()) {
std::cout << "CPU affinity mask count is '" << cpus.size() << "'.\n";
} else {
std::cout << "CPU affinity not supported on this platform.\n";
}
return 0;
}