runner.py 1.58 KB
Newer Older
1 2 3 4 5 6 7 8 9
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import print_function
import subprocess, time

def run_dist(master, slaves, version, workers, iwp):
  # Setup the slave nodes
  for slave in slaves:
10
    cmd = "./orbit +RTS -N2 -RTS dist slave %s %s" % (slave["host"], slave["port"])
11 12 13 14 15 16 17 18 19 20 21 22 23 24
    process = subprocess.Popen(cmd, shell=True)
  time.sleep(2)
  # Run the master node
  t1 = time.time()
  cmd = "./orbit dist master %s %s %s %s %s" % (
    iwp, version, workers, master["host"], master["port"]
  )
  p = subprocess.Popen(cmd, shell=True)
  p.wait()
  t2 = time.time()
  return t2 - t1

# Configuration

25
reps = 2
26
iwp = False
27
max_cpu = 16
28
versions = ["short"]
29
master = {"host": "127.0.0.1", "port": 5050}
30 31 32
slaves = [ {"host": "127.0.0.1", "port": 5051}
         , {"host": "127.0.0.1", "port": 5052}
         , {"host": "127.0.0.1", "port": 5053}
33 34 35 36 37
         , {"host": "127.0.0.1", "port": 5054}
         , {"host": "127.0.0.1", "port": 5055}
         , {"host": "127.0.0.1", "port": 5056}
         , {"host": "127.0.0.1", "port": 5057}
         , {"host": "127.0.0.1", "port": 5058}
38 39 40 41
         ]

f = open('statistics.txt', 'w')

42 43 44 45 46
### 1 host

for nSlaves in range(1, len(slaves)+1):
  for iwp in [False, True]:
    for vsn in versions:
47 48
#      for n in range(2, 2*max_cpu+1, 2):
        n = nSlaves
49 50 51 52 53 54 55 56
        slvs = slaves[0:nSlaves]
        print ("Slaves: %s, Workers: %s, Version: %s, IWP: %s" % (nSlaves, n, vsn, iwp), file=f)
        ts = []
        for _ in range(reps):
          t = run_dist(master, slvs, vsn, n, iwp)
          ts.append(t)
        print ("%s" % ts, file=f)
        f.flush()
57 58

f.close()