Skip to content

Commit

Permalink
abi: treat MPI_File the same way as other handle types
Browse files Browse the repository at this point in the history
Now that we added explicit conversion routines for MPI_File
(ABI_File_{from,to}_mpi), we should treat MPI_File the same way as other
MPI handle types.
  • Loading branch information
hzhou committed Apr 29, 2024
1 parent 5c42dc7 commit aabae44
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
11 changes: 3 additions & 8 deletions maint/gen_abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def load_mpi_abi_h(mpi_abi_h):
def dump_mpi_abi_internal_h(mpi_abi_internal_h):
define_constants = {}
def gen_mpi_abi_internal_h(out):
re_Handle = r'\bMPI_(Comm|Datatype|Errhandler|Group|Info|Message|Op|Request|Session|Win|KEYVAL_INVALID|TAG_UB|IO|HOST|WTIME_IS_GLOBAL|APPNUM|LASTUSEDCODE|UNIVERSE_SIZE|WIN_BASE|WIN_DISP_UNIT|WIN_SIZE|WIN_CREATE_FLAVOR|WIN_MODEL)\b'
re_Handle = r'\bMPI_(Comm|Datatype|Errhandler|Group|Info|Message|Op|Request|Session|Win|File|KEYVAL_INVALID|TAG_UB|IO|HOST|WTIME_IS_GLOBAL|APPNUM|LASTUSEDCODE|UNIVERSE_SIZE|WIN_BASE|WIN_DISP_UNIT|WIN_SIZE|WIN_CREATE_FLAVOR|WIN_MODEL)\b'
for line in G.abi_h_lines:
if RE.search(r'MPI_ABI_H_INCLUDED', line):
# skip the include guard, harmless
Expand All @@ -58,13 +58,8 @@ def gen_mpi_abi_internal_h(out):
elif T == "MPI_Op":
idx = int(val, 0) & G.op_mask
G.abi_ops[idx] = name

if T == "MPI_File":
# pass through
out.append(line.rstrip())
else:
# replace param prefix
out.append(re.sub(r'\bMPI_', 'ABI_', line.rstrip()))
# replace param prefix
out.append(re.sub(r'\bMPI_', 'ABI_', line.rstrip()))
elif RE.match(r'#define MPI_(LONG_LONG|C_COMPLEX)', line):
# datatype aliases
out.append(re.sub(r'\bMPI_', 'ABI_', line.rstrip()))
Expand Down
9 changes: 5 additions & 4 deletions maint/local_python/binding_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -1047,11 +1047,12 @@ def out_can_be_undefined(p):
return True
return False
# ----
re_Handle = r'MPI_(Comm|Datatype|Errhandler|Group|Info|Message|Op|Request|Session|Win|File)\b'
for p in func['c_parameters']:
skip_abi_swap = False
param_type = mapping[p['kind']]
name = p['name']
if RE.match(r'MPI_(Comm|Datatype|Errhandler|Group|Info|Message|Op|Request|Session|Win)\b', param_type):
if RE.match(re_Handle, param_type):
process_handle(p)
elif p['kind'] == 'KEYVAL' and p['param_direction'] == 'in':
pre_filters.append("int %s = ABI_KEYVAL_to_mpi(%s_abi);" % (name, name))
Expand All @@ -1070,7 +1071,7 @@ def out_can_be_undefined(p):

# MPI_Comm comm -> ABI_Comm comm_abi
param = get_C_param(p, func, mapping)
param = re.sub(r'MPI_(Comm|Datatype|Errhandler|Group|Info|Message|Op|Request|Session|Win)\b', r'ABI_\1', param)
param = re.sub(re_Handle, r'ABI_\1', param)
if not skip_abi_swap:
param = re.sub(r'\b' + name, name+"_abi", param)
param_list.append(param)
Expand All @@ -1081,7 +1082,7 @@ def out_can_be_undefined(p):
ret = "int"
if 'return' in func:
ret = mapping[func['return']]
ret = re.sub(r'MPI_(Comm|Datatype|Errhandler|Group|Info|Message|Op|Request|Session|Win)\b', r'ABI_\1', ret)
ret = re.sub(re_Handle, r'ABI_\1', ret)

static_call = get_static_call_internal(func, is_large)

Expand All @@ -1098,7 +1099,7 @@ def out_can_be_undefined(p):

if ret != 'int':
# MPI_Wtime, MPI_Aint_{add,diff}, MPI_{Comm,...}_{c2f,f2c}
if RE.match(r'..._(Comm|Datatype|Errhandler|Group|Info|Message|Op|Request|Session|Win)\b', ret):
if RE.match(r'..._(Comm|Datatype|Errhandler|Group|Info|Message|Op|Request|Session|Win|File)\b', ret):
G.out.append("return ABI_%s_from_mpi(%s);" % (RE.m.group(1), static_call))
else:
G.out.append("return " + static_call + ";")
Expand Down
2 changes: 0 additions & 2 deletions src/include/mpi.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,13 @@ typedef int MPI_Win;
typedef int MPI_Session;
#define MPI_SESSION_NULL ((MPI_Session)0x38000000)

#ifndef BUILD_MPI_ABI
/* File and IO */
/* This define lets ROMIO know that MPI_File has been defined */
#define MPI_FILE_DEFINED
/* ROMIO uses a pointer for MPI_File objects. This must be the same definition
as in src/mpi/romio/include/mpio.h.in */
typedef struct ADIOI_FileD *MPI_File;
#define MPI_FILE_NULL ((MPI_File)0)
#endif

/* Collective operations */
typedef int MPI_Op;
Expand Down

0 comments on commit aabae44

Please sign in to comment.