This source file includes following definitions.
- MPI_Dist_graph_create
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #include "ompi_config.h"
19
20 #include "ompi/mpi/c/bindings.h"
21 #include "ompi/runtime/params.h"
22 #include "ompi/communicator/communicator.h"
23 #include "ompi/errhandler/errhandler.h"
24 #include "ompi/memchecker.h"
25 #include "ompi/mca/topo/topo.h"
26 #include "ompi/mca/topo/base/base.h"
27
28 #if OMPI_BUILD_MPI_PROFILING
29 #if OPAL_HAVE_WEAK_SYMBOLS
30 #pragma weak MPI_Dist_graph_create = PMPI_Dist_graph_create
31 #endif
32 #define MPI_Dist_graph_create PMPI_Dist_graph_create
33 #endif
34
35 static const char FUNC_NAME[] = "MPI_Dist_graph_create";
36
37 int MPI_Dist_graph_create(MPI_Comm comm_old, int n, const int sources[],
38 const int degrees[], const int destinations[], const int weights[],
39 MPI_Info info, int reorder, MPI_Comm * newcomm)
40 {
41 mca_topo_base_module_t* topo;
42 int i, j, index, err, comm_size;
43
44 MEMCHECKER(
45 memchecker_comm(comm_old);
46 );
47
48 if (MPI_PARAM_CHECK) {
49 OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
50 if (ompi_comm_invalid(comm_old)) {
51 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
52 FUNC_NAME);
53 } else if (OMPI_COMM_IS_INTER(comm_old)) {
54 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
55 FUNC_NAME);
56 } else if (n < 0 || NULL == newcomm) {
57 return OMPI_ERRHANDLER_INVOKE(comm_old, MPI_ERR_ARG, FUNC_NAME);
58 } else if (n > 0 && (NULL == sources || NULL == degrees ||
59 NULL == destinations || NULL == weights)) {
60 return OMPI_ERRHANDLER_INVOKE(comm_old, MPI_ERR_ARG, FUNC_NAME);
61 }
62
63 comm_size = ompi_comm_size(comm_old);
64 for( i = index = 0; i < n; ++i ) {
65 if (((sources[i] < 0) && (sources[i] != MPI_PROC_NULL)) || sources[i] >= comm_size) {
66 return OMPI_ERRHANDLER_INVOKE(comm_old, MPI_ERR_ARG,
67 FUNC_NAME);
68 } else if (degrees[i] < 0) {
69 return OMPI_ERRHANDLER_INVOKE(comm_old, MPI_ERR_ARG,
70 FUNC_NAME);
71 }
72 for( j = 0; j < degrees[i]; ++j ) {
73 if (((destinations[index] < 0) && (destinations[index] != MPI_PROC_NULL)) || destinations[index] >= comm_size) {
74 return OMPI_ERRHANDLER_INVOKE(comm_old, MPI_ERR_ARG,
75 FUNC_NAME);
76 } else if (MPI_UNWEIGHTED != weights && weights[index] < 0) {
77 return OMPI_ERRHANDLER_INVOKE(comm_old, MPI_ERR_ARG,
78 FUNC_NAME);
79 }
80 index++;
81 }
82 }
83 }
84
85
86 if(OMPI_SUCCESS != (err = mca_topo_base_comm_select(comm_old, NULL,
87 &topo, OMPI_COMM_DIST_GRAPH))) {
88 return OMPI_ERRHANDLER_INVOKE(comm_old, err, FUNC_NAME);
89 }
90
91 err = topo->topo.dist_graph.dist_graph_create(topo, comm_old, n, sources, degrees,
92 destinations, weights, &(info->super),
93 reorder, newcomm);
94 OMPI_ERRHANDLER_RETURN(err, comm_old, err, FUNC_NAME);
95 }
96