Open MPI logo

Portable Hardware Locality (hwloc) Documentation: v2.2.0

  |   Home   |   Support   |   FAQ   |  
distances.h
1 /*
2  * Copyright © 2010-2019 Inria. All rights reserved.
3  * See COPYING in top-level directory.
4  */
5 
10 #ifndef HWLOC_DISTANCES_H
11 #define HWLOC_DISTANCES_H
12 
13 #ifndef HWLOC_H
14 #error Please include the main hwloc.h instead
15 #endif
16 
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #elif 0
21 }
22 #endif
23 
24 
42  unsigned nbobjs;
48  unsigned long kind;
49  hwloc_uint64_t *values;
54 };
55 
76 
91 
96 };
97 
121 HWLOC_DECLSPEC int
123  unsigned *nr, struct hwloc_distances_s **distances,
124  unsigned long kind, unsigned long flags);
125 
130 HWLOC_DECLSPEC int
132  unsigned *nr, struct hwloc_distances_s **distances,
133  unsigned long kind, unsigned long flags);
134 
139 HWLOC_DECLSPEC int
141  unsigned *nr, struct hwloc_distances_s **distances,
142  unsigned long kind, unsigned long flags);
143 
148 HWLOC_DECLSPEC int
149 hwloc_distances_get_by_name(hwloc_topology_t topology, const char *name,
150  unsigned *nr, struct hwloc_distances_s **distances,
151  unsigned long flags);
152 
158 HWLOC_DECLSPEC const char *
159 hwloc_distances_get_name(hwloc_topology_t topology, struct hwloc_distances_s *distances);
160 
165 HWLOC_DECLSPEC void
166 hwloc_distances_release(hwloc_topology_t topology, struct hwloc_distances_s *distances);
167 
180 static __hwloc_inline int
182 {
183  unsigned i;
184  for(i=0; i<distances->nbobjs; i++)
185  if (distances->objs[i] == obj)
186  return (int)i;
187  return -1;
188 }
189 
197 static __hwloc_inline int
199  hwloc_obj_t obj1, hwloc_obj_t obj2,
200  hwloc_uint64_t *value1to2, hwloc_uint64_t *value2to1)
201 {
202  int i1 = hwloc_distances_obj_index(distances, obj1);
203  int i2 = hwloc_distances_obj_index(distances, obj2);
204  if (i1 < 0 || i2 < 0)
205  return -1;
206  *value1to2 = distances->values[i1 * distances->nbobjs + i2];
207  *value2to1 = distances->values[i2 * distances->nbobjs + i1];
208  return 0;
209 }
210 
231 };
232 
247 HWLOC_DECLSPEC int hwloc_distances_add(hwloc_topology_t topology,
248  unsigned nbobjs, hwloc_obj_t *objs, hwloc_uint64_t *values,
249  unsigned long kind, unsigned long flags);
250 
259 HWLOC_DECLSPEC int hwloc_distances_remove(hwloc_topology_t topology);
260 
265 HWLOC_DECLSPEC int hwloc_distances_remove_by_depth(hwloc_topology_t topology, int depth);
266 
271 static __hwloc_inline int
273 {
274  int depth = hwloc_get_type_depth(topology, type);
275  if (depth == HWLOC_TYPE_DEPTH_UNKNOWN || depth == HWLOC_TYPE_DEPTH_MULTIPLE)
276  return 0;
277  return hwloc_distances_remove_by_depth(topology, depth);
278 }
279 
284 HWLOC_DECLSPEC int hwloc_distances_release_remove(hwloc_topology_t topology, struct hwloc_distances_s *distances);
285 
289 #ifdef __cplusplus
290 } /* extern "C" */
291 #endif
292 
293 
294 #endif /* HWLOC_DISTANCES_H */
@ HWLOC_DISTANCES_ADD_FLAG_GROUP_INACCURATE
If grouping, consider the distance values as inaccurate and relax the comparisons during the grouping...
Definition: distances.h:230
@ HWLOC_DISTANCES_KIND_HETEROGENEOUS_TYPES
This distances structure covers objects of different types.
Definition: distances.h:95
@ HWLOC_DISTANCES_ADD_FLAG_GROUP
Try to group objects based on the newly provided distance information.
Definition: distances.h:224
hwloc_distances_kind_e
Kinds of distance matrices.
Definition: distances.h:67
int hwloc_get_type_depth(hwloc_topology_t topology, hwloc_obj_type_t type)
Returns the depth of objects of type type.
int hwloc_distances_release_remove(hwloc_topology_t topology, struct hwloc_distances_s *distances)
Release and remove the given distance matrice from the topology.
@ HWLOC_TYPE_DEPTH_MULTIPLE
Objects of given type exist at different depth in the topology (only for Groups).
Definition: hwloc.h:809
static int hwloc_distances_obj_pair_values(struct hwloc_distances_s *distances, hwloc_obj_t obj1, hwloc_obj_t obj2, hwloc_uint64_t *value1to2, hwloc_uint64_t *value2to1)
Find the values between two objects in a distance matrices.
Definition: distances.h:198
hwloc_obj_t * objs
Array of objects described by the distance matrix. These objects are not in any particular order,...
Definition: distances.h:43
hwloc_distances_add_flag_e
Flags for adding a new distances to a topology.
Definition: distances.h:220
static int hwloc_distances_obj_index(struct hwloc_distances_s *distances, hwloc_obj_t obj)
Find the index of an object in a distances structure.
Definition: distances.h:181
Matrix of distances between a set of objects.
Definition: distances.h:41
int hwloc_distances_get(hwloc_topology_t topology, unsigned *nr, struct hwloc_distances_s **distances, unsigned long kind, unsigned long flags)
Retrieve distance matrices.
void hwloc_distances_release(hwloc_topology_t topology, struct hwloc_distances_s *distances)
Release a distance matrix structure previously returned by hwloc_distances_get().
@ HWLOC_DISTANCES_KIND_MEANS_LATENCY
Distance values are similar to latencies between objects. Values are smaller for closer objects,...
Definition: distances.h:83
struct hwloc_topology * hwloc_topology_t
Topology context.
Definition: hwloc.h:678
unsigned long kind
OR'ed set of hwloc_distances_kind_e.
Definition: distances.h:48
int hwloc_distances_get_by_type(hwloc_topology_t topology, hwloc_obj_type_t type, unsigned *nr, struct hwloc_distances_s **distances, unsigned long kind, unsigned long flags)
Retrieve distance matrices for object of a specific type.
@ HWLOC_DISTANCES_KIND_FROM_OS
These distances were obtained from the operating system or hardware.
Definition: distances.h:71
unsigned nbobjs
Number of objects described by the distance matrix.
Definition: distances.h:42
int hwloc_distances_add(hwloc_topology_t topology, unsigned nbobjs, hwloc_obj_t *objs, hwloc_uint64_t *values, unsigned long kind, unsigned long flags)
Provide a new distance matrix.
static int hwloc_distances_remove_by_type(hwloc_topology_t topology, hwloc_obj_type_t type)
Remove distance matrices for objects of a specific type in the topology.
Definition: distances.h:272
int hwloc_distances_remove_by_depth(hwloc_topology_t topology, int depth)
Remove distance matrices for objects at a specific depth in the topology.
@ HWLOC_DISTANCES_KIND_MEANS_BANDWIDTH
Distance values are similar to bandwidths between objects. Values are higher for closer objects,...
Definition: distances.h:90
Structure of a topology object.
Definition: hwloc.h:384
int hwloc_distances_get_by_name(hwloc_topology_t topology, const char *name, unsigned *nr, struct hwloc_distances_s **distances, unsigned long flags)
Retrieve a distance matrix with the given name.
hwloc_uint64_t * values
Matrix of distances between objects, stored as a one-dimension array.
Definition: distances.h:49
@ HWLOC_DISTANCES_KIND_FROM_USER
These distances were provided by the user.
Definition: distances.h:75
@ HWLOC_TYPE_DEPTH_UNKNOWN
No object of given type exists in the topology.
Definition: hwloc.h:808
hwloc_obj_type_t
Type of topology object.
Definition: hwloc.h:176
int hwloc_distances_remove(hwloc_topology_t topology)
Remove all distance matrices from a topology.
const char * hwloc_distances_get_name(hwloc_topology_t topology, struct hwloc_distances_s *distances)
Get a description of what a distances structure contains.
int hwloc_distances_get_by_depth(hwloc_topology_t topology, int depth, unsigned *nr, struct hwloc_distances_s **distances, unsigned long kind, unsigned long flags)
Retrieve distance matrices for object at a specific depth in the topology.