Skip to content

Commit 64c809f

Browse files
committed
API: reorder object types
Die and MemCache were added after 2.0 got released. Break the 3.0 ABI even more by moving them near their friends so simplify type test helpers such as is_normal() etc. Virtual depths are not reordered since their order doesn't matter anywhere afaik. Signed-off-by: Brice Goglin <[email protected]>
1 parent efe4b7c commit 64c809f

File tree

54 files changed

+385
-380
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+385
-380
lines changed

doc/hwloc.doxy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4681,6 +4681,13 @@ All users are strong encouraged to stop using hwloc 1.x.
46814681
See \ref faq5 for detecting the hwloc version that you are compiling
46824682
and/or running against.
46834683

4684+
\section upgrade_to_api_3x_type_order Object types are reordered
4685+
4686+
Die and MemCache object types are now near their neighbors in the type enum
4687+
(Die between Package and Core, MemCache after NUMANode).
4688+
One should use helpers such hwloc_obj_type_is_normal() instead of assumptions
4689+
about type ordering in the enum.
4690+
46844691
\section upgrade_to_api_3x_osdev OS device type is now a bitmask
46854692

46864693
The OS device "type" attribute is now a bitmask named "types".

hwloc/topology.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,7 @@ hwloc_topology_dup(hwloc_topology_t *newp,
12951295
static const unsigned obj_type_order[] = {
12961296
/* first entry is HWLOC_OBJ_MACHINE */ 0,
12971297
/* next entry is HWLOC_OBJ_PACKAGE */ 4,
1298+
/* next entry is HWLOC_OBJ_DIE */ 5,
12981299
/* next entry is HWLOC_OBJ_CORE */ 14,
12991300
/* next entry is HWLOC_OBJ_PU */ 18,
13001301
/* next entry is HWLOC_OBJ_L1CACHE */ 12,
@@ -1307,12 +1308,11 @@ static const unsigned obj_type_order[] = {
13071308
/* next entry is HWLOC_OBJ_L3ICACHE */ 9,
13081309
/* next entry is HWLOC_OBJ_GROUP */ 1,
13091310
/* next entry is HWLOC_OBJ_NUMANODE */ 3,
1311+
/* next entry is HWLOC_OBJ_MEMCACHE */ 2,
13101312
/* next entry is HWLOC_OBJ_BRIDGE */ 15,
13111313
/* next entry is HWLOC_OBJ_PCI_DEVICE */ 16,
13121314
/* next entry is HWLOC_OBJ_OS_DEVICE */ 17,
1313-
/* next entry is HWLOC_OBJ_MISC */ 19,
1314-
/* next entry is HWLOC_OBJ_MEMCACHE */ 2,
1315-
/* next entry is HWLOC_OBJ_DIE */ 5
1315+
/* next entry is HWLOC_OBJ_MISC */ 19
13161316
};
13171317

13181318
#ifndef NDEBUG /* only used in debug check assert if !NDEBUG */
@@ -1358,6 +1358,7 @@ static const hwloc_obj_type_t obj_order_type[] = {
13581358
static const int obj_type_priority[] = {
13591359
/* first entry is HWLOC_OBJ_MACHINE */ 90,
13601360
/* next entry is HWLOC_OBJ_PACKAGE */ 40,
1361+
/* next entry is HWLOC_OBJ_DIE */ 30,
13611362
/* next entry is HWLOC_OBJ_CORE */ 60,
13621363
/* next entry is HWLOC_OBJ_PU */ 100,
13631364
/* next entry is HWLOC_OBJ_L1CACHE */ 20,
@@ -1370,12 +1371,11 @@ static const int obj_type_priority[] = {
13701371
/* next entry is HWLOC_OBJ_L3ICACHE */ 19,
13711372
/* next entry is HWLOC_OBJ_GROUP */ 0,
13721373
/* next entry is HWLOC_OBJ_NUMANODE */ 100,
1374+
/* next entry is HWLOC_OBJ_MEMCACHE */ 19,
13731375
/* next entry is HWLOC_OBJ_BRIDGE */ 0,
13741376
/* next entry is HWLOC_OBJ_PCI_DEVICE */ 100,
13751377
/* next entry is HWLOC_OBJ_OS_DEVICE */ 100,
1376-
/* next entry is HWLOC_OBJ_MISC */ 0,
1377-
/* next entry is HWLOC_OBJ_MEMCACHE */ 19,
1378-
/* next entry is HWLOC_OBJ_DIE */ 30
1378+
/* next entry is HWLOC_OBJ_MISC */ 0
13791379
};
13801380

13811381
int hwloc_compare_types (hwloc_obj_type_t type1, hwloc_obj_type_t type2)
@@ -2616,7 +2616,6 @@ hwloc_reset_normal_type_depths(hwloc_topology_t topology)
26162616
for (i=HWLOC_OBJ_TYPE_MIN; i<=HWLOC_OBJ_GROUP; i++)
26172617
topology->type_depth[i] = HWLOC_TYPE_DEPTH_UNKNOWN;
26182618
/* type contiguity is asserted in topology_check() */
2619-
topology->type_depth[HWLOC_OBJ_DIE] = HWLOC_TYPE_DEPTH_UNKNOWN;
26202619
}
26212620

26222621
static int
@@ -5239,13 +5238,12 @@ hwloc_topology_check(struct hwloc_topology *topology)
52395238
* and hwloc_reset_normal_type_depths()
52405239
* want special types to be ordered like this, after all normal types.
52415240
*/
5242-
HWLOC_BUILD_ASSERT(HWLOC_OBJ_NUMANODE + 1 == HWLOC_OBJ_BRIDGE);
5241+
HWLOC_BUILD_ASSERT(HWLOC_OBJ_NUMANODE + 1 == HWLOC_OBJ_MEMCACHE);
5242+
HWLOC_BUILD_ASSERT(HWLOC_OBJ_MEMCACHE + 1 == HWLOC_OBJ_BRIDGE);
52435243
HWLOC_BUILD_ASSERT(HWLOC_OBJ_BRIDGE + 1 == HWLOC_OBJ_PCI_DEVICE);
52445244
HWLOC_BUILD_ASSERT(HWLOC_OBJ_PCI_DEVICE + 1 == HWLOC_OBJ_OS_DEVICE);
52455245
HWLOC_BUILD_ASSERT(HWLOC_OBJ_OS_DEVICE + 1 == HWLOC_OBJ_MISC);
5246-
HWLOC_BUILD_ASSERT(HWLOC_OBJ_MISC + 1 == HWLOC_OBJ_MEMCACHE);
5247-
HWLOC_BUILD_ASSERT(HWLOC_OBJ_MEMCACHE + 1 == HWLOC_OBJ_DIE);
5248-
HWLOC_BUILD_ASSERT(HWLOC_OBJ_DIE + 1 == HWLOC_OBJ_TYPE_MAX);
5246+
HWLOC_BUILD_ASSERT(HWLOC_OBJ_MISC + 1 == HWLOC_OBJ_TYPE_MAX);
52495247

52505248
/* make sure order and priority arrays have the right size */
52515249
HWLOC_BUILD_ASSERT(sizeof(obj_type_order)/sizeof(*obj_type_order) == HWLOC_OBJ_TYPE_MAX);

include/hwloc.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,16 @@ typedef enum {
215215
* A processor package usually contains multiple cores,
216216
* and possibly some dies.
217217
*/
218+
HWLOC_OBJ_DIE, /**< \brief Die within a physical package.
219+
* A subpart of the physical package, that contains multiple cores.
220+
*
221+
* Some operating systems (e.g. Linux) may expose a single die per package
222+
* even if the hardware does not support dies at all. To avoid showing
223+
* such non-existing dies, the corresponding hwloc backend may filter them out.
224+
* This is functionally equivalent to ::HWLOC_TYPE_FILTER_KEEP_STRUCTURE
225+
* being enforced.
226+
*/
227+
218228
HWLOC_OBJ_CORE, /**< \brief Core.
219229
* A computation unit (may be shared by several
220230
* PUs, aka logical processors).
@@ -280,6 +290,19 @@ typedef enum {
280290
* main tree.
281291
*/
282292

293+
HWLOC_OBJ_MEMCACHE, /**< \brief Memory-side cache (filtered out by default).
294+
* A cache in front of a specific NUMA node.
295+
*
296+
* This object always has at least one NUMA node as a memory child.
297+
*
298+
* Memory objects are not listed in the main children list,
299+
* but rather in the dedicated Memory children list.
300+
*
301+
* Memory-side cache have a special depth ::HWLOC_TYPE_DEPTH_MEMCACHE
302+
* instead of a normal depth just like other objects in the
303+
* main tree.
304+
*/
305+
283306
HWLOC_OBJ_BRIDGE, /**< \brief Bridge (filtered out by default).
284307
* Any bridge (or PCI switch) that connects the host or an I/O bus,
285308
* to another I/O bus.
@@ -328,29 +351,6 @@ typedef enum {
328351
* Misc objects have NULL CPU and node sets.
329352
*/
330353

331-
HWLOC_OBJ_MEMCACHE, /**< \brief Memory-side cache (filtered out by default).
332-
* A cache in front of a specific NUMA node.
333-
*
334-
* This object always has at least one NUMA node as a memory child.
335-
*
336-
* Memory objects are not listed in the main children list,
337-
* but rather in the dedicated Memory children list.
338-
*
339-
* Memory-side cache have a special depth ::HWLOC_TYPE_DEPTH_MEMCACHE
340-
* instead of a normal depth just like other objects in the
341-
* main tree.
342-
*/
343-
344-
HWLOC_OBJ_DIE, /**< \brief Die within a physical package.
345-
* A subpart of the physical package, that contains multiple cores.
346-
*
347-
* Some operating systems (e.g. Linux) may expose a single die per package
348-
* even if the hardware does not support dies at all. To avoid showing
349-
* such non-existing dies, the corresponding hwloc backend may filter them out.
350-
* This is functionally equivalent to ::HWLOC_TYPE_FILTER_KEEP_STRUCTURE
351-
* being enforced.
352-
*/
353-
354354
HWLOC_OBJ_TYPE_MAX /**< \private Sentinel value */
355355
} hwloc_obj_type_t;
356356

include/private/misc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,14 +439,14 @@ hwloc_linux_pci_link_speed_from_string(const char *string)
439439
static __hwloc_inline int hwloc__obj_type_is_normal (hwloc_obj_type_t type)
440440
{
441441
/* type contiguity is asserted in topology_check() */
442-
return type <= HWLOC_OBJ_GROUP || type == HWLOC_OBJ_DIE;
442+
return type <= HWLOC_OBJ_GROUP;
443443
}
444444

445445
/* Any object attached to memory children, currently NUMA nodes or Memory-side caches */
446446
static __hwloc_inline int hwloc__obj_type_is_memory (hwloc_obj_type_t type)
447447
{
448448
/* type contiguity is asserted in topology_check() */
449-
return type == HWLOC_OBJ_NUMANODE || type == HWLOC_OBJ_MEMCACHE;
449+
return type >= HWLOC_OBJ_NUMANODE && type <= HWLOC_OBJ_MEMCACHE;
450450
}
451451

452452
/* I/O or Misc object, without cpusets or nodesets. */

tests/hwloc/linux/128arm-2pa2n8cluster4co.console

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -683,14 +683,14 @@ Machine (P#0 total=503GiB DMIProductName="XA320 V2 " DMIProductVersion="To be fi
683683
PU L#127 (P#127)
684684
depth 0: 1 Machine (type #0)
685685
depth 1: 2 Package (type #1)
686-
depth 2: 4 L3Cache (type #6)
687-
depth 3: 32 Group0 (type #12)
688-
depth 4: 128 L2Cache (type #5)
689-
depth 5: 128 L1dCache (type #4)
690-
depth 6: 128 L1iCache (type #9)
691-
depth 7: 128 Core (type #2)
692-
depth 8: 128 PU (type #3)
693-
Special depth -3: 4 NUMANode (type #13)
686+
depth 2: 4 L3Cache (type #7)
687+
depth 3: 32 Group0 (type #13)
688+
depth 4: 128 L2Cache (type #6)
689+
depth 5: 128 L1dCache (type #5)
690+
depth 6: 128 L1iCache (type #10)
691+
depth 7: 128 Core (type #3)
692+
depth 8: 128 PU (type #4)
693+
Special depth -3: 4 NUMANode (type #14)
694694
Relative latency matrix (name NUMALatency kind 5) between 4 NUMANodes (depth -3) by logical indexes:
695695
index 0 1 2 3
696696
0 10 16 32 33

tests/hwloc/linux/128ia64-17n4s2c.console

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,11 @@ Machine (P#0 total=1535GiB)
354354
Group0 L#16 (total=996MiB)
355355
NUMANode L#16 (P#16 local=996MiB total=996MiB)
356356
depth 0: 1 Machine (type #0)
357-
depth 1: 17 Group0 (type #12)
357+
depth 1: 17 Group0 (type #13)
358358
depth 2: 64 Package (type #1)
359-
depth 3: 128 Core (type #2)
360-
depth 4: 128 PU (type #3)
361-
Special depth -3: 17 NUMANode (type #13)
359+
depth 3: 128 Core (type #3)
360+
depth 4: 128 PU (type #4)
361+
Special depth -3: 17 NUMANode (type #14)
362362
Relative latency matrix (name NUMALatency kind 5) between 17 NUMANodes (depth -3) by logical indexes:
363363
index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
364364
0 10 17 17 17 20 20 20 20 20 20 20 20 20 20 20 20 14

tests/hwloc/linux/16amd64-4n4c-cgroup-distance-merge.console

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ Machine (P#0 total=16GiB DMIProductName=H8QM8 DMIProductVersion=1234567890 DMIBo
1111
NUMANode L#1 (P#3 local=8192MiB total=8192MiB)
1212
depth 0: 1 Machine (type #0)
1313
depth 1: 3 Package (type #1)
14-
depth 2: 1 L3Cache (type #6)
15-
depth 3: 4 PU (type #3)
16-
Special depth -3: 2 NUMANode (type #13)
14+
depth 2: 1 L3Cache (type #7)
15+
depth 3: 4 PU (type #4)
16+
Special depth -3: 2 NUMANode (type #14)
1717
Relative latency matrix (name NUMALatency kind 5) between 2 NUMANodes (depth -3) by logical indexes:
1818
index 0 1
1919
0 10 20

tests/hwloc/linux/16amd64-8n2c-cpusets-disallowed.console

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ Machine (P#0 total=64GiB DMIBoardVendor="TYAN Computer Corp" DMIBoardName="S4881
9292
PU L#14 (P#15)
9393
depth 0: 1 Machine (type #0)
9494
depth 1: 8 Package (type #1)
95-
depth 2: 15 L2Cache (type #5)
96-
depth 3: 15 L1dCache (type #4)
97-
depth 4: 15 L1iCache (type #9)
98-
depth 5: 15 Core (type #2)
99-
depth 6: 15 PU (type #3)
100-
Special depth -3: 8 NUMANode (type #13)
95+
depth 2: 15 L2Cache (type #6)
96+
depth 3: 15 L1dCache (type #5)
97+
depth 4: 15 L1iCache (type #10)
98+
depth 5: 15 Core (type #3)
99+
depth 6: 15 PU (type #4)
100+
Special depth -3: 8 NUMANode (type #14)
101101
Relative latency matrix (name NUMALatency kind 5) between 8 NUMANodes (depth -3) by logical indexes:
102102
index 0 1 2 3 4 5 6 7
103103
0 10 20 20 20 20 20 20 20

tests/hwloc/linux/16amd64-8n2c-cpusets.console

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ Machine (P#0 total=32GiB DMIBoardVendor="TYAN Computer Corp" DMIBoardName="S4881
6262
PU L#9 (P#15)
6363
depth 0: 1 Machine (type #0)
6464
depth 1: 7 Package (type #1)
65-
depth 2: 10 L2Cache (type #5)
66-
depth 3: 10 L1dCache (type #4)
67-
depth 4: 10 L1iCache (type #9)
68-
depth 5: 10 Core (type #2)
69-
depth 6: 10 PU (type #3)
70-
Special depth -3: 4 NUMANode (type #13)
65+
depth 2: 10 L2Cache (type #6)
66+
depth 3: 10 L1dCache (type #5)
67+
depth 4: 10 L1iCache (type #10)
68+
depth 5: 10 Core (type #3)
69+
depth 6: 10 PU (type #4)
70+
Special depth -3: 4 NUMANode (type #14)
7171
Relative latency matrix (name NUMALatency kind 5) between 4 NUMANodes (depth -3) by logical indexes:
7272
index 0 1 2 3
7373
0 10 20 20 20

tests/hwloc/linux/16amd64-8n2c.console

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ Machine (P#0 total=64GiB DMIBoardVendor="TYAN Computer Corp" DMIBoardName="S4881
9797
PU L#15 (P#15)
9898
depth 0: 1 Machine (type #0)
9999
depth 1: 8 Package (type #1)
100-
depth 2: 16 L2Cache (type #5)
101-
depth 3: 16 L1dCache (type #4)
102-
depth 4: 16 L1iCache (type #9)
103-
depth 5: 16 Core (type #2)
104-
depth 6: 16 PU (type #3)
105-
Special depth -3: 8 NUMANode (type #13)
100+
depth 2: 16 L2Cache (type #6)
101+
depth 3: 16 L1dCache (type #5)
102+
depth 4: 16 L1iCache (type #10)
103+
depth 5: 16 Core (type #3)
104+
depth 6: 16 PU (type #4)
105+
Special depth -3: 8 NUMANode (type #14)
106106
Relative latency matrix (name NUMALatency kind 5) between 8 NUMANodes (depth -3) by logical indexes:
107107
index 0 1 2 3 4 5 6 7
108108
0 10 20 20 20 20 20 20 20

0 commit comments

Comments
 (0)