This contains my bachelors thesis and associated tex files, code snippets and maybe more. Topic: Data Movement in Heterogeneous Memories with Intel Data Streaming Accelerator
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.

69 lines
2.6 KiB

  1. #pragma once
  2. #include <iostream>
  3. #include "json/single_include/nlohmann/json.hpp"
  4. #include "execute-move.hpp"
  5. inline const std::string StatusCodeToString(const dml::status_code code) {
  6. switch(code) {
  7. case dml::status_code::ok: return "[ok]";
  8. case dml::status_code::false_predicate: return "[false predicate]";
  9. case dml::status_code::partial_completion: return "[partial completion]";
  10. case dml::status_code::nullptr_error: return "[nullptr error]";
  11. case dml::status_code::bad_size: return "[bad size]";
  12. case dml::status_code::bad_length: return "[bad length]";
  13. case dml::status_code::inconsistent_size: return "[inconsistent size]";
  14. case dml::status_code::dualcast_bad_padding: return "[dualcast bad padding]";
  15. case dml::status_code::bad_alignment: return "[bad alignment]";
  16. case dml::status_code::buffers_overlapping: return "[buffers overlapping]";
  17. case dml::status_code::delta_delta_empty: return "[delta delta empty]";
  18. case dml::status_code::batch_overflow: return "[batch overflow]";
  19. case dml::status_code::execution_failed: return "[execution failed]";
  20. case dml::status_code::unsupported_operation: return "[unsupported operation]";
  21. case dml::status_code::queue_busy: return "[queue busy]";
  22. case dml::status_code::error: return "[unknown error]";
  23. case dml::status_code::config_error: return "[config error]";
  24. default: return "[unhandled error]";
  25. }
  26. }
  27. inline void to_json(nlohmann::json& j, const ThreadArgs& a) {
  28. j = nlohmann::json{
  29. {"node", a.numa_node}, {"core", a.core}, {"size", a.size},
  30. {"nnode_src", a.nnode_src}, {"nnode_dst", a.nnode_dst},
  31. {"time_us", a.duration.count()},
  32. {"status", StatusCodeToString(a.status)}
  33. };
  34. }
  35. inline void from_json(const nlohmann::json& j, ThreadArgs& a) {
  36. j.at("node").get_to(a.numa_node);
  37. j.at("core").get_to(a.core);
  38. j.at("size").get_to(a.size);
  39. j.at("nnode_src").get_to(a.nnode_src);
  40. j.at("nnode_dst").get_to(a.nnode_dst);
  41. }
  42. inline void WriteResultLog(const std::vector<ThreadArgs>& args, const std::string& path, std::ostream& os) {
  43. nlohmann::json json;
  44. json["count"] = args.size();
  45. json["path"] = path;
  46. json["list"] = args;
  47. os << std::setw(4) << json;
  48. }
  49. inline void ReadWorkDescription(std::vector<ThreadArgs>& args, std::string& path, std::istream& is) {
  50. nlohmann::json json;
  51. is >> json;
  52. const uint32_t count = json.at("count");
  53. args.resize(count);
  54. path = json.at("path");
  55. for (uint32_t i = 0; i < count; i++) {
  56. args[i] = json["list"][i].template get<ThreadArgs>();
  57. }
  58. }