1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- #!/usr/bin/env python3
- import argparse
- import os
- import shlex
- import subprocess
- import sys
- import threading
- import yaml
- sys.path.insert(0, os.getcwd())
- sys.path.insert(1, './../App/')
- import mkconfig
- # The default manifest file
- MANIFEST = "./../App/manifest.yaml"
- # The default pubkeys file
- PUBKEYS = "./../App/pubkeys.yaml"
- # The client binary
- CLIENTS = "./clients"
- # Client thread allocation
- prefix = "numactl -C24-31 "
- def launch(config, cmd, threads):
- cmdline = ''
- cmdline += prefix + CLIENTS + " -t " + str(threads) + ""
- proc = subprocess.Popen(shlex.split(cmdline) + cmd,
- stdin=subprocess.PIPE, stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT, bufsize=0)
- print(cmdline)
- proc.stdin.write(config.encode('utf-8'))
- while True:
- line = proc.stdout.readline()
- if not line:
- break
- print(line.decode('utf-8'), end='', flush=True)
- if __name__ == "__main__":
- print("In clientlaunch")
- aparse = argparse.ArgumentParser(
- description='Launch CLIENTS'
- )
- aparse.add_argument('-m', default=MANIFEST,
- help='manifest.yaml file')
- aparse.add_argument('-p', default=PUBKEYS,
- help='pubkeys.yaml file')
- aparse.add_argument('-t', default=1,
- help='number of threads')
- aparse.add_argument('-z', default=None,
- help='override message size')
- aparse.add_argument('-u', default=None,
- help='override max number of users')
- aparse.add_argument('-B', default=None,
- help='override max number of outgoing private messages per user per epoch')
- aparse.add_argument('-b', default=None,
- help='override max number of incoming private messages per user per epoch')
- aparse.add_argument('-C', default=None,
- help='override max number of outgoing public messages per user per epoch')
- aparse.add_argument('-c', default=None,
- help='override max number of incoming public messages per user per epoch')
- aparse.add_argument('-n', nargs='*', help='nodes to include')
- aparse.add_argument('cmd', nargs='*', help='experiment to run')
- args = aparse.parse_args()
- with open(args.m) as mf:
- manifest = yaml.safe_load(mf)
- params_overrides = {
- 'msg_size': args.z,
- 'user_count': args.u,
- 'priv_out': args.B,
- 'priv_in': args.b,
- 'pub_out': args.C,
- 'pub_in': args.c,
- }
- config = mkconfig.create_json(args.m, args.p, args.n, params_overrides)
- # There must not be any newlines in the config json string
- if "\n" in config:
- print("Error: config.json must not contain embedded newlines")
- sys.exit(1)
- # Now add a trailing newline
- config += "\n"
- thread = threading.Thread(target=launch,
- args=(config, args.cmd, args.t))
- thread.start()
- thread.join()
|