Skip to content

Commit dedcf72

Browse files
committed
checkpoint
many changes. go back to generating abi_converters.h fix up tools for abi case, etc. Signed-off-by: Howard Pritchard <[email protected]>
1 parent 111f48b commit dedcf72

37 files changed

+749
-1652
lines changed

ompi/mpi/bindings/bindings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ def main():
5757
parser_header.add_argument('--external', action='store_true', help='generate external mpi.h header file')
5858
parser_header.add_argument('--srcdir', help='source directory')
5959
parser_header.set_defaults(handler=lambda args, out: c.generate_header(args, out))
60+
parser_header = subparsers_c.add_parser('converters', help='generate converter header file')
61+
parser_header.set_defaults(handler=lambda args, out: c.generate_converters(args, out))
6062
parser_gen = subparsers_c.add_parser('source', help='generate source file from template file')
6163
# parser = argparse.ArgumentParser(description='C ABI binding generation code')
6264
parser_gen.add_argument('type', choices=('ompi', 'standard'),

ompi/mpi/bindings/c_header.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,16 @@ def output_constant(const, use_enum: bool, mangle_name: bool):
256256
output.append("extern int ompi_abi_mpi_proc_null_val;\n")
257257
output.append("extern int ompi_abi_mpi_any_source_val;\n")
258258
output.append("\n")
259+
output.append("int ABI_C_MPI_COMM_NULL_DELETE_FN( MPI_Comm_ABI_INTERNAL comm, int comm_keyval, void* attribute_val_out, void* extra_state );\n")
260+
output.append("int ABI_C_MPI_COMM_NULL_COPY_FN( MPI_Comm_ABI_INTERNAL comm, int comm_keyval, void* extra_state, void* attribute_val_in, void* attribute_val_out, int* flag );\n")
261+
output.append("int ABI_C_MPI_COMM_DUP_FN( MPI_Comm_ABI_INTERNAL comm, int comm_keyval, void* extra_state, void* attribute_val_in, void* attribute_val_out, int* flag );\n")
262+
output.append("int ABI_C_MPI_TYPE_NULL_DELETE_FN( MPI_Datatype_ABI_INTERNAL datatype, int type_keyval, void* attribute_val_out, void* extra_state );\n")
263+
output.append("int ABI_C_MPI_TYPE_NULL_COPY_FN( MPI_Datatype_ABI_INTERNAL datatype, int type_keyval, void* extra_state, void* attribute_val_in, void* attribute_val_out, int* flag );\n")
264+
output.append("int ABI_C_MPI_TYPE_DUP_FN( MPI_Datatype_ABI_INTERNAL datatype, int type_keyval, void* extra_state, void* attribute_val_in, void* attribute_val_out, int* flag );\n")
265+
output.append("int ABI_C_MPI_WIN_NULL_DELETE_FN( MPI_Win_ABI_INTERNAL window, int win_keyval, void* attribute_val_out, void* extra_state );\n")
266+
output.append("int ABI_C_MPI_WIN_NULL_COPY_FN( MPI_Win_ABI_INTERNAL window, int win_keyval, void* extra_state, void* attribute_val_in, void* attribute_val_out, int* flag );\n")
267+
output.append("int ABI_C_MPI_WIN_DUP_FN( MPI_Win_ABI_INTERNAL window, int win_keyval, void* extra_state, void* attribute_val_in, void* attribute_val_out, int* flag );\n")
268+
output.append("\n")
259269

260270
# ================================ Final Output ================================
261271
output.append("#if defined(__cplusplus)\n")

ompi/mpi/bindings/ompi_bindings/c.py

Lines changed: 409 additions & 132 deletions
Large diffs are not rendered by default.

ompi/mpi/bindings/ompi_bindings/c_type.py

Lines changed: 69 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,20 +1387,21 @@ def type_text(self, enable_count=False):
13871387

13881388

13891389
@Type.add_type('COMM_COPY_ATTR_FUNCTION', abi_type=['standard'])
1390-
class TypeCommCopyAttrFunctionStandard(Type):
1390+
class TypeCommCopyAttrFunctionStandard(StandardABIType):
13911391

13921392
def type_text(self, enable_count=False):
13931393
type_name = self.mangle_name('MPI_Comm_copy_attr_function')
13941394
return f'{type_name} *'
13951395

1396-
@property
1397-
def argument(self):
1398-
return f'(MPI_Comm_copy_attr_function *) {self.name}'
1396+
# @property
1397+
# def argument(self):
1398+
# return f'(MPI_Comm_copy_attr_function *) {self.name}'
13991399

14001400
@property
14011401
def init_code(self):
14021402
code = []
1403-
code = ['ompi_abi_wrapper_helper_t *helper = NULL;']
1403+
code = [f'MPI_Comm_copy_attr_function *{self.tmpname} = {ConvertFuncs.COMM_COPY_ATTR_FUNCTION}({self.name});']
1404+
code.append('ompi_abi_wrapper_helper_t *helper = NULL;')
14041405
code.append('MPI_Comm_copy_attr_function_ABI_INTERNAL *copy_fn;')
14051406
code.append('helper = ( ompi_abi_wrapper_helper_t *)malloc(sizeof(ompi_abi_wrapper_helper_t));')
14061407
code.append('if (NULL == helper) return MPI_ERR_NO_MEM;')
@@ -1436,7 +1437,6 @@ def callback_wrapper_code(self):
14361437
code.append(' ompi_abi_wrapper_helper_t *helper = (ompi_abi_wrapper_helper_t *)extra_state;')
14371438
code.append(' MPI_Comm_ABI_INTERNAL comm_tmp = ompi_convert_comm_ompi_to_standard(oldcomm);')
14381439
code.append(' return helper->user_delete_fn((MPI_Comm_ABI_INTERNAL)comm_tmp, comm_keyval, attribute_val, helper->user_extra_state);')
1439-
code.append(' free(helper);')
14401440
code.append('}')
14411441
return code
14421442

@@ -1448,15 +1448,15 @@ def type_text(self, enable_count=False):
14481448

14491449

14501450
@Type.add_type('COMM_DELETE_ATTR_FUNCTION', abi_type=['standard'])
1451-
class TypeCommDeleteAttrFunctionStandard(Type):
1451+
class TypeCommDeleteAttrFunctionStandard(StandardABIType):
14521452

14531453
def type_text(self, enable_count=False):
14541454
type_name = self.mangle_name('MPI_Comm_delete_attr_function')
14551455
return f'{type_name} *'
14561456

1457-
@property
1458-
def argument(self):
1459-
return f'(MPI_Comm_delete_attr_function *) {self.name}'
1457+
# @property
1458+
# def argument(self):
1459+
# return f'(MPI_Comm_delete_attr_function *) {self.name}'
14601460

14611461
#
14621462
# note the code generated here relies on that generated for
@@ -1465,6 +1465,7 @@ def argument(self):
14651465
@property
14661466
def init_code(self):
14671467
code = []
1468+
code = [f'MPI_Comm_delete_attr_function *{self.tmpname} = {ConvertFuncs.COMM_DELETE_ATTR_FUNCTION}({self.name});']
14681469
code.append('MPI_Comm_delete_attr_function_ABI_INTERNAL *delete_fn;')
14691470
code.append(f'if ({self.name} == MPI_COMM_NULL_DELETE_FN_ABI_INTERNAL)' + '{')
14701471
code.append('delete_fn = ABI_C_MPI_COMM_NULL_DELETE_FN;')
@@ -2336,7 +2337,7 @@ class TypeCbSafetyStandard(StandardABIType):
23362337

23372338
@property
23382339
def init_code(self):
2339-
return [f'MPI_T_cb_safety {self.tmpname} = {ConvertFuncs.CB_SAFETY}({self.name});']
2340+
return [f'MPI_T_cb_safety {self.tmpname} = {ConvertFuncs.T_CB_SAFETY}({self.name});']
23402341

23412342
def type_text(self, enable_count=False):
23422343
return self.mangle_name('MPI_T_cb_safety')
@@ -2355,7 +2356,7 @@ class TypeSourceOrderStandard(StandardABIType):
23552356

23562357
@property
23572358
def init_code(self):
2358-
return [f'MPI_T_source_order {self.tmpname} = {ConvertFuncs.SOURCE_ORDER}({self.name});']
2359+
return [f'MPI_T_source_order {self.tmpname} = {ConvertFuncs.T_SOURCE_ORDER}({self.name});']
23592360

23602361
def type_text(self, enable_count=False):
23612362
return self.mangle_name('MPI_T_source_order')
@@ -2375,7 +2376,7 @@ class TypeSourceOrderOutStandard(StandardABIType):
23752376

23762377
@property
23772378
def final_code(self):
2378-
return [f'*{self.name} = {ConvertOMPIToStandard.SOURCE_ORDER}((MPI_T_source_order) {self.name});']
2379+
return [f'*{self.name} = {ConvertOMPIToStandard.T_SOURCE_ORDER}((MPI_T_source_order) {self.name});']
23792380

23802381
def type_text(self, enable_count=False):
23812382
type_name = self.mangle_name('MPI_T_source_order')
@@ -2505,3 +2506,58 @@ def type_text(self, enable_count=False):
25052506
def argument(self):
25062507
return f'&{self.tmpname}'
25072508

2509+
@Type.add_type('SPLIT_TYPE', abi_type=['ompi'])
2510+
class TypeSplitType(Type):
2511+
2512+
def type_text(self, enable_count=False):
2513+
return 'int'
2514+
2515+
@Type.add_type('SPLIT_TYPE', abi_type=['standard'])
2516+
class TyperSplitTypeStandard(StandardABIType):
2517+
2518+
@property
2519+
def init_code(self):
2520+
return [f'int {self.tmpname} = {ConvertFuncs.SPLIT_TYPE}({self.name});']
2521+
2522+
def type_text(self, enable_count=False):
2523+
return 'int'
2524+
2525+
@Type.add_type('COMM_CMP_OUT', abi_type=['ompi'])
2526+
class TypeCommCmpOut(Type):
2527+
2528+
def type_text(self, enable_count=False):
2529+
return 'int *'
2530+
2531+
@Type.add_type('COMM_CMP_OUT', abi_type=['standard'])
2532+
class TyperCommCmpOutStandard(StandardABIType):
2533+
2534+
@property
2535+
def final_code(self):
2536+
return [f'*{self.name} = {ConvertOMPIToStandard.COMM_CMP}(*{self.name});']
2537+
2538+
def type_text(self, enable_count=False):
2539+
return 'int *'
2540+
2541+
@property
2542+
def argument(self):
2543+
return f'{self.name}'
2544+
2545+
@Type.add_type('EVENT_INSTANCE', abi_type=['ompi'])
2546+
class TypeEventInstance(Type):
2547+
2548+
def type_text(self, enable_count=False):
2549+
return 'MPI_T_event_instance'
2550+
2551+
2552+
@Type.add_type('EVENT_INSTANCE', abi_type=['standard'])
2553+
class TypeEventInstanceStandard(StandardABIType):
2554+
2555+
def return_code(self, name):
2556+
return [f'return {ConvertOMPIToStandard.COMM}({name});']
2557+
2558+
def type_text(self, enable_count=False):
2559+
return self.mangle_name('MPI_T_event_instance')
2560+
2561+
@property
2562+
def argument(self):
2563+
return f'{self.name}'

ompi/mpi/bindings/ompi_bindings/consts.py

Lines changed: 168 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,34 @@
143143
'MPI_2INT',
144144
'MPI_SHORT_INT',
145145
'MPI_LONG_DOUBLE_INT',
146+
'MPI_LOGICAL',
147+
'MPI_INTEGER',
148+
'MPI_REAL',
149+
'MPI_COMPLEX',
150+
'MPI_DOUBLE_PRECISION',
151+
'MPI_CHARACTER',
152+
'MPI_DOUBLE_COMPLEX',
153+
]
154+
155+
PREDEFINED_OPTIONAL_FORTRAN_DATATYPES = [
156+
'MPI_LOGICAL1',
157+
'MPI_LOGICAL2',
158+
'MPI_LOGICAL4',
159+
'MPI_LOGICAL8',
160+
'MPI_LOGICAL16',
161+
'MPI_INTEGER1',
162+
'MPI_INTEGER2',
163+
'MPI_INTEGER4',
164+
'MPI_INTEGER8',
165+
'MPI_INTEGER16',
166+
'MPI_REAL2',
167+
'MPI_REAL4',
168+
'MPI_REAL8',
169+
'MPI_REAL16',
170+
'MPI_COMPLEX4',
171+
'MPI_COMPLEX8',
172+
'MPI_COMPLEX16',
173+
'MPI_COMPLEX32',
146174
]
147175

