def main():
    
    if len(sys.argv) < 2:
        raise Exception("Invalid parameters")
    
    fname = sys.argv[1]
    if len(sys.argv) > 2:
        overhead = float(sys.argv[2])
    else:
        overhead = 0.6
    if len(sys.argv) > 3:
        min_c = float(sys.argv[3])
    else:
        min_c = 0.0
    
    print 'Opening {0}'.format(fname)
    
    with open(fname, 'r') as f:
        data = f.read().strip()
    
    try:
        schedule = eval(data)
    except:
        schedule = run_exps.convert_data(data)
    
    ts = []
    for task_conf in schedule['task']:
        
        (task, args) = (task_conf[0], task_conf[1])
        real_args = args.split()
        if '-s' in real_args:
            index = real_args.index('-s')
            real_args.pop(index + 1)
            real_args.pop(index)
        
        C = float(real_args[-2])
        if C > 0 and round((overhead / C), 3) > 0.999:
            min_c = max(min_c, C)
        if (C > min_c):
            s = 1 - round((overhead / C), 3)
            ts.append('-s {0:.3f} {1}\n'.format(s, ' '.join(real_args)))
        else:
            print 'Discarded task: {0} {1}'.format(C, real_args[-1])
        #print '-s {0:.3f} {1}'.format(s, args)
    
    with open(fname, 'w') as out_file:
        for t in ts:
            out_file.write(t)
Esempio n. 2
0
 def _from_file(self, file_name):
     with open(file_name, 'r') as f:
         data = f.read().strip()
     try:
         schedule = eval(data)
     except:
         schedule = run_exps.convert_data(data)
     ts = []
     for task_conf in schedule['task']:
         (task, args) = (task_conf[0], task_conf[1])
         real_args = args.split()
         index = 0
         if '-S' in real_args:
             index = real_args.index('-S') + 2
         ts.append(SporadicTask(int(real_args[index + 0]), int(real_args[index + 1])))
     return ts
def main():
    
    if len(sys.argv) != 3:
        raise Exception("Invalid parameters! USAGE: qps_partitioner.py SCHED_FILE CPUS")
    
    fname = sys.argv[1]
    (path, name) = os.path.split(fname)
    cpus = int(sys.argv[2])
    
    with open(fname, 'r') as f:
        data = f.read().strip()
    
    try:
        schedule = eval(data)
    except:
        schedule = run_exps.convert_data(data)
    
    ts = []
    for task_conf in schedule['task']:
    
        (task, args) = (task_conf[0], task_conf[1])
        real_args = args.split()
        
        #index = 0
        #if '-S' in real_args:
        #    index = real_args.index('-S') + 2
        #    
        #if '-p'in real_args:
        #    index = real_args.index('-p') + 2
        index = -2    
        ts.append(tasks.SporadicTask(int(real_args[index + 0]), int(real_args[index + 1])))
    
    generator = QPSGenerator()
    generator.out_dir = path
    generator._customize(ts, {'cpus': cpus})
    
    with open(path + "/" + 'sched.py', 'w') as out_file:
        for t in ts:
            out_file.write("-p {0} -S {1} {2} {3}\n".format(t.cpu, t.set, t.cost, t.period))
Esempio n. 4
0
def main():

    if len(sys.argv) != 3:
        raise Exception("Invalid parameters")

    fname = sys.argv[1]
    cpus = int(sys.argv[2])

    with open(fname, 'r') as f:
        data = f.read().strip()

    try:
        schedule = eval(data)
    except:
        schedule = run_exps.convert_data(data)

    ts = []
    for task_conf in schedule['task']:

        (task, args) = (task_conf[0], task_conf[1])
        real_args = args.split()

        index = 0
        if '-S' in real_args:
            index = real_args.index('-S') + 2

        if '-p' in real_args:
            index = real_args.index('-p') + 2

        ts.append(
            tasks.SporadicTask(int(real_args[index + 0]),
                               int(real_args[index + 1])))

    ts.sort(key=lambda x: x.utilization(), reverse=True)
    _pack(ts, cpus)
    with open('out_sched.py', 'w') as out_file:
        for t in ts:
            out_file.write("-p {0} {1} {2}\n".format(t.cpu, t.cost, t.period))
def main():
    
    if len(sys.argv) != 3:
        raise Exception("Invalid parameters! USAGE: run_partitioner.py SCHED_FILE CPUS")
    
    fname = sys.argv[1]
    (path, name) = os.path.split(fname)
    cpus = int(sys.argv[2])
    
    with open(fname, 'r') as f:
        data = f.read().strip()
    
    try:
        schedule = eval(data)
    except:
        schedule = run_exps.convert_data(data)
    
    ts = []
    for task_conf in schedule['task']:
    
        (task, args) = (task_conf[0], task_conf[1])
        real_args = args.split()
        
        #index = 0
        #if '-S' in real_args:
        #    index = real_args.index('-S') + 2
        #    
        #if '-p'in real_args:
        #    index = real_args.index('-p') + 2
        index = -2    
        ts.append(tasks.SporadicTask(int(real_args[index + 0]), int(real_args[index + 1])))
    if len(ts) == 0:
        raise Exception('No task')
    generator = RUNGenerator()
    generator.out_dir = path
    generator._customize(ts, {'cpus': cpus})