[libc-commits] [PATCH] D155121: [libc] Add support for the 'fread' function on the GPU

Johannes Doerfert via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Jul 26 10:04:11 PDT 2023


jdoerfert added a comment.

This is what confused me earlier:
If I read the `fread` definition properly, libc's implementation is wrong. The read is supposed to be quantized, but in libc it is not (or it is quantized with an element size of 1).



================
Comment at: libc/utils/gpu/server/rpc_server.cpp:120
+        delete[] reinterpret_cast<uint8_t *>(data[id]);
+        buffer->data[0] = rets[id] >= 0 ? sizes[id] : rets[id];
+      });
----------------
jhuber6 wrote:
> jdoerfert wrote:
> > I don't get this. We should always return rets[id], no?
> I think this is a consequence of me not using the `size` argument instead of the `nmemb` argument. Since the return value is supposed to correspond to the size. I can fix it and test.
I mean, whatever host fread returns is what we should return. That said, we really need to pass `size` and `nmemb` from the device to the host.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155121/new/

https://reviews.llvm.org/D155121



More information about the libc-commits mailing list