148176
# C type: MPI_Comm
@@ -195,9 +223,18 @@
195223

196224
RESERVED_ERRHANDLERS = [
197225
'MPI_ERRHANDLER_NULL',
198-
'MPI_ERRHANDLER_ARE_FATAL',
199-
'MPI_ERRHANDLER_ABORT',
200-
'MPI_ERRHANDLER_RETURN',
226+
'MPI_ERRORS_ARE_FATAL',
227+
'MPI_ERRORS_ABORT',
228+
'MPI_ERRORS_RETURN',
229+
]
230+
231+
RESERVED_COMM_COPY_ATTR_FNS = [
232+
'MPI_COMM_NULL_COPY_FN',
233+
'MPI_COMM_DUP_FN',
234+
]
235+
236+
RESERVED_COMM_DEL_ATTR_FNS = [
237+
'MPI_COMM_NULL_DELETE_FN'
201238
]
202239

203240
IGNORED_STATUS_HANDLES = [
@@ -222,6 +259,127 @@
222259
'MPI_NO_OP',
223260
]
224261

262+
COMM_GROUP_COMPARE_VALS = [
263+
'MPI_IDENT',
264+
'MPI_CONGRUENT',
265+
'MPI_SIMILAR',
266+
'MPI_UNEQUAL',
267+
]
268+
269+
RESERVED_ATTR_KEYS = [
270+
'MPI_KEYVAL_INVALID',
271+
'MPI_TAG_UB',
272+
'MPI_IO',
273+
'MPI_HOST',
274+
'MPI_WTIME_IS_GLOBAL',
275+
'MPI_APPNUM',
276+
'MPI_LASTUSEDCODE',
277+
'MPI_UNIVERSE_SIZE',
278+
'MPI_WIN_BASE',
279+
'MPI_WIN_DISP_UNIT',
280+
'MPI_WIN_SIZE',
281+
'MPI_WIN_CREATE_FLAVOR',
282+
'MPI_WIN_MODEL',
283+
]
284+
285+
TS_LEVEL_VALUES = [
286+
'MPI_THREAD_SINGLE',
287+
'MPI_THREAD_FUNNELED',
288+
'MPI_THREAD_SERIALIZED',
289+
'MPI_THREAD_MULTIPLE',
290+
]
291+
292+
293+
T_SCOPE_VALUES = [
294+
'MPI_T_SCOPE_CONSTANT',
295+
'MPI_T_SCOPE_READONLY',
296+
'MPI_T_SCOPE_LOCAL',
297+
'MPI_T_SCOPE_GROUP',
298+
'MPI_T_SCOPE_GROUP_EQ',
299+
'MPI_T_SCOPE_ALL',
300+
'MPI_T_SCOPE_ALL_EQ',
301+
]
302+
303+
RESERVED_TAGS = [
304+
'MPI_ANY_TAG',
305+
]
306+
307+
RESERVED_SOURCE = [
308+
'MPI_ANY_SOURCE',
309+
]
310+
311+
RESERVED_ROOT = [
312+
'MPI_ROOT',
313+
]
314+
315+
RESERVED_PVAR_SESSIONS = [
316+
'MPI_T_PVAR_SESSION_NULL',
317+
]
318+
319+
RESERVED_CVAR_HANDLES = [
320+
'MPI_T_CVAR_HANDLE_NULL',
321+
]
322+
323+
RESERVED_PVAR_HANDLES = [
324+
'MPI_T_PVAR_HANDLE_NULL',
325+
]
326+
327+
RESERVED_T_ENUMS = [
328+
'MPI_T_ENUM_NULL',
329+
]
330+
331+
T_BIND_VALUES = [
332+
'MPI_T_BIND_NO_OBJECT',
333+
'MPI_T_BIND_MPI_COMM',
334+
'MPI_T_BIND_MPI_DATATYPE',
335+
'MPI_T_BIND_MPI_ERRHANDLER',
336+
'MPI_T_BIND_MPI_FILE',
337+
'MPI_T_BIND_MPI_GROUP',
338+
'MPI_T_BIND_MPI_OP',
339+
'MPI_T_BIND_MPI_REQUEST',
340+
'MPI_T_BIND_MPI_WIN',
341+
'MPI_T_BIND_MPI_MESSAGE',
342+
'MPI_T_BIND_MPI_INFO',
343+
'MPI_T_BIND_MPI_SESSION',
344+
]
345+
346+
T_VERBOSITY_VALUES = [
347+
'MPI_T_VERBOSITY_USER_BASIC',
348+
'MPI_T_VERBOSITY_USER_DETAIL',
349+
'MPI_T_VERBOSITY_USER_ALL',
350+
'MPI_T_VERBOSITY_TUNER_BASIC',
351+
'MPI_T_VERBOSITY_TUNER_DETAIL',
352+
'MPI_T_VERBOSITY_TUNER_ALL',
353+
'MPI_T_VERBOSITY_MPIDEV_BASIC',
354+
'MPI_T_VERBOSITY_MPIDEV_DETAIL',
355+
'MPI_T_VERBOSITY_MPIDEV_ALL',
356+
]
357+
358+
T_CB_SAFETY_VALUES = [
359+
'MPI_T_CB_REQUIRE_NONE',
360+
'MPI_T_CB_REQUIRE_MPI_RESTRICTED',
361+
'MPI_T_CB_REQUIRE_THREAD_SAFE',
362+
'MPI_T_CB_REQUIRE_ASYNC_SIGNAL_SAFE',
363+
]
364+
365+
T_SOURCE_ORDER_VALUES = [
366+
'MPI_T_SOURCE_ORDERED',
367+
'MPI_T_SOURCE_UNORDERED',
368+
]
369+
370+
T_PVAR_CLASS_VALUES = [
371+
'MPI_T_PVAR_CLASS_STATE',
372+
'MPI_T_PVAR_CLASS_LEVEL',
373+
'MPI_T_PVAR_CLASS_SIZE',
374+
'MPI_T_PVAR_CLASS_PERCENTAGE',
375+
'MPI_T_PVAR_CLASS_HIGHWATERMARK',
376+
'MPI_T_PVAR_CLASS_LOWWATERMARK',
377+
'MPI_T_PVAR_CLASS_COUNTER',
378+
'MPI_T_PVAR_CLASS_AGGREGATE',
379+
'MPI_T_PVAR_CLASS_TIMER',
380+
'MPI_T_PVAR_CLASS_GENERIC',
381+
]
382+
225383
VARIOUS_CONSTANTS = {
226384
# Just setting this to the same as ompi ABI for right now, but will need to
227385
# match the standard ABI value when defined
@@ -289,9 +447,12 @@ class ConvertFuncs:
289447
CVAR_HANDLE = 'ompi_convert_abi_cvar_handle_intern_cvar_handle'
290448
T_ENUM = 'ompi_convert_abi_t_enum_intern_t_enum'
291449
T_BIND = 'ompi_convert_abi_t_bind_intern_t_bind'
292-
CB_SAFETY = 'ompi_convert_abi_cb_safety_intern_cb_safety'
293-
SOURCE_ORDER = 'ompi_convert_abi_source_order_intern_source_order'
450+
T_CB_SAFETY = 'ompi_convert_abi_cb_safety_intern_cb_safety'
451+
T_SOURCE_ORDER = 'ompi_convert_abi_source_order_intern_source_order'
294452
ATTR_KEY = 'ompi_convert_abi_attr_key_intern_attr_key'
453+
COMM_COPY_ATTR_FUNCTION = 'ompi_convert_comm_copy_attr_fn_intern_comm_copy_attr_fn'
454+
COMM_DELETE_ATTR_FUNCTION = 'ompi_convert_comm_delete_attr_fn_intern_comm_delete_attr_fn'
455+
SPLIT_TYPE = 'ompi_convert_split_type_intern_type'
295456

296457

297458
class ConvertOMPIToStandard:
@@ -319,8 +480,9 @@ class ConvertOMPIToStandard:
319480
CVAR_HANDLE = 'ompi_convert_cvar_handle_ompi_to_standard'
320481
T_ENUM = 'ompi_convert_t_enum_ompi_to_standard'
321482
T_BIND = 'ompi_convert_t_bind_ompi_to_standard'
322-
SOURCE_ORDER = 'ompi_convert_source_order_ompi_to_standard'
483+
T_SOURCE_ORDER = 'ompi_convert_source_order_ompi_to_standard'
323484
ATTR_KEY = 'ompi_convert_attr_key_ompi_to_standard'
485+
COMM_CMP = 'ompi_convert_comm_cmp_ompi_to_standard'
324486

325487

326488
# Inline function attributes

0 commit comments

Comments
 (0)