[cmake-developers] Fixing ProcessorCount.cmake

David Cole david.cole at kitware.com
Tue Nov 9 05:45:19 EST 2010


On Mon, Nov 8, 2010 at 3:46 PM, Bill Hoffman <bill.hoffman at kitware.com> wrote:
> On 11/8/2010 3:30 PM, Rolf Eike Beer wrote:
>>
>> Am Montag, 8. November 2010 schrieb Bill Hoffman:
>>>
>>> On 11/8/2010 1:55 PM, Rolf Eike Beer wrote:
>>>>
>>>> Am Montag, 8. November 2010 schrieb David Cole:
>>>>>
>>>>> Hi Rolf,
>>>>>
>>>>> Can you update to a CMake based on 'next' and try the commit I made
>>>>> this
>>>>> morning on a QNX machine? (based on your patch, thank you for that...)
>>>>
>>>> Still needs some tweak, as the output is:
>>>>
>>>> getconf: Can't find _NPROCESSORS_ONLN
>>>> ProcessorCount: using getconf '/usr/bin/getconf'
>>>> ProcessorCount: using pidin '/bin/pidin'
>>>> processor_count='1'
>>>>
>>>> Patch attached.
>>>>
>>>> Eike
>>>
>>> I wonder if we could create a test for this that called the
>>> SystemInformation class and compared its results with this script.  I
>>> bet it would fix bugs in both the script and SystemInformation.
>>
>> It would show up for sure places where at one place this is divided into
>> physical and logical cores and just "cpus" on the other hand.
>>
> On my machine I get this:
>
>   CMake.ProcessorCount
>
> 180: ProcessorCount: using environment variable
> 180: processor_count='4'
>
>  kwsys.testSystemInformation
>
> 11: GetNumberOfLogicalCPU: 1
> 11: GetNumberOfPhysicalCPU: 4
>
> So, if we had a test that just ran:
>  kwsys.testSystemInformation
>
> And pulled out the GetNumberOfPhysicalCPU value and did a compare, they
> "should" be consistent.  If they are not, then one of them will need
> fixing...
>
> -Bill
>
>
> _______________________________________________
> cmake-developers mailing list
> cmake-developers at cmake.org
> http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
>

How can this output:

  11: GetNumberOfLogicalCPU: 1
  11: GetNumberOfPhysicalCPU: 4

...be correct? I would think the number of logical cpus should be >=
number of physical cpus... Maybe I'm not understanding something
fully. Does anyone have a reasonable explanation of why this is
correct? Or is it simply incorrect?


The ProcessorCount module is intended for determining how high a
number N it is reasonable to attempt to use for:
  make -j N
  ctest -j N
  set(CTEST_BUILD_FLAGS -j${N})
  ctest_test(... PARALLEL_LEVEL ${N})

First, I would like to make sure we get the ProcessorCount module
reasonably correct on all the platforms that the CMake community cares
about.

Then, secondly, I think the SystemInformation output should be
explainable or self-consistent, before we decide which numbers to
compare between the two different methods.

Thirdly, it would be a good idea to do the comparison and see if there
are differences on the dashboard machines.

Fourthly, (lastly?), once they are consistent everywhere we care
about, maybe we should consider simply building SystemInformation into
a CMake built-in command, so that we can access the information
without doing an execute_process from the ProcessorCount module...


Today's results (before doing any work on SystemInformation at all):

http://www.cdash.org/CDash/queryTests.php?project=CMake&date=&filtercount=1&showfilters=1&field1=testname/string&compare1=61&value1=CMake.ProcessorCount


Cheers,
David


More information about the cmake-developers mailing list