Skip to content

Commit

Permalink
Fixed calculation of bytes for STDIO.
Browse files Browse the repository at this point in the history
1. Add the return value for calculation of size in bytes
2. Fix the I/O function to use it.
  • Loading branch information
hariharan-devarajan committed Jul 29, 2024
1 parent bbb62e1 commit 6890089
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 14 additions & 2 deletions dfanalyzer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,22 @@ def io_function(json_object, current_dict, time_approximate,condition_fn):
d["hostname"] = json_object["args"]["hostname"]

if "POSIX" == json_object["cat"] and "ret" in json_object["args"]:
if "write" in json_object["name"]:
if json_object["name"] == "write":
d["size"] = int(json_object["args"]["ret"])
elif "read" in json_object["name"] and "readdir" not in json_object["name"]:
elif json_object["name"] == "read":
d["size"] = int(json_object["args"]["ret"])
elif json_object["name"] == "fwrite":
d["size"] = 1
if "ret" in json_object["args"]:
d["size"] *= int(json_object["args"]["ret"])
if "size" in json_object["args"]:
d["size"] *= int(json_object["args"]["size"])
elif json_object["name"] == "fread":
d["size"] = 1
if "ret" in json_object["args"]:
d["size"] *= int(json_object["args"]["ret"])
if "size" in json_object["args"]:
d["size"] *= int(json_object["args"]["size"])
else:
if "image_size" in json_object["args"]:
d["size"] = int(json_object["args"]["image_size"])
Expand Down
4 changes: 4 additions & 0 deletions src/dftracer/brahma/stdio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ size_t brahma::STDIODFTracer::fread(void *ptr, size_t size, size_t nmemb,
DFT_LOGGER_UPDATE(size);
DFT_LOGGER_UPDATE(nmemb);
size_t ret = __real_fread(ptr, size, nmemb, fp);
DFT_LOGGER_UPDATE(ret);
DFT_LOGGER_END();
return ret;
}
Expand All @@ -58,6 +59,7 @@ size_t brahma::STDIODFTracer::fwrite(const void *ptr, size_t size, size_t nmemb,
DFT_LOGGER_UPDATE(size);
DFT_LOGGER_UPDATE(nmemb);
size_t ret = __real_fwrite(ptr, size, nmemb, fp);
DFT_LOGGER_UPDATE(ret);
DFT_LOGGER_END();
return ret;
}
Expand All @@ -66,6 +68,7 @@ long brahma::STDIODFTracer::ftell(FILE *fp) {
BRAHMA_MAP_OR_FAIL(ftell);
DFT_LOGGER_START(fp);
long ret = __real_ftell(fp);
DFT_LOGGER_UPDATE(ret);
DFT_LOGGER_END();
return ret;
}
Expand All @@ -76,6 +79,7 @@ int brahma::STDIODFTracer::fseek(FILE *fp, long offset, int whence) {
DFT_LOGGER_UPDATE(offset);
DFT_LOGGER_UPDATE(whence);
int ret = __real_fseek(fp, offset, whence);
DFT_LOGGER_UPDATE(ret);
DFT_LOGGER_END();
return ret;
}

0 comments on commit 6890089

Please sign in to comment.