submap_scaling_legacy.py 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import os
  2. import subprocess
  3. SENDS = 1048576
  4. FETCHES = 1048576
  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-legacy")
  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(
  17. DATA_DIR, f"baseline-{FETCHES}-{THREADS}.csv")
  18. SPARTA_FILE = os.path.join(DATA_DIR, f"sparta-{FETCHES}-{THREADS}.csv")
  19. SPARTA_D_FILE = os.path.join(
  20. DATA_DIR, f"sparta-d-{FETCHES}-{THREADS}.csv")
  21. def sparta_cmd(mt):
  22. (num_maps, num_threads) = mt
  23. cmd = ["cargo", "run", "--release", "--",
  24. str(SENDS), str(FETCHES), str(num_threads),
  25. str(USERS), str(num_maps), "-r", str(RUNS), "-w", str(WARMUP)]
  26. print(cmd)
  27. result = subprocess.run(cmd, capture_output=True,
  28. text=True, cwd=SPARTA_DIR)
  29. return result.stdout
  30. def sparta_d_cmd(mt):
  31. (num_maps, _num_threads) = mt
  32. cmd = ["cargo", "run", "--release", "--",
  33. str(SENDS), str(FETCHES), str(48),
  34. str(USERS), str(num_maps), "-r", str(RUNS), "-w", str(WARMUP)]
  35. print(cmd)
  36. result = subprocess.run(cmd, capture_output=True,
  37. text=True, cwd=SPARTA_D_DIR)
  38. return result.stdout
  39. def baseline_cmd(mt):
  40. (_num_maps, num_threads) = mt
  41. cmd = ["cargo", "run", "--release", "--",
  42. str(SENDS), str(FETCHES), str(num_threads), "-r", str(RUNS), "-w", str(WARMUP)]
  43. print(cmd)
  44. result = subprocess.run(cmd, capture_output=True,
  45. text=True, cwd=BASELINE_DIR)
  46. return result.stdout
  47. for mt in MAP_THREADS:
  48. print(mt)
  49. with open(SPARTA_FILE, "a") as sparta_file:
  50. output = sparta_cmd(mt)
  51. print("\tsparta:", output)
  52. sparta_file.write(output)
  53. with open(SPARTA_D_FILE, "a") as sparta_d_file:
  54. output = sparta_d_cmd(mt)
  55. print("\tsparta_d:", output)
  56. sparta_d_file.write(output)
  57. # with open(BASELINE_FILE, "a") as baseline_file:
  58. # output = baseline_cmd(mt)
  59. # print("\tbaseline:", output)
  60. # baseline_file.write(output)