You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
2.6 KiB
70 lines
2.6 KiB
#pragma once
|
|
|
|
#include <iostream>
|
|
|
|
#include "json/single_include/nlohmann/json.hpp"
|
|
|
|
#include "execute-move.hpp"
|
|
|
|
inline const std::string StatusCodeToString(const dml::status_code code) {
|
|
switch(code) {
|
|
case dml::status_code::ok: return "[ok]";
|
|
case dml::status_code::false_predicate: return "[false predicate]";
|
|
case dml::status_code::partial_completion: return "[partial completion]";
|
|
case dml::status_code::nullptr_error: return "[nullptr error]";
|
|
case dml::status_code::bad_size: return "[bad size]";
|
|
case dml::status_code::bad_length: return "[bad length]";
|
|
case dml::status_code::inconsistent_size: return "[inconsistent size]";
|
|
case dml::status_code::dualcast_bad_padding: return "[dualcast bad padding]";
|
|
case dml::status_code::bad_alignment: return "[bad alignment]";
|
|
case dml::status_code::buffers_overlapping: return "[buffers overlapping]";
|
|
case dml::status_code::delta_delta_empty: return "[delta delta empty]";
|
|
case dml::status_code::batch_overflow: return "[batch overflow]";
|
|
case dml::status_code::execution_failed: return "[execution failed]";
|
|
case dml::status_code::unsupported_operation: return "[unsupported operation]";
|
|
case dml::status_code::queue_busy: return "[queue busy]";
|
|
case dml::status_code::error: return "[unknown error]";
|
|
case dml::status_code::config_error: return "[config error]";
|
|
default: return "[unhandled error]";
|
|
}
|
|
}
|
|
|
|
inline void to_json(nlohmann::json& j, const ThreadArgs& a) {
|
|
j = nlohmann::json{
|
|
{"node", a.numa_node}, {"core", a.core}, {"size", a.size},
|
|
{"nnode_src", a.nnode_src}, {"nnode_dst", a.nnode_dst},
|
|
{"time_us", a.duration.count()},
|
|
{"status", StatusCodeToString(a.status)}
|
|
};
|
|
}
|
|
|
|
inline void from_json(const nlohmann::json& j, ThreadArgs& a) {
|
|
j.at("node").get_to(a.numa_node);
|
|
j.at("core").get_to(a.core);
|
|
j.at("size").get_to(a.size);
|
|
j.at("nnode_src").get_to(a.nnode_src);
|
|
j.at("nnode_dst").get_to(a.nnode_dst);
|
|
}
|
|
|
|
inline void WriteResultLog(const std::vector<ThreadArgs>& args, const std::string& path, std::ostream& os) {
|
|
nlohmann::json json;
|
|
|
|
json["count"] = args.size();
|
|
json["path"] = path;
|
|
json["list"] = args;
|
|
|
|
os << std::setw(4) << json;
|
|
}
|
|
|
|
inline void ReadWorkDescription(std::vector<ThreadArgs>& args, std::string& path, std::istream& is) {
|
|
nlohmann::json json;
|
|
is >> json;
|
|
|
|
const uint32_t count = json.at("count");
|
|
args.resize(count);
|
|
path = json.at("path");
|
|
|
|
for (uint32_t i = 0; i < count; i++) {
|
|
args[i] = json["list"][i].template get<ThreadArgs>();
|
|
}
|
|
}
|