Esempio n. 1
0
 def test_res7(self):
     rm = taskrun.ResourceManager(
         taskrun.CounterResource('core', 9999, 4),
         taskrun.CounterResource('mem', 9999, 8000))
     ob = ComparisonCheckObserver(8, [
         '+t1 < +t2 +t3 +t4 -t4 -t3 -t2 -t1',
         '+t2 < +t3 +t4 -t4 -t3 -t2 -t1', '+t3 < +t4 -t4 -t3 -t2 -t1',
         '+t4 < -t4 -t3 -t2 -t1'
     ],
                                  verbose=False)
     tm = taskrun.TaskManager(resource_manager=rm, observers=[ob])
     t1 = taskrun.ProcessTask(tm, 't1', 'sleep 0.01')
     t1.resources = {'core': 1, 'mem': 0}
     t1.priority = 4
     t2 = taskrun.ProcessTask(tm, 't2', 'sleep 0.02')
     t2.resources = {'core': 1, 'mem': 0}
     t2.priority = 3
     t3 = taskrun.ProcessTask(tm, 't3', 'sleep 0.03')
     t3.resources = {'core': 1, 'mem': 0}
     t3.priority = 2
     t4 = taskrun.ProcessTask(tm, 't4', 'sleep 0.04')
     t4.resources = {'core': 1, 'mem': 0}
     t4.priority = 1
     tm.run_tasks()
     self.assertTrue(ob.ok())
Esempio n. 2
0
 def test_res1(self):
     rm = taskrun.ResourceManager(
         taskrun.CounterResource('core', 9999, 4),
         taskrun.CounterResource('mem', 9999, 8000))
     tm = taskrun.TaskManager(resource_manager=rm)
     t1 = taskrun.ProcessTask(tm, 't1', '')
     with self.assertRaises(ValueError):
         tm.run_tasks()
Esempio n. 3
0
 def test_res2(self):
     rm = taskrun.ResourceManager(
         taskrun.CounterResource('core', 9999, 4),
         taskrun.CounterResource('mem', 9999, 8000))
     ob = OrderCheckObserver(['@t1', '+t1', '-t1'])
     tm = taskrun.TaskManager(resource_manager=rm, observers=[ob])
     t1 = taskrun.ProcessTask(tm, 't1', '')
     t1.resources = {'core': 1, 'mem': 5000}
     tm.run_tasks()
     self.assertTrue(ob.ok())
Esempio n. 4
0
 def test_complex_good(self):
     tm = taskrun.TaskManager(
         observers=[taskrun.VerboseObserver(summary=False)],
         resource_manager=taskrun.ResourceManager(
             taskrun.CounterResource('cpu', 10, 64),
             taskrun.CounterResource('mem', 1024 * 1024 * 1024,
                                     256 * 1024 * 1024 * 1024),
             taskrun.CounterResource('net', 1000, 10000),
             taskrun.CounterResource('fds', 500, 50000)),
         failure_mode=taskrun.FailureMode.AGGRESSIVE_FAIL)
     tm.run_tasks()
Esempio n. 5
0
 def test_active_multiroottree_narrow(self):
     ob = ComparisonCheckObserver(8, [
         '+t1 < -t1 +t2 -t2 +t3 !t3 +t4 -t4', '-t1 > +t1',
         '-t1 < +t2 -t2 +t3 !t3 +t4 -t4', '+t2 > -t1 +t1',
         '+t2 < -t2 +t3 !t3 +t4 -t4', '-t2 > +t2 -t1 +t1',
         '-t2 < +t3 !t3 +t4 -t4', '+t3 > -t2 +t2 -t1 +t1',
         '+t3 < !t3 +t4 -t4', '!t3 > +t3 -t2 +t2 -t1 +t1', '!t3 < +t4 -t4',
         '+t4 > !t3 +t3 -t2 +t2 -t1 +t1', '+t4 < -t4',
         '-t4 > +t4 !t3 +t3 -t2 +t2 -t1 +t1'
     ],
                                  verbose=False)
     rm = taskrun.ResourceManager(taskrun.CounterResource('slot', 1, 1))
     tm = taskrun.TaskManager(observers=[ob],
                              resource_manager=rm,
                              failure_mode='active_continue')
     t1 = taskrun.ProcessTask(tm, 't1', '')
     t1.priority = 4
     t2 = taskrun.ProcessTask(tm, 't2', '')
     t2.priority = 3
     t3 = taskrun.ProcessTask(tm, 't3', 'false')
     t3.priority = 2
     t4 = taskrun.ProcessTask(tm, 't4', '')
     t4.priority = 1
     t3a = taskrun.ProcessTask(tm, 't3a', '')
     t3a.add_dependency(t3)
     t3b = taskrun.ProcessTask(tm, 't3b', '')
     t3b.add_dependency(t3)
     t3ba = taskrun.ProcessTask(tm, 't3ba', '')
     t3ba.add_dependency(t3b)
     tm.run_tasks()
     self.assertTrue(ob.ok())
