Skip to content

Commit

Permalink
#2302: Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrepebay committed Nov 25, 2024
1 parent b4280af commit 6b043c0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cmake/load_papi.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ if (vt_papi_enabled)
find_package(PAPI REQUIRED)
message(STATUS: "FOUND PAPI: PAPI LIBRARY: ${PAPI_LIBRARY}\n PAPI INCLUDE DIR: ${PAPI_INCLUDE_DIR}")
set(vt_papi_found "1")
endif ()
endif ()
2 changes: 1 addition & 1 deletion cmake/load_perf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ if (vt_perf_enabled)
set(vt_perf_enabled "0")
set(vt_perf_found "0")
endif ()
endif ()
endif ()
25 changes: 16 additions & 9 deletions src/vt/metrics/perf_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,27 +135,34 @@ void PerfData::stopTaskMeasurement()
}
}

std::unordered_map<std::string, uint64_t> PerfData::getTaskMeasurements()
{
std::unordered_map<std::string, uint64_t> PerfData::getTaskMeasurements() {
std::unordered_map<std::string, uint64_t> measurements;
for (size_t i = 0; i < event_fds_.size(); ++i)
{

if (event_fds_.size() != event_names_.size()) {
vtAbort("Mismatch between event_fds_ and event_names_ sizes.");
}

for (size_t i = 0; i < event_fds_.size(); ++i) {
uint64_t count = 0;

if (event_fds_[i] != -1) {
ssize_t bytesRead = read(event_fds_[i], &count, sizeof(uint64_t));

if (bytesRead == sizeof(uint64_t)) {
measurements[event_names_[i]] = count;
} else if (bytesRead == -1) {
vtAbort("Failed to read perf event data for: " + event_names_[i] + ". Error: " + std::strerror(errno));
vtAbort("Failed to read perf event data for: " + event_names_[i] +
". Error: " + std::strerror(errno));
} else {
vtAbort("Incomplete read for: " + event_names_[i] + ". Expected " + std::to_string(sizeof(uint64_t)) +
" bytes, but got " + std::to_string(bytesRead));
vtAbort("Incomplete read for: " + event_names_[i] +
". Expected " + std::to_string(sizeof(uint64_t)) +
" bytes, but got " + std::to_string(bytesRead));
}
}
else {
} else {
vtAbort("Invalid file descriptor for: " + event_names_[i]);
}
}

return measurements;
}

Expand Down

0 comments on commit 6b043c0

Please sign in to comment.