clientlaunch 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/usr/bin/env python3
  2. import argparse
  3. import os
  4. import shlex
  5. import subprocess
  6. import sys
  7. import threading
  8. import yaml
  9. sys.path.insert(0, os.getcwd())
  10. sys.path.insert(1, './../App/')
  11. import mkconfig
  12. # The default manifest file
  13. MANIFEST = "./../App/manifest.yaml"
  14. # The default pubkeys file
  15. PUBKEYS = "./../App/pubkeys.yaml"
  16. # The client binary
  17. CLIENTS = "./clients"
  18. # Client thread allocation
  19. prefix = "numactl -C24-31 "
  20. def launch(config, cmd, threads):
  21. cmdline = ''
  22. cmdline += prefix + CLIENTS + " -t " + str(threads) + ""
  23. proc = subprocess.Popen(shlex.split(cmdline) + cmd,
  24. stdin=subprocess.PIPE, stdout=subprocess.PIPE,
  25. stderr=subprocess.STDOUT, bufsize=0)
  26. print(cmdline)
  27. proc.stdin.write(config.encode('utf-8'))
  28. while True:
  29. line = proc.stdout.readline()
  30. if not line:
  31. break
  32. print(line.decode('utf-8'), end='', flush=True)
  33. if __name__ == "__main__":
  34. print("In clientlaunch")
  35. aparse = argparse.ArgumentParser(
  36. description='Launch CLIENTS'
  37. )
  38. aparse.add_argument('-m', default=MANIFEST,
  39. help='manifest.yaml file')
  40. aparse.add_argument('-p', default=PUBKEYS,
  41. help='pubkeys.yaml file')
  42. aparse.add_argument('-t', default=1,
  43. help='number of threads')
  44. aparse.add_argument('-z', default=None,
  45. help='override message size')
  46. aparse.add_argument('-u', default=None,
  47. help='override max number of users')
  48. aparse.add_argument('-B', default=None,
  49. help='override max number of outgoing private messages per user per epoch')
  50. aparse.add_argument('-b', default=None,
  51. help='override max number of incoming private messages per user per epoch')
  52. aparse.add_argument('-C', default=None,
  53. help='override max number of outgoing public messages per user per epoch')
  54. aparse.add_argument('-c', default=None,
  55. help='override max number of incoming public messages per user per epoch')
  56. aparse.add_argument('-n', nargs='*', help='nodes to include')
  57. aparse.add_argument('cmd', nargs='*', help='experiment to run')
  58. args = aparse.parse_args()
  59. with open(args.m) as mf:
  60. manifest = yaml.safe_load(mf)
  61. params_overrides = {
  62. 'msg_size': args.z,
  63. 'user_count': args.u,
  64. 'priv_out': args.B,
  65. 'priv_in': args.b,
  66. 'pub_out': args.C,
  67. 'pub_in': args.c,
  68. }
  69. config = mkconfig.create_json(args.m, args.p, args.n, params_overrides)
  70. # There must not be any newlines in the config json string
  71. if "\n" in config:
  72. print("Error: config.json must not contain embedded newlines")
  73. sys.exit(1)
  74. # Now add a trailing newline
  75. config += "\n"
  76. thread = threading.Thread(target=launch,
  77. args=(config, args.cmd, args.t))
  78. thread.start()
  79. thread.join()