Example #1
0
def run_script(script_params, exp, exp_dir, out_dir):
    '''Run an executable (arguments optional)'''
    if not script_params:
        return

    # Split into arguments and program name
    if type(script_params) != type([]):
        script_params = [script_params]

    exp.log("Running %s" % script_params.join(" "))

    script_name = script_params.pop(0)
    script = com.get_executable(script_name, cwd=exp_dir)

    out = open('%s/%s-out.txt' % (out_dir, script_name), 'w')
    prog = Executable(script,
                      script_params,
                      cwd=out_dir,
                      stderr_file=out,
                      stdout_file=out)

    prog.execute()
    prog.wait()

    out.close()
Example #2
0
def load_schedule(name, fname, duration):
    '''Turn schedule file @fname into ProcEntry's and Executable's which execute
    for @duration time.'''
    with open(fname, 'r') as f:
        data = f.read().strip()
    try:
        schedule = eval(data)
    except:
        schedule = convert_data(data)

    sched_dir = os.path.split(fname)[0]

    # Make paths relative to the file's directory
    fix_paths(schedule, sched_dir, fname)

    proc_entries = []
    executables  = []

    # Create proc entries
    for entry_conf in schedule['proc']:
        proc_entries += [ProcEntry(*entry_conf)]

    # Create executables
    for task_conf in schedule['task']:
        if len(task_conf) != 2:
            raise Exception("Invalid task conf %s: %s" % (task_conf, name))

        (task, args) = (task_conf[0], task_conf[1])

        real_task = com.get_executable(task, sched_dir)

        # Last argument must always be duration
        real_args = args.split() + [duration]

        # Get the name of the task (for after-processing and matching with pid).
        # If it exists, it is flagged as '-n'
        task_id = ""
        i = 0
        while i<len(real_args):
            if real_args[i] == "-n":
                task_id = real_args[i+1]
                real_args.pop(i) # remove '-n' from args
                real_args.pop(i) # remove 'taskname' from args
                break
            i+=1

        # All spins take a -w flag
        if re.match(".*spin$", real_task) and '-w' not in real_args:
            real_args = ['-w'] + real_args

        executables += [Executable(real_task, real_args, taskid=task_id)]

    return proc_entries, executables
    def __init__(self, exec_file, extra_args=None, stdout_file = None,
                 stderr_file = None, cwd = None):
        self.exec_file = get_executable(exec_file)
        self.cwd = cwd
        self.stdout_file = stdout_file
        self.stderr_file = stderr_file
        self.sp = None

        if extra_args is None:
            self.extra_args = None
        else:
            self.extra_args = [str(a) for a in list(extra_args)] # make a duplicate

        if not self.exec_file:
            raise Exception("Not executable ? : %s" % self.exec_file)
Example #4
0
def run_exp(name, schedule, scheduler, kernel, duration, work_dir, out_dir):
    proc_entries = []
    executables  = []

    # Parse values for proc entries
    for entry_conf in schedule['proc']:
        path = entry_conf[0]
        data = entry_conf[1]

        if not os.path.exists(path):
            raise IOError("Invalid proc path %s: %s" % (path, name))

        proc_entries += [ProcEntry(path, data)]

    # Parse spinners
    for spin_conf in schedule['spin']:
        if isinstance(spin_conf, str):
            # Just a string defaults to default spin
            (spin, args) = (conf.DEFAULTS['spin'], spin_conf)
        else:
            # Otherwise its a pair, the type and the args
            if len(spin_conf) != 2:
                raise IOError("Invalid spin conf %s: %s" % (spin_conf, name))
            (spin, args) = (spin_conf[0], spin_conf[1])

        # if not conf.BINS[spin]:
        #     raise IndexError("No knowledge of program %s: %s" % (spin, name))

        real_spin = com.get_executable(spin, "")
        real_args = args.split()
        if re.match(".*spin", real_spin):
            real_args = ['-w'] + real_args + [duration]

        if not com.is_executable(real_spin):
            raise OSError("Cannot run spin %s: %s" % (real_spin, name))

        executables += [Executable(real_spin, real_args)]

    exp = Experiment(name, scheduler, work_dir, out_dir,
                     proc_entries, executables)

    exp.run_exp()
Example #5
0
    def __init__(self,
                 exec_file,
                 extra_args=None,
                 stdout_file=None,
                 stderr_file=None,
                 cwd=None):
        self.exec_file = get_executable(exec_file)
        self.cwd = cwd
        self.stdout_file = stdout_file
        self.stderr_file = stderr_file
        self.sp = None

        if extra_args is None:
            self.extra_args = None
        else:
            self.extra_args = [str(a)
                               for a in list(extra_args)]  # make a duplicate

        if not self.exec_file:
            raise Exception("Not executable ? : %s" % self.exec_file)
Example #6
0
def load_schedule(name, fname, duration):
    '''Turn schedule file @fname into ProcEntry's and Executable's which execute
    for @duration time.'''
    with open(fname, 'r') as f:
        data = f.read().strip()
    try:
        schedule = eval(data)
    except:
        schedule = convert_data(data)

    sched_dir = os.path.split(fname)[0]

    # Make paths relative to the file's directory
    fix_paths(schedule, sched_dir, fname)

    proc_entries = []
    executables = []

    # Create proc entries
    for entry_conf in schedule['proc']:
        proc_entries += [ProcEntry(*entry_conf)]

    # Create executables
    for task_conf in schedule['task']:
        if len(task_conf) != 2:
            raise Exception("Invalid task conf %s: %s" % (task_conf, name))

        (task, args) = (task_conf[0], task_conf[1])

        real_task = com.get_executable(task, sched_dir)

        # Last argument must always be duration
        real_args = args.split() + [duration]

        # All spins take a -w flag
        if re.match(".*spin$", real_task) and '-w' not in real_args:
            real_args = ['-w'] + real_args

        executables += [Executable(real_task, real_args)]

    return proc_entries, executables
def load_schedule(name, fname, duration):
    '''Turn schedule file @fname into ProcEntry's and Executable's which execute
    for @duration time.'''
    with open(fname, 'r') as f:
        data = f.read().strip()
    try:
        schedule = eval(data)
    except:
        schedule = convert_data(data)

    sched_dir = os.path.split(fname)[0]

    # Make paths relative to the file's directory
    fix_paths(schedule, sched_dir, fname)

    proc_entries = []
    executables  = []

    # Create proc entries
    for entry_conf in schedule['proc']:
        proc_entries += [ProcEntry(*entry_conf)]

    # Create executables
    for task_conf in schedule['task']:
        if len(task_conf) != 2:
            raise Exception("Invalid task conf %s: %s" % (task_conf, name))

        (task, args) = (task_conf[0], task_conf[1])

        real_task = com.get_executable(task, sched_dir)

        # Last argument must always be duration
        real_args = args.split() + [duration]

        # All spins take a -w flag
        if re.match(".*spin$", real_task) and '-w' not in real_args:
            real_args = ['-w'] + real_args

        executables += [Executable(real_task, real_args)]

    return proc_entries, executables
Example #8
0
def run_script(script_params, exp, exp_dir, out_dir):
    '''Run an executable (arguments optional)'''
    if not script_params:
        return

    # Split into arguments and program name
    if type(script_params) != type([]):
        script_params = [script_params]

    exp.log("Running %s" % " ".join(script_params))

    script_name = script_params.pop(0)
    script = com.get_executable(script_name, cwd=exp_dir)

    out  = open('%s/%s-out.txt' % (out_dir, script_name), 'w')
    prog = Executable(script, script_params, cwd=out_dir,
                      stderr_file=out, stdout_file=out)

    prog.execute()
    prog.wait()

    out.close()
def run_parameter(exp_dir, out_dir, params, param_name):
    '''Run an executable (arguments optional) specified as a configurable
    @param_name in @params.'''
    if conf.PARAMS[param_name] not in params:
        return

    script_params = params[conf.PARAMS[param_name]]

    # Split into arguments and program name
    if type(script_params) != type([]):
        script_params = [script_params]
    script_name = script_params.pop(0)

    script = com.get_executable(script_name, cwd=exp_dir)

    out  = open('%s/%s-out.txt' % (out_dir, param_name), 'w')
    prog = Executable(script, script_params, cwd=out_dir,
                      stderr_file=out, stdout_file=out)

    prog.execute()
    prog.wait()

    out.close()
Example #10
0
from __future__ import print_function
import itertools
from common import get_executable,ft_freq

'''Paths to binaries.'''
BINS = {'rtspin'    : get_executable('rtspin', 'liblitmus'),
        'release'   : get_executable('release_ts', 'liblitmus'),
        'ftcat'     : get_executable('ftcat', 'feather-trace-tools'),
        'ftsplit'   : get_executable('ft2csv', 'feather-trace-tools'),
        'ftsort'    : get_executable('ftsort', 'feather-trace-tools'),
        'st_trace'  : get_executable('st_trace', 'feather-trace-tools'),
        # Option, as not everyone uses kernelshark yet
        'trace-cmd' : get_executable('trace-cmd', 'rt-kernelshark', True),
        # Optional, as sched_trace is not a publically supported repository
        'st_show'   : get_executable('st_show', 'sched_trace', True)}

'''Names of output files.'''
FILES = {'ft_data'    : 'ft.bin',
         'ft_matches' : r'(ft.*\.bin)|(.*\.ft)',
         'linux_data' : 'trace.dat',
         'sched_data' : 'st-{}.bin',
         'log_data'   : 'trace.slog'}

'''Default parameter names in params.py.'''
PARAMS = {'sched'   : 'scheduler',       # Scheduler used by run_exps
          'dur'     : 'duration',        # Duration of tests in run_exps
          'kernel'  : 'uname',           # Regex of required OS name in run_exps
          'copts'   : 'config-options',  # Required kernel configuration options
          'cycles'  : 'clock-frequency', # Frequency run_exps was run with
          'tasks'   : 'tasks',           # Number of tasks
          'trial'   : 'trial'            # For multiple exps with same config