예제 #1
0
def get_loop_addrs(split):
    split = addr_to_loop_id(split)
    f = functions[trace_refute.get_body_addrs_fun(split)]
    return [
        addr for addr in f.nodes if trace_refute.is_addr(addr)
        if addr_to_loop_id_cache.get(addr) == split
    ]
예제 #2
0
def save_bound(glob, split_bin_addr, call_ctxt, prob_hash, prev_bounds, bound, time=None):
    f_names = [trace_refute.get_body_addrs_fun(x) for x in call_ctxt + [split_bin_addr]]
    loop_name = "<%s>" % " -> ".join(f_names)
    comment = "# bound for loop in %s:" % loop_name
    ss = ["LoopBound"] + serialise_bound(split_bin_addr, bound)
    if glob:
        ss[0] = "GlobalLoopBound"
    ss += [str(len(call_ctxt))] + map(hex, call_ctxt)
    ss += [str(prob_hash)]
    if glob:
        assert prev_bounds == None
    else:
        ss += [str(len(prev_bounds))]
        for (split, bound) in prev_bounds:
            ss += serialise_bound(split, bound)
    s = " ".join(ss)
    f = open("%s/LoopBounds.txt" % target_objects.target_dir, "a")
    f.write(comment + "\n")
    f.write(s + "\n")
    if time != None:
        ctxt2 = call_ctxt + [split_bin_addr]
        ctxt2 = " ".join([str(len(ctxt2))] + map(hex, ctxt2))
        f.write("LoopBoundTiming %s %s\n" % (ctxt2, time))
    f.close()
    trace("Found bound %s for 0x%x in %s." % (bound, split_bin_addr, loop_name))
예제 #3
0
def save_bound(glob,
               split_bin_addr,
               call_ctxt,
               prob_hash,
               prev_bounds,
               bound,
               time=None):
    f_names = [
        trace_refute.get_body_addrs_fun(x)
        for x in call_ctxt + [split_bin_addr]
    ]
    loop_name = '<%s>' % ' -> '.join(f_names)
    comment = '# bound for loop in %s:' % loop_name
    ss = ['LoopBound'] + serialise_bound(split_bin_addr, bound)
    if glob:
        ss[0] = 'GlobalLoopBound'
    ss += [str(len(call_ctxt))] + map(hex, call_ctxt)
    ss += [str(prob_hash)]
    if glob:
        assert prev_bounds == None
    else:
        ss += [str(len(prev_bounds))]
        for (split, bound) in prev_bounds:
            ss += serialise_bound(split, bound)
    s = ' '.join(ss)
    f = open('%s/LoopBounds.txt' % target_objects.target_dir, 'a')
    f.write(comment + '\n')
    f.write(s + '\n')
    if time != None:
        ctxt2 = call_ctxt + [split_bin_addr]
        ctxt2 = ' '.join([str(len(ctxt2))] + map(hex, ctxt2))
        f.write('LoopBoundTiming %s %s\n' % (ctxt2, time))
    f.close()
    trace('Found bound %s for 0x%x in %s.' %
          (bound, split_bin_addr, loop_name))
예제 #4
0
def save_bound (glob, split_bin_addr, call_ctxt, prob_hash, prev_bounds, bound,
        time = None):
    f_names = [trace_refute.get_body_addrs_fun (x)
      for x in call_ctxt + [split_bin_addr]]
    loop_name = '<%s>' % ' -> '.join (f_names)
    comment = '# bound for loop in %s:' % loop_name
    ss = ['LoopBound'] + serialise_bound (split_bin_addr, bound)
    if glob:
      ss[0] = 'GlobalLoopBound'
    ss += [str (len (call_ctxt))] + map (hex, call_ctxt)
    ss += [str (prob_hash)]
    if glob:
      assert prev_bounds == None
    else:
      ss += [str (len (prev_bounds))]
      for (split, bound) in prev_bounds:
        ss += serialise_bound (split, bound)
    s = ' '.join (ss)
    f = open ('%s/LoopBounds.txt' % target_objects.target_dir, 'a')
    f.write (comment + '\n')
    f.write (s + '\n')
    if time != None:
      ctxt2 = call_ctxt + [split_bin_addr]
      ctxt2 = ' '.join ([str (len (ctxt2))] + map (hex, ctxt2))
      f.write ('LoopBoundTiming %s %s\n' % (ctxt2, time))
    f.close ()
    trace ('Found bound %s for 0x%x in %s.' % (bound, split_bin_addr,
      loop_name))
예제 #5
0
def get_bound_super_ctxt (split, call_ctxt, no_splitting=False,
        known_bound_only=False):
    if not known_bounds:
      load_bounds ()
    for (ctxt2, fn_hash, bound) in known_bounds.get ((split, 'Global'), []):
      if ctxt2 == call_ctxt and fn_hash == get_functions_hash ():
        return bound
    f = trace_refute.get_body_addrs_fun (split)
    p = functions[f].as_problem (problem.Problem)
    p.do_loop_analysis ()
    min_addr = min ([n for n in p.loop_body (split)
      if trace_refute.is_addr (n)])
    if min_addr != split:
      return get_bound_super_ctxt (min_addr, call_ctxt,
            no_splitting = no_splitting, known_bound_only = known_bound_only)

    if known_bound_only:
        return None
    no_splitting_abort = [False]
    try:
      bound = get_bound_super_ctxt_inner (split, call_ctxt,
        no_splitting = (no_splitting, no_splitting_abort))
    except problem.Abort, e:
      bound = None
예제 #6
0
def get_loop_addrs(split):
    split = addr_to_loop_id(split)
    f = functions[trace_refute.get_body_addrs_fun(split)]
    return [addr for addr in f.nodes if trace_refute.is_addr(addr) if addr_to_loop_id_cache.get(addr) == split]
예제 #7
0
def is_complex_loop(split):
    split = addr_to_loop_id(split)
    if split not in complex_loop_id_cache:
        add_fun_to_loop_data_cache(trace_refute.get_body_addrs_fun(split))
    return complex_loop_id_cache[split]
예제 #8
0
def addr_to_loop_id(split):
    if split not in addr_to_loop_id_cache:
        add_fun_to_loop_data_cache(trace_refute.get_body_addrs_fun(split))
    return addr_to_loop_id_cache[split]
예제 #9
0
def is_complex_loop(split):
    split = addr_to_loop_id(split)
    if split not in complex_loop_id_cache:
        add_fun_to_loop_data_cache(trace_refute.get_body_addrs_fun(split))
    return complex_loop_id_cache[split]
예제 #10
0
def addr_to_loop_id(split):
    if split not in addr_to_loop_id_cache:
        add_fun_to_loop_data_cache(trace_refute.get_body_addrs_fun(split))
    return addr_to_loop_id_cache[split]