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.

82 lines
2.6 KiB

  1. #pragma once
  2. #include <iostream>
  3. #include "json/single_include/nlohmann/json.hpp"
  4. #include "statuscode-tostring.hpp"
  5. #include "barrier.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. uint32_t barrier_after_n_operations;
  18. // thread output
  19. dml::status_code status;
  20. // average run duration in microseconds
  21. double combined_duration;
  22. double submit_duration;
  23. double complete_duration;
  24. // completed iterations
  25. uint32_t rep_completed;
  26. // set by execution
  27. barrier* barrier_;
  28. };
  29. inline void to_json(nlohmann::json& j, const TaskData& a) {
  30. j["task"]["size"] = a.size;
  31. j["task"]["iterations"] = a.rep_count;
  32. j["task"]["batching"]["enabled"] = a.batch_submit;
  33. j["task"]["batching"]["batch_size"] = a.batch_size;
  34. j["task"]["batching"]["barrier_after_n_operations"] = a.barrier_after_n_operations;
  35. j["affinity"]["node"] = a.numa_node;
  36. j["affinity"]["nnode_src"] = a.nnode_src;
  37. j["affinity"]["nnode_dst"] = a.nnode_dst;
  38. j["report"]["time"]["unit"] = "microseconds";
  39. j["report"]["time"]["completion_avg"] = a.complete_duration;
  40. j["report"]["time"]["submission_avg"] = a.submit_duration;
  41. j["report"]["time"]["combined_avg"] = a.combined_duration;
  42. j["report"]["iterations_completed"] = a.rep_completed;
  43. j["report"]["status"] = StatusCodeToString(a.status);
  44. }
  45. inline void from_json(const nlohmann::json& j, TaskData& a) {
  46. j["task"]["size"].get_to(a.size);
  47. j["task"]["iterations"].get_to(a.rep_count);
  48. j["task"]["batching"]["enabled"].get_to(a.batch_submit);
  49. j["task"]["batching"]["batch_size"].get_to(a.batch_size);
  50. j["task"]["batching"]["barrier_after_n_operations"].get_to(a.barrier_after_n_operations);
  51. j["affinity"]["node"].get_to(a.numa_node);
  52. j["affinity"]["nnode_src"].get_to(a.nnode_src);
  53. j["affinity"]["nnode_dst"].get_to(a.nnode_dst);
  54. }
  55. inline void WriteResultLog(const std::vector<TaskData>& args, const std::string& path, std::ostream& os) {
  56. nlohmann::json json;
  57. json["count"] = args.size();
  58. json["path"] = path;
  59. json["list"] = args;
  60. os << std::setw(4) << json;
  61. }
  62. inline void ReadWorkDescription(std::vector<TaskData>& args, std::string& path, std::istream& is) {
  63. nlohmann::json json;
  64. is >> json;
  65. const uint32_t count = json.at("count");
  66. args.resize(count);
  67. path = json.at("path");
  68. for (uint32_t i = 0; i < count; i++) {
  69. args[i] = json["list"][i].template get<TaskData>();
  70. }
  71. }