Skip to content

Commit

Permalink
Merge pull request #6876 from hzhou/2401_abi
Browse files Browse the repository at this point in the history
abi: redefine MPI_THREAD_XXX constants into macros

Approved-by: Ken Raffenetti
  • Loading branch information
hzhou committed Jan 22, 2024
2 parents c5f56f7 + 7a3f687 commit c2f04da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions maint/gen_abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def load_mpi_abi_h(mpi_abi_h):
G.abi_h_lines = In.readlines()

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'
for line in G.abi_h_lines:
Expand Down Expand Up @@ -78,6 +79,10 @@ def gen_mpi_abi_internal_h(out):
elif RE.match(r'^extern\s+(\w+\s*\**)\s+(MPI_\w+);', line):
(T, name) = RE.m.group(1,2)
out.append("extern %s %s MPICH_API_PUBLIC;" % (T, name))
elif RE.match(r'\s*(MPI_THREAD_\w+)\s*=\s*(\d+)', line):
# These constants need to be converted from enum-constants into macro-constants
define_constants[RE.m.group(1)] = RE.m.group(2)
pass
else:
# replace param prefix
out.append(re.sub(re_Handle, r'ABI_\1', line.rstrip()))
Expand All @@ -93,6 +98,8 @@ def gen_mpi_abi_internal_h(out):
print("#define MPI_ABI_INTERNAL_H_INCLUDED", file=Out)
print("", file=Out)

for k in define_constants:
print("#define %s %s" % (k, define_constants[k]), file=Out)
print("", file=Out)
for line in output_lines:
print(line, file=Out)
Expand Down
4 changes: 2 additions & 2 deletions maint/local_python/binding_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -1007,12 +1007,12 @@ def process_handle(p):
else:
if p['param_direction'] == 'out':
# pass NULL thru for error-checking
pre_filters.append("MPI_%s %s_i;" % (T, name))
pre_filters.append("MPI_%s %s_i = MPI_%s_NULL;" % (T, name, T.upper()))
pre_filters.append("MPI_%s *%s = NULL;" % (T, name))
pre_filters.append("if (%s_abi != NULL) {" % name)
pre_filters.append(" %s = &%s_i;" % (name, name))
pre_filters.append("}")
post_filters.append("if (ret == MPI_SUCCESS && %s_abi != NULL) {" % name)
post_filters.append("if (%s_abi != NULL) {" % name)
post_filters.append(" *%s_abi = ABI_%s_from_mpi(%s_i);" % (name, T, name));
post_filters.append("}")
elif p['param_direction'] == 'inout' or func['name'] == "MPI_Cancel":
Expand Down

0 comments on commit c2f04da

Please sign in to comment.