submap_scaling.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import os
  2. import subprocess
  3. SENDS = 1048576
  4. FETCHES = 8192
  5. USERS = FETCHES
  6. THREADS = 8
  7. MAP_THREADS = [(i, 8 + 8 * i) for i in range(6, int(16))]
  8. # MAP_THREADS = [(i, 8 + 8 * i) for i in range(1, int(48 / THREADS))]
  9. RUNS = 10
  10. WARMUP = 0
  11. DATA_DIR = os.path.join(os.getcwd(), "data", "submap-scaling")
  12. os.makedirs(DATA_DIR, exist_ok=True)
  13. SPARTA_DIR = os.path.join(os.getcwd(), "sparta")
  14. SPARTA_D_DIR = os.path.join(os.getcwd(), "sparta-d")
  15. BASELINE_DIR = os.path.join(os.getcwd(), "baseline")
  16. BASELINE_FILE = os.path.join(DATA_DIR, f"baseline-{FETCHES}-{THREADS}.csv")
  17. SPARTA_FILE = os.path.join(DATA_DIR, f"sparta-{FETCHES}-{THREADS}.csv")
  18. SPARTA_D_FILE = os.path.join(DATA_DIR, f"sparta-d-{FETCHES}-{THREADS}.csv")
  19. def sparta_cmd(mt):
  20. (num_maps, num_threads) = mt
  21. cmd = ["cargo", "run", "--release", "--",
  22. str(SENDS), str(FETCHES), str(num_threads),
  23. str(USERS), str(num_maps), "-r", str(RUNS), "-w", str(WARMUP)]
  24. result = subprocess.run(cmd, capture_output=True,
  25. text=True, cwd=SPARTA_DIR)
  26. return result.stdout
  27. def sparta_d_cmd(mt):
  28. (num_maps, _num_threads) = mt
  29. cmd = ["cargo", "run", "--release", "--",
  30. str(SENDS), str(FETCHES), str(48),
  31. str(USERS), str(num_maps), "-r", str(RUNS), "-w", str(WARMUP)]
  32. result = subprocess.run(cmd, capture_output=True,
  33. text=True, cwd=SPARTA_D_DIR)
  34. return result.stdout
  35. def baseline_cmd(mt):
  36. (_num_maps, num_threads) = mt
  37. cmd = ["cargo", "run", "--release", "--",
  38. str(SENDS), str(FETCHES), str(num_threads), "-r", str(RUNS), "-w", str(WARMUP)]
  39. result = subprocess.run(cmd, capture_output=True,
  40. text=True, cwd=BASELINE_DIR)
  41. return result.stdout
  42. for mt in MAP_THREADS:
  43. print(mt)
  44. # with open(SPARTA_FILE, "a") as sparta_file:
  45. # output = sparta_cmd(mt)
  46. # print("\tsparta:", output)
  47. # sparta_file.write(output)
  48. with open(SPARTA_D_FILE, "a") as sparta_d_file:
  49. output = sparta_d_cmd(mt)
  50. print("\tsparta_d:", output)
  51. sparta_d_file.write(output)
  52. # with open(BASELINE_FILE, "a") as baseline_file:
  53. # output = baseline_cmd(mt)
  54. # print("\tbaseline:", output)
  55. # baseline_file.write(output)