Add the ability to specify a topology-containing xml file to describe the simulated nodes to support mapping tests against arbitrary topologies
This commit was SVN r25388.
Этот коммит содержится в:
родитель
21d45b0807
Коммит
e50bcbf028
@ -21,6 +21,7 @@ struct orte_ras_sim_component_t {
|
||||
int num_nodes;
|
||||
int slots;
|
||||
int slots_max;
|
||||
char *topofile;
|
||||
};
|
||||
typedef struct orte_ras_sim_component_t orte_ras_sim_component_t;
|
||||
|
||||
|
@ -77,6 +77,12 @@ static int ras_sim_open(void)
|
||||
"max_slots",
|
||||
"Number of max slots on each node to simulate",
|
||||
false, false, 0, &mca_ras_simulator_component.slots_max);
|
||||
#if OPAL_HAVE_HWLOC
|
||||
mca_base_param_reg_string(&mca_ras_simulator_component.super.base_version,
|
||||
"topo_file",
|
||||
"File containing xml topology description for simulated nodes",
|
||||
false, false, NULL, &mca_ras_simulator_component.topofile);
|
||||
#endif
|
||||
|
||||
return ORTE_SUCCESS;
|
||||
}
|
||||
|
@ -41,6 +41,11 @@ static int allocate(opal_list_t *nodes)
|
||||
{
|
||||
int i, val, dig;
|
||||
orte_node_t *node;
|
||||
#if OPAL_HAVE_HWLOC
|
||||
hwloc_topology_t topo;
|
||||
hwloc_obj_t obj;
|
||||
unsigned j, k;
|
||||
#endif
|
||||
|
||||
/* get number of digits */
|
||||
val = mca_ras_simulator_component.num_nodes;
|
||||
@ -48,6 +53,57 @@ static int allocate(opal_list_t *nodes)
|
||||
val /= 10;
|
||||
}
|
||||
|
||||
/* check for topology */
|
||||
#if OPAL_HAVE_HWLOC
|
||||
if (NULL == mca_ras_simulator_component.topofile) {
|
||||
/* use our topology */
|
||||
topo = opal_hwloc_topology;
|
||||
} else {
|
||||
if (0 != hwloc_topology_init(&topo)) {
|
||||
return ORTE_ERROR;
|
||||
}
|
||||
if (0 != hwloc_topology_set_xml(topo, mca_ras_simulator_component.topofile)) {
|
||||
hwloc_topology_destroy(topo);
|
||||
return ORTE_ERROR;
|
||||
}
|
||||
/* since we are loading this from an external source, we have to
|
||||
* explicitly set a flag so hwloc sets things up correctly
|
||||
*/
|
||||
if (0 != hwloc_topology_set_flags(topo, HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM)) {
|
||||
hwloc_topology_destroy(topo);
|
||||
return ORTE_ERROR;
|
||||
}
|
||||
if (0 != hwloc_topology_load(topo)) {
|
||||
hwloc_topology_destroy(topo);
|
||||
return ORTE_ERROR;
|
||||
}
|
||||
/* remove the hostname from the topology. Unfortunately, hwloc
|
||||
* decided to add the source hostname to the "topology", thus
|
||||
* rendering it unusable as a pure topological description. So
|
||||
* we remove that information here.
|
||||
*/
|
||||
obj = hwloc_get_root_obj(topo);
|
||||
for (k=0; k < obj->infos_count; k++) {
|
||||
if (NULL == obj->infos[k].name ||
|
||||
NULL == obj->infos[k].value) {
|
||||
continue;
|
||||
}
|
||||
if (0 == strncmp(obj->infos[k].name, "HostName", strlen("HostName"))) {
|
||||
free(obj->infos[k].name);
|
||||
free(obj->infos[k].value);
|
||||
/* left justify the array */
|
||||
for (j=k; j < obj->infos_count-1; j++) {
|
||||
obj->infos[j] = obj->infos[j+1];
|
||||
}
|
||||
obj->infos[obj->infos_count-1].name = NULL;
|
||||
obj->infos[obj->infos_count-1].value = NULL;
|
||||
obj->infos_count--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i=0; i < mca_ras_simulator_component.num_nodes; i++) {
|
||||
node = OBJ_NEW(orte_node_t);
|
||||
asprintf(&node->name, "node%0*d", dig, i);
|
||||
@ -56,7 +112,7 @@ static int allocate(opal_list_t *nodes)
|
||||
node->slots_max = mca_ras_simulator_component.slots_max;
|
||||
node->slots = mca_ras_simulator_component.slots;
|
||||
#if OPAL_HAVE_HWLOC
|
||||
node->topology = opal_hwloc_topology;
|
||||
node->topology = topo;
|
||||
#endif
|
||||
opal_list_append(nodes, &node->super);
|
||||
}
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user