[libc] Fix the implementation of exit on the GPU
authorJoseph Huber <jhuber6@vols.utk.edu>
Thu, 29 Jun 2023 17:03:40 +0000 (12:03 -0500)
committerJoseph Huber <jhuber6@vols.utk.edu>
Thu, 29 Jun 2023 18:22:23 +0000 (13:22 -0500)
commit667c10353e87d2be5b981cdac0a698c93946cc92
tree564ae82c9c3df28ae05dce7fc5a434705c683f92
parent46f42e2ee59ac5ff7b153648e30273e499f7b7e3
[libc] Fix the implementation of exit on the GPU

The RPC calls all have delays associated with them. Currently the `exit`
function does an async send and immediately exits the GPU. This can have
the effect that the RPC server never sees the exit call and we continue.
This patch changes that to first sync with the server before continuing
to perform its exit. There is still a hazard here, where the kernel can
complete before the RPC call reads back its response, but this is simply
multi-threaded hazards. This change ensures that the server *will*
always exit some time after the GPU exits.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D154112
libc/docs/gpu/support.rst
libc/src/__support/OSUtil/gpu/quick_exit.cpp
libc/utils/gpu/server/rpc_server.cpp