Skip to content

Commit

Permalink
python/binding_c: Add streamsync directive
Browse files Browse the repository at this point in the history
Extend the functionality of MPIX stream by allowing passing a stream
communication with local gpu stream to regular MPI functions. The
semantics is to run an implicit gpu stream synchronize before the MPI
operation. This is semantically serializing the MPI oepration with the
GPU stream, albeit in a heavy handed way.
  • Loading branch information
hzhou committed Jun 5, 2024
1 parent 36ade32 commit 8018793
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions maint/local_python/binding_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -1474,6 +1474,16 @@ def dump_function_normal(func):
# ----
def dump_body_of_routine():
do_threadcomm = False
if RE.search(r'streamsync', func['extra'], re.IGNORECASE):
if '_has_comm' in func:
G.out.append("MPIR_Stream *stream = MPIR_stream_comm_get_local_stream(%s_ptr);" % func['_has_comm'])
elif '_has_win' in func:
G.out.append("MPIR_Stream *stream = MPIR_stream_comm_get_local_stream(%s_ptr->comm_ptr);" % func['_has_win'])
else:
raise Exception("streamsync not supported in %s" % func['name'])
dump_if_open("stream && stream->type == MPIR_STREAM_GPU")
G.out.append("MPL_gpu_stream_synchronize(stream->u.gpu_stream);")
dump_if_close()
if RE.search(r'threadcomm', func['extra'], re.IGNORECASE):
do_threadcomm = True
G.out.append("#ifdef ENABLE_THREADCOMM")
Expand Down Expand Up @@ -1506,6 +1516,7 @@ def dump_body_of_routine():

if do_threadcomm:
dump_if_close()

# ----
G.out.append("/* ... body of routine ... */")

Expand Down

0 comments on commit 8018793

Please sign in to comment.