This source file includes following definitions.
- ompi_mpi_errcode_is_invalid
- ompi_mpi_errcode_get_class
- ompi_mpi_errcode_is_predefined
- ompi_mpi_errnum_is_class
- ompi_mpi_errnum_get_string
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 #ifndef OMPI_MPI_ERRCODE_H
26 #define OMPI_MPI_ERRCODE_H
27
28 #include "ompi_config.h"
29
30 #include "mpi.h"
31 #include "opal/class/opal_object.h"
32 #include "opal/class/opal_pointer_array.h"
33
34 BEGIN_C_DECLS
35
36
37
38
39
40
41
42
43
44 struct ompi_mpi_errcode_t {
45 opal_object_t super;
46 int code;
47 int cls;
48 char errstring[MPI_MAX_ERROR_STRING];
49 };
50 typedef struct ompi_mpi_errcode_t ompi_mpi_errcode_t;
51
52 OMPI_DECLSPEC extern opal_pointer_array_t ompi_mpi_errcodes;
53 OMPI_DECLSPEC extern int ompi_mpi_errcode_lastused;
54 OMPI_DECLSPEC extern int ompi_mpi_errcode_lastpredefined;
55
56 OMPI_DECLSPEC extern ompi_mpi_errcode_t ompi_err_unknown;
57
58
59
60
61 static inline bool ompi_mpi_errcode_is_invalid(int errcode)
62 {
63 if ( errcode >= 0 && errcode <= ompi_mpi_errcode_lastused )
64 return 0;
65 else
66 return 1;
67 }
68
69
70
71
72 static inline int ompi_mpi_errcode_get_class (int errcode)
73 {
74 ompi_mpi_errcode_t *err = NULL;
75
76 if (errcode >= 0) {
77 err = (ompi_mpi_errcode_t *)opal_pointer_array_get_item(&ompi_mpi_errcodes, errcode);
78
79 }
80
81 if (NULL != err) {
82 if ( err->code != MPI_UNDEFINED ) {
83 return err->cls;
84 }
85 }
86 return ompi_err_unknown.cls;
87 }
88
89 static inline int ompi_mpi_errcode_is_predefined ( int errcode )
90 {
91 if ( errcode >= 0 && errcode <= ompi_mpi_errcode_lastpredefined )
92 return true;
93
94 return false;
95 }
96
97 static inline int ompi_mpi_errnum_is_class ( int errnum )
98 {
99 ompi_mpi_errcode_t *err;
100
101 if (errnum < 0) {
102 return false;
103 }
104
105 if ( errnum <= ompi_mpi_errcode_lastpredefined ) {
106
107
108 return true;
109 }
110
111 err = (ompi_mpi_errcode_t *)opal_pointer_array_get_item(&ompi_mpi_errcodes, errnum);
112 if (NULL != err) {
113 if ( MPI_UNDEFINED == err->code) {
114
115
116 return true;
117 }
118 }
119
120 return false;
121 }
122
123
124
125
126
127 static inline char* ompi_mpi_errnum_get_string (int errnum)
128 {
129 ompi_mpi_errcode_t *err = NULL;
130
131 if (errnum >= 0) {
132 err = (ompi_mpi_errcode_t *)opal_pointer_array_get_item(&ompi_mpi_errcodes, errnum);
133
134
135 }
136
137 if (NULL != err) {
138 return err->errstring;
139 } else {
140 return "Unknown error (this should not happen!)";
141 }
142 }
143
144
145
146
147
148
149
150
151
152
153 int ompi_mpi_errcode_init(void);
154
155
156
157
158
159
160
161
162 int ompi_mpi_errcode_finalize(void);
163
164
165
166
167
168
169
170
171
172
173 int ompi_mpi_errcode_add (int errclass);
174
175
176
177
178
179
180
181
182
183
184 int ompi_mpi_errclass_add (void);
185
186
187
188
189
190
191
192
193
194
195
196 int ompi_mpi_errnum_add_string (int errnum, const char* string, int len);
197
198 END_C_DECLS
199
200 #endif