Example #1
0
def auto_infea(dir_name, entry_point_function, manual_conflicts_file, results_dir, initial_case_iteration, preemption_limit):
    kernel_elf_file = dir_name+'/kernel.elf'
    tcfg_map = dir_name + '/%s.imm.map' % entry_point_function
    kernel_elf_file = dir_name+'/kernel.elf'
    ilp_nofooter = cplex.stripFooter(dir_name + '/%s.imm.ilp' % entry_point_function)
    
    auto_refutes_file = results_dir+'/refutes.txt'

    p = Popen(['touch', auto_refutes_file])
    p.communicate()
    assert not p.returncode

    results_file = results_dir+ '/results.txt'
#we want to see results as we go, set bufsize to 0
    results_f = open(results_file,'w',0)

#setup trace_refute's environment
    from graph_refine.target_objects import target_dir, target_args
    target = '%s/target.py' % dir_name
    target_dir.set_dir(dir_name)

    case_i = initial_i
    while True:
        sol_file = results_dir+'/case_%d.sol' % case_i
        ilp_file = results_dir+'/case_%d.ilp' % case_i
        print 'case_i = %d' % case_i
        print 'calling conflict.conflict'
#silence()
#get the wcet with existing conflicts
        conflict.cleanGlobalStates()

        #FIXME: un-hardcode the entry function
        wcet = conflict.conflict(entry_point_function, tcfg_map, [manual_conflicts_file,auto_refutes_file],ilp_nofooter,ilp_file,dir_name, sol_file, emit_conflicts=True, do_cplex=True, silent_cplex=True, preempt_limit=preemption_limit)
#unsilence()

        print 'conflict.main returned'

        results_f.write('case %d\n' % case_i)
        results_f.write('   wcet: %s\n' % wcet)

#reconstruct the worst case
        refutables_fname = results_dir + '/refutables_%d' % case_i 
        f_refutables = open(refutables_fname,'w')
        print 'reconstructing the worst case for case %d' % case_i
        p = Popen(['python', 'reconstruct.py', '--refutable', dir_name, sol_file, tcfg_map, kernel_elf_file], stdout=f_refutables)
        p.communicate()
        ret = p.returncode
        print 'ret: %d'% ret
        assert ret == 0
        
        f_refutables.close()
        #now call trace_refute
        t = time.asctime()
        c1 = time.time()
        print 'calling trace_refute, time is: %s' % t
        results_f.write(' trace_refute called at: %s\n' % t)
        silence_all = False
        if silence_all:
            #but before we do, supress output.
            (saved_fds, null_fds) = silence()
        new_refutes,_ = trace_refute.refute(refutables_fname, auto_refutes_file, [auto_refutes_file])
        if silence_all:
            #restore stdin and stderr
            unsilence(saved_fds, null_fds)
        c2 = time.time()
        t = time.asctime()
        print 'trace_refute returned, time is: %s' % t
        results_f.write(' trace_refute returned at: %s\n' % t)

        results_f.write('   this took %f seconds\n' % (c2-c1))

        if not new_refutes:
            print 'At case %d, trace_refute cannot find any more refutations' % case_i
            results_f.write('terminated normally: trace_refute cannot find any more refutations\n')
            break

#cp the auto_refutes_file to keep a copy
        p = Popen(['cp', auto_refutes_file, results_dir+'/refutes_%d.txt'% case_i])
        p.communicate()
        assert not p.returncode
        case_i += 1

    results_f.close()
