#pragma once #include #include "json/single_include/nlohmann/json.hpp" #include "barrier.hpp" #include "dml-helper.hpp" struct TaskData { // thread placement / engine selection uint8_t numa_node; // region size and source+destination for move size_t size; uint8_t nnode_src; uint8_t nnode_dst; // repetition uint32_t rep_count; bool batch_submit; uint32_t batch_size; // thread output dml::status_code status; // average run duration in microseconds std::vector combined_duration; std::vector submit_duration; std::vector complete_duration; // completed iterations uint32_t rep_completed; // set by execution barrier* barrier_; }; inline void to_json(nlohmann::json& j, const TaskData& a) { j["task"]["size"] = a.size; j["task"]["iterations"] = a.rep_count; j["task"]["batching"]["batch_submit"] = a.batch_submit; j["task"]["batching"]["batch_size"] = a.batch_size; j["affinity"]["node"] = a.numa_node; j["affinity"]["nnode_src"] = a.nnode_src; j["affinity"]["nnode_dst"] = a.nnode_dst; j["report"]["time"]["unit"] = "nanoseconds"; j["report"]["time"]["completion"] = a.complete_duration; j["report"]["time"]["submission"] = a.submit_duration; j["report"]["time"]["combined"] = a.combined_duration; j["report"]["iterations_completed"] = a.rep_completed; j["report"]["status"] = StatusCodeToString(a.status); } inline void from_json(const nlohmann::json& j, TaskData& a) { j["task"]["size"].get_to(a.size); j["task"]["iterations"].get_to(a.rep_count); j["task"]["batching"]["batch_submit"].get_to(a.batch_submit); j["task"]["batching"]["batch_size"].get_to(a.batch_size); j["affinity"]["node"].get_to(a.numa_node); j["affinity"]["nnode_src"].get_to(a.nnode_src); j["affinity"]["nnode_dst"].get_to(a.nnode_dst); } inline void WriteResultLog(const std::vector& args, const std::string& path, std::ostream& os) { nlohmann::json json; json["count"] = args.size(); json["path"] = path; json["list"] = args; os << json; } inline void ReadWorkDescription(std::vector& 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(); } }