[libc-commits] [PATCH] D150992: [libc] Fix the `send_n` and `recv_n` utilities under divergent lanes

Joseph Huber via Phabricator via libc-commits libc-commits at lists.llvm.org
Fri May 19 13:06:03 PDT 2023


jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, JonChesterfield, sivachandra, michaelrj, lntue.
Herald added subscribers: libc-commits, mattd, asavonic, ecnelises, kerbowa, tschuett, jvesely.
Herald added projects: libc-project, All.
jhuber6 requested review of this revision.

We provide the `send_n` and `recv_n` utilities as a generic way to
stream data between both sides of the process. This was previously
tested and performed as expected when using a string of constant size.
However, when the size was allowed to diverge between the threads in the
warp or wavefront this could deadlock. This did not occur on NVPTX
because of the use of the explicit warp sync. However, on AMD one of the
work items in the wavefront could continue executing and hit the next
`recv` call before the other threads, then we would deadlock as we
violated the RPC invariants.

This patch replaces the for loop with a thread ballot. This will cause
every thread in the warp or wavefront to continue executing the loop
until all of them can exit. This acts as a more explicit wavefront sync.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150992

Files:
  libc/src/__support/GPU/amdgpu/utils.h
  libc/src/__support/GPU/nvptx/utils.h
  libc/src/__support/RPC/rpc.h
  libc/test/integration/startup/gpu/CMakeLists.txt
  libc/test/integration/startup/gpu/rpc_stream_test.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150992.523908.patch
Type: text/x-patch
Size: 6606 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230519/ba1ae509/attachment-0001.bin>


More information about the libc-commits mailing list