Example #2
0
         print "loop bounds automatically determined via graph-refine and results stored in %s/loop_counts.py" % dir_name
         print "Using automatically determined loopbounds to generate ILP problem"
         analyseFunction(entry_point_function,
                         asm_fs,
                         dir_name,
                         False,
                         True,
                         False,
                         stopAtILP=True)
         print "Annotating ILP problem with preemption bounds"
         entry_point_function = entry_point_function.strip()
         prefix = dir_name + '/' + entry_point_function
         tcfg_map_file_name = prefix + ".imm.map"
         current_ilp = prefix + ".imm.ilp"
         print "current_ilp: %s" % current_ilp
         stripped_ilp = cplex.stripFooter(current_ilp)
         ilp_to_generate = prefix + "_annotated.imm.ilp"
         sol_to_generate = prefix + "_annotated.imm.sol"
         preemption_limit = 5
         conflict.conflict(entry_point_function,
                           tcfg_map_file_name, [],
                           stripped_ilp,
                           ilp_to_generate,
                           dir_name,
                           sol_to_generate,
                           emit_conflicts=True,
                           do_cplex=True,
                           preempt_limit=preemption_limit,
                           default_phantom_preempt=True)
         sys.exit(0)
 bench_ret = bench.bench(dir_name, entry_point_function, gen_heads,
Example #3
0
def auto_infea(dir_name, entry_point_function, manual_conflicts_file, results_dir, initial_case_iteration, preemption_limit):
    kernel_elf_file = dir_name+'/kernel.elf'
    tcfg_map = dir_name + '/%s.imm.map' % entry_point_function
    kernel_elf_file = dir_name+'/kernel.elf'
    ilp_nofooter = cplex.stripFooter(dir_name + '/%s.imm.ilp' % entry_point_function)

    auto_refutes_file = results_dir+'/refutes.txt'

    p = Popen(['touch', auto_refutes_file])
    p.communicate()
    assert not p.returncode

    results_file = results_dir+ '/results.txt'
#we want to see results as we go, set bufsize to 0
    results_f = open(results_file,'w',0)

#setup trace_refute's environment
    from graph_refine.target_objects import target_dir, target_args
    target = '%s/target.py' % dir_name
    target_dir.set_dir(dir_name)

    case_i = initial_i
    while True:
        sol_file = results_dir+'/case_%d.sol' % case_i
        ilp_file = results_dir+'/case_%d.ilp' % case_i
        print 'case_i = %d' % case_i
        print 'calling conflict.conflict'
#silence()
#get the wcet with existing conflicts
        conflict.cleanGlobalStates()

        #FIXME: un-hardcode the entry function
        wcet = conflict.conflict(entry_point_function, tcfg_map, [manual_conflicts_file,auto_refutes_file],ilp_nofooter,ilp_file,dir_name, sol_file, emit_conflicts=True, do_cplex=True, silent_cplex=True, preempt_limit=preemption_limit)
#unsilence()

        print 'conflict.main returned'

        results_f.write('case %d\n' % case_i)
        results_f.write('   wcet: %s\n' % wcet)

#reconstruct the worst case
        refutables_fname = results_dir + '/refutables_%d' % case_i
        f_refutables = open(refutables_fname,'w')
        print 'reconstructing the worst case for case %d' % case_i
        p = Popen(['python', 'reconstruct.py', '--refutable', dir_name, sol_file, tcfg_map, kernel_elf_file], stdout=f_refutables)
        p.communicate()
        ret = p.returncode
        print 'ret: %d'% ret
        assert ret == 0

        f_refutables.close()
        #now call trace_refute
        t = time.asctime()
        c1 = time.time()
        print 'calling trace_refute, time is: %s' % t
        results_f.write(' trace_refute called at: %s\n' % t)
        silence_all = False
        if silence_all:
            #but before we do, supress output.
            (saved_fds, null_fds) = silence()
        new_refutes,_ = trace_refute.refute(refutables_fname, auto_refutes_file, [auto_refutes_file])
        if silence_all:
            #restore stdin and stderr
            unsilence(saved_fds, null_fds)
        c2 = time.time()
        t = time.asctime()
        print 'trace_refute returned, time is: %s' % t
        results_f.write(' trace_refute returned at: %s\n' % t)

        results_f.write('   this took %f seconds\n' % (c2-c1))

        if not new_refutes:
            print 'At case %d, trace_refute cannot find any more refutations' % case_i
            results_f.write('terminated normally: trace_refute cannot find any more refutations\n')
            break

#cp the auto_refutes_file to keep a copy
        p = Popen(['cp', auto_refutes_file, results_dir+'/refutes_%d.txt'% case_i])
        p.communicate()
        assert not p.returncode
        case_i += 1

    results_f.close()
Example #4
0
          load_counts = True
        if flag == '--i':
          interactive = True
        if flag == '--x' or flag == '--xL':
            if len(sys.argv) < 4:
                printHelp()
                sys.exit(-1)
            asm_fs = bench.init(dir_name)
            if flag == '--x':
                import convert_loop_bounds
                analyseFunction(entry_point_function,asm_fs, dir_name, True, False, False)
                print "loop heads generated"
            convert_loop_bounds.convert_loop_bounds(dir_name)
            print "loop bounds automatically determined via graph-refine and results stored in %s/loop_counts.py" % dir_name
            print "Using automatically determined loopbounds to generate ILP problem"
            analyseFunction(entry_point_function, asm_fs, dir_name, False, True, False, stopAtILP= True)
            print "Annotating ILP problem with preemption bounds"
            entry_point_function = entry_point_function.strip()
            prefix = dir_name + '/' + entry_point_function
            tcfg_map_file_name = prefix + ".imm.map"
            current_ilp = prefix + ".imm.ilp"
            print "current_ilp: %s" % current_ilp
            stripped_ilp = cplex.stripFooter(current_ilp)
            ilp_to_generate = prefix + "_annotated.imm.ilp"
            sol_to_generate = prefix + "_annotated.imm.sol"
            preemption_limit = 5
            conflict.conflict(entry_point_function, tcfg_map_file_name, [], stripped_ilp, ilp_to_generate, dir_name, sol_to_generate, emit_conflicts=True, do_cplex=True, preempt_limit= preemption_limit,default_phantom_preempt=True)
            sys.exit(0)
    bench_ret = bench.bench(dir_name, entry_point_function, gen_heads,load_counts,interactive)
    print 'bench returned: ' +  str(bench_ret)