16 std::vector<LogEntry> allLogs;
29 std::vector<LogEntry> localLogs;
32 const auto& logs = loggingHandler.getLogs();
33 localLogs.insert(localLogs.end(), logs.begin(), logs.end());
42 int logSize = buffer.size();
44 this->
send(logSize, 1, 0, 0);
45 this->
send<char>(buffer.data(), logSize, 0, 0);
49 const std::vector<LogEntry>& localLogs) {
50 std::vector<LogEntry> allLogs = localLogs;
56 this->
recv(logSize, 1,
rank, 0, status);
58 std::vector<char> buffer(logSize);
62 allLogs.insert(allLogs.end(), deserializedLogs.begin(), deserializedLogs.end());
69 std::vector<char> buffer;
71 for (
const auto& logEntry : logs) {
72 std::vector<char> serializedEntry = logEntry.serialize();
73 buffer.insert(buffer.end(), serializedEntry.begin(), serializedEntry.end());
80 std::vector<LogEntry> logs;
83 while (offset < buffer.size()) {
86 logs.push_back(logEntry);
94 const std::string& filename) {
98 logFile <<
"Timestamp,Method,Rank,MemorySpace,usedSize,FreeSize,Parameters" <<
endl;
100 for (
const auto& log : allLogs) {
101 auto timestamp = std::chrono::duration_cast<std::chrono::milliseconds>(
102 log.timestamp.time_since_epoch())
105 logFile << timestamp <<
"," << log.methodName <<
"," << log.rank <<
","
106 << log.memorySpace <<
"," << log.usedSize <<
"," << log.freeSize;
110 for (
const auto& [key, value] : log.parameters) {
114 logFile << key <<
": " << value;
117 logFile <<
"\"" <<
endl;
constexpr KOKKOS_INLINE_FUNCTION auto first()
Inform & endl(Inform &inf)
std::vector< LogEntry > deserializeLogs(const std::vector< char > &buffer)
std::vector< char > serializeLogs(const std::vector< LogEntry > &logs)
void writeLogsToFile(const std::vector< LogEntry > &allLogs, const std::string &filename)
void send(const T &buffer, int count, int dest, int tag)
void printLogs(const std::string &filename)
int rank() const noexcept
void recv(T &output, int count, int source, int tag, Status &status)
std::vector< LogEntry > gatherLocalLogs()
buffer_handler_type buffer_handlers_m
std::vector< LogEntry > gatherLogsFromAllRanks(const std::vector< LogEntry > &localLogs)
void sendLogsToRank0(const std::vector< LogEntry > &localLogs)
static LogEntry deserialize(const std::vector< char > &buffer, size_t offset=0)
std::vector< char > serialize() const
Inform & setOutputLevel(const int)