9
9
10
10
#include <stdlib.h>
11
11
12
+ static int
13
+ hwloc_look_fake (struct hwloc_backend * backend , struct hwloc_disc_status * dstatus )
14
+ {
15
+ hwloc_topology_t topology = backend -> topology ;
16
+
17
+ assert (dstatus -> phase == HWLOC_DISC_PHASE_TWEAK );
18
+
19
+ if (getenv ("HWLOC_DEBUG_FAKE_COMPONENT_TWEAK" )) {
20
+ hwloc_obj_t obj ;
21
+ int err ;
22
+ /* restrict to single (last) PU */
23
+ obj = hwloc_get_obj_by_type (topology , HWLOC_OBJ_PU , hwloc_get_nbobjs_by_type (topology , HWLOC_OBJ_PU )- 1 );
24
+ assert (obj );
25
+ err = hwloc_topology_restrict (topology , obj -> cpuset , 0 );
26
+ assert (!err );
27
+ /* restrict to single (first) NUMA node */
28
+ obj = hwloc_get_obj_by_type (topology , HWLOC_OBJ_NUMANODE , 0 );
29
+ assert (obj );
30
+ err = hwloc_topology_restrict (topology , obj -> nodeset , HWLOC_RESTRICT_FLAG_BYNODESET );
31
+ assert (!err );
32
+ }
33
+
34
+ return 0 ;
35
+ }
36
+
12
37
static struct hwloc_backend *
13
38
hwloc_fake_component_instantiate (struct hwloc_topology * topology __hwloc_attribute_unused ,
14
39
struct hwloc_disc_component * component __hwloc_attribute_unused ,
@@ -17,14 +42,25 @@ hwloc_fake_component_instantiate(struct hwloc_topology *topology __hwloc_attribu
17
42
const void * _data2 __hwloc_attribute_unused ,
18
43
const void * _data3 __hwloc_attribute_unused )
19
44
{
45
+ struct hwloc_backend * backend ;
46
+
47
+ backend = hwloc_backend_alloc (topology , component );
48
+ if (!backend )
49
+ goto out ;
50
+ backend -> discover = hwloc_look_fake ;
51
+
20
52
if (getenv ("HWLOC_DEBUG_FAKE_COMPONENT" ))
21
53
printf ("fake component instantiated\n" );
54
+
55
+ return backend ;
56
+
57
+ out :
22
58
return NULL ;
23
59
}
24
60
25
61
static struct hwloc_disc_component hwloc_fake_disc_component = {
26
62
"fake" ,
27
- HWLOC_DISC_PHASE_MISC , /* so that it's always enabled when using the OS discovery */
63
+ HWLOC_DISC_PHASE_TWEAK ,
28
64
0 , /* nothing to exclude */
29
65
hwloc_fake_component_instantiate ,
30
66
100 , /* make sure it's loaded before anything conflicting excludes it */
0 commit comments