Esempio n. 6
0
 def test_passive_multiroottree_wide(self):
     ob = ComparisonCheckObserver(8, [
         '+t1 < +t2 +t3 +t4 !t3 -t4 -t2 -t1', '+t2 > +t1',
         '+t2 < +t3 +t4 !t3 -t4 -t2 -t1', '+t3 > +t2 +t1',
         '+t3 < +t4 !t3 -t4 -t2 -t1', '+t4 > +t3 +t2 +t1',
         '+t4 < !t3 -t4 -t2 -t1', '!t3 > +t4 +t3 +t2 +t1',
         '!t3 < -t4 -t2 -t1', '-t4 > !t3 +t4 +t3 +t2 +t1',
         '-t2 > !t3 +t4 +t3 +t2 +t1', '-t1 > !t3 +t4 +t3 +t2 +t1'
     ],
                                  verbose=False)
     rm = taskrun.ResourceManager(taskrun.CounterResource('slot', 1, 1000))
     tm = taskrun.TaskManager(observers=[ob],
                              resource_manager=rm,
                              failure_mode='passive_fail')
     t1 = taskrun.ProcessTask(tm, 't1', 'sleep 0.04')
     t1.priority = 4
     t2 = taskrun.ProcessTask(tm, 't2', 'sleep 0.03')
     t2.priority = 3
     t3 = taskrun.ProcessTask(tm, 't3', 'sleep 0.01; false')
     t3.priority = 2
     t4 = taskrun.ProcessTask(tm, 't4', 'sleep 0.02')
     t4.priority = 1
     t3a = taskrun.ProcessTask(tm, 't3a', '')
     t3a.add_dependency(t3)
     t3b = taskrun.ProcessTask(tm, 't3b', '')
     t3b.add_dependency(t3)
     t3ba = taskrun.ProcessTask(tm, 't3ba', '')
     t3ba.add_dependency(t3b)
     tm.run_tasks()
     self.assertTrue(ob.ok())
Esempio n. 7
0
def main(args):
    lock = threading.Lock()
    results = {}

    if args.verbose and args.cores > 1:
        print('verbose mode forces cores to 1')
        args.cores = 1
    if args.verbose:
        print('using {0} cores for execution'.format(args.cores))

    rm = taskrun.ResourceManager(
        taskrun.CounterResource('cores', 1, args.cores))
    tm = taskrun.TaskManager(resource_manager=rm, observers=[])

    for radix in range(args.minradix, args.maxradix + 1, 1):
        task = taskrun.FunctionTask(tm, 'radix_{0}'.format(radix),
                                    largestNetwork, args.hyperxsearch, radix,
                                    args.minbandwidth, None,
                                    args.maxdimensions, args.minconcentration,
                                    args.maxconcentration, lock, results,
                                    args.verbose)
        task.priority = radix

    tm.run_tasks()

    grid = []
    grid.append([
        '#', 'Dimensions', 'Widths', 'Weights', 'Concentration', 'Terminals',
        'Routers', 'Radix', 'Channels', 'Bisections', 'Cost'
    ])
    for radix in range(args.minradix, args.maxradix + 1, 1):
        grid.append(results[radix])
    print(search_util.makeGrid(grid))
