|
|
|||
File indexing completed on 2026-09-16 09:13:58
0001 /* 0002 * SPDX-License-Identifier: BSD-3-Clause 0003 * Copyright © 2020-2021 Inria. All rights reserved. 0004 * See COPYING in top-level directory. 0005 */ 0006 0007 /** \file 0008 * \brief Kinds of CPU cores. 0009 */ 0010 0011 #ifndef HWLOC_CPUKINDS_H 0012 #define HWLOC_CPUKINDS_H 0013 0014 #include "hwloc.h" 0015 0016 #ifdef __cplusplus 0017 extern "C" { 0018 #elif 0 0019 } 0020 #endif 0021 0022 /** \defgroup hwlocality_cpukinds Kinds of CPU cores 0023 * 0024 * Platforms with heterogeneous CPUs may have some cores with 0025 * different features or frequencies. 0026 * This API exposes identical PUs in sets called CPU kinds. 0027 * Each PU of the topology may only be in a single kind. 0028 * 0029 * The number of kinds may be obtained with hwloc_cpukinds_get_nr(). 0030 * If the platform is homogeneous, there may be a single kind 0031 * with all PUs. 0032 * If the platform or operating system does not expose any 0033 * information about CPU cores, there may be no kind at all. 0034 * 0035 * The index of the kind that describes a given CPU set 0036 * (if any, and not partially) 0037 * may be obtained with hwloc_cpukinds_get_by_cpuset(). 0038 * 0039 * From the index of a kind, it is possible to retrieve information 0040 * with hwloc_cpukinds_get_info(): 0041 * an abstracted efficiency value, 0042 * and an array of info attributes 0043 * (for instance the "CoreType" and "FrequencyMaxMHz", 0044 * see \ref topoattrs_cpukinds). 0045 * 0046 * A higher efficiency value means greater intrinsic performance 0047 * (and possibly less performance/power efficiency). 0048 * Kinds with lower efficiency values are ranked first: 0049 * Passing 0 as \p kind_index to hwloc_cpukinds_get_info() will 0050 * return information about the CPU kind with lower performance 0051 * but higher energy-efficiency. 0052 * Higher \p kind_index values would rather return information 0053 * about power-hungry high-performance cores. 0054 * 0055 * When available, efficiency values are gathered from the operating system. 0056 * If so, \p cpukind_efficiency is set in the struct hwloc_topology_discovery_support array. 0057 * This is currently available on Windows 10, Mac OS X (Darwin), 0058 * and on some Linux platforms where core "capacity" is exposed in sysfs. 0059 * 0060 * If the operating system does not expose core efficiencies natively, 0061 * hwloc tries to compute efficiencies by comparing CPU kinds using 0062 * frequencies (on ARM), or core types and frequencies (on other architectures). 0063 * The environment variable HWLOC_CPUKINDS_RANKING may be used 0064 * to change this heuristics, see \ref envvar_heuristics. 0065 * 0066 * If hwloc fails to rank any kind, for instance because the operating 0067 * system does not expose efficiencies and core frequencies, 0068 * all kinds will have an unknown efficiency (\c -1), 0069 * and they are not indexed/ordered in any specific way. 0070 * 0071 * @{ 0072 */ 0073 0074 /** \brief Get the number of different kinds of CPU cores in the topology. 0075 * 0076 * \p flags must be \c 0 for now. 0077 * 0078 * \return The number of CPU kinds (positive integer) on success. 0079 * \return \c 0 if no information about kinds was found. 0080 * \return \c -1 with \p errno set to \c EINVAL if \p flags is invalid. 0081 */ 0082 HWLOC_DECLSPEC int 0083 hwloc_cpukinds_get_nr(hwloc_topology_t topology, 0084 unsigned long flags); 0085 0086 /** \brief Get the index of the CPU kind that contains CPUs listed in \p cpuset. 0087 * 0088 * \p flags must be \c 0 for now. 0089 * 0090 * \return The index of the CPU kind (positive integer or 0) on success. 0091 * \return \c -1 with \p errno set to \c EXDEV if \p cpuset is 0092 * only partially included in the some kind. 0093 * \return \c -1 with \p errno set to \c ENOENT if \p cpuset is 0094 * not included in any kind, even partially. 0095 * \return \c -1 with \p errno set to \c EINVAL if parameters are invalid. 0096 */ 0097 HWLOC_DECLSPEC int 0098 hwloc_cpukinds_get_by_cpuset(hwloc_topology_t topology, 0099 hwloc_const_bitmap_t cpuset, 0100 unsigned long flags); 0101 0102 /** \brief Get the CPU set and infos about a CPU kind in the topology. 0103 * 0104 * \p kind_index identifies one kind of CPU between 0 and the number 0105 * of kinds returned by hwloc_cpukinds_get_nr() minus 1. 0106 * 0107 * If not \c NULL, the bitmap \p cpuset will be filled with 0108 * the set of PUs of this kind. 0109 * 0110 * The integer pointed by \p efficiency, if not \c NULL will, be filled 0111 * with the ranking of this kind of CPU in term of efficiency (see above). 0112 * It ranges from \c 0 to the number of kinds 0113 * (as reported by hwloc_cpukinds_get_nr()) minus 1. 0114 * 0115 * Kinds with lower efficiency are reported first. 0116 * 0117 * If there is a single kind in the topology, its efficiency \c 0. 0118 * If the efficiency of some kinds of cores is unknown, 0119 * the efficiency of all kinds is set to \c -1, 0120 * and kinds are reported in no specific order. 0121 * 0122 * The array of info attributes (for instance the "CoreType", 0123 * "FrequencyMaxMHz" or "FrequencyBaseMHz", see \ref topoattrs_cpukinds) 0124 * and its length are returned in \p infos or \p nr_infos. 0125 * The array belongs to the topology, it should not be freed or modified. 0126 * 0127 * If \p nr_infos or \p infos is \c NULL, no info is returned. 0128 * 0129 * \p flags must be \c 0 for now. 0130 * 0131 * \return \c 0 on success. 0132 * \return \c -1 with \p errno set to \c ENOENT if \p kind_index does not match any CPU kind. 0133 * \return \c -1 with \p errno set to \c EINVAL if parameters are invalid. 0134 */ 0135 HWLOC_DECLSPEC int 0136 hwloc_cpukinds_get_info(hwloc_topology_t topology, 0137 unsigned kind_index, 0138 hwloc_bitmap_t cpuset, 0139 int *efficiency, 0140 unsigned *nr_infos, struct hwloc_info_s **infos, 0141 unsigned long flags); 0142 0143 /** \brief Register a kind of CPU in the topology. 0144 * 0145 * Mark the PUs listed in \p cpuset as being of the same kind 0146 * with respect to the given attributes. 0147 * 0148 * \p forced_efficiency should be \c -1 if unknown. 0149 * Otherwise it is an abstracted efficiency value to enforce 0150 * the ranking of all kinds if all of them have valid (and 0151 * different) efficiencies. 0152 * 0153 * The array \p infos of size \p nr_infos may be used to provide 0154 * info names and values describing this kind of PUs. 0155 * 0156 * \p flags must be \c 0 for now. 0157 * 0158 * Parameters \p cpuset and \p infos will be duplicated internally, 0159 * the caller is responsible for freeing them. 0160 * 0161 * If \p cpuset overlaps with some existing kinds, those might get 0162 * modified or split. For instance if existing kind A contains 0163 * PUs 0 and 1, and one registers another kind for PU 1 and 2, 0164 * there will be 3 resulting kinds: 0165 * existing kind A is restricted to only PU 0; 0166 * new kind B contains only PU 1 and combines information from A 0167 * and from the newly-registered kind; 0168 * new kind C contains only PU 2 and only gets information from 0169 * the newly-registered kind. 0170 * 0171 * \note The efficiency \p forced_efficiency provided to this function 0172 * may be different from the one reported later by hwloc_cpukinds_get_info() 0173 * because hwloc will scale efficiency values down to 0174 * between 0 and the number of kinds minus 1. 0175 * 0176 * \return \c 0 on success. 0177 * \return \c -1 with \p errno set to \c EINVAL if some parameters are invalid, 0178 * for instance if \p cpuset is \c NULL or empty. 0179 */ 0180 HWLOC_DECLSPEC int 0181 hwloc_cpukinds_register(hwloc_topology_t topology, 0182 hwloc_bitmap_t cpuset, 0183 int forced_efficiency, 0184 unsigned nr_infos, struct hwloc_info_s *infos, 0185 unsigned long flags); 0186 0187 /** @} */ 0188 0189 #ifdef __cplusplus 0190 } /* extern "C" */ 0191 #endif 0192 0193 0194 #endif /* HWLOC_CPUKINDS_H */
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|