Group available CPU IDs by the Linux package/core topology, without adding unavailable siblings.
(cpus)
| 186 | |
| 187 | |
| 188 | def physical_cpu_groups(cpus): |
| 189 | """Group available CPU IDs by the Linux package/core topology, without adding unavailable siblings.""" |
| 190 | groups = {} |
| 191 | for cpu in sorted(cpus): |
| 192 | topology = f"/sys/devices/system/cpu/cpu{cpu}/topology" |
| 193 | try: |
| 194 | with open(f"{topology}/physical_package_id") as handle: |
| 195 | package = int(handle.read()) |
| 196 | with open(f"{topology}/core_id") as handle: |
| 197 | core = int(handle.read()) |
| 198 | except (OSError, ValueError) as error: |
| 199 | raise ValueError("Reflow physical CPU placement requires readable Linux CPU topology") from error |
| 200 | groups.setdefault((package, core), []).append(cpu) |
| 201 | return list(groups.values()) |
| 202 | |
| 203 | |
| 204 | def partition_physical_cpus(cpus, ranks, position): |
no test coverage detected