pytorch / cpuinfo

CPU INFOrmation library (x86/x86-64/ARM/ARM64, Linux/Windows/Android/macOS/iOS)
BSD 2-Clause "Simplified" License
962 stars 306 forks source link

Use cluster_cpus_list to detect clusters for ARM #240

Open prashanthswami opened 2 months ago

prashanthswami commented 2 months ago

On newer kernels (6.x+) a separate topology node exists to express the list of cpus associated with each cluster. The cluster topology node explicitly refers to cores that share some resources (e.g. cache) as opposed to 'core_siblings', which only indicate they are on the same physical package.

This distinction is relevant on 6.x, where some devices may have all their cores on a single physical package but cores do not all share the same resources on that package. In these cases, the existing logic incorrectly reports that there is a single cluster (because all cores are siblings), even though not all cores share the same resources.

Test: Verified on ARM64 Android device that has multiple clusters, where core_siblings reports all cores are siblings. Test: Added mock hardware tests, verified pass on ARM64 hardware.