forked from davemenendez/alive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug_count.py
73 lines (54 loc) · 1.54 KB
/
debug_count.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
'''Find all 2-cycles.
'''
from loops import *
import traceback
import logging
logging.basicConfig(filename='debug_count.log', filemode='w', level=logging.WARNING)
sys.stderr.write('reading master.opt\n')
opts = parse_transforms(open('master.opt').read())
#opts = opts[0:1]
#opts = opts[0:40]
sys.stderr.write('%s optimizations\n' % len(opts))
count = 0
increasing = 0
unsat = 0
loops = 0
errors = [0]
def count_error(*a):
errors[0] += 1
for i1 in range(0,len(opts)):
o1 = opts[i1]
for i1 in range(i1+1,len(opts)):
try:
for o3 in all_bin_compositions(o1,o2, count_error):
o3_src = sum(1 for v in o3.src.itervalues() if isinstance(v, Instr))
#o3c = o3.copy()
for oo in all_bin_compositions(o3, o3, count_error):
count += 1
oo_src = sum(1 for v in oo.src.itervalues() if isinstance(v, Instr))
sys.stderr.write('\rTested: ' + str(count))
sys.stdout.flush()
if o3_src < oo_src:
increasing += 1
continue
if satisfiable(oo):
print '\n-----\nLoop: ', o3.name
o1.dump()
print
o2.dump()
print
o3.dump()
loops += 1
else:
unsat += 1
except Exception, e:
logging.exception('combining <%s> <%s>', o1.name, o2.name)
errors[0] += 1
sys.stderr.write('\n')
print
print '----'
print 'final count', count
print 'loops', loops
print 'unsat', unsat
print 'increasing', increasing
print 'errors', errors[0]