jscop2iscc.py
1.46 KB
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
#!/usr/bin/env python
import argparse, isl, os
import json
def printDomain(scop):
domain = isl.USet('{}')
for statement in scop['statements']:
domain = domain.union(isl.USet(statement['domain']))
print "D :=",
print str(domain) + ";"
def printAccesses(scop):
read = isl.UMap('{}')
for statement in scop['statements']:
for access in statement['accesses']:
if access['kind'] == 'read':
read = read.union(isl.UMap(access['relation']))
print "R :=",
print str(read) + ";"
write = isl.UMap('{}')
for statement in scop['statements']:
for access in statement['accesses']:
if access['kind'] == 'write':
write = write.union(isl.UMap(access['relation']))
print "W :=",
print str(write) + ";"
def printSchedule(scop):
schedule = isl.UMap('{}')
for statement in scop['statements']:
schedule = schedule.union(isl.UMap(statement['schedule']))
print "S :=",
print str(schedule) + ";"
def __main__():
description = 'Translate JSCoP into iscc input'
parser = argparse.ArgumentParser(description)
parser.add_argument('inputFile', metavar='N', type=file,
help='The JSCoP file')
args = parser.parse_args()
inputFile = args.inputFile
scop = json.load(inputFile)
printDomain(scop)
printAccesses(scop)
printSchedule(scop)
print 'R := R * D;'
print 'W := W * D;'
print 'Dep := (last W before R under S)[0];'
print 'schedule D respecting Dep minimizing Dep;'
__main__()