3
3
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
4
4
* University Research and Technology
5
5
* Corporation. All rights reserved.
6
- * Copyright (c) 2004-2007 The University of Tennessee and The University
6
+ * Copyright (c) 2004-2020 The University of Tennessee and The University
7
7
* of Tennessee Research Foundation. All rights
8
8
* reserved.
9
9
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@@ -55,11 +55,68 @@ OMPI_DECLSPEC extern int ompi_mpi_errcode_lastpredefined;
55
55
56
56
OMPI_DECLSPEC extern ompi_mpi_errcode_t ompi_err_unknown ;
57
57
58
+ /**
59
+ * Initialize the error codes
60
+ *
61
+ * @returns OMPI_SUCCESS Upon success
62
+ * @returns OMPI_ERROR Otherwise
63
+ *
64
+ * Invoked from ompi_mpi_init(); sets up all static MPI error codes,
65
+ */
66
+ int ompi_mpi_errcode_init (void );
67
+
68
+ /**
69
+ * Finalize the error codes.
70
+ *
71
+ * @returns OMPI_SUCCESS Always
72
+ *
73
+ * Invokes from ompi_mpi_finalize(); tears down the error code array.
74
+ */
75
+ int ompi_mpi_errcode_finalize (void );
76
+
77
+ /**
78
+ * Add an error code
79
+ *
80
+ * @param: error class to which this new error code belongs to
81
+ *
82
+ * @returns the new error code on SUCCESS (>0)
83
+ * @returns OMPI_ERROR otherwise
84
+ *
85
+ */
86
+ int ompi_mpi_errcode_add (int errclass );
87
+
88
+ /**
89
+ * Add an error class
90
+ *
91
+ * @param: none
92
+ *
93
+ * @returns the new error class on SUCCESS (>0)
94
+ * @returns OMPI_ERROR otherwise
95
+ *
96
+ */
97
+ int ompi_mpi_errclass_add (void );
98
+
99
+ /**
100
+ * Add an error string to an error code
101
+ *
102
+ * @param: error code for which the string is defined
103
+ * @param: error string to add
104
+ * @param: length of the string
105
+ *
106
+ * @returns OMPI_SUCCESS on success
107
+ * @returns OMPI_ERROR on error
108
+ */
109
+ int ompi_mpi_errnum_add_string (int errnum , const char * string , int len );
110
+
58
111
/**
59
112
* Check for a valid error code
60
113
*/
61
114
static inline bool ompi_mpi_errcode_is_invalid (int errcode )
62
115
{
116
+ if (OPAL_UNLIKELY ( 0 == ompi_mpi_errcode_lastpredefined )) {
117
+ ompi_mpi_errcode_init ();
118
+ }
119
+
63
120
if ( errcode >= 0 && errcode <= ompi_mpi_errcode_lastused )
64
121
return 0 ;
65
122
else
@@ -73,23 +130,31 @@ static inline int ompi_mpi_errcode_get_class (int errcode)
73
130
{
74
131
ompi_mpi_errcode_t * err = NULL ;
75
132
133
+ if (OPAL_UNLIKELY ( 0 == ompi_mpi_errcode_lastpredefined )) {
134
+ ompi_mpi_errcode_init ();
135
+ }
136
+
76
137
if (errcode >= 0 ) {
77
138
err = (ompi_mpi_errcode_t * )opal_pointer_array_get_item (& ompi_mpi_errcodes , errcode );
78
139
/* If we get a bogus errcode, return MPI_ERR_UNKNOWN */
79
140
}
80
141
81
142
if (NULL != err ) {
82
- if ( err -> code != MPI_UNDEFINED ) {
83
- return err -> cls ;
84
- }
143
+ if ( err -> code != MPI_UNDEFINED ) {
144
+ return err -> cls ;
145
+ }
85
146
}
86
147
return ompi_err_unknown .cls ;
87
148
}
88
149
89
150
static inline int ompi_mpi_errcode_is_predefined ( int errcode )
90
151
{
152
+ if (OPAL_UNLIKELY ( 0 == ompi_mpi_errcode_lastpredefined )) {
153
+ ompi_mpi_errcode_init ();
154
+ }
155
+
91
156
if ( errcode >= 0 && errcode <= ompi_mpi_errcode_lastpredefined )
92
- return true;
157
+ return true;
93
158
94
159
return false;
95
160
}
@@ -98,23 +163,27 @@ static inline int ompi_mpi_errnum_is_class ( int errnum )
98
163
{
99
164
ompi_mpi_errcode_t * err ;
100
165
166
+ if (OPAL_UNLIKELY ( 0 == ompi_mpi_errcode_lastpredefined )) {
167
+ ompi_mpi_errcode_init ();
168
+ }
169
+
101
170
if (errnum < 0 ) {
102
171
return false;
103
172
}
104
173
105
174
if ( errnum <= ompi_mpi_errcode_lastpredefined ) {
106
- /* Predefined error values represent an error code and
107
- an error class at the same time */
108
- return true;
175
+ /* Predefined error values represent an error code and
176
+ an error class at the same time */
177
+ return true;
109
178
}
110
179
111
180
err = (ompi_mpi_errcode_t * )opal_pointer_array_get_item (& ompi_mpi_errcodes , errnum );
112
181
if (NULL != err ) {
113
- if ( MPI_UNDEFINED == err -> code ) {
114
- /* Distinction between error class and error code is that for the
115
- first one the code section is set to MPI_UNDEFINED */
116
- return true;
117
- }
182
+ if ( MPI_UNDEFINED == err -> code ) {
183
+ /* Distinction between error class and error code is that for the
184
+ first one the code section is set to MPI_UNDEFINED */
185
+ return true;
186
+ }
118
187
}
119
188
120
189
return false;
@@ -128,6 +197,10 @@ static inline char* ompi_mpi_errnum_get_string (int errnum)
128
197
{
129
198
ompi_mpi_errcode_t * err = NULL ;
130
199
200
+ if (OPAL_UNLIKELY ( 0 == ompi_mpi_errcode_lastpredefined )) {
201
+ ompi_mpi_errcode_init ();
202
+ }
203
+
131
204
if (errnum >= 0 ) {
132
205
err = (ompi_mpi_errcode_t * )opal_pointer_array_get_item (& ompi_mpi_errcodes , errnum );
133
206
/* If we get a bogus errcode, return a string indicating that this
@@ -142,59 +215,6 @@ static inline char* ompi_mpi_errnum_get_string (int errnum)
142
215
}
143
216
144
217
145
- /**
146
- * Initialize the error codes
147
- *
148
- * @returns OMPI_SUCCESS Upon success
149
- * @returns OMPI_ERROR Otherwise
150
- *
151
- * Invoked from ompi_mpi_init(); sets up all static MPI error codes,
152
- */
153
- int ompi_mpi_errcode_init (void );
154
-
155
- /**
156
- * Finalize the error codes.
157
- *
158
- * @returns OMPI_SUCCESS Always
159
- *
160
- * Invokes from ompi_mpi_finalize(); tears down the error code array.
161
- */
162
- int ompi_mpi_errcode_finalize (void );
163
-
164
- /**
165
- * Add an error code
166
- *
167
- * @param: error class to which this new error code belongs to
168
- *
169
- * @returns the new error code on SUCCESS (>0)
170
- * @returns OMPI_ERROR otherwise
171
- *
172
- */
173
- int ompi_mpi_errcode_add (int errclass );
174
-
175
- /**
176
- * Add an error class
177
- *
178
- * @param: none
179
- *
180
- * @returns the new error class on SUCCESS (>0)
181
- * @returns OMPI_ERROR otherwise
182
- *
183
- */
184
- int ompi_mpi_errclass_add (void );
185
-
186
- /**
187
- * Add an error string to an error code
188
- *
189
- * @param: error code for which the string is defined
190
- * @param: error string to add
191
- * @param: length of the string
192
- *
193
- * @returns OMPI_SUCCESS on success
194
- * @returns OMPI_ERROR on error
195
- */
196
- int ompi_mpi_errnum_add_string (int errnum , const char * string , int len );
197
-
198
218
END_C_DECLS
199
219
200
220
#endif /* OMPI_MPI_ERRCODE_H */
0 commit comments