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.

79 lines
2.5 KiB

  1. #pragma once
  2. #include <iostream>
  3. #include "json/single_include/nlohmann/json.hpp"
  4. #include "barrier.hpp"
  5. #include "dml-helper.hpp"
  6. struct TaskData {
  7. // thread placement / engine selection
  8. uint8_t numa_node;
  9. // region size and source+destination for move
  10. size_t size;
  11. uint8_t nnode_src;
  12. uint8_t nnode_dst;
  13. // repetition
  14. uint32_t rep_count;
  15. bool batch_submit;
  16. uint32_t batch_size;
  17. // thread output
  18. dml::status_code status;
  19. // average run duration in microseconds
  20. std::vector<double> combined_duration;
  21. std::vector<double> submit_duration;
  22. std::vector<double> complete_duration;
  23. // completed iterations
  24. uint32_t rep_completed;
  25. // set by execution
  26. barrier* barrier_;
  27. };
  28. inline void to_json(nlohmann::json& j, const TaskData& a) {
  29. j["task"]["size"] = a.size;
  30. j["task"]["iterations"] = a.rep_count;
  31. j["task"]["batching"]["batch_submit"] = a.batch_submit;
  32. j["task"]["batching"]["batch_size"] = a.batch_size;
  33. j["affinity"]["node"] = a.numa_node;
  34. j["affinity"]["nnode_src"] = a.nnode_src;
  35. j["affinity"]["nnode_dst"] = a.nnode_dst;
  36. j["report"]["time"]["unit"] = "nanoseconds";
  37. j["report"]["time"]["completion"] = a.complete_duration;
  38. j["report"]["time"]["submission"] = a.submit_duration;
  39. j["report"]["time"]["combined"] = a.combined_duration;
  40. j["report"]["iterations_completed"] = a.rep_completed;
  41. j["report"]["status"] = StatusCodeToString(a.status);
  42. }
  43. inline void from_json(const nlohmann::json& j, TaskData& a) {
  44. j["task"]["size"].get_to(a.size);
  45. j["task"]["iterations"].get_to(a.rep_count);
  46. j["task"]["batching"]["batch_submit"].get_to(a.batch_submit);
  47. j["task"]["batching"]["batch_size"].get_to(a.batch_size);
  48. j["affinity"]["node"].get_to(a.numa_node);
  49. j["affinity"]["nnode_src"].get_to(a.nnode_src);
  50. j["affinity"]["nnode_dst"].get_to(a.nnode_dst);
  51. }
  52. inline void WriteResultLog(const std::vector<TaskData>& args, const std::string& path, std::ostream& os) {
  53. nlohmann::json json;
  54. json["count"] = args.size();
  55. json["path"] = path;
  56. json["list"] = args;
  57. os << std::setw(4) << json;
  58. }
  59. inline void ReadWorkDescription(std::vector<TaskData>& args, std::string& path, std::istream& is) {
  60. nlohmann::json json;
  61. is >> json;
  62. const uint32_t count = json.at("count");
  63. args.resize(count);
  64. path = json.at("path");
  65. for (uint32_t i = 0; i < count; i++) {
  66. args[i] = json["list"][i].template get<TaskData>();
  67. }
  68. }