Esempio n. 8
0
 def test_res8(self):
     for div in [1, 2, 3, 10, 25, 50, 100, 187]:
         cr = taskrun.CounterResource('foo', 4.3 / div, 4.3)
         rm = taskrun.ResourceManager(cr)
         tm = taskrun.TaskManager(resource_manager=rm)
         rnd = random.Random(12345678)
         for t in range(10000):
             cmd = 'usleep {}'.format(rnd.gauss(1000, 500))
             taskrun.ProcessTask(tm, str(t), cmd)
         tm.run_tasks()
         self.assertEqual(cr.total, 4.3)
         self.assertEqual(cr.used, 0)
Esempio n. 9
0
 def test_res4(self):
     rm = taskrun.ResourceManager(
         taskrun.CounterResource('core', 9999, 4),
         taskrun.CounterResource('mem', 9999, 8000))
     ob = OrderCheckObserver([
         '@t1', '@t2', '@t3', '@t4', '+t1', '-t1', '+t2', '-t2', '+t3',
         '-t3', '+t4', '-t4'
     ])
     tm = taskrun.TaskManager(resource_manager=rm, observers=[ob])
     t1 = taskrun.ProcessTask(tm, 't1', '')
     t1.resources = {'core': 1, 'mem': 0}
     t2 = taskrun.ProcessTask(tm, 't2', '')
     t2.resources = {'core': 1, 'mem': 0}
     t3 = taskrun.ProcessTask(tm, 't3', '')
     t3.resources = {'core': 1, 'mem': 0}
     t4 = taskrun.ProcessTask(tm, 't4', '')
     t4.resources = {'core': 1, 'mem': 0}
     t4.add_dependency(t3)
     t3.add_dependency(t2)
     t2.add_dependency(t1)
     tm.run_tasks()
     self.assertTrue(ob.ok())
Esempio n. 10
0
 def test_res5(self):
     rm = taskrun.ResourceManager(
         taskrun.CounterResource('core', 9999, 1),
         taskrun.CounterResource('mem', 9999, 8000))
     ob = OrderCheckObserver([
         '@t1', '@t2', '@t3', '@t4', '+t1', '-t1', '+t2', '-t2', '+t3',
         '-t3', '+t4', '-t4'
     ])
     tm = taskrun.TaskManager(resource_manager=rm, observers=[ob])
     t1 = taskrun.ProcessTask(tm, 't1', '')
     t1.resources = {'core': 1, 'mem': 0}
     t1.priority = 4
     t2 = taskrun.ProcessTask(tm, 't2', '')
     t2.resources = {'core': 1, 'mem': 0}
     t2.priority = 3
     t3 = taskrun.ProcessTask(tm, 't3', '')
     t3.resources = {'core': 1, 'mem': 0}
     t3.priority = 2
     t4 = taskrun.ProcessTask(tm, 't4', '')
     t4.resources = {'core': 1, 'mem': 0}
     t4.priority = 1
     tm.run_tasks()
     self.assertTrue(ob.ok())
