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.

60 lines
2.3 KiB

  1. import os
  2. import json
  3. import shutil
  4. import copy
  5. def make_new_list(old,size):
  6. entry = old[0]
  7. new_list = []
  8. for i in range(size): new_list.append(copy.deepcopy(entry))
  9. return new_list
  10. def process_json_file(file_path):
  11. with open(file_path, 'r') as f:
  12. json_data = json.load(f)
  13. v_src = json_data["list"][0]["affinity"]["nnode_src"]
  14. v_dst = json_data["list"][0]["affinity"]["nnode_dst"]
  15. # Adjust v_src and v_dst based on HBM memory
  16. v_src = v_src - 8 if v_src >= 8 else v_src
  17. v_dst = v_dst - 8 if v_dst >= 8 else v_dst
  18. if (0 <= v_src <= 3 and 0 <= v_dst <= 3):
  19. list_size = 4
  20. json_data["list"] = make_new_list(json_data["list"], list_size)
  21. json_data["count"] = list_size
  22. json_data["list"][0]["affinity"]["node"] = 0
  23. json_data["list"][1]["affinity"]["node"] = 1
  24. json_data["list"][2]["affinity"]["node"] = 2
  25. json_data["list"][3]["affinity"]["node"] = 3
  26. elif (4 <= v_src <= 7 and 4 <= v_dst <= 7):
  27. list_size = 4
  28. json_data["list"] = make_new_list(json_data["list"], list_size)
  29. json_data["count"] = list_size
  30. json_data["list"][0]["affinity"]["node"] = 4
  31. json_data["list"][1]["affinity"]["node"] = 5
  32. json_data["list"][2]["affinity"]["node"] = 6
  33. json_data["list"][3]["affinity"]["node"] = 7
  34. else:
  35. # Case B: inter-socket operation
  36. list_size = 2
  37. json_data["list"] = make_new_list(json_data["list"], list_size)
  38. json_data["count"] = list_size
  39. json_data["list"][0]["affinity"]["node"] = v_src
  40. json_data["list"][1]["affinity"]["node"] = v_dst
  41. # Save modified JSON back to file
  42. with open(file_path, 'w') as f:
  43. json.dump(json_data, f, indent=2)
  44. def process_files_in_folder(folder_path):
  45. for filename in os.listdir(folder_path):
  46. file_path = os.path.join(folder_path, filename)
  47. if os.path.isfile(file_path) and filename.endswith('.json'):
  48. if "copy-n" in filename and "ton" in filename and "-1gib-smart.json" in filename:
  49. process_json_file(file_path)
  50. if __name__ == "__main__":
  51. folder_path = "./benchmark-descriptors/peak-perf-smart/"
  52. process_files_in_folder(folder_path)