hwlocality_distances_get.3 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. .TH "hwlocality_distances_get" 3 "Thu Sep 7 2023" "Version 2.9.3" "Hardware Locality (hwloc)" \" -*- nroff -*-
  2. .ad l
  3. .nh
  4. .SH NAME
  5. hwlocality_distances_get \- Retrieve distances between objects
  6. .SH SYNOPSIS
  7. .br
  8. .PP
  9. .SS "Data Structures"
  10. .in +1c
  11. .ti -1c
  12. .RI "struct \fBhwloc_distances_s\fP"
  13. .br
  14. .in -1c
  15. .SS "Enumerations"
  16. .in +1c
  17. .ti -1c
  18. .RI "enum \fBhwloc_distances_kind_e\fP { \fBHWLOC_DISTANCES_KIND_FROM_OS\fP, \fBHWLOC_DISTANCES_KIND_FROM_USER\fP, \fBHWLOC_DISTANCES_KIND_MEANS_LATENCY\fP, \fBHWLOC_DISTANCES_KIND_MEANS_BANDWIDTH\fP, \fBHWLOC_DISTANCES_KIND_HETEROGENEOUS_TYPES\fP }"
  19. .br
  20. .ti -1c
  21. .RI "enum \fBhwloc_distances_transform_e\fP { \fBHWLOC_DISTANCES_TRANSFORM_REMOVE_NULL\fP, \fBHWLOC_DISTANCES_TRANSFORM_LINKS\fP, \fBHWLOC_DISTANCES_TRANSFORM_MERGE_SWITCH_PORTS\fP, \fBHWLOC_DISTANCES_TRANSFORM_TRANSITIVE_CLOSURE\fP }"
  22. .br
  23. .in -1c
  24. .SS "Functions"
  25. .in +1c
  26. .ti -1c
  27. .RI "int \fBhwloc_distances_get\fP (\fBhwloc_topology_t\fP topology, unsigned *nr, struct \fBhwloc_distances_s\fP **distances, unsigned long kind, unsigned long flags)"
  28. .br
  29. .ti -1c
  30. .RI "int \fBhwloc_distances_get_by_depth\fP (\fBhwloc_topology_t\fP topology, int depth, unsigned *nr, struct \fBhwloc_distances_s\fP **distances, unsigned long kind, unsigned long flags)"
  31. .br
  32. .ti -1c
  33. .RI "int \fBhwloc_distances_get_by_type\fP (\fBhwloc_topology_t\fP topology, \fBhwloc_obj_type_t\fP type, unsigned *nr, struct \fBhwloc_distances_s\fP **distances, unsigned long kind, unsigned long flags)"
  34. .br
  35. .ti -1c
  36. .RI "int \fBhwloc_distances_get_by_name\fP (\fBhwloc_topology_t\fP topology, const char *name, unsigned *nr, struct \fBhwloc_distances_s\fP **distances, unsigned long flags)"
  37. .br
  38. .ti -1c
  39. .RI "const char * \fBhwloc_distances_get_name\fP (\fBhwloc_topology_t\fP topology, struct \fBhwloc_distances_s\fP *distances)"
  40. .br
  41. .ti -1c
  42. .RI "void \fBhwloc_distances_release\fP (\fBhwloc_topology_t\fP topology, struct \fBhwloc_distances_s\fP *distances)"
  43. .br
  44. .ti -1c
  45. .RI "int \fBhwloc_distances_transform\fP (\fBhwloc_topology_t\fP topology, struct \fBhwloc_distances_s\fP *distances, enum \fBhwloc_distances_transform_e\fP transform, void *transform_attr, unsigned long flags)"
  46. .br
  47. .in -1c
  48. .SH "Detailed Description"
  49. .PP
  50. .SH "Enumeration Type Documentation"
  51. .PP
  52. .SS "enum \fBhwloc_distances_kind_e\fP"
  53. .PP
  54. Kinds of distance matrices\&. The \fCkind\fP attribute of struct \fBhwloc_distances_s\fP is a OR'ed set of kinds\&.
  55. .PP
  56. A kind of format HWLOC_DISTANCES_KIND_FROM_* specifies where the distance information comes from, if known\&.
  57. .PP
  58. A kind of format HWLOC_DISTANCES_KIND_MEANS_* specifies whether values are latencies or bandwidths, if applicable\&.
  59. .PP
  60. \fBEnumerator\fP
  61. .in +1c
  62. .TP
  63. \fB\fIHWLOC_DISTANCES_KIND_FROM_OS \fP\fP
  64. These distances were obtained from the operating system or hardware\&.
  65. .TP
  66. \fB\fIHWLOC_DISTANCES_KIND_FROM_USER \fP\fP
  67. These distances were provided by the user\&.
  68. .TP
  69. \fB\fIHWLOC_DISTANCES_KIND_MEANS_LATENCY \fP\fP
  70. Distance values are similar to latencies between objects\&. Values are smaller for closer objects, hence minimal on the diagonal of the matrix (distance between an object and itself)\&. It could also be the number of network hops between objects, etc\&.
  71. .TP
  72. \fB\fIHWLOC_DISTANCES_KIND_MEANS_BANDWIDTH \fP\fP
  73. Distance values are similar to bandwidths between objects\&. Values are higher for closer objects, hence maximal on the diagonal of the matrix (distance between an object and itself)\&. Such values are currently ignored for distance-based grouping\&.
  74. .TP
  75. \fB\fIHWLOC_DISTANCES_KIND_HETEROGENEOUS_TYPES \fP\fP
  76. This distances structure covers objects of different types\&. This may apply to the 'NVLinkBandwidth' structure in presence of a NVSwitch or POWER processor NVLink port\&.
  77. .SS "enum \fBhwloc_distances_transform_e\fP"
  78. .PP
  79. Transformations of distances structures\&.
  80. .PP
  81. \fBEnumerator\fP
  82. .in +1c
  83. .TP
  84. \fB\fIHWLOC_DISTANCES_TRANSFORM_REMOVE_NULL \fP\fP
  85. Remove \fCNULL\fP objects from the distances structure\&. Every object that was replaced with \fCNULL\fP in the \fCobjs\fP array is removed and the \fCvalues\fP array is updated accordingly\&.
  86. .PP
  87. At least \fC2\fP objects must remain, otherwise \fBhwloc_distances_transform()\fP will return \fC-1\fP with \fCerrno\fP set to \fCEINVAL\fP\&.
  88. .PP
  89. \fCkind\fP will be updated with or without \fBHWLOC_DISTANCES_KIND_HETEROGENEOUS_TYPES\fP according to the remaining objects\&.
  90. .TP
  91. \fB\fIHWLOC_DISTANCES_TRANSFORM_LINKS \fP\fP
  92. Replace bandwidth values with a number of links\&. Usually all values will be either \fC0\fP (no link) or \fC1\fP (one link)\&. However some matrices could get larger values if some pairs of peers are connected by different numbers of links\&.
  93. .PP
  94. Values on the diagonal are set to \fC0\fP\&.
  95. .PP
  96. This transformation only applies to bandwidth matrices\&.
  97. .TP
  98. \fB\fIHWLOC_DISTANCES_TRANSFORM_MERGE_SWITCH_PORTS \fP\fP
  99. Merge switches with multiple ports into a single object\&. This currently only applies to NVSwitches where GPUs seem connected to different separate switch ports in the NVLinkBandwidth matrix\&. This transformation will replace all of them with the same port connected to all GPUs\&. Other ports are removed by applying \fBHWLOC_DISTANCES_TRANSFORM_REMOVE_NULL\fP internally\&.
  100. .TP
  101. \fB\fIHWLOC_DISTANCES_TRANSFORM_TRANSITIVE_CLOSURE \fP\fP
  102. Apply a transitive closure to the matrix to connect objects across switches\&. This currently only applies to GPUs and NVSwitches in the NVLinkBandwidth matrix\&. All pairs of GPUs will be reported as directly connected\&.
  103. .SH "Function Documentation"
  104. .PP
  105. .SS "int hwloc_distances_get (\fBhwloc_topology_t\fP topology, unsigned * nr, struct \fBhwloc_distances_s\fP ** distances, unsigned long kind, unsigned long flags)"
  106. .PP
  107. Retrieve distance matrices\&. Retrieve distance matrices from the topology into the \fCdistances\fP array\&.
  108. .PP
  109. \fCflags\fP is currently unused, should be \fC0\fP\&.
  110. .PP
  111. \fCkind\fP serves as a filter\&. If \fC0\fP, all distance matrices are returned\&. If it contains some HWLOC_DISTANCES_KIND_FROM_*, only distance matrices whose kind matches one of these are returned\&. If it contains some HWLOC_DISTANCES_KIND_MEANS_*, only distance matrices whose kind matches one of these are returned\&.
  112. .PP
  113. On input, \fCnr\fP points to the number of distance matrices that may be stored in \fCdistances\fP\&. On output, \fCnr\fP points to the number of distance matrices that were actually found, even if some of them couldn't be stored in \fCdistances\fP\&. Distance matrices that couldn't be stored are ignored, but the function still returns success (\fC0\fP)\&. The caller may find out by comparing the value pointed by \fCnr\fP before and after the function call\&.
  114. .PP
  115. Each distance matrix returned in the \fCdistances\fP array should be released by the caller using \fBhwloc_distances_release()\fP\&.
  116. .PP
  117. \fBReturns\fP
  118. .RS 4
  119. 0 on success, -1 on error\&.
  120. .RE
  121. .PP
  122. .SS "int hwloc_distances_get_by_depth (\fBhwloc_topology_t\fP topology, int depth, unsigned * nr, struct \fBhwloc_distances_s\fP ** distances, unsigned long kind, unsigned long flags)"
  123. .PP
  124. Retrieve distance matrices for object at a specific depth in the topology\&. Identical to \fBhwloc_distances_get()\fP with the additional \fCdepth\fP filter\&.
  125. .PP
  126. \fBReturns\fP
  127. .RS 4
  128. 0 on success, -1 on error\&.
  129. .RE
  130. .PP
  131. .SS "int hwloc_distances_get_by_name (\fBhwloc_topology_t\fP topology, const char * name, unsigned * nr, struct \fBhwloc_distances_s\fP ** distances, unsigned long flags)"
  132. .PP
  133. Retrieve a distance matrix with the given name\&. Usually only one distances structure may match a given name\&.
  134. .PP
  135. The name of the most common structure is 'NUMALatency'\&. Others include 'XGMIBandwidth', 'XGMIHops', 'XeLinkBandwidth', and 'NVLinkBandwidth'\&.
  136. .PP
  137. \fBReturns\fP
  138. .RS 4
  139. 0 on success, -1 on error\&.
  140. .RE
  141. .PP
  142. .SS "int hwloc_distances_get_by_type (\fBhwloc_topology_t\fP topology, \fBhwloc_obj_type_t\fP type, unsigned * nr, struct \fBhwloc_distances_s\fP ** distances, unsigned long kind, unsigned long flags)"
  143. .PP
  144. Retrieve distance matrices for object of a specific type\&. Identical to \fBhwloc_distances_get()\fP with the additional \fCtype\fP filter\&.
  145. .PP
  146. \fBReturns\fP
  147. .RS 4
  148. 0 on success, -1 on error\&.
  149. .RE
  150. .PP
  151. .SS "const char * hwloc_distances_get_name (\fBhwloc_topology_t\fP topology, struct \fBhwloc_distances_s\fP * distances)"
  152. .PP
  153. Get a description of what a distances structure contains\&. For instance 'NUMALatency' for hardware-provided NUMA distances (ACPI SLIT), or \fCNULL\fP if unknown\&.
  154. .PP
  155. \fBReturns\fP
  156. .RS 4
  157. the constant string with the name of the distance structure\&.
  158. .RE
  159. .PP
  160. \fBNote\fP
  161. .RS 4
  162. The returned name should not be freed by the caller, it belongs to the hwloc library\&.
  163. .RE
  164. .PP
  165. .SS "void hwloc_distances_release (\fBhwloc_topology_t\fP topology, struct \fBhwloc_distances_s\fP * distances)"
  166. .PP
  167. Release a distance matrix structure previously returned by \fBhwloc_distances_get()\fP\&.
  168. .PP
  169. \fBNote\fP
  170. .RS 4
  171. This function is not required if the structure is removed with \fBhwloc_distances_release_remove()\fP\&.
  172. .RE
  173. .PP
  174. .SS "int hwloc_distances_transform (\fBhwloc_topology_t\fP topology, struct \fBhwloc_distances_s\fP * distances, enum \fBhwloc_distances_transform_e\fP transform, void * transform_attr, unsigned long flags)"
  175. .PP
  176. Apply a transformation to a distances structure\&. Modify a distances structure that was previously obtained with \fBhwloc_distances_get()\fP or one of its variants\&.
  177. .PP
  178. This modifies the local copy of the distances structures but does not modify the distances information stored inside the topology (retrieved by another call to \fBhwloc_distances_get()\fP or exported to XML)\&. To do so, one should add a new distances structure with same name, kind, objects and values (see \fBAdd distances between objects\fP) and then remove this old one with \fBhwloc_distances_release_remove()\fP\&.
  179. .PP
  180. \fCtransform\fP must be one of the transformations listed in \fBhwloc_distances_transform_e\fP\&.
  181. .PP
  182. These transformations may modify the contents of the \fCobjs\fP or \fCvalues\fP arrays\&.
  183. .PP
  184. \fCtransform_attr\fP must be \fCNULL\fP for now\&.
  185. .PP
  186. \fCflags\fP must be \fC0\fP for now\&.
  187. .PP
  188. \fBReturns\fP
  189. .RS 4
  190. 0 on success, -1 on error for instance if flags are invalid\&.
  191. .RE
  192. .PP
  193. \fBNote\fP
  194. .RS 4
  195. Objects in distances array \fCobjs\fP may be directly modified in place without using \fBhwloc_distances_transform()\fP\&. One may use \fBhwloc_get_obj_with_same_locality()\fP to easily convert between similar objects of different types\&.
  196. .RE
  197. .PP
  198. .SH "Author"
  199. .PP
  200. Generated automatically by Doxygen for Hardware Locality (hwloc) from the source code\&.