Esempio n. 11
0
 def __randN(self, b, n):
     rm = taskrun.ResourceManager(taskrun.CounterResource(
         'something', 1, 1))
     order = []
     for num in range(n):
         order.append('@t{}'.format(num))
     for num in range(n):
         order.append('+t{}'.format(num))
         order.append('-t{}'.format(num))
     ob = OrderCheckObserver(order, verbose=False)
     tm = taskrun.TaskManager(observers=[ob], resource_manager=rm)
     for num in range(n):
         taskrun.NopTask(tm, 't{}'.format(num))
     if b:
         tm.randomize()
     tm.run_tasks()
     if b and n > 1:
         self.assertFalse(ob.ok())
     else:
         self.assertTrue(ob.ok())
    def test_noexec(self):
        global total
        global thres
        total = 0
        thres = 0
        rm = taskrun.ResourceManager(taskrun.CounterResource('slot', 1, 1))
        ob = OrderCheckObserver(
            ['@t1', '@t2', '@t3', '@t4', '*t1', '*t2', '*t3', '*t4'])
        tm = taskrun.TaskManager(resource_manager=rm, observers=[ob])

        t1 = taskrun.FunctionTask(tm, 't1', myfunc, 'jimbo', 5)
        t1.add_condition(taskrun.FunctionCondition(cond))
        t2 = taskrun.FunctionTask(tm, 't2', myfunc, 'gertrude', 6)
        t2.add_condition(taskrun.FunctionCondition(cond))
        t3 = taskrun.FunctionTask(tm, 't3', myfunc, 'sally', 2)
        t3.add_condition(taskrun.FunctionCondition(cond))
        t4 = taskrun.FunctionTask(tm, 't4', myfunc, 'william', 3)
        t4.add_condition(taskrun.FunctionCondition(cond))

        tm.run_tasks()
        self.assertTrue(ob.ok())
        self.assertEqual(total, 0)
Esempio n. 13
0
def main(args):
    # ensure rundir exists, if not make it
    if not os.path.isdir(args.rundir):
        try:
            os.mkdir(args.rundir)
        except:
            error('couldn\'t create {0}'.format(args.rundir))

    # ensure the supersim environment exists
    if not os.path.isdir(args.ssenv):
        error('{0} does not exist'.format(args.ssenv))

    # create a task manager to handle all tasks
    rm = taskrun.ResourceManager(
        taskrun.CounterResource('cpus', 9999, args.cpus),
        taskrun.MemoryResource('mem', 9999, args.mem))
    ob = taskrun.VerboseObserver(description=args.verbose)
    tm = taskrun.TaskManager(resource_manager=rm,
                             observer=ob,
                             failure_mode=taskrun.FailureMode.ACTIVE_CONTINUE)

    # sweep params
    sweepStart = 1
    sweepStop = 100
    sweepStep = 9
    loads = [
        '{0:.02f}'.format(x / 100)
        for x in range(sweepStart, sweepStop + 1, sweepStep)
    ]

    # sweep load
    parse_tasks = []
    for load in loads:
        runId = '{0:02d}_{1}'.format(args.queue, load)

        # create file names
        supersim_bin = os.path.join(args.ssenv, 'poem_supersim', 'bin',
                                    'supersim')
        sslatency_bin = os.path.join(args.ssenv, 'sslatency', 'bin',
                                     'sslatency')
        settings_json = os.path.join(args.ssenv, 'poem_supersim', 'json',
                                     'hierarchyhyperx_iq_GlueFactory1.json')
        simout_log = os.path.join(args.rundir, 'simout_{0}.log'.format(runId))
        messages_mpf = os.path.join(args.rundir,
                                    'messages_{0}.mpf'.format(runId))
        rates_csv = os.path.join(args.rundir, 'rates_{0}.csv'.format(runId))
        channels_csv = os.path.join(args.rundir,
                                    'channels_{0}.mpf'.format(runId))
        messages_csv = os.path.join(args.rundir,
                                    'messages_{0}.csv'.format(runId))
        packets_csv = os.path.join(args.rundir,
                                   'packets_{0}.csv'.format(runId))
        aggregate_csv = os.path.join(args.rundir,
                                     'aggregate_{0}.csv'.format(runId))
        packets_png = os.path.join(args.rundir,
                                   'packets_{0}.png'.format(runId))

        # create simulation task
        sim_cmd = ('{0} {1} '
                   'application.max_injection_rate=float={2} '
                   'application.message_log.file=string={3} '
                   'application.rate_log.file=string={4} '
                   'network.channel_log.file=string={5} '
                   'network.interface.init_credits=uint={6} '
                   'network.router.input_queue_depth=uint={6} ').format(
                       supersim_bin, settings_json, load, messages_mpf,
                       rates_csv, channels_csv, args.queue)
        sim_task = taskrun.ProcessTask(tm, 'sim_{0}'.format(runId), sim_cmd)
        sim_task.stdout_file = simout_log
        sim_task.stderr_file = simout_log
        sim_task.resources = {'cpus': 1, 'mem': 10}
        sim_task.add_condition(
            taskrun.FileModificationCondition(
                [settings_json],
                [simout_log, messages_mpf, rates_csv, channels_csv]))

        # create parser task
        parse_cmd = '{0} -m {1} -p {2} -a {3} {4}'.format(
            sslatency_bin, messages_csv, packets_csv, aggregate_csv,
            messages_mpf)
        parse_task = taskrun.ProcessTask(tm, 'parse_{0}'.format(runId),
                                         parse_cmd)
        parse_task.resources = {'cpus': 1, 'mem': 2}
        parse_task.add_dependency(sim_task)
        parse_task.add_condition(
            taskrun.FileModificationCondition(
                [messages_mpf], [messages_csv, packets_csv, aggregate_csv]))
        parse_tasks.append(parse_task)

        # create plot task
        plot_cmd = 'sslqp {0} {1}'.format(packets_csv, packets_png)
        plot_task = taskrun.ProcessTask(tm, 'plot_{0}'.format(runId), plot_cmd)
        plot_task.resources = {'cpus': 1, 'mem': 2}
        plot_task.add_dependency(parse_task)
        plot_task.add_condition(
            taskrun.FileModificationCondition([packets_csv], [packets_png]))

    # create a task to make a load latency graph
    loadlat_file = os.path.join(args.rundir,
                                'load_latency_{0:02d}.png'.format(args.queue))
    loadlat_cmd = ('ssllp --row Packet --title "QueueSize={0}" '
                   '{1} {2} {3} {4}').format(args.queue, loadlat_file,
                                             sweepStart, sweepStop + 1,
                                             sweepStep)
    agg_files = []
    for load in loads:
        runId = '{0:02d}_{1}'.format(args.queue, load)
        aggregate_csv = os.path.join(args.rundir,
                                     'aggregate_{0}.csv'.format(runId))
        loadlat_cmd += ' {0}'.format(aggregate_csv)
        agg_files.append(aggregate_csv)
    loadlat_task = taskrun.ProcessTask(tm, 'loadlat_{0}'.format(args.queue),
                                       loadlat_cmd)
    loadlat_task.resources = {'cpus': 1, 'mem': 2}
    for dep in parse_tasks:
        loadlat_task.add_dependency(dep)
    loadlat_task.add_condition(
        taskrun.FileModificationCondition(agg_files, [loadlat_file]))

    # run all tasks
    tm.run_tasks()
