Skip to content

Commit ca47e54

Browse files
committed
handle user error classes and codes
Signed-off-by: Howard Pritchard <[email protected]>
1 parent 32d6fde commit ca47e54

14 files changed

+101
-25
lines changed

ompi/mpi/bindings/ompi_bindings/c.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def generate_error_convert_fn(self):
226226
lines.append(f'case {self.mangle_name(error)}:')
227227
lines.append(f'return {error};')
228228
lines.append('default:')
229-
lines.append('return error_class;')
229+
lines.append('return (error_class - %s);' % ('OMPI_ABI_HANDLE_BASE_OFFSET'))
230230
lines.append('}')
231231
self.dump_lines(lines)
232232
self.dump('}')
@@ -240,7 +240,7 @@ def generate_error_convert_fn_intern_to_abi(self):
240240
lines.append(f'case {error}:')
241241
lines.append(f'return {self.mangle_name(error)};')
242242
lines.append('default:')
243-
lines.append('return error_class;')
243+
lines.append('return (error_class + %s);' % ('OMPI_ABI_HANDLE_BASE_OFFSET'))
244244
lines.append('}')
245245
self.dump_lines(lines)
246246
self.dump('}')

ompi/mpi/bindings/ompi_bindings/c_type.py

Lines changed: 87 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,17 @@ def callback_wrapper_code(self):
9090
"""Return True if this parameter has callback wrapper code to generate."""
9191
return False
9292

93+
class StandardABIType(Type):
94+
95+
@property
96+
def tmpname(self):
97+
return f'{self.name}_tmp'
98+
99+
@property
100+
def argument(self):
101+
return self.tmpname
102+
103+
93104
@Type.add_type('ERROR_CLASS', abi_type=['ompi'])
94105
class TypeErrorClass(Type):
95106

@@ -100,15 +111,90 @@ def return_code(self, name):
100111
return [f'return {name};']
101112

102113
@Type.add_type('ERROR_CLASS', abi_type=['standard'])
103-
class TypeErrorClass(Type):
114+
class TypeErrorClassStandard(StandardABIType):
104115

105116
def type_text(self, enable_count=False):
106117
return 'int'
107118

119+
@property
120+
def init_code(self):
121+
return [f'int {self.tmpname} = {ConvertFuncs.ERROR_CLASS}({self.name});']
122+
108123
def return_code(self, name):
109124
return [f'return {ConvertOMPIToStandard.ERROR_CLASS}({name});']
110125

111126

127+
@Type.add_type('ERROR_CLASS_OUT', abi_type=['ompi'])
128+
class TypeErrorClassOut(Type):
129+
130+
def type_text(self, enable_count=False):
131+
return 'int *'
132+
133+
@Type.add_type('ERROR_CLASS_OUT', abi_type=['standard'])
134+
class TypeErrorClassOutStandard(StandardABIType):
135+
136+
def type_text(self, enable_count=False):
137+
return 'int *'
138+
139+
@property
140+
def final_code(self):
141+
return [f'*{self.name} = {ConvertOMPIToStandard.ERROR_CLASS}(*{self.name});']
142+
143+
@property
144+
def argument(self):
145+
return f'{self.name}'
146+
147+
#
148+
# types below seem duplicative of ERROR_CLASS but
149+
# are provided for clarity in the template files
150+
# to distinguish between classes and codes which can
151+
# have different values (in theory) if they are not
152+
# predeinfed by MPI
153+
#
154+
@Type.add_type('ERROR_CODE', abi_type=['ompi'])
155+
class TypeErrorCode(Type):
156+
157+
def type_text(self, enable_count=False):
158+
return 'int'
159+
160+
def return_code(self, name):
161+
return [f'return {name};']
162+
163+
@Type.add_type('ERROR_CODE', abi_type=['standard'])
164+
class TypeErrorCodeStandard(StandardABIType):
165+
166+
def type_text(self, enable_count=False):
167+
return 'int'
168+
169+
@property
170+
def init_code(self):
171+
return [f'int {self.tmpname} = {ConvertFuncs.ERROR_CLASS}({self.name});']
172+
173+
def return_code(self, name):
174+
return [f'return {ConvertOMPIToStandard.ERROR_CLASS}({name});']
175+
176+
177+
@Type.add_type('ERROR_CODE_OUT', abi_type=['ompi'])
178+
class TypeErrorCodeOut(Type):
179+
180+
def type_text(self, enable_count=False):
181+
return 'int *'
182+
183+
@Type.add_type('ERROR_CODE_OUT', abi_type=['standard'])
184+
class TypeErrorCodeOutStandard(StandardABIType):
185+
186+
def type_text(self, enable_count=False):
187+
return 'int *'
188+
189+
@property
190+
def final_code(self):
191+
return [f'*{self.name} = {ConvertOMPIToStandard.ERROR_CLASS}(*{self.name});']
192+
193+
@property
194+
def argument(self):
195+
return f'{self.name}'
196+
197+
112198
@Type.add_type('BUFFER')
113199
class TypeBuffer(Type):
114200

