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.

85 lines
2.7 KiB

  1. #pragma once
  2. #include <iostream>
  3. #include "json/single_include/nlohmann/json.hpp"
  4. #include "statuscode-tostring.hpp"
  5. struct TaskData {
  6. // thread placement / engine selection
  7. uint8_t numa_node;
  8. uint8_t core;
  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. sem_t* sig;
  28. };
  29. inline void to_json(nlohmann::json& j, const TaskData& a) {
  30. j["task"]["size"] = a.size;
  31. j["task"]["iterations"]["desired"] = a.rep_count;
  32. j["task"]["iterations"]["actual"] = a.rep_completed;
  33. j["task"]["batching"]["enabled"] = a.batch_submit;
  34. j["task"]["batching"]["batch_size"] = a.batch_size;
  35. j["task"]["batching"]["barrier_after_n_operations"] = a.barrier_after_n_operations;
  36. j["affinity"]["cpu_core"] = a.core;
  37. j["affinity"]["numa"] = a.numa_node;
  38. j["affinity"]["nnode_src"] = a.nnode_src;
  39. j["affinity"]["nnode_dst"] = a.nnode_dst;
  40. j["time"]["unit"] = "microseconds";
  41. j["time"]["summation"] = "average";
  42. j["time"]["completion"] = a.complete_duration;
  43. j["time"]["submission"] = a.submit_duration;
  44. j["time"]["combined"] = a.combined_duration;
  45. j["report"]["status"] = StatusCodeToString(a.status);
  46. }
  47. inline void from_json(const nlohmann::json& j, TaskData& a) {
  48. j["task"]["size"].get_to(a.size);
  49. j["task"]["iterations"]["desired"].get_to(a.rep_count);
  50. j["task"]["batching"]["enabled"].get_to(a.batch_submit);
  51. j["task"]["batching"]["batch_size"].get_to(a.batch_size);
  52. j["task"]["batching"]["barrier_after_n_operations"].get_to(a.barrier_after_n_operations);
  53. j["affinity"]["numa"].get_to(a.numa_node);
  54. j["affinity"]["core"].get_to(a.core);
  55. j["affinity"]["nnode_src"].get_to(a.nnode_src);
  56. j["affinity"]["nnode_dst"].get_to(a.nnode_dst);
  57. }
  58. inline void WriteResultLog(const std::vector<TaskData>& args, const std::string& path, std::ostream& os) {
  59. nlohmann::json json;
  60. json["count"] = args.size();
  61. json["path"] = path;
  62. json["list"] = args;
  63. os << std::setw(4) << json;
  64. }
  65. inline void ReadWorkDescription(std::vector<TaskData>& args, std::string& path, std::istream& is) {
  66. nlohmann::json json;
  67. is >> json;
  68. const uint32_t count = json.at("count");
  69. args.resize(count);
  70. path = json.at("path");
  71. for (uint32_t i = 0; i < count; i++) {
  72. args[i] = json["list"][i].template get<TaskData>();
  73. }
  74. }