diff options
| author | Joseph Huber <35342157+jhuber6@users.noreply.github.com> | 2023-09-25 11:17:22 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-25 11:17:22 -0500 |
| commit | 791b2799247f0aca5f10656923709ec1098a6920 (patch) | |
| tree | b68b615052a71a51379e0901d06893e60e6d5772 /libc/src/stdio/gpu/puts.cpp | |
| parent | e3d6a3ac6925862f5829e4883942be9eec591164 (diff) | |
[libc] Change the `puts` implementation on the GPU (#67189)
Summary:
Normally, the implementation of `puts` simply writes a second newline
charcter after printing the first string. However, because the GPU does
everything in batches of the SIMT group size, this will end up with very
poor output where you get the strings printed and then 1-64 newline
characters all in a row. Optimizations like to turn `printf` calls into
`puts` so it's a good idea to make this produce the expected output.
The least invasive way I could do this was to add a new opcode. It's a
little bloated, but it avoids an unneccessary and slow send operation to
configure this.
Diffstat (limited to 'libc/src/stdio/gpu/puts.cpp')
| -rw-r--r-- | libc/src/stdio/gpu/puts.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/libc/src/stdio/gpu/puts.cpp b/libc/src/stdio/gpu/puts.cpp index 58a3534c57ef..e50e2cc7d55d 100644 --- a/libc/src/stdio/gpu/puts.cpp +++ b/libc/src/stdio/gpu/puts.cpp @@ -17,11 +17,9 @@ namespace __llvm_libc { LLVM_LIBC_FUNCTION(int, puts, (const char *__restrict str)) { cpp::string_view str_view(str); - auto written = file::write(stdout, str, str_view.size()); - if (written != str_view.size()) - return EOF; - written = file::write(stdout, "\n", 1); - if (written != 1) + auto written = file::write_impl<RPC_WRITE_TO_STDOUT_NEWLINE>(stdout, str, + str_view.size()); + if (written != str_view.size() + 1) return EOF; return 0; } |