@@ -411,16 +497,6 @@ def type_text(self, enable_count=False):
411497
def parameter(self, enable_count=False, **kwargs):
412498
return f'{self.type_text(enable_count=enable_count)} {self.name}[]'
413499

414-
class StandardABIType(Type):
415-
416-
@property
417-
def tmpname(self):
418-
return f'{self.name}_tmp'
419-
420-
@property
421-
def argument(self):
422-
return self.tmpname
423-
424500

425501
@Type.add_type('DATATYPE', abi_type=['standard'])
426502
class TypeDatatypeStandard(StandardABIType):

ompi/mpi/c/add_error_class.c.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "ompi/communicator/communicator.h"
3232
#include "ompi/attribute/attribute.h"
3333

34-
PROTOTYPE ERROR_CLASS add_error_class(INT_OUT errorclass)
34+
PROTOTYPE ERROR_CLASS add_error_class(ERROR_CLASS_OUT errorclass)
3535
{
3636
int err_class;
3737
int rc;

ompi/mpi/c/add_error_code.c.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "ompi/errhandler/errcode.h"
3232
#include "ompi/attribute/attribute.h"
3333

34-
PROTOTYPE ERROR_CLASS add_error_code(INT errorclass, INT_OUT errorcode)
34+
PROTOTYPE ERROR_CLASS add_error_code(ERROR_CLASS errorclass, ERROR_CODE_OUT errorcode)
3535
{
3636
int code;
3737
int rc;

ompi/mpi/c/add_error_string.c.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include "ompi/errhandler/errhandler.h"
3131
#include "ompi/errhandler/errcode.h"
3232

33-
PROTOTYPE ERROR_CLASS add_error_string(INT errorcode, STRING string)
33+
PROTOTYPE ERROR_CLASS add_error_string(ERROR_CODE errorcode, STRING string)
3434
{
3535
int rc;
3636

ompi/mpi/c/comm_call_errhandler.c.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "ompi/errhandler/errhandler.h"
2929
#include "ompi/memchecker.h"
3030

31-
PROTOTYPE ERROR_CLASS comm_call_errhandler(COMM comm, INT errorcode)
31+
PROTOTYPE ERROR_CLASS comm_call_errhandler(COMM comm, ERROR_CODE errorcode)
3232
{
3333
MEMCHECKER(
3434
memchecker_comm(comm);

ompi/mpi/c/error_class.c.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "ompi/errhandler/errhandler.h"
2929
#include "ompi/errhandler/errcode.h"
3030

31-
PROTOTYPE ERROR_CLASS error_class(INT errorcode, INT_OUT errorclass)
31+
PROTOTYPE ERROR_CLASS error_class(ERROR_CODE errorcode, ERROR_CLASS_OUT errorclass)
3232
{
3333
int ret;
3434

ompi/mpi/c/error_string.c.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include "ompi/errhandler/errhandler.h"
3333
#include "ompi/errhandler/errcode.h"
3434

35-
PROTOTYPE ERROR_CLASS error_string(INT errorcode, STRING_OUT string,
35+
PROTOTYPE ERROR_CLASS error_string(ERROR_CLASS errorcode, STRING_OUT string,
3636
INT_OUT resultlen)
3737
{
3838
int ret;

ompi/mpi/c/file_call_errhandler.c.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "ompi/errhandler/errhandler.h"
2929
#include "ompi/file/file.h"
3030

31-
PROTOTYPE ERROR_CLASS file_call_errhandler(FILE fh, INT errorcode)
31+
PROTOTYPE ERROR_CLASS file_call_errhandler(FILE fh, ERROR_CODE errorcode)
3232
{
3333
/* Error checking */
3434

ompi/mpi/c/remove_error_class.c.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include "ompi/communicator/communicator.h"
3333
#include "ompi/attribute/attribute.h"
3434

35-
PROTOTYPE ERROR_CLASS remove_error_class(INT errorclass)
35+
PROTOTYPE ERROR_CLASS remove_error_class(ERROR_CLASS errorclass)
3636
{
3737
int rc;
3838

0 commit comments

Comments
 (0)