Esempio n. 14
0
def func(first, second, *args, **kwargs):
    assert first == 'you'
    assert second == 'me'
    assert len(args) == 1
    assert args[0] == 'yall'
    assert 'mom' in kwargs
    assert kwargs['mom'] == True
    assert 'dad' in kwargs
    assert kwargs['dad'] == False


num = 3000
cpus = os.cpu_count()
assert cpus > 0
rm = taskrun.ResourceManager(taskrun.CounterResource('cpu', 1, cpus))
tm = taskrun.TaskManager(resource_manager=rm)

# Process task
print('\n*** ProcessTask ***')
start = time.clock()
for idx in range(num):
    taskrun.ProcessTask(tm, 'Task_{0:04d}'.format(idx), '')
stop = time.clock()
elapsed = stop - start
print('setup time: {0:.3f}s'.format(elapsed))

start = time.clock()
tm.run_tasks()
stop = time.clock()
elapsed = stop - start
Esempio n. 15
0
ap.add_argument('-d', '--directory', type=str, default='output',
                help='the output directory')
ap.add_argument('--supersim', type=str, default='bin/supersim',
                help='supersim binary to run')
ap.add_argument('--ssparse', type=str, default='../ssparse/',
                help='ssparse directory')
ap.add_argument('--settings', type=str, default='json/fattree_iq_blast.json',
                help='settings file to use')
args = ap.parse_args()

# get the current amount of resources
cpus = os.cpu_count()
mem = taskrun.MemoryResource.current_available_memory_gib();

# build the task manager
rm = taskrun.ResourceManager(taskrun.CounterResource('cpus', 9999, cpus),
                             taskrun.MemoryResource('mem', 9999, mem))
cob = taskrun.FileCleanupObserver()
vob = taskrun.VerboseObserver(description=False, summary=True)
tm = taskrun.TaskManager(resource_manager=rm,
                 observers=[cob, vob],
                 failure_mode=taskrun.FailureMode.AGGRESSIVE_FAIL)

# output directory
out_dir = args.directory
if not os.path.isdir(out_dir):
  os.mkdir(out_dir)

# create task and resources function
def set_task_function(tm, name, cmd, console_out, task_type, config):
  task = taskrun.ProcessTask(tm, name, cmd)
Esempio n. 16
0
def main(args):
  total_cpus = args.cpus
  if total_cpus == None:
    total_cpus = os.cpu_count()

  total_mem = args.mem
  if total_mem == None:
    psmem = psutil.virtual_memory()
    total_mem = math.floor((psmem.free + psmem.cached) / (1024 * 1024 * 1024))

  print('using up to {0} CPUs'.format(total_cpus))
  print('using up to {0} GiB of memory'.format(total_mem))

  if args.check:
    subprocess.check_call('valgrind -h', shell=True,
                          stdout=subprocess.PIPE, stderr=subprocess.PIPE)

  rm = taskrun.ResourceManager(
    taskrun.CounterResource('cpu', 9999, total_cpus),
    taskrun.MemoryResource('mem', 9999, total_mem))
  vob = taskrun.VerboseObserver()
  cob = taskrun.FileCleanupObserver()
  tm = taskrun.TaskManager(resource_manager=rm,
                           observers=[vob,cob],
                           failure_mode='passive_fail')

  # find all files
  settingsFiles = glob.glob('json/{0}.json'.format(args.glob))
  print('config files to test: {0}'.format(settingsFiles))

  # generate all tasks
  for settingsFile in settingsFiles:
    cmd = 'bin/supersim {0}'.format(settingsFile)
    if args.check:
      cmd = ('valgrind --log-fd=1 --leak-check=full --show-reachable=yes '
             '--track-origins=yes --track-fds=yes {0}'.format(cmd))
    log = logFile(settingsFile)
    if not args.skip:
      try:
        os.remove(log)
      except OSError:
        pass
    cmd = '{0} 2>&1 | tee {1}'.format(cmd, log)
    task = taskrun.ProcessTask(tm, settingsFile, cmd)
    task.resources = {'cpu': 1, 'mem': 10 if args.check else 3}

  # run tasks
  if args.skip:
    print('skipping simulations')
  else:
    print('running simulations')
    tm.run_tasks()
    print('done')

  # check output for failures
  anyError = False
  for settingsFile in settingsFiles:
    error = False
    print('analyzing {0} output'.format(settingsFile))

    # read in text
    log = logFile(settingsFile)
    with open(log, 'r') as fd:
      lines = fd.readlines();

    # analyze output
    simComplete = False
    for idx, line in enumerate(lines):

      if line.find('Simulation complete') >= 0:
        simComplete = True
      if args.check:
        if (line.find('Open file descriptor') >= 0 and
            lines[idx+1].find('inherited from parent') < 0):
          error = True
          bad('open file descriptor')
        if line.find('blocks are definitely lost') >= 0:
          error = True
          bad('definitely lost memory')
        if line.find('blocks are indirectly lost') >= 0:
          error = True
          bad('indirectly lost memory')
        if (line.find('blocks are still reachable') >= 0 and
            # TODO(nic): REMOVE ME WHEN G++ STOPS SUCKING
            not line.find('72,704 bytes') >= 0):
          error = True
          bad('still reachable memory')
        if line.find('depends on uninitialised value') >= 0:
          error = True
          bad('depends on uninitialised value')

    if not simComplete:
      error = True;
      bad('no "Simulation complete" message')

    # show status
    if error:
      anyError = True
    else:
      good('passed all tests')

  return 0 if not anyError else -1