hwlocality_cpukinds.3 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. .TH "hwlocality_cpukinds" 3 "Thu Sep 7 2023" "Version 2.9.3" "Hardware Locality (hwloc)" \" -*- nroff -*-
  2. .ad l
  3. .nh
  4. .SH NAME
  5. hwlocality_cpukinds \- Kinds of CPU cores
  6. .SH SYNOPSIS
  7. .br
  8. .PP
  9. .SS "Functions"
  10. .in +1c
  11. .ti -1c
  12. .RI "int \fBhwloc_cpukinds_get_nr\fP (\fBhwloc_topology_t\fP topology, unsigned long flags)"
  13. .br
  14. .ti -1c
  15. .RI "int \fBhwloc_cpukinds_get_by_cpuset\fP (\fBhwloc_topology_t\fP topology, \fBhwloc_const_bitmap_t\fP cpuset, unsigned long flags)"
  16. .br
  17. .ti -1c
  18. .RI "int \fBhwloc_cpukinds_get_info\fP (\fBhwloc_topology_t\fP topology, unsigned kind_index, \fBhwloc_bitmap_t\fP cpuset, int *efficiency, unsigned *nr_infos, struct \fBhwloc_info_s\fP **infos, unsigned long flags)"
  19. .br
  20. .ti -1c
  21. .RI "int \fBhwloc_cpukinds_register\fP (\fBhwloc_topology_t\fP topology, \fBhwloc_bitmap_t\fP cpuset, int forced_efficiency, unsigned nr_infos, struct \fBhwloc_info_s\fP *infos, unsigned long flags)"
  22. .br
  23. .in -1c
  24. .SH "Detailed Description"
  25. .PP
  26. Platforms with heterogeneous CPUs may have some cores with different features or frequencies\&. This API exposes identical PUs in sets called CPU kinds\&. Each PU of the topology may only be in a single kind\&.
  27. .PP
  28. The number of kinds may be obtained with \fBhwloc_cpukinds_get_nr()\fP\&. If the platform is homogeneous, there may be a single kind with all PUs\&. If the platform or operating system does not expose any information about CPU cores, there may be no kind at all\&.
  29. .PP
  30. The index of the kind that describes a given CPU set (if any, and not partially) may be obtained with \fBhwloc_cpukinds_get_by_cpuset()\fP\&.
  31. .PP
  32. From the index of a kind, it is possible to retrieve information with \fBhwloc_cpukinds_get_info()\fP: an abstracted efficiency value, and an array of info attributes (for instance the 'CoreType' and 'FrequencyMaxMHz', see \fBCPU Kinds\fP)\&.
  33. .PP
  34. A higher efficiency value means greater intrinsic performance (and possibly less performance/power efficiency)\&. Kinds with lower efficiency values are ranked first: Passing 0 as \fCkind_index\fP to \fBhwloc_cpukinds_get_info()\fP will return information about the CPU kind with lower performance but higher energy-efficiency\&. Higher \fCkind_index\fP values would rather return information about power-hungry high-performance cores\&.
  35. .PP
  36. When available, efficiency values are gathered from the operating system\&. If so, \fCcpukind_efficiency\fP is set in the struct \fBhwloc_topology_discovery_support\fP array\&. This is currently available on Windows 10, Mac OS X (Darwin), and on some Linux platforms where core 'capacity' is exposed in sysfs\&.
  37. .PP
  38. If the operating system does not expose core efficiencies natively, hwloc tries to compute efficiencies by comparing CPU kinds using frequencies (on ARM), or core types and frequencies (on other architectures)\&. The environment variable HWLOC_CPUKINDS_RANKING may be used to change this heuristics, see \fBEnvironment Variables\fP\&.
  39. .PP
  40. If hwloc fails to rank any kind, for instance because the operating system does not expose efficiencies and core frequencies, all kinds will have an unknown efficiency (\fC-1\fP), and they are not indexed/ordered in any specific way\&.
  41. .SH "Function Documentation"
  42. .PP
  43. .SS "int hwloc_cpukinds_get_by_cpuset (\fBhwloc_topology_t\fP topology, \fBhwloc_const_bitmap_t\fP cpuset, unsigned long flags)"
  44. .PP
  45. Get the index of the CPU kind that contains CPUs listed in \fCcpuset\fP\&. \fCflags\fP must be \fC0\fP for now\&.
  46. .PP
  47. \fBReturns\fP
  48. .RS 4
  49. The index of the CPU kind (positive integer or 0) on success\&.
  50. .PP
  51. \fC-1\fP with \fCerrno\fP set to \fCEXDEV\fP if \fCcpuset\fP is only partially included in the some kind\&.
  52. .PP
  53. \fC-1\fP with \fCerrno\fP set to \fCENOENT\fP if \fCcpuset\fP is not included in any kind, even partially\&.
  54. .PP
  55. \fC-1\fP with \fCerrno\fP set to \fCEINVAL\fP if parameters are invalid\&.
  56. .RE
  57. .PP
  58. .SS "int hwloc_cpukinds_get_info (\fBhwloc_topology_t\fP topology, unsigned kind_index, \fBhwloc_bitmap_t\fP cpuset, int * efficiency, unsigned * nr_infos, struct \fBhwloc_info_s\fP ** infos, unsigned long flags)"
  59. .PP
  60. Get the CPU set and infos about a CPU kind in the topology\&. \fCkind_index\fP identifies one kind of CPU between 0 and the number of kinds returned by \fBhwloc_cpukinds_get_nr()\fP minus 1\&.
  61. .PP
  62. If not \fCNULL\fP, the bitmap \fCcpuset\fP will be filled with the set of PUs of this kind\&.
  63. .PP
  64. The integer pointed by \fCefficiency\fP, if not \fCNULL\fP will, be filled with the ranking of this kind of CPU in term of efficiency (see above)\&. It ranges from \fC0\fP to the number of kinds (as reported by \fBhwloc_cpukinds_get_nr()\fP) minus 1\&.
  65. .PP
  66. Kinds with lower efficiency are reported first\&.
  67. .PP
  68. If there is a single kind in the topology, its efficiency \fC0\fP\&. If the efficiency of some kinds of cores is unknown, the efficiency of all kinds is set to \fC-1\fP, and kinds are reported in no specific order\&.
  69. .PP
  70. The array of info attributes (for instance the 'CoreType', 'FrequencyMaxMHz' or 'FrequencyBaseMHz', see \fBCPU Kinds\fP) and its length are returned in \fCinfos\fP or \fCnr_infos\fP\&. The array belongs to the topology, it should not be freed or modified\&.
  71. .PP
  72. If \fCnr_infos\fP or \fCinfos\fP is \fCNULL\fP, no info is returned\&.
  73. .PP
  74. \fCflags\fP must be \fC0\fP for now\&.
  75. .PP
  76. \fBReturns\fP
  77. .RS 4
  78. \fC0\fP on success\&.
  79. .PP
  80. \fC-1\fP with \fCerrno\fP set to \fCENOENT\fP if \fCkind_index\fP does not match any CPU kind\&.
  81. .PP
  82. \fC-1\fP with \fCerrno\fP set to \fCEINVAL\fP if parameters are invalid\&.
  83. .RE
  84. .PP
  85. .SS "int hwloc_cpukinds_get_nr (\fBhwloc_topology_t\fP topology, unsigned long flags)"
  86. .PP
  87. Get the number of different kinds of CPU cores in the topology\&. \fCflags\fP must be \fC0\fP for now\&.
  88. .PP
  89. \fBReturns\fP
  90. .RS 4
  91. The number of CPU kinds (positive integer) on success\&.
  92. .PP
  93. \fC0\fP if no information about kinds was found\&.
  94. .PP
  95. \fC-1\fP with \fCerrno\fP set to \fCEINVAL\fP if \fCflags\fP is invalid\&.
  96. .RE
  97. .PP
  98. .SS "int hwloc_cpukinds_register (\fBhwloc_topology_t\fP topology, \fBhwloc_bitmap_t\fP cpuset, int forced_efficiency, unsigned nr_infos, struct \fBhwloc_info_s\fP * infos, unsigned long flags)"
  99. .PP
  100. Register a kind of CPU in the topology\&. Mark the PUs listed in \fCcpuset\fP as being of the same kind with respect to the given attributes\&.
  101. .PP
  102. \fCforced_efficiency\fP should be \fC-1\fP if unknown\&. Otherwise it is an abstracted efficiency value to enforce the ranking of all kinds if all of them have valid (and different) efficiencies\&.
  103. .PP
  104. The array \fCinfos\fP of size \fCnr_infos\fP may be used to provide info names and values describing this kind of PUs\&.
  105. .PP
  106. \fCflags\fP must be \fC0\fP for now\&.
  107. .PP
  108. Parameters \fCcpuset\fP and \fCinfos\fP will be duplicated internally, the caller is responsible for freeing them\&.
  109. .PP
  110. If \fCcpuset\fP overlaps with some existing kinds, those might get modified or split\&. For instance if existing kind A contains PUs 0 and 1, and one registers another kind for PU 1 and 2, there will be 3 resulting kinds: existing kind A is restricted to only PU 0; new kind B contains only PU 1 and combines information from A and from the newly-registered kind; new kind C contains only PU 2 and only gets information from the newly-registered kind\&.
  111. .PP
  112. \fBNote\fP
  113. .RS 4
  114. The efficiency \fCforced_efficiency\fP provided to this function may be different from the one reported later by \fBhwloc_cpukinds_get_info()\fP because hwloc will scale efficiency values down to between 0 and the number of kinds minus 1\&.
  115. .RE
  116. .PP
  117. \fBReturns\fP
  118. .RS 4
  119. \fC0\fP on success\&.
  120. .PP
  121. \fC-1\fP with \fCerrno\fP set to \fCEINVAL\fP if some parameters are invalid, for instance if \fCcpuset\fP is \fCNULL\fP or empty\&.
  122. .RE
  123. .PP
  124. .SH "Author"
  125. .PP
  126. Generated automatically by Doxygen for Hardware Locality (hwloc) from the source code\&.