1.1 --- a/pprocess.py Sat Sep 06 00:30:13 2008 +0200
1.2 +++ b/pprocess.py Sun May 17 23:29:54 2009 +0200
1.3 @@ -4,7 +4,7 @@
1.4 A simple parallel processing API for Python, inspired somewhat by the thread
1.5 module, slightly less by pypar, and slightly less still by pypvm.
1.6
1.7 -Copyright (C) 2005, 2006, 2007, 2008 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2005, 2006, 2007, 2008, 2009 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This program is free software; you can redistribute it and/or modify it under
1.11 the terms of the GNU Lesser General Public License as published by the Free
1.12 @@ -20,7 +20,7 @@
1.13 with this program. If not, see <http://www.gnu.org/licenses/>.
1.14 """
1.15
1.16 -__version__ = "0.4"
1.17 +__version__ = "0.4.1"
1.18
1.19 import os
1.20 import sys
1.21 @@ -816,7 +816,7 @@
1.22
1.23 # Utility functions.
1.24
1.25 -_cpuinfo_fields = "physical id", "core id"
1.26 +_cpuinfo_fields = "processor", "physical id", "core id"
1.27
1.28 def _get_number_of_cores():
1.29
1.30 @@ -829,18 +829,31 @@
1.31 f = open("/proc/cpuinfo")
1.32 try:
1.33 processors = set()
1.34 - processor = [None, None]
1.35 +
1.36 + # Use the _cpuinfo_field values as "digits" in a larger unique
1.37 + # core identifier.
1.38 +
1.39 + processor = [None, None, None]
1.40
1.41 for line in f.xreadlines():
1.42 for i, field in enumerate(_cpuinfo_fields):
1.43 +
1.44 + # Where the field is found, insert the value into the
1.45 + # appropriate location in the processor identifier.
1.46 +
1.47 if line.startswith(field):
1.48 t = line.split(":")
1.49 processor[i] = int(t[1].strip())
1.50 break
1.51 - else:
1.52 - if line.startswith("processor") and processor[0] is not None:
1.53 - processors.add(tuple(processor))
1.54 - processor = [None, None]
1.55 +
1.56 + # Where a new processor description is started, record the
1.57 + # identifier.
1.58 +
1.59 + if line.startswith("processor") and processor[0] is not None:
1.60 + processors.add(tuple(processor))
1.61 + processor = [None, None, None]
1.62 +
1.63 + # At the end of reading the file, add any unrecorded processors.
1.64
1.65 if processor[0] is not None:
1.66 processors.add(tuple(processor))