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.
62 lines
2.1 KiB
62 lines
2.1 KiB
#pragma once
|
|
|
|
#include <iostream>
|
|
|
|
#include "json/single_include/nlohmann/json.hpp"
|
|
|
|
#include "execute-move.hpp"
|
|
#include "statuscode-tostring.hpp"
|
|
|
|
inline void to_json(nlohmann::json& j, const ThreadArgs& a) {
|
|
j["task"]["size"] = a.size;
|
|
j["task"]["iterations"]["desired"] = a.rep_count;
|
|
j["task"]["iterations"]["actual"] = a.rep_completed;
|
|
j["task"]["batching"]["enabled"] = a.batch_submit;
|
|
j["task"]["batching"]["batch_size"] = a.batch_size;
|
|
j["task"]["batching"]["barrier_after_n_operations"] = a.barrier_after_n_operations;
|
|
j["affinity"]["cpu_core"] = a.core;
|
|
j["affinity"]["numa"] = a.numa_node;
|
|
j["affinity"]["nnode_src"] = a.nnode_src;
|
|
j["affinity"]["nnode_dst"] = a.nnode_dst;
|
|
j["time"]["unit"] = "microseconds";
|
|
j["time"]["summation"] = "average";
|
|
j["time"]["completion"] = a.complete_duration;
|
|
j["time"]["submission"] = a.submit_duration;
|
|
j["time"]["combined"] = a.combined_duration;
|
|
j["report"]["status"] = StatusCodeToString(a.status);
|
|
}
|
|
|
|
inline void from_json(const nlohmann::json& j, ThreadArgs& a) {
|
|
j["task"]["size"].get_to(a.size);
|
|
j["task"]["iterations"]["desired"].get_to(a.rep_count);
|
|
j["task"]["batching"]["enabled"].get_to(a.batch_submit);
|
|
j["task"]["batching"]["batch_size"].get_to(a.batch_size);
|
|
j["task"]["batching"]["barrier_after_n_operations"].get_to(a.barrier_after_n_operations);
|
|
j["affinity"]["numa"].get_to(a.numa_node);
|
|
j["affinity"]["core"].get_to(a.core);
|
|
j["affinity"]["nnode_src"].get_to(a.nnode_src);
|
|
j["affinity"]["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>();
|
|
}
|
|
}
|