[DeLICM] Introduce unittesting infrastructure for Known and Written. NFC.
[polly-mirror.git] / utils / pyscop / jscop2iscc.py
blob3267e8ebc3c2c5679ba2330c54437d923fbd5218
1 #!/usr/bin/python
2 import argparse, isl, os
3 import json
5 def printDomain(scop):
7 domain = isl.USet('{}')
9 for statement in scop['statements']:
10 domain = domain.union(isl.USet(statement['domain']))
12 print "D :=",
13 print str(domain) + ";"
15 def printAccesses(scop):
17 read = isl.UMap('{}')
19 for statement in scop['statements']:
20 for access in statement['accesses']:
21 if access['kind'] == 'read':
22 read = read.union(isl.UMap(access['relation']))
24 print "R :=",
25 print str(read) + ";"
27 write = isl.UMap('{}')
29 for statement in scop['statements']:
30 for access in statement['accesses']:
31 if access['kind'] == 'write':
32 write = write.union(isl.UMap(access['relation']))
34 print "W :=",
35 print str(write) + ";"
37 def printSchedule(scop):
39 schedule = isl.UMap('{}')
41 for statement in scop['statements']:
42 schedule = schedule.union(isl.UMap(statement['schedule']))
44 print "S :=",
45 print str(schedule) + ";"
47 def __main__():
48 description = 'Translate JSCoP into iscc input'
49 parser = argparse.ArgumentParser(description)
50 parser.add_argument('inputFile', metavar='N', type=file,
51 help='The JSCoP file')
53 args = parser.parse_args()
54 inputFile = args.inputFile
55 scop = json.load(inputFile)
57 printDomain(scop)
58 printAccesses(scop)
59 printSchedule(scop)
61 print 'R := R * D;'
62 print 'W := W * D;'
63 print 'Dep := (last W before R under S)[0];'
64 print 'schedule D respecting Dep minimizing Dep;'
67 __main__()