69 lines · python
1#!/usr/bin/env python2import argparse, os3import json4 5def getDomains(scop):6 statements = scop['statements'];7 numStatements = len(statements)8 9 output = "%s\n\n" % str(numStatements)10 11 for statement in scop['statements']:12 output += "%s\n\n" % statement['domain']13 output += "0 0 0 # for future options\n\n"14 15 16 return output17 18def getSchedules(scop):19 statements = scop['statements'];20 numStatements = len(statements)21 22 output = "%s\n\n" % str(numStatements)23 24 for statement in scop['statements']:25 output += "%s\n\n" % statement['schedule']26 27 return output28 29def writeCloog(scop):30 template = """31# ---------------------- CONTEXT ----------------------32c # language is C33 34# Context (no constraints on two parameters)35%s36 370 # We do not want to set manually the parameter names38 39# --------------------- STATEMENTS --------------------40%s41 420 # We do not want to set manually the iterator names43 44# --------------------- SCATTERING --------------------45%s46 470 # We do not want to set manually the schedule dimension names48"""49 50 context = scop['context']51 domains = getDomains(scop)52 schedules = getSchedules(scop)53 print template % (context, domains, schedules)54 55def __main__():56 description = 'Translate JSCoP into iscc input'57 parser = argparse.ArgumentParser(description)58 parser.add_argument('inputFile', metavar='N', type=file,59 help='The JSCoP file')60 61 args = parser.parse_args()62 inputFile = args.inputFile63 scop = json.load(inputFile)64 65 writeCloog(scop)66 67__main__()68 69