This source file includes following definitions.
- MPI_Lookup_name
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 #include "ompi_config.h"
27
28 #include "opal/class/opal_list.h"
29 #include "opal/mca/pmix/pmix.h"
30 #include "opal/util/show_help.h"
31 #include "opal/util/string_copy.h"
32
33 #include "ompi/mpi/c/bindings.h"
34 #include "ompi/runtime/params.h"
35 #include "ompi/errhandler/errhandler.h"
36 #include "ompi/info/info.h"
37 #include "ompi/communicator/communicator.h"
38
39 #if OMPI_BUILD_MPI_PROFILING
40 #if OPAL_HAVE_WEAK_SYMBOLS
41 #pragma weak MPI_Lookup_name = PMPI_Lookup_name
42 #endif
43 #define MPI_Lookup_name PMPI_Lookup_name
44 #endif
45
46 static const char FUNC_NAME[] = "MPI_Lookup_name";
47
48
49 int MPI_Lookup_name(const char *service_name, MPI_Info info, char *port_name)
50 {
51 char range[OPAL_MAX_INFO_VAL];
52 int flag=0, ret;
53 opal_value_t *rng;
54 opal_list_t results, pinfo;
55 opal_pmix_pdata_t *pdat;
56
57 if ( MPI_PARAM_CHECK ) {
58 OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
59
60 if ( NULL == port_name ) {
61 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
62 FUNC_NAME);
63 }
64 if ( NULL == service_name ) {
65 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
66 FUNC_NAME);
67 }
68 if (NULL == info || ompi_info_is_freed(info)) {
69 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_INFO,
70 FUNC_NAME);
71 }
72 }
73
74 if (NULL == opal_pmix.lookup) {
75 opal_show_help("help-mpi-api.txt",
76 "MPI function not supported",
77 true,
78 FUNC_NAME,
79 "Underlying runtime environment does not support name lookup functionality");
80 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD,
81 OMPI_ERR_NOT_SUPPORTED,
82 FUNC_NAME);
83 }
84
85 OPAL_CR_ENTER_LIBRARY();
86
87 OBJ_CONSTRUCT(&pinfo, opal_list_t);
88
89
90
91 if (MPI_INFO_NULL != info) {
92 ompi_info_get (info, "range", sizeof(range) - 1, range, &flag);
93 if (flag) {
94 if (0 == strcmp(range, "nspace")) {
95 rng = OBJ_NEW(opal_value_t);
96 rng->key = strdup(OPAL_PMIX_RANGE);
97 rng->type = OPAL_INT;
98 rng->data.integer = OPAL_PMIX_RANGE_NAMESPACE;
99 opal_list_append(&pinfo, &rng->super);
100 } else if (0 == strcmp(range, "session")) {
101 rng = OBJ_NEW(opal_value_t);
102 rng->key = strdup(OPAL_PMIX_RANGE);
103 rng->type = OPAL_INT;
104 rng->data.integer = OPAL_PMIX_RANGE_SESSION;
105 opal_list_append(&pinfo, &rng->super);
106 } else {
107
108 OPAL_LIST_DESTRUCT(&pinfo);
109 OPAL_CR_EXIT_LIBRARY();
110 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
111 FUNC_NAME);
112 }
113 }
114 }
115
116
117 OBJ_CONSTRUCT(&results, opal_list_t);
118 pdat = OBJ_NEW(opal_pmix_pdata_t);
119 pdat->value.key = strdup(service_name);
120 opal_list_append(&results, &pdat->super);
121
122 ret = opal_pmix.lookup(&results, &pinfo);
123 OPAL_LIST_DESTRUCT(&pinfo);
124 if (OPAL_SUCCESS != ret ||
125 OPAL_STRING != pdat->value.type ||
126 NULL == pdat->value.data.string) {
127 if (OPAL_ERR_NOT_SUPPORTED == ret) {
128 ret = OMPI_ERR_NOT_SUPPORTED;
129 opal_show_help("help-mpi-api.txt",
130 "MPI function not supported",
131 true,
132 FUNC_NAME,
133 "Underlying runtime environment does not support name lookup functionality");
134 } else {
135 ret = MPI_ERR_NAME;
136 }
137
138 OPAL_CR_EXIT_LIBRARY();
139 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, ret, FUNC_NAME);
140 }
141
142 opal_string_copy( port_name, pdat->value.data.string,
143 MPI_MAX_PORT_NAME );
144 OPAL_LIST_DESTRUCT(&results);
145
146 OPAL_CR_EXIT_LIBRARY();
147 return MPI_SUCCESS;
148 }