[libc-commits] [PATCH] D159296: [libc] Support 'assert.h' on the GPU
Joseph Huber via Phabricator via libc-commits
libc-commits at lists.llvm.org
Thu Aug 31 10:19:59 PDT 2023
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992, JonChesterfield, sivachandra, michaelrj, arsenm.
Herald added projects: libc-project, All.
Herald added a subscriber: libc-commits.
jhuber6 requested review of this revision.
Herald added a subscriber: wdng.
This patch adds the necessary support to provide `assert` functionality
through the GPU `libc` implementation. This implementation creates a
special-case GPU implementation rather than relying on the common
version. This is because the GPU has special considerings for printing.
The assertion is printed out in chunks with `write_to_stderr`, however
when combined with the GPU execution model this causes 32+ threads to
all execute in-lock step. Meaning that we'll get a horribly fragmented
message. Furthermore, potentially thousands of threads could hit the
assertion at once and try to print even if we had it all in one
`printf`.
This is solved by having a one-time lock that each thread group / wave /
warp will attempt to claim. We only let one thread group pass through
while the others simply stop executing. Finally only the first thread in
that group will do the printing until we finally abort execution.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D159296
Files:
libc/config/gpu/api.td
libc/config/gpu/entrypoints.txt
libc/config/gpu/headers.txt
libc/docs/gpu/support.rst
libc/src/__support/GPU/utils.h
libc/src/__support/RPC/rpc_util.h
libc/src/assert/CMakeLists.txt
libc/src/assert/gpu/CMakeLists.txt
libc/src/assert/gpu/__assert_fail.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159296.555093.patch
Type: text/x-patch
Size: 6555 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230831/6f023341/attachment.bin>
More information about the libc-commits
mailing list