mirror of https://github.com/google/gemma.cpp.git
Add logging to io.cc on failed write and read.
This should provide insights into any failures. PiperOrigin-RevId: 815784482
This commit is contained in:
parent
684a0444e9
commit
9dc802c7aa
16
io/io.cc
16
io/io.cc
|
|
@ -106,7 +106,13 @@ class FilePosix : public File {
|
|||
for (;;) {
|
||||
// pread seems to be faster than lseek + read when parallelized.
|
||||
const auto bytes_read = pread(fd_, bytes + pos, size - pos, offset + pos);
|
||||
if (bytes_read <= 0) break;
|
||||
if (bytes_read <= 0) {
|
||||
HWY_WARN(
|
||||
"Read failure at pos %zu within size %zu with offset %zu and "
|
||||
"errno %d\n",
|
||||
pos, size, offset, errno);
|
||||
break;
|
||||
}
|
||||
pos += bytes_read;
|
||||
HWY_ASSERT(pos <= size);
|
||||
if (pos == size) break;
|
||||
|
|
@ -120,7 +126,13 @@ class FilePosix : public File {
|
|||
for (;;) {
|
||||
const auto bytes_written =
|
||||
pwrite(fd_, bytes + pos, size - pos, offset + pos);
|
||||
if (bytes_written <= 0) break;
|
||||
if (bytes_written <= 0) {
|
||||
HWY_WARN(
|
||||
"Write failure at pos %zu within size %zu with offset %zu and "
|
||||
"errno %d\n",
|
||||
pos, size, offset, errno);
|
||||
break;
|
||||
}
|
||||
pos += bytes_written;
|
||||
HWY_ASSERT(pos <= size);
|
||||
if (pos == size) break;
|
||||
|
|
|
|||
Loading…
Reference in New Issue