1#!/usr/bin/env python 2import argparse, isl, os 3import json 4 5def printDomain(scop): 6 7 domain = isl.USet('{}') 8 9 for statement in scop['statements']: 10 domain = domain.union(isl.USet(statement['domain'])) 11 12 print "D :=", 13 print str(domain) + ";" 14 15def printAccesses(scop): 16 17 read = isl.UMap('{}') 18 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'])) 23 24 print "R :=", 25 print str(read) + ";" 26 27 write = isl.UMap('{}') 28 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'])) 33 34 print "W :=", 35 print str(write) + ";" 36 37def printSchedule(scop): 38 39 schedule = isl.UMap('{}') 40 41 for statement in scop['statements']: 42 schedule = schedule.union(isl.UMap(statement['schedule'])) 43 44 print "S :=", 45 print str(schedule) + ";" 46 47def __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') 52 53 args = parser.parse_args() 54 inputFile = args.inputFile 55 scop = json.load(inputFile) 56 57 printDomain(scop) 58 printAccesses(scop) 59 printSchedule(scop) 60 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;' 65 66 67__main__() 68 69