Do a little cleanup on the opal graph class and opal carto framework to conform to OMPI naming conventions and avoid potential conflict with user applications - no change in functionality, passes carto test program
This commit was SVN r18407.
Этот коммит содержится в:
родитель
e76d2dd518
Коммит
7c7b9b0486
@ -1333,7 +1333,7 @@ static int get_ib_dev_distance(struct ibv_device *dev)
|
|||||||
if(opal_paffinity_base_get_processor_info(&num_processors, &max_proc_id) != OMPI_SUCCESS)
|
if(opal_paffinity_base_get_processor_info(&num_processors, &max_proc_id) != OMPI_SUCCESS)
|
||||||
max_proc_id = 100; /* Choose something big enough */
|
max_proc_id = 100; /* Choose something big enough */
|
||||||
|
|
||||||
hca_node = carto_base_find_node(host_topo, hca);
|
hca_node = opal_carto_base_find_node(host_topo, hca);
|
||||||
|
|
||||||
/* no topology info for HCA found. Assume that it is close */
|
/* no topology info for HCA found. Assume that it is close */
|
||||||
if(NULL == hca_node)
|
if(NULL == hca_node)
|
||||||
@ -1353,14 +1353,14 @@ static int get_ib_dev_distance(struct ibv_device *dev)
|
|||||||
opal_paffinity_base_map_to_socket_core(i, &socket, &core);
|
opal_paffinity_base_map_to_socket_core(i, &socket, &core);
|
||||||
asprintf(&slot, "slot%d", socket);
|
asprintf(&slot, "slot%d", socket);
|
||||||
|
|
||||||
slot_node = carto_base_find_node(host_topo, slot);
|
slot_node = opal_carto_base_find_node(host_topo, slot);
|
||||||
|
|
||||||
free(slot);
|
free(slot);
|
||||||
|
|
||||||
if(NULL == slot_node)
|
if(NULL == slot_node)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
distance = carto_base_spf(host_topo, slot_node, hca_node);
|
distance = opal_carto_base_spf(host_topo, slot_node, hca_node);
|
||||||
|
|
||||||
if(distance < 0)
|
if(distance < 0)
|
||||||
return 0;
|
return 0;
|
||||||
@ -1391,7 +1391,7 @@ sort_devs_by_distance(struct ibv_device **ib_devs, int count)
|
|||||||
int i;
|
int i;
|
||||||
struct dev_distance *devs = malloc(count * sizeof(struct dev_distance));
|
struct dev_distance *devs = malloc(count * sizeof(struct dev_distance));
|
||||||
|
|
||||||
carto_base_get_host_graph(&host_topo, "Infiniband");
|
opal_carto_base_get_host_graph(&host_topo, "Infiniband");
|
||||||
|
|
||||||
for(i = 0; i < count; i++) {
|
for(i = 0; i < count; i++) {
|
||||||
devs[i].ib_dev = ib_devs[i];
|
devs[i].ib_dev = ib_devs[i];
|
||||||
@ -1400,7 +1400,7 @@ sort_devs_by_distance(struct ibv_device **ib_devs, int count)
|
|||||||
|
|
||||||
qsort(devs, count, sizeof(struct dev_distance), compare_distance);
|
qsort(devs, count, sizeof(struct dev_distance), compare_distance);
|
||||||
|
|
||||||
carto_base_free_graph(host_topo);
|
opal_carto_base_free_graph(host_topo);
|
||||||
|
|
||||||
return devs;
|
return devs;
|
||||||
}
|
}
|
||||||
|
@ -612,7 +612,7 @@ uint32_t opal_graph_spf(opal_graph_t *graph, opal_graph_vertex_t *vertex1, opal_
|
|||||||
distance_array = OBJ_NEW(opal_value_array_t);
|
distance_array = OBJ_NEW(opal_value_array_t);
|
||||||
opal_value_array_init(distance_array, sizeof(vertex_distance_from_t));
|
opal_value_array_init(distance_array, sizeof(vertex_distance_from_t));
|
||||||
opal_value_array_reserve(distance_array,50);
|
opal_value_array_reserve(distance_array,50);
|
||||||
items_in_distance_array = dijkstra(graph, vertex1, distance_array);
|
items_in_distance_array = opal_graph_dijkstra(graph, vertex1, distance_array);
|
||||||
/**
|
/**
|
||||||
* find the end vertex in the distance array that Dijkstra
|
* find the end vertex in the distance array that Dijkstra
|
||||||
* algorithm returned.
|
* algorithm returned.
|
||||||
@ -675,7 +675,7 @@ static int compare_vertex_distance(const void *item1, const void *item2)
|
|||||||
*
|
*
|
||||||
* @return uint32_t the size of the distance array
|
* @return uint32_t the size of the distance array
|
||||||
*/
|
*/
|
||||||
uint32_t dijkstra(opal_graph_t *graph, opal_graph_vertex_t *vertex, opal_value_array_t *distance_array)
|
uint32_t opal_graph_dijkstra(opal_graph_t *graph, opal_graph_vertex_t *vertex, opal_value_array_t *distance_array)
|
||||||
{
|
{
|
||||||
int graph_order;
|
int graph_order;
|
||||||
vertex_distance_from_t *Q, *q_start, *current_vertex;
|
vertex_distance_from_t *Q, *q_start, *current_vertex;
|
||||||
@ -690,7 +690,7 @@ uint32_t dijkstra(opal_graph_t *graph, opal_graph_vertex_t *vertex, opal_value_a
|
|||||||
* Verify that the reference vertex belongs to the graph.
|
* Verify that the reference vertex belongs to the graph.
|
||||||
*/
|
*/
|
||||||
if (graph != vertex->in_graph) {
|
if (graph != vertex->in_graph) {
|
||||||
OPAL_OUTPUT((0,"dijkstra: vertex %p not in the graph %p\n",(void *)vertex,(void *)graph));
|
OPAL_OUTPUT((0,"opal:graph:dijkstra: vertex %p not in the graph %p\n",(void *)vertex,(void *)graph));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* get the order of the graph and allocate a working queue accordingly */
|
/* get the order of the graph and allocate a working queue accordingly */
|
||||||
|
@ -34,9 +34,7 @@
|
|||||||
#include "opal/class/opal_pointer_array.h"
|
#include "opal/class/opal_pointer_array.h"
|
||||||
#include "opal/class/opal_value_array.h"
|
#include "opal/class/opal_value_array.h"
|
||||||
|
|
||||||
#if defined(c_plusplus) || defined(__cplusplus)
|
BEGIN_C_DECLS
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* When two vertices are not connected, the distance between them is infinite. */
|
/* When two vertices are not connected, the distance between them is infinite. */
|
||||||
#define DISTANCE_INFINITY 0x7fffffff
|
#define DISTANCE_INFINITY 0x7fffffff
|
||||||
@ -341,7 +339,7 @@ uint32_t opal_graph_spf(opal_graph_t *graph, opal_graph_vertex_t *vertex1, opal_
|
|||||||
*
|
*
|
||||||
* @return uint32_t the size of the distance array
|
* @return uint32_t the size of the distance array
|
||||||
*/
|
*/
|
||||||
uint32_t dijkstra(opal_graph_t *graph, opal_graph_vertex_t *vertex, opal_value_array_t *distance_array);
|
uint32_t opal_graph_dijkstra(opal_graph_t *graph, opal_graph_vertex_t *vertex, opal_value_array_t *distance_array);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This graph API prints a graph - mostly for debug uses.
|
* This graph API prints a graph - mostly for debug uses.
|
||||||
@ -349,10 +347,7 @@ uint32_t dijkstra(opal_graph_t *graph, opal_graph_vertex_t *vertex, opal_value_a
|
|||||||
*/
|
*/
|
||||||
void opal_graph_print(opal_graph_t *graph);
|
void opal_graph_print(opal_graph_t *graph);
|
||||||
|
|
||||||
#if defined(c_plusplus) || defined(__cplusplus)
|
END_C_DECLS
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* OPAL_GRAPH_H */
|
#endif /* OPAL_GRAPH_H */
|
||||||
|
@ -54,11 +54,11 @@ static int opal_carto_auto_detect_finalize(void);
|
|||||||
*/
|
*/
|
||||||
static const opal_carto_base_module_1_0_0_t loc_module = {
|
static const opal_carto_base_module_1_0_0_t loc_module = {
|
||||||
opal_carto_auto_detect_init,
|
opal_carto_auto_detect_init,
|
||||||
opal_carto_base_graph_get_host_graph,
|
opal_carto_base_graph_get_host_graph_fn,
|
||||||
opal_carto_base_free_graph,
|
opal_carto_base_free_graph_fn,
|
||||||
opal_carto_base_get_nodes_distance,
|
opal_carto_base_get_nodes_distance_fn,
|
||||||
opal_carto_base_graph_spf,
|
opal_carto_base_graph_spf_fn,
|
||||||
opal_carto_base_graph_find_node,
|
opal_carto_base_graph_find_node_fn,
|
||||||
opal_carto_auto_detect_finalize,
|
opal_carto_auto_detect_finalize,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -85,7 +85,10 @@ int opal_carto_auto_detect_component_query(mca_base_module_t **module, int *prio
|
|||||||
*/
|
*/
|
||||||
static int opal_carto_auto_detect_init(void)
|
static int opal_carto_auto_detect_init(void)
|
||||||
{
|
{
|
||||||
opal_carto_base_graph_create(&carto_base_common_host_graph);
|
/* create an empty graph */
|
||||||
|
if (NULL == opal_carto_base_common_host_graph) {
|
||||||
|
opal_carto_base_graph_create_fn(&opal_carto_base_common_host_graph);
|
||||||
|
}
|
||||||
return OPAL_SUCCESS;
|
return OPAL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +99,10 @@ static int opal_carto_auto_detect_init(void)
|
|||||||
*/
|
*/
|
||||||
static int opal_carto_auto_detect_finalize(void)
|
static int opal_carto_auto_detect_finalize(void)
|
||||||
{
|
{
|
||||||
opal_carto_base_free_graph(carto_base_common_host_graph);
|
/* free the host cartography graph. */
|
||||||
|
if (NULL != opal_carto_base_common_host_graph) {
|
||||||
|
opal_carto_base_free_graph_fn(opal_carto_base_common_host_graph);
|
||||||
|
}
|
||||||
return OPAL_SUCCESS;
|
return OPAL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ OPAL_DECLSPEC extern opal_list_t opal_carto_base_components_opened;
|
|||||||
*
|
*
|
||||||
* @return OPAL_DECLSPEC int
|
* @return OPAL_DECLSPEC int
|
||||||
*/
|
*/
|
||||||
OPAL_DECLSPEC int carto_base_get_host_graph(opal_carto_graph_t **graph, const char *graph_type);
|
OPAL_DECLSPEC int opal_carto_base_get_host_graph(opal_carto_graph_t **graph, const char *graph_type);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -149,7 +149,7 @@ OPAL_DECLSPEC int carto_base_get_host_graph(opal_carto_graph_t **graph, const ch
|
|||||||
*
|
*
|
||||||
* @return OPAL_DECLSPEC void
|
* @return OPAL_DECLSPEC void
|
||||||
*/
|
*/
|
||||||
OPAL_DECLSPEC void carto_base_free_graph(opal_carto_graph_t *graph);
|
OPAL_DECLSPEC void opal_carto_base_free_graph(opal_carto_graph_t *graph);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the distance (weight) from a start node to all other
|
* Get the distance (weight) from a start node to all other
|
||||||
@ -163,7 +163,7 @@ OPAL_DECLSPEC void carto_base_free_graph(opal_carto_graph_t *graph);
|
|||||||
*
|
*
|
||||||
* @return OPAL_DECLSPEC int
|
* @return OPAL_DECLSPEC int
|
||||||
*/
|
*/
|
||||||
OPAL_DECLSPEC int carto_base_get_nodes_distance(opal_carto_graph_t *graph, opal_carto_base_node_t *start, const char *node_type, opal_value_array_t *distance_);
|
OPAL_DECLSPEC int opal_carto_base_get_nodes_distance(opal_carto_graph_t *graph, opal_carto_base_node_t *start, const char *node_type, opal_value_array_t *distance_);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* find the distance between two nodes.
|
* find the distance between two nodes.
|
||||||
@ -174,7 +174,7 @@ OPAL_DECLSPEC int carto_base_get_nodes_distance(opal_carto_graph_t *graph, opal_
|
|||||||
*
|
*
|
||||||
* @return OPAL_DECLSPEC uint32_t
|
* @return OPAL_DECLSPEC uint32_t
|
||||||
*/
|
*/
|
||||||
OPAL_DECLSPEC uint32_t carto_base_spf(opal_carto_graph_t *graph,opal_carto_base_node_t *start, opal_carto_base_node_t *end);
|
OPAL_DECLSPEC uint32_t opal_carto_base_spf(opal_carto_graph_t *graph,opal_carto_base_node_t *start, opal_carto_base_node_t *end);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a node in the graph
|
* Find a node in the graph
|
||||||
@ -184,7 +184,7 @@ OPAL_DECLSPEC uint32_t carto_base_spf(opal_carto_graph_t *graph,opal_carto_base_
|
|||||||
*
|
*
|
||||||
* @return OPAL_DECLSPEC opal_carto_base_node_t
|
* @return OPAL_DECLSPEC opal_carto_base_node_t
|
||||||
*/
|
*/
|
||||||
OPAL_DECLSPEC opal_carto_base_node_t *carto_base_find_node(opal_carto_graph_t *graph, const char *node_name);
|
OPAL_DECLSPEC opal_carto_base_node_t *opal_carto_base_find_node(opal_carto_graph_t *graph, const char *node_name);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -192,7 +192,7 @@ OPAL_DECLSPEC opal_carto_base_node_t *carto_base_find_node(opal_carto_graph_t *g
|
|||||||
*/
|
*/
|
||||||
extern int opal_carto_base_output;
|
extern int opal_carto_base_output;
|
||||||
|
|
||||||
extern opal_carto_graph_t *carto_base_common_host_graph;
|
extern opal_carto_graph_t *opal_carto_base_common_host_graph;
|
||||||
|
|
||||||
END_C_DECLS
|
END_C_DECLS
|
||||||
|
|
||||||
|
@ -42,8 +42,6 @@ static void *opal_carto_base_alloc_node(void);
|
|||||||
static int opal_carto_compare_nodes(void *node1, void *node2);
|
static int opal_carto_compare_nodes(void *node1, void *node2);
|
||||||
static char* opal_carto_print_node(void* node);
|
static char* opal_carto_print_node(void* node);
|
||||||
|
|
||||||
opal_carto_graph_t *carto_base_common_host_graph;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -157,7 +155,7 @@ static int opal_carto_compare_nodes(void *node1, void *node2)
|
|||||||
*
|
*
|
||||||
* @param graph an empty graph pointer
|
* @param graph an empty graph pointer
|
||||||
*/
|
*/
|
||||||
void opal_carto_base_graph_create(opal_carto_graph_t **graph)
|
void opal_carto_base_graph_create_fn(opal_carto_graph_t **graph)
|
||||||
{
|
{
|
||||||
*graph = (opal_carto_graph_t *)OBJ_NEW(opal_graph_t);
|
*graph = (opal_carto_graph_t *)OBJ_NEW(opal_graph_t);
|
||||||
}
|
}
|
||||||
@ -168,7 +166,7 @@ void opal_carto_base_graph_create(opal_carto_graph_t **graph)
|
|||||||
* @param graph the carto graph to add the node to.
|
* @param graph the carto graph to add the node to.
|
||||||
* @param node the node to add.
|
* @param node the node to add.
|
||||||
*/
|
*/
|
||||||
void opal_carto_base_graph_add_node(opal_carto_graph_t *graph, opal_carto_base_node_t *node)
|
void opal_carto_base_graph_add_node_fn(opal_carto_graph_t *graph, opal_carto_base_node_t *node)
|
||||||
{
|
{
|
||||||
/* construct new vertex */
|
/* construct new vertex */
|
||||||
node->vertex = OBJ_NEW(opal_graph_vertex_t);
|
node->vertex = OBJ_NEW(opal_graph_vertex_t);
|
||||||
@ -188,7 +186,7 @@ void opal_carto_base_graph_add_node(opal_carto_graph_t *graph, opal_carto_base_n
|
|||||||
* Free a carto graph
|
* Free a carto graph
|
||||||
* @param graph the graph we want to free.
|
* @param graph the graph we want to free.
|
||||||
*/
|
*/
|
||||||
void opal_carto_base_free_graph(opal_carto_graph_t *graph)
|
void opal_carto_base_free_graph_fn(opal_carto_graph_t *graph)
|
||||||
{
|
{
|
||||||
int i, graph_order;
|
int i, graph_order;
|
||||||
opal_carto_base_node_t *node;
|
opal_carto_base_node_t *node;
|
||||||
@ -221,7 +219,7 @@ void opal_carto_base_free_graph(opal_carto_graph_t *graph)
|
|||||||
* @return int success or error (if one of the nodes does not
|
* @return int success or error (if one of the nodes does not
|
||||||
* belong to the graph.
|
* belong to the graph.
|
||||||
*/
|
*/
|
||||||
int opal_carto_base_connect_nodes(opal_carto_graph_t *graph, opal_carto_base_node_t *start, opal_carto_base_node_t *end, uint32_t weight)
|
int opal_carto_base_connect_nodes_fn(opal_carto_graph_t *graph, opal_carto_base_node_t *start, opal_carto_base_node_t *end, uint32_t weight)
|
||||||
{
|
{
|
||||||
opal_graph_edge_t *edge;
|
opal_graph_edge_t *edge;
|
||||||
|
|
||||||
@ -246,7 +244,7 @@ int opal_carto_base_connect_nodes(opal_carto_graph_t *graph, opal_carto_base_nod
|
|||||||
* @param node_type the node type(s) that the new graph will
|
* @param node_type the node type(s) that the new graph will
|
||||||
* include.
|
* include.
|
||||||
*/
|
*/
|
||||||
void opal_carto_base_duplicate_graph(opal_carto_graph_t **destination, const opal_carto_graph_t *source, const char *node_type)
|
void opal_carto_base_duplicate_graph_fn(opal_carto_graph_t **destination, const opal_carto_graph_t *source, const char *node_type)
|
||||||
{
|
{
|
||||||
opal_pointer_array_t *vertices;
|
opal_pointer_array_t *vertices;
|
||||||
int i, graph_order;
|
int i, graph_order;
|
||||||
@ -286,7 +284,7 @@ void opal_carto_base_duplicate_graph(opal_carto_graph_t **destination, const opa
|
|||||||
*
|
*
|
||||||
* @return int number of nodes in the returned array.
|
* @return int number of nodes in the returned array.
|
||||||
*/
|
*/
|
||||||
int opal_carto_base_get_nodes_distance(opal_carto_graph_t *graph, opal_carto_base_node_t *reference_node,
|
int opal_carto_base_get_nodes_distance_fn(opal_carto_graph_t *graph, opal_carto_base_node_t *reference_node,
|
||||||
const char *node_type, opal_value_array_t *dist_array)
|
const char *node_type, opal_value_array_t *dist_array)
|
||||||
{
|
{
|
||||||
opal_value_array_t *distance_array;
|
opal_value_array_t *distance_array;
|
||||||
@ -301,7 +299,7 @@ int opal_carto_base_get_nodes_distance(opal_carto_graph_t *graph, opal_carto_bas
|
|||||||
opal_value_array_init(distance_array, sizeof(vertex_distance_from_t));
|
opal_value_array_init(distance_array, sizeof(vertex_distance_from_t));
|
||||||
opal_value_array_reserve(distance_array,50);
|
opal_value_array_reserve(distance_array,50);
|
||||||
/* use dijkstra algorithm to receive the distance of all the nodes from the referenced node */
|
/* use dijkstra algorithm to receive the distance of all the nodes from the referenced node */
|
||||||
graph_order = dijkstra(graph, reference_node->vertex, distance_array);
|
graph_order = opal_graph_dijkstra(graph, reference_node->vertex, distance_array);
|
||||||
/* for all the nodes in the dijkstra array */
|
/* for all the nodes in the dijkstra array */
|
||||||
for (i = 0, distance_array_size = 0; i < graph_order; i++) {
|
for (i = 0, distance_array_size = 0; i < graph_order; i++) {
|
||||||
vertex_distance = opal_value_array_get_item(distance_array, i);
|
vertex_distance = opal_value_array_get_item(distance_array, i);
|
||||||
@ -327,7 +325,7 @@ int opal_carto_base_get_nodes_distance(opal_carto_graph_t *graph, opal_carto_bas
|
|||||||
*
|
*
|
||||||
* @return uint32_t he distance between the nodes.
|
* @return uint32_t he distance between the nodes.
|
||||||
*/
|
*/
|
||||||
uint32_t opal_carto_base_graph_spf(opal_carto_graph_t *graph, opal_carto_base_node_t *node1, opal_carto_base_node_t *node2)
|
uint32_t opal_carto_base_graph_spf_fn(opal_carto_graph_t *graph, opal_carto_base_node_t *node1, opal_carto_base_node_t *node2)
|
||||||
{
|
{
|
||||||
return opal_graph_spf((opal_graph_t *)graph, node1->vertex, node2->vertex);
|
return opal_graph_spf((opal_graph_t *)graph, node1->vertex, node2->vertex);
|
||||||
}
|
}
|
||||||
@ -341,7 +339,7 @@ uint32_t opal_carto_base_graph_spf(opal_carto_graph_t *graph, opal_carto_base_no
|
|||||||
* @return opal_carto_base_node_t* the node with the name -if
|
* @return opal_carto_base_node_t* the node with the name -if
|
||||||
* found or NULL.
|
* found or NULL.
|
||||||
*/
|
*/
|
||||||
opal_carto_base_node_t *opal_carto_base_graph_find_node(opal_carto_graph_t *graph, const char *node_name)
|
opal_carto_base_node_t *opal_carto_base_graph_find_node_fn(opal_carto_graph_t *graph, const char *node_name)
|
||||||
{
|
{
|
||||||
opal_carto_base_node_t node;
|
opal_carto_base_node_t node;
|
||||||
opal_graph_vertex_t *vertex;
|
opal_graph_vertex_t *vertex;
|
||||||
@ -364,16 +362,6 @@ opal_carto_base_node_t *opal_carto_base_graph_find_node(opal_carto_graph_t *grap
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Print a carto graph (for debug uses)
|
|
||||||
*
|
|
||||||
* @param graph the graph we want to print.
|
|
||||||
*/
|
|
||||||
void opal_carto_print_graph(opal_carto_graph_t *graph)
|
|
||||||
{
|
|
||||||
opal_graph_print(graph);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the host cartography graph.
|
* Get the host cartography graph.
|
||||||
*
|
*
|
||||||
@ -383,10 +371,10 @@ void opal_carto_print_graph(opal_carto_graph_t *graph)
|
|||||||
*
|
*
|
||||||
* @return int success or error
|
* @return int success or error
|
||||||
*/
|
*/
|
||||||
int opal_carto_base_graph_get_host_graph(opal_carto_graph_t **graph, const char *graph_type)
|
int opal_carto_base_graph_get_host_graph_fn(opal_carto_graph_t **graph, const char *graph_type)
|
||||||
{
|
{
|
||||||
/* duplicate the host graph and delete all the relevant nodes */
|
/* duplicate the host graph and delete all the relevant nodes */
|
||||||
opal_carto_base_duplicate_graph(graph, carto_base_common_host_graph, graph_type);
|
opal_carto_base_duplicate_graph_fn(graph, opal_carto_base_common_host_graph, graph_type);
|
||||||
return OPAL_SUCCESS;
|
return OPAL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,18 +21,26 @@
|
|||||||
#ifndef OPAL_CARTO_BASE_GRAPH_H
|
#ifndef OPAL_CARTO_BASE_GRAPH_H
|
||||||
#define OPAL_CARTO_BASE_GRAPH_H
|
#define OPAL_CARTO_BASE_GRAPH_H
|
||||||
|
|
||||||
|
/* THIS FILE CONTAINS THE ACTUAL BASE FUNCTION IMPLEMENTATIONS FOR
|
||||||
|
* THE CARTO FRAMEWORK - THESE FUNCTIONS ARE TO BE CALLED STRICTLY
|
||||||
|
* FROM THE VARIOUS COMPONENTS, AS PASSED THROUGH BY THE PUBLIC
|
||||||
|
* BASE FUNCTIONS
|
||||||
|
*
|
||||||
|
* DO -NOT- CALL THESE FUNCTIONS DIRECTLY!
|
||||||
|
*/
|
||||||
|
|
||||||
#include "opal_config.h"
|
#include "opal_config.h"
|
||||||
|
|
||||||
#include "opal/mca/carto/carto.h"
|
#include "opal/mca/carto/carto.h"
|
||||||
|
|
||||||
OPAL_DECLSPEC extern opal_carto_graph_t *carto_base_common_host_graph;
|
OPAL_DECLSPEC extern opal_carto_graph_t *opal_carto_base_common_host_graph;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new carto graph.
|
* Create new carto graph.
|
||||||
*
|
*
|
||||||
* @param graph an empty graph pointer
|
* @param graph an empty graph pointer
|
||||||
*/
|
*/
|
||||||
OPAL_DECLSPEC void opal_carto_base_graph_create(opal_carto_graph_t **graph);
|
OPAL_DECLSPEC void opal_carto_base_graph_create_fn(opal_carto_graph_t **graph);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a node to carto graph.
|
* Add a node to carto graph.
|
||||||
@ -41,13 +49,13 @@ OPAL_DECLSPEC void opal_carto_base_graph_create(opal_carto_graph_t **graph);
|
|||||||
* @param node the node to add.
|
* @param node the node to add.
|
||||||
*/
|
*/
|
||||||
OPAL_DECLSPEC void
|
OPAL_DECLSPEC void
|
||||||
opal_carto_base_graph_add_node(opal_carto_graph_t *graph, opal_carto_base_node_t *node);
|
opal_carto_base_graph_add_node_fn(opal_carto_graph_t *graph, opal_carto_base_node_t *node);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free a carto graph
|
* Free a carto graph
|
||||||
* @param graph the graph we want to free.
|
* @param graph the graph we want to free.
|
||||||
*/
|
*/
|
||||||
OPAL_DECLSPEC void opal_carto_base_free_graph(opal_carto_graph_t *graph);
|
OPAL_DECLSPEC void opal_carto_base_free_graph_fn(opal_carto_graph_t *graph);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connect two nodes by adding an edge to the graph.
|
* Connect two nodes by adding an edge to the graph.
|
||||||
@ -61,7 +69,7 @@ OPAL_DECLSPEC void opal_carto_base_free_graph(opal_carto_graph_t *graph);
|
|||||||
* belong to the graph.
|
* belong to the graph.
|
||||||
*/
|
*/
|
||||||
OPAL_DECLSPEC int
|
OPAL_DECLSPEC int
|
||||||
opal_carto_base_connect_nodes(opal_carto_graph_t *graph, opal_carto_base_node_t *start,
|
opal_carto_base_connect_nodes_fn(opal_carto_graph_t *graph, opal_carto_base_node_t *start,
|
||||||
opal_carto_base_node_t *end, uint32_t weight);
|
opal_carto_base_node_t *end, uint32_t weight);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,7 +82,7 @@ opal_carto_base_connect_nodes(opal_carto_graph_t *graph, opal_carto_base_node_t
|
|||||||
* include.
|
* include.
|
||||||
*/
|
*/
|
||||||
OPAL_DECLSPEC void
|
OPAL_DECLSPEC void
|
||||||
opal_carto_base_duplicate_graph(opal_carto_graph_t **destination, const opal_carto_graph_t *source,
|
opal_carto_base_duplicate_graph_fn(opal_carto_graph_t **destination, const opal_carto_graph_t *source,
|
||||||
const char *node_type);
|
const char *node_type);
|
||||||
|
|
||||||
|
|
||||||
@ -90,7 +98,7 @@ opal_carto_base_duplicate_graph(opal_carto_graph_t **destination, const opal_car
|
|||||||
* @return int number of nodes in the returned array.
|
* @return int number of nodes in the returned array.
|
||||||
*/
|
*/
|
||||||
OPAL_DECLSPEC int
|
OPAL_DECLSPEC int
|
||||||
opal_carto_base_get_nodes_distance(opal_carto_graph_t *graph, opal_carto_base_node_t *reference_node,
|
opal_carto_base_get_nodes_distance_fn(opal_carto_graph_t *graph, opal_carto_base_node_t *reference_node,
|
||||||
const char *node_type, opal_value_array_t *dist_array);
|
const char *node_type, opal_value_array_t *dist_array);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -103,7 +111,7 @@ opal_carto_base_get_nodes_distance(opal_carto_graph_t *graph, opal_carto_base_no
|
|||||||
* @return uint32_t he distance between the nodes.
|
* @return uint32_t he distance between the nodes.
|
||||||
*/
|
*/
|
||||||
OPAL_DECLSPEC uint32_t
|
OPAL_DECLSPEC uint32_t
|
||||||
opal_carto_base_graph_spf(opal_carto_graph_t *graph, opal_carto_base_node_t *node1,
|
opal_carto_base_graph_spf_fn(opal_carto_graph_t *graph, opal_carto_base_node_t *node1,
|
||||||
opal_carto_base_node_t *node2);
|
opal_carto_base_node_t *node2);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -116,14 +124,7 @@ opal_carto_base_graph_spf(opal_carto_graph_t *graph, opal_carto_base_node_t *nod
|
|||||||
* found or NULL.
|
* found or NULL.
|
||||||
*/
|
*/
|
||||||
OPAL_DECLSPEC opal_carto_base_node_t
|
OPAL_DECLSPEC opal_carto_base_node_t
|
||||||
*opal_carto_base_graph_find_node(opal_carto_graph_t *graph, const char *node_name);
|
*opal_carto_base_graph_find_node_fn(opal_carto_graph_t *graph, const char *node_name);
|
||||||
|
|
||||||
/**
|
|
||||||
* Print a carto graph (for debug uses)
|
|
||||||
*
|
|
||||||
* @param graph the graph we want to print.
|
|
||||||
*/
|
|
||||||
OPAL_DECLSPEC void opal_carto_print_graph(opal_carto_graph_t *graph);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the host cartography graph.
|
* Get the host cartography graph.
|
||||||
@ -134,6 +135,6 @@ OPAL_DECLSPEC void opal_carto_print_graph(opal_carto_graph_t *graph);
|
|||||||
*
|
*
|
||||||
* @return int success or error
|
* @return int success or error
|
||||||
*/
|
*/
|
||||||
OPAL_DECLSPEC int opal_carto_base_graph_get_host_graph(opal_carto_graph_t **graph, const char * graph_type);
|
OPAL_DECLSPEC int opal_carto_base_graph_get_host_graph_fn(opal_carto_graph_t **graph, const char * graph_type);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
int opal_carto_base_output = -1;
|
int opal_carto_base_output = -1;
|
||||||
bool opal_carto_base_components_opened_valid = false;
|
bool opal_carto_base_components_opened_valid = false;
|
||||||
opal_list_t opal_carto_base_components_opened;
|
opal_list_t opal_carto_base_components_opened;
|
||||||
|
opal_carto_graph_t *opal_carto_base_common_host_graph=NULL;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include "opal/mca/carto/base/base.h"
|
#include "opal/mca/carto/base/base.h"
|
||||||
|
|
||||||
|
|
||||||
int carto_base_get_host_graph(opal_carto_graph_t **graph, const char *graph_type)
|
int opal_carto_base_get_host_graph(opal_carto_graph_t **graph, const char *graph_type)
|
||||||
{
|
{
|
||||||
if (!opal_carto_base_selected) {
|
if (!opal_carto_base_selected) {
|
||||||
return OPAL_ERR_NOT_FOUND;
|
return OPAL_ERR_NOT_FOUND;
|
||||||
@ -34,7 +34,7 @@ int carto_base_get_host_graph(opal_carto_graph_t **graph, const char *graph_type
|
|||||||
return opal_carto_base_module->get_host_graph(graph, graph_type);
|
return opal_carto_base_module->get_host_graph(graph, graph_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void carto_base_free_graph(opal_carto_graph_t *graph)
|
void opal_carto_base_free_graph(opal_carto_graph_t *graph)
|
||||||
{
|
{
|
||||||
if (!opal_carto_base_selected) {
|
if (!opal_carto_base_selected) {
|
||||||
return ;
|
return ;
|
||||||
@ -43,7 +43,7 @@ void carto_base_free_graph(opal_carto_graph_t *graph)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int carto_base_get_nodes_distance(opal_carto_graph_t *graph, opal_carto_base_node_t *start, const char *node_type, opal_value_array_t *distance_)
|
int opal_carto_base_get_nodes_distance(opal_carto_graph_t *graph, opal_carto_base_node_t *start, const char *node_type, opal_value_array_t *distance_)
|
||||||
{
|
{
|
||||||
if (!opal_carto_base_selected) {
|
if (!opal_carto_base_selected) {
|
||||||
return OPAL_ERR_NOT_FOUND;
|
return OPAL_ERR_NOT_FOUND;
|
||||||
@ -51,7 +51,7 @@ int carto_base_get_nodes_distance(opal_carto_graph_t *graph, opal_carto_base_nod
|
|||||||
return opal_carto_base_module->get_nodes_distance(graph, start, node_type, distance_);
|
return opal_carto_base_module->get_nodes_distance(graph, start, node_type, distance_);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t carto_base_spf(opal_carto_graph_t *graph,opal_carto_base_node_t *start, opal_carto_base_node_t *end)
|
uint32_t opal_carto_base_spf(opal_carto_graph_t *graph,opal_carto_base_node_t *start, opal_carto_base_node_t *end)
|
||||||
{
|
{
|
||||||
if (!opal_carto_base_selected) {
|
if (!opal_carto_base_selected) {
|
||||||
return OPAL_ERR_NOT_FOUND;
|
return OPAL_ERR_NOT_FOUND;
|
||||||
@ -59,7 +59,7 @@ uint32_t carto_base_spf(opal_carto_graph_t *graph,opal_carto_base_node_t *start,
|
|||||||
return opal_carto_base_module->spf(graph, start, end);
|
return opal_carto_base_module->spf(graph, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
opal_carto_base_node_t *carto_base_find_node(opal_carto_graph_t *graph, const char *node_name)
|
opal_carto_base_node_t *opal_carto_base_find_node(opal_carto_graph_t *graph, const char *node_name)
|
||||||
{
|
{
|
||||||
if (!opal_carto_base_selected) {
|
if (!opal_carto_base_selected) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -101,7 +101,7 @@ typedef uint32_t (*opal_carto_base_spf_fn_t)
|
|||||||
/**
|
/**
|
||||||
* Find a node in the graph
|
* Find a node in the graph
|
||||||
*/
|
*/
|
||||||
typedef opal_carto_base_node_t *(*opal_carto_base_find_node)
|
typedef opal_carto_base_node_t *(*opal_carto_base_find_node_fn_t)
|
||||||
(opal_carto_graph_t *graph, const char *node_name);
|
(opal_carto_graph_t *graph, const char *node_name);
|
||||||
|
|
||||||
|
|
||||||
@ -134,19 +134,19 @@ typedef struct opal_carto_base_component_1_0_0_t opal_carto_base_component_t;
|
|||||||
*/
|
*/
|
||||||
struct opal_carto_base_module_1_0_0_t {
|
struct opal_carto_base_module_1_0_0_t {
|
||||||
/** Module initialization function */
|
/** Module initialization function */
|
||||||
opal_carto_base_module_init_1_0_0_fn_t carto_module_init;
|
opal_carto_base_module_init_1_0_0_fn_t carto_module_init;
|
||||||
/** Get host graph */
|
/** Get host graph */
|
||||||
opal_carto_base_get_host_graph_fn_t get_host_graph;
|
opal_carto_base_get_host_graph_fn_t get_host_graph;
|
||||||
/** free graph */
|
/** free graph */
|
||||||
opal_carto_base_free_graph_fn_t free_graph;
|
opal_carto_base_free_graph_fn_t free_graph;
|
||||||
/** Get the distance from one node to all other nodes */
|
/** Get the distance from one node to all other nodes */
|
||||||
opal_carto_base_get_nodes_distance_fn_t get_nodes_distance;
|
opal_carto_base_get_nodes_distance_fn_t get_nodes_distance;
|
||||||
/** Find the distance between two nodes */
|
/** Find the distance between two nodes */
|
||||||
opal_carto_base_spf_fn_t spf;
|
opal_carto_base_spf_fn_t spf;
|
||||||
/** Find a node in the graph */
|
/** Find a node in the graph */
|
||||||
opal_carto_base_find_node find_node;
|
opal_carto_base_find_node_fn_t find_node;
|
||||||
/** Shut down this module */
|
/** Shut down this module */
|
||||||
opal_carto_base_module_finalize_fn_t carto_module_finalize;
|
opal_carto_base_module_finalize_fn_t carto_module_finalize;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Convenience typedef
|
* Convenience typedef
|
||||||
|
@ -61,11 +61,11 @@ static int opal_carto_file_parse(const char *cartofile);
|
|||||||
*/
|
*/
|
||||||
static const opal_carto_base_module_1_0_0_t loc_module = {
|
static const opal_carto_base_module_1_0_0_t loc_module = {
|
||||||
opal_carto_file_init,
|
opal_carto_file_init,
|
||||||
opal_carto_base_graph_get_host_graph,
|
opal_carto_base_graph_get_host_graph_fn,
|
||||||
opal_carto_base_free_graph,
|
opal_carto_base_free_graph_fn,
|
||||||
opal_carto_base_get_nodes_distance,
|
opal_carto_base_get_nodes_distance_fn,
|
||||||
opal_carto_base_graph_spf,
|
opal_carto_base_graph_spf_fn,
|
||||||
opal_carto_base_graph_find_node,
|
opal_carto_base_graph_find_node_fn,
|
||||||
opal_carto_file_finalize,
|
opal_carto_file_finalize,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -96,7 +96,9 @@ static int opal_carto_file_init(void)
|
|||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* create an empty graph */
|
/* create an empty graph */
|
||||||
opal_carto_base_graph_create(&carto_base_common_host_graph);
|
if (NULL == opal_carto_base_common_host_graph) {
|
||||||
|
opal_carto_base_graph_create_fn(&opal_carto_base_common_host_graph);
|
||||||
|
}
|
||||||
if (NULL == carto_file_path) {
|
if (NULL == carto_file_path) {
|
||||||
return OPAL_ERROR;
|
return OPAL_ERROR;
|
||||||
}
|
}
|
||||||
@ -113,7 +115,9 @@ static int opal_carto_file_init(void)
|
|||||||
static int opal_carto_file_finalize(void)
|
static int opal_carto_file_finalize(void)
|
||||||
{
|
{
|
||||||
/* free the host cartography graph. */
|
/* free the host cartography graph. */
|
||||||
opal_carto_base_free_graph(carto_base_common_host_graph);
|
if (NULL != opal_carto_base_common_host_graph) {
|
||||||
|
opal_carto_base_free_graph_fn(opal_carto_base_common_host_graph);
|
||||||
|
}
|
||||||
return OPAL_SUCCESS;
|
return OPAL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +181,7 @@ static int opal_carto_file_parse(const char *cartofile)
|
|||||||
switch (token) {
|
switch (token) {
|
||||||
case OPAL_CARTO_FILE_NAME:
|
case OPAL_CARTO_FILE_NAME:
|
||||||
node->node_name = strdup(carto_file_value.sval);
|
node->node_name = strdup(carto_file_value.sval);
|
||||||
opal_carto_base_graph_add_node(carto_base_common_host_graph, node);
|
opal_carto_base_graph_add_node_fn(opal_carto_base_common_host_graph, node);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
free(node);
|
free(node);
|
||||||
@ -215,7 +219,7 @@ static int opal_carto_file_parse(const char *cartofile)
|
|||||||
}
|
}
|
||||||
opal_argv_free (argv);
|
opal_argv_free (argv);
|
||||||
/* find the start node of the connection */
|
/* find the start node of the connection */
|
||||||
node = opal_carto_base_graph_find_node(carto_base_common_host_graph,node1_name);
|
node = opal_carto_base_graph_find_node_fn(opal_carto_base_common_host_graph,node1_name);
|
||||||
if (NULL == node) {
|
if (NULL == node) {
|
||||||
opal_show_help("help-opal-carto-file.txt", "vertex not found", true, cartofile, line_number, node1_name);
|
opal_show_help("help-opal-carto-file.txt", "vertex not found", true, cartofile, line_number, node1_name);
|
||||||
free(node1_name);
|
free(node1_name);
|
||||||
@ -223,14 +227,14 @@ static int opal_carto_file_parse(const char *cartofile)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
/* find the end node of the connection */
|
/* find the end node of the connection */
|
||||||
end_node = opal_carto_base_graph_find_node(carto_base_common_host_graph,node2_name);
|
end_node = opal_carto_base_graph_find_node_fn(opal_carto_base_common_host_graph,node2_name);
|
||||||
if (NULL == end_node) {
|
if (NULL == end_node) {
|
||||||
opal_show_help("help-opal-carto-file.txt", "vertex not found", true, cartofile, line_number, node2_name);
|
opal_show_help("help-opal-carto-file.txt", "vertex not found", true, cartofile, line_number, node2_name);
|
||||||
free(node1_name);
|
free(node1_name);
|
||||||
free(node2_name);
|
free(node2_name);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
opal_carto_base_connect_nodes(carto_base_common_host_graph, node, end_node, weight);
|
opal_carto_base_connect_nodes_fn(opal_carto_base_common_host_graph, node, end_node, weight);
|
||||||
free(node2_name);
|
free(node2_name);
|
||||||
break;
|
break;
|
||||||
case OPAL_CARTO_FILE_NEWLINE:
|
case OPAL_CARTO_FILE_NEWLINE:
|
||||||
@ -274,7 +278,7 @@ static int opal_carto_file_parse(const char *cartofile)
|
|||||||
}
|
}
|
||||||
opal_argv_free (argv);
|
opal_argv_free (argv);
|
||||||
/* find the start node of the connection */
|
/* find the start node of the connection */
|
||||||
node = opal_carto_base_graph_find_node(carto_base_common_host_graph,node1_name);
|
node = opal_carto_base_graph_find_node_fn(opal_carto_base_common_host_graph,node1_name);
|
||||||
if (NULL == node) {
|
if (NULL == node) {
|
||||||
opal_show_help("help-opal-carto-file.txt", "vertex not found", true, cartofile, line_number, node1_name);
|
opal_show_help("help-opal-carto-file.txt", "vertex not found", true, cartofile, line_number, node1_name);
|
||||||
free(node1_name);
|
free(node1_name);
|
||||||
@ -282,15 +286,15 @@ static int opal_carto_file_parse(const char *cartofile)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
/* find the end node of the connection */
|
/* find the end node of the connection */
|
||||||
end_node = opal_carto_base_graph_find_node(carto_base_common_host_graph,node2_name);
|
end_node = opal_carto_base_graph_find_node_fn(opal_carto_base_common_host_graph,node2_name);
|
||||||
if (NULL == end_node) {
|
if (NULL == end_node) {
|
||||||
opal_show_help("help-opal-carto-file.txt", "vertex not found", true, cartofile, line_number, node2_name);
|
opal_show_help("help-opal-carto-file.txt", "vertex not found", true, cartofile, line_number, node2_name);
|
||||||
free(node1_name);
|
free(node1_name);
|
||||||
free(node2_name);
|
free(node2_name);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
opal_carto_base_connect_nodes(carto_base_common_host_graph, node, end_node, weight);
|
opal_carto_base_connect_nodes_fn(opal_carto_base_common_host_graph, node, end_node, weight);
|
||||||
opal_carto_base_connect_nodes(carto_base_common_host_graph, end_node, node, weight);
|
opal_carto_base_connect_nodes_fn(opal_carto_base_common_host_graph, end_node, node, weight);
|
||||||
free(node2_name);
|
free(node2_name);
|
||||||
break;
|
break;
|
||||||
case OPAL_CARTO_FILE_NEWLINE:
|
case OPAL_CARTO_FILE_NEWLINE:
|
||||||
|
@ -51,125 +51,125 @@ main(int argc, char* argv[])
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
opal_output(0," \n\nget_host_graph Full\n");
|
opal_output(0," \n\nget_host_graph Full\n");
|
||||||
carto_base_get_host_graph(&graph,NULL);
|
opal_carto_base_get_host_graph(&graph,NULL);
|
||||||
opal_graph_print(graph);
|
opal_graph_print(graph);
|
||||||
slot0 = carto_base_find_node(graph, "slot0");
|
slot0 = opal_carto_base_find_node(graph, "slot0");
|
||||||
if (NULL == slot0) {
|
if (NULL == slot0) {
|
||||||
opal_output(0,"couldnt find slot0 in the graph exiting\n");
|
opal_output(0,"couldnt find slot0 in the graph exiting\n");
|
||||||
carto_base_free_graph(graph);
|
opal_carto_base_free_graph(graph);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
end_node = carto_base_find_node(graph, "slot3");
|
end_node = opal_carto_base_find_node(graph, "slot3");
|
||||||
if (NULL == end_node) {
|
if (NULL == end_node) {
|
||||||
opal_output(0,"couldnt find mthca1 in the graph exiting\n");
|
opal_output(0,"couldnt find mthca1 in the graph exiting\n");
|
||||||
carto_base_free_graph(graph);
|
opal_carto_base_free_graph(graph);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
distance = carto_base_spf(graph, slot0, end_node);
|
distance = opal_carto_base_spf(graph, slot0, end_node);
|
||||||
opal_output(0,"\nThe distance between slot0 and slot3 is %d\n",distance);
|
opal_output(0,"\nThe distance between slot0 and slot3 is %d\n",distance);
|
||||||
distance_array = OBJ_NEW(opal_value_array_t);
|
distance_array = OBJ_NEW(opal_value_array_t);
|
||||||
opal_value_array_init(distance_array, sizeof(opal_carto_node_distance_t));
|
opal_value_array_init(distance_array, sizeof(opal_carto_node_distance_t));
|
||||||
opal_value_array_reserve(distance_array, 50);
|
opal_value_array_reserve(distance_array, 50);
|
||||||
distance_array_size = carto_base_get_nodes_distance(graph, slot0, NULL, distance_array);
|
distance_array_size = opal_carto_base_get_nodes_distance(graph, slot0, NULL, distance_array);
|
||||||
for (i=0; i < distance_array_size; i++) {
|
for (i=0; i < distance_array_size; i++) {
|
||||||
node_distance = opal_value_array_get_item(distance_array, i);
|
node_distance = opal_value_array_get_item(distance_array, i);
|
||||||
opal_output(0,"Node %s distance from slot0 is %d\n",node_distance->node->node_name, node_distance->node_distance);
|
opal_output(0,"Node %s distance from slot0 is %d\n",node_distance->node->node_name, node_distance->node_distance);
|
||||||
}
|
}
|
||||||
OBJ_RELEASE(distance_array);
|
OBJ_RELEASE(distance_array);
|
||||||
carto_base_free_graph(graph);
|
opal_carto_base_free_graph(graph);
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
opal_output(0," \n\nget_host_graph Infiniband\n");
|
opal_output(0," \n\nget_host_graph Infiniband\n");
|
||||||
carto_base_get_host_graph(&graph,"Infiniband");
|
opal_carto_base_get_host_graph(&graph,"Infiniband");
|
||||||
opal_graph_print(graph);
|
opal_graph_print(graph);
|
||||||
slot0 = carto_base_find_node(graph, "slot0");
|
slot0 = opal_carto_base_find_node(graph, "slot0");
|
||||||
if (NULL == slot0) {
|
if (NULL == slot0) {
|
||||||
opal_output(0,"couldnt find slot0 in the graph exiting\n");
|
opal_output(0,"couldnt find slot0 in the graph exiting\n");
|
||||||
carto_base_free_graph(graph);
|
opal_carto_base_free_graph(graph);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
end_node = carto_base_find_node(graph, "mthca1");
|
end_node = opal_carto_base_find_node(graph, "mthca1");
|
||||||
if (NULL == end_node) {
|
if (NULL == end_node) {
|
||||||
opal_output(0,"couldnt find mthca1 in the graph exiting\n");
|
opal_output(0,"couldnt find mthca1 in the graph exiting\n");
|
||||||
carto_base_free_graph(graph);
|
opal_carto_base_free_graph(graph);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
distance = carto_base_spf(graph, slot0, end_node);
|
distance = opal_carto_base_spf(graph, slot0, end_node);
|
||||||
opal_output(0,"\nThe distance between slot0 and mthca1 is %d\n",distance);
|
opal_output(0,"\nThe distance between slot0 and mthca1 is %d\n",distance);
|
||||||
distance_array = OBJ_NEW(opal_value_array_t);
|
distance_array = OBJ_NEW(opal_value_array_t);
|
||||||
opal_value_array_init(distance_array, sizeof(opal_carto_node_distance_t));
|
opal_value_array_init(distance_array, sizeof(opal_carto_node_distance_t));
|
||||||
opal_value_array_reserve(distance_array, 50);
|
opal_value_array_reserve(distance_array, 50);
|
||||||
distance_array_size = carto_base_get_nodes_distance(graph, slot0, "Infiniband", distance_array);
|
distance_array_size = opal_carto_base_get_nodes_distance(graph, slot0, "Infiniband", distance_array);
|
||||||
for (i=0; i < distance_array_size; i++) {
|
for (i=0; i < distance_array_size; i++) {
|
||||||
node_distance = opal_value_array_get_item(distance_array, i);
|
node_distance = opal_value_array_get_item(distance_array, i);
|
||||||
opal_output(0,"Node %s distance from slot0 is %d\n",node_distance->node->node_name, node_distance->node_distance);
|
opal_output(0,"Node %s distance from slot0 is %d\n",node_distance->node->node_name, node_distance->node_distance);
|
||||||
}
|
}
|
||||||
OBJ_RELEASE(distance_array);
|
OBJ_RELEASE(distance_array);
|
||||||
carto_base_free_graph(graph);
|
opal_carto_base_free_graph(graph);
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
opal_output(0," \n\nget_host_graph Ethernet\n");
|
opal_output(0," \n\nget_host_graph Ethernet\n");
|
||||||
carto_base_get_host_graph(&graph,"Ethernet");
|
opal_carto_base_get_host_graph(&graph,"Ethernet");
|
||||||
opal_graph_print(graph);
|
opal_graph_print(graph);
|
||||||
slot0 = carto_base_find_node(graph, "slot0");
|
slot0 = opal_carto_base_find_node(graph, "slot0");
|
||||||
if (NULL == slot0) {
|
if (NULL == slot0) {
|
||||||
opal_output(0,"couldnt find slot0 in the graph exiting\n");
|
opal_output(0,"couldnt find slot0 in the graph exiting\n");
|
||||||
carto_base_free_graph(graph);
|
opal_carto_base_free_graph(graph);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
end_node = carto_base_find_node(graph, "eth1");
|
end_node = opal_carto_base_find_node(graph, "eth1");
|
||||||
if (NULL == end_node) {
|
if (NULL == end_node) {
|
||||||
opal_output(0,"couldnt find mthca1 in the graph exiting\n");
|
opal_output(0,"couldnt find mthca1 in the graph exiting\n");
|
||||||
carto_base_free_graph(graph);
|
opal_carto_base_free_graph(graph);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
distance = carto_base_spf(graph, slot0, end_node);
|
distance = opal_carto_base_spf(graph, slot0, end_node);
|
||||||
opal_output(0,"\nThe distance between slot0 and eth1 is %d\n",distance);
|
opal_output(0,"\nThe distance between slot0 and eth1 is %d\n",distance);
|
||||||
distance_array = OBJ_NEW(opal_value_array_t);
|
distance_array = OBJ_NEW(opal_value_array_t);
|
||||||
opal_value_array_init(distance_array, sizeof(opal_carto_node_distance_t));
|
opal_value_array_init(distance_array, sizeof(opal_carto_node_distance_t));
|
||||||
opal_value_array_reserve(distance_array, 50);
|
opal_value_array_reserve(distance_array, 50);
|
||||||
distance_array_size = carto_base_get_nodes_distance(graph, slot0, "Ethernet", distance_array);
|
distance_array_size = opal_carto_base_get_nodes_distance(graph, slot0, "Ethernet", distance_array);
|
||||||
for (i=0; i < distance_array_size; i++) {
|
for (i=0; i < distance_array_size; i++) {
|
||||||
node_distance = opal_value_array_get_item(distance_array, i);
|
node_distance = opal_value_array_get_item(distance_array, i);
|
||||||
opal_output(0,"Node %s distance from slot0 is %d\n",node_distance->node->node_name, node_distance->node_distance);
|
opal_output(0,"Node %s distance from slot0 is %d\n",node_distance->node->node_name, node_distance->node_distance);
|
||||||
}
|
}
|
||||||
OBJ_RELEASE(distance_array);
|
OBJ_RELEASE(distance_array);
|
||||||
carto_base_free_graph(graph);
|
opal_carto_base_free_graph(graph);
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
opal_output(0," \n\nget_host_graph Memory\n");
|
opal_output(0," \n\nget_host_graph Memory\n");
|
||||||
carto_base_get_host_graph(&graph,"Memory");
|
opal_carto_base_get_host_graph(&graph,"Memory");
|
||||||
opal_graph_print(graph);
|
opal_graph_print(graph);
|
||||||
slot0 = carto_base_find_node(graph, "slot0");
|
slot0 = opal_carto_base_find_node(graph, "slot0");
|
||||||
if (NULL == slot0) {
|
if (NULL == slot0) {
|
||||||
opal_output(0,"couldnt find slot0 in the graph exiting\n");
|
opal_output(0,"couldnt find slot0 in the graph exiting\n");
|
||||||
carto_base_free_graph(graph);
|
opal_carto_base_free_graph(graph);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
end_node = carto_base_find_node(graph, "mem3");
|
end_node = opal_carto_base_find_node(graph, "mem3");
|
||||||
if (NULL == end_node) {
|
if (NULL == end_node) {
|
||||||
opal_output(0,"couldnt find mthca1 in the graph exiting\n");
|
opal_output(0,"couldnt find mthca1 in the graph exiting\n");
|
||||||
carto_base_free_graph(graph);
|
opal_carto_base_free_graph(graph);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
distance = carto_base_spf(graph, slot0, end_node);
|
distance = opal_carto_base_spf(graph, slot0, end_node);
|
||||||
opal_output(0,"\nThe distance between slot0 and mem3 is %d\n",distance);
|
opal_output(0,"\nThe distance between slot0 and mem3 is %d\n",distance);
|
||||||
distance_array = OBJ_NEW(opal_value_array_t);
|
distance_array = OBJ_NEW(opal_value_array_t);
|
||||||
opal_value_array_init(distance_array, sizeof(opal_carto_node_distance_t));
|
opal_value_array_init(distance_array, sizeof(opal_carto_node_distance_t));
|
||||||
opal_value_array_reserve(distance_array, 50);
|
opal_value_array_reserve(distance_array, 50);
|
||||||
distance_array_size = carto_base_get_nodes_distance(graph, slot0, "Memory", distance_array);
|
distance_array_size = opal_carto_base_get_nodes_distance(graph, slot0, "Memory", distance_array);
|
||||||
for (i=0; i < distance_array_size; i++) {
|
for (i=0; i < distance_array_size; i++) {
|
||||||
node_distance = opal_value_array_get_item(distance_array, i);
|
node_distance = opal_value_array_get_item(distance_array, i);
|
||||||
opal_output(0,"Node %s distance from slot0 is %d\n",node_distance->node->node_name, node_distance->node_distance);
|
opal_output(0,"Node %s distance from slot0 is %d\n",node_distance->node->node_name, node_distance->node_distance);
|
||||||
}
|
}
|
||||||
OBJ_RELEASE(distance_array);
|
OBJ_RELEASE(distance_array);
|
||||||
carto_base_free_graph(graph);
|
opal_carto_base_free_graph(graph);
|
||||||
|
|
||||||
}
|
}
|
||||||
MPI_Barrier(MPI_COMM_WORLD);
|
MPI_Barrier(MPI_COMM_WORLD);
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user