diff options
author | Marat Dukhan <maratek@gmail.com> | 2018-03-18 21:36:39 +0300 |
---|---|---|
committer | Marat Dukhan <maratek@gmail.com> | 2018-03-18 21:36:39 +0300 |
commit | 4d376c36d5d430c3d558b992487c101df168e029 (patch) | |
tree | 509f238a83eeb6419661f2d1b30a5bb12b456976 /include | |
parent | 90883359aa0b14851291022de85850bd3d9fed60 (diff) |
Expose core clusters on x86
Diffstat (limited to 'include')
-rw-r--r-- | include/cpuinfo.h | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/include/cpuinfo.h b/include/cpuinfo.h index bdfd0f0..b02104e 100644 --- a/include/cpuinfo.h +++ b/include/cpuinfo.h @@ -420,6 +420,8 @@ struct cpuinfo_processor { uint32_t smt_id; /** Core containing this logical processor */ const struct cpuinfo_core* core; + /** Cluster of cores containing this logical processor */ + const struct cpuinfo_cluster* cluster; /** Physical package containing this logical processor */ const struct cpuinfo_package* package; #if defined(__linux__) @@ -458,13 +460,15 @@ struct cpuinfo_processor { }; struct cpuinfo_core { - /** Index of the first logical processor on this core */ + /** Index of the first logical processor on this core. */ uint32_t processor_start; /** Number of logical processors on this core */ uint32_t processor_count; /** Core ID within a package */ uint32_t core_id; - /** Physical package containing this core */ + /** Cluster containing this core */ + const struct cpuinfo_cluster* cluster; + /** Physical package containing this core. */ const struct cpuinfo_package* package; /** Vendor of the CPU microarchitecture for this core */ enum cpuinfo_vendor vendor; @@ -481,6 +485,34 @@ struct cpuinfo_core { uint64_t frequency; }; +struct cpuinfo_cluster { + /** Index of the first logical processor in the cluster */ + uint32_t processor_start; + /** Number of logical processors in the cluster */ + uint32_t processor_count; + /** Index of the first core in the cluster */ + uint32_t core_start; + /** Number of cores on the cluster */ + uint32_t core_count; + /** Cluster ID within a package */ + uint32_t cluster_id; + /** Physical package containing the cluster */ + const struct cpuinfo_package* package; + /** CPU microarchitecture vendor of the cores in the cluster */ + enum cpuinfo_vendor vendor; + /** CPU microarchitecture of the cores in the cluster */ + enum cpuinfo_uarch uarch; +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + /** Value of CPUID leaf 1 EAX register of the cores in the cluster */ + uint32_t cpuid; +#elif CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 + /** Value of Main ID Register (MIDR) of the cores in the cluster */ + uint32_t midr; +#endif + /** Clock rate (non-Turbo) of the cores in the cluster, in Hz */ + uint64_t frequency; +}; + #define CPUINFO_PACKAGE_NAME_MAX 48 #define CPUINFO_GPU_NAME_MAX 64 @@ -499,6 +531,10 @@ struct cpuinfo_package { uint32_t core_start; /** Number of cores on this physical package */ uint32_t core_count; + /** Index of the first cluster of cores on this physical package */ + uint32_t cluster_start; + /** Number of clusters of cores on this physical package */ + uint32_t cluster_count; }; #ifdef __cplusplus @@ -1570,6 +1606,7 @@ static inline bool cpuinfo_has_arm_crc32(void) { const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_processors(void); const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_cores(void); +const struct cpuinfo_cluster* CPUINFO_ABI cpuinfo_get_clusters(void); const struct cpuinfo_package* CPUINFO_ABI cpuinfo_get_packages(void); const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1i_caches(void); const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1d_caches(void); @@ -1579,6 +1616,7 @@ const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l4_caches(void); const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_processor(uint32_t index); const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_core(uint32_t index); +const struct cpuinfo_cluster* CPUINFO_ABI cpuinfo_get_cluster(uint32_t index); const struct cpuinfo_package* CPUINFO_ABI cpuinfo_get_package(uint32_t index); const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1i_cache(uint32_t index); const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1d_cache(uint32_t index); @@ -1588,6 +1626,7 @@ const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l4_cache(uint32_t index); uint32_t CPUINFO_ABI cpuinfo_get_processors_count(void); uint32_t CPUINFO_ABI cpuinfo_get_cores_count(void); +uint32_t CPUINFO_ABI cpuinfo_get_clusters_count(void); uint32_t CPUINFO_ABI cpuinfo_get_packages_count(void); uint32_t CPUINFO_ABI cpuinfo_get_l1i_caches_count(void); uint32_t CPUINFO_ABI cpuinfo_get_l1d_caches_count(void); |