[libc-commits] [libc] [libc] Implement temporary `printf` on the GPU (PR #85331)

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Tue Mar 19 06:55:01 PDT 2024


jhuber6 wrote:

> I haven't decoded the implementation.

Broadly speaking we copy over the string and arguments from the GPU. The CPU then parses the string to get the needed buffer size and to identify any `%s` arguments. If it was `%s` the next packet sent will contain a pointer for the client to copy back. If it wasn't the pointer will be `null` and we will have a return value. Once all that information is on the server it just uses the `printf` utilities to emit the string.

> I'd suggest going _much_ heavier on testing though. Especially since said tests will remain valid and useful if this implementation is replaced. Perhaps libc already has some large number of printf style tests that will run on the GPU (successfully) with this shim in place?

I can add some more tests, however since all this amounts to is passing data to the CPU version of libc's printf I was primarily just concerned with whether or not it handles situations relating to the GPU correctly. Evenutally when this is "real" `printf` we'll get those tests on the GPU as well, but for now I'm just relying on CPU testing to verify stuff like `%0.03-f` works.

https://github.com/llvm/llvm-project/pull/85331


More information about the libc-commits mailing list