From 7a168ab689ed8c0136dfaa393ab8410f0da5078e Mon Sep 17 00:00:00 2001 From: Eirini Koutsaniti Date: Wed, 29 Sep 2021 13:12:06 +0200 Subject: [PATCH 1/3] Fix error when cache associativity information is not available --- reframe/utility/cpuinfo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reframe/utility/cpuinfo.py b/reframe/utility/cpuinfo.py index a770a71c22..45d7d2438d 100644 --- a/reframe/utility/cpuinfo.py +++ b/reframe/utility/cpuinfo.py @@ -195,7 +195,7 @@ def _sysfs_topo(): def _sysctl_topo(): try: - exec_output = osext.run_command('sysctl hw machdep.cpu.cache', + exec_output = osext.run_command('sysctl hw machdep.cpu', check=True) except (FileNotFoundError, SpawnedProcessError): return {} From 38a4170dfb0c5330dc108a76e3df3cc1cc0fea12 Mon Sep 17 00:00:00 2001 From: Eirini Koutsaniti Date: Wed, 29 Sep 2021 13:34:23 +0200 Subject: [PATCH 2/3] Issue warnings for the processor information we cannot detect --- reframe/utility/cpuinfo.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/reframe/utility/cpuinfo.py b/reframe/utility/cpuinfo.py index 45d7d2438d..ec56a5f865 100644 --- a/reframe/utility/cpuinfo.py +++ b/reframe/utility/cpuinfo.py @@ -11,6 +11,7 @@ import reframe.utility.osext as osext from reframe.core.exceptions import SpawnedProcessError +from reframe.core.logging import getlogger def _bits_from_str(mask_s): @@ -206,32 +207,44 @@ def _sysctl_topo(): match = re.search(r'hw\.ncpu: (?P\d+)', exec_output.stdout) if match: num_cpus = int(match.group('num_cpus')) + else: + getlogger().warning(f'not able to detect num_cpus') match = re.search(r'hw\.physicalcpu: (?P\d+)', exec_output.stdout) if match: num_cores = int(match.group('num_cores')) + else: + getlogger().warning(f'not able to detect num_cores') match = re.search(r'hw\.packages: (?P\d+)', exec_output.stdout) if match: num_sockets = int(match.group('num_sockets')) cpuinfo['num_sockets'] = num_sockets + else: + getlogger().warning(f'not able to detect num_sockets') match = re.search(r'hw\.cacheconfig:(?P(\s\d+)*)', exec_output.stdout) if match: cacheconfig = list(map(int, match.group('cacheconfig').split())) + else: + getlogger().warning(f'not able to detect cacheconfig') match = re.search(r'hw\.cachesize:(?P(\s\d+)*)', exec_output.stdout) if match: cachesize = list(map(int, match.group('cachesize').split())) + else: + getlogger().warning(f'not able to detect cachesize') match = re.search(r'hw\.cachelinesize: (?P\d+)', exec_output.stdout) if match: linesize = int(match.group('linesize')) + else: + getlogger().warning(f'not able to detect cache linesize') # index 0 is referring to memory cache_associativity = [0] @@ -242,7 +255,13 @@ def _sysctl_topo(): match = re.search(rf'machdep\.cpu\.cache\.L{i}_associativity: ' rf'(?P\d+)', exec_output.stdout) - assoc = int(match.group('associativity')) if match else 0 + if match: + assoc = int(match.group('associativity')) + else: + assoc = 0 + getlogger().warning(f'not able to detect L{i} cache ' + f'associativity') + cache_associativity.append(assoc) num_cpus_per_socket = num_cpus // num_sockets From 7f2e0bcce6f7ec4705810459e476fc98290614e6 Mon Sep 17 00:00:00 2001 From: Eirini Koutsaniti Date: Thu, 30 Sep 2021 10:26:55 +0200 Subject: [PATCH 3/3] Revert "Issue warnings for the processor information we cannot detect" This reverts commit 38a4170dfb0c5330dc108a76e3df3cc1cc0fea12. --- reframe/utility/cpuinfo.py | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/reframe/utility/cpuinfo.py b/reframe/utility/cpuinfo.py index ec56a5f865..45d7d2438d 100644 --- a/reframe/utility/cpuinfo.py +++ b/reframe/utility/cpuinfo.py @@ -11,7 +11,6 @@ import reframe.utility.osext as osext from reframe.core.exceptions import SpawnedProcessError -from reframe.core.logging import getlogger def _bits_from_str(mask_s): @@ -207,44 +206,32 @@ def _sysctl_topo(): match = re.search(r'hw\.ncpu: (?P\d+)', exec_output.stdout) if match: num_cpus = int(match.group('num_cpus')) - else: - getlogger().warning(f'not able to detect num_cpus') match = re.search(r'hw\.physicalcpu: (?P\d+)', exec_output.stdout) if match: num_cores = int(match.group('num_cores')) - else: - getlogger().warning(f'not able to detect num_cores') match = re.search(r'hw\.packages: (?P\d+)', exec_output.stdout) if match: num_sockets = int(match.group('num_sockets')) cpuinfo['num_sockets'] = num_sockets - else: - getlogger().warning(f'not able to detect num_sockets') match = re.search(r'hw\.cacheconfig:(?P(\s\d+)*)', exec_output.stdout) if match: cacheconfig = list(map(int, match.group('cacheconfig').split())) - else: - getlogger().warning(f'not able to detect cacheconfig') match = re.search(r'hw\.cachesize:(?P(\s\d+)*)', exec_output.stdout) if match: cachesize = list(map(int, match.group('cachesize').split())) - else: - getlogger().warning(f'not able to detect cachesize') match = re.search(r'hw\.cachelinesize: (?P\d+)', exec_output.stdout) if match: linesize = int(match.group('linesize')) - else: - getlogger().warning(f'not able to detect cache linesize') # index 0 is referring to memory cache_associativity = [0] @@ -255,13 +242,7 @@ def _sysctl_topo(): match = re.search(rf'machdep\.cpu\.cache\.L{i}_associativity: ' rf'(?P\d+)', exec_output.stdout) - if match: - assoc = int(match.group('associativity')) - else: - assoc = 0 - getlogger().warning(f'not able to detect L{i} cache ' - f'associativity') - + assoc = int(match.group('associativity')) if match else 0 cache_associativity.append(assoc) num_cpus_per_socket = num_cpus // num_sockets