def makeDummyCallGraphDocument(self): from tools.metadata import parseString, ImmutableDOMDocument import re dummyCallGraphXML = re.sub( r"[\n\t]*", "", """ <callGraph> <routines> <routine module="foo" name="bar" source="foo"> <domainDependants> <templateRelation id="testTemplateID"> <entry>testSymbol</entry> </templateRelation> </domainDependants> </routine> </routines> <modules> <module name="foo"/> </modules> <domainDependantTemplates> <domainDependantTemplate id="testTemplateID"> <attribute> <entry>present</entry> <entry>autoDom</entry> </attribute> <domName> <entry>x</entry> <entry>y</entry> <entry>k</entry> </domName> <domSize> <entry>nx</entry> <entry>ny</entry> <entry>nz</entry> </domSize> </domainDependantTemplate> </domainDependantTemplates> </callGraph> """) return ImmutableDOMDocument( parseString(dummyCallGraphXML, immutable=False))
def makeDummyCallGraphDocument(self): from tools.metadata import parseString, ImmutableDOMDocument import re dummyCallGraphXML = re.sub(r"[\n\t]*", "", """ <callGraph> <routines> <routine module="foo" name="bar" source="foo"> <domainDependants> <templateRelation id="testTemplateID"> <entry>testSymbol</entry> </templateRelation> </domainDependants> </routine> </routines> <modules> <module name="foo"/> </modules> <domainDependantTemplates> <domainDependantTemplate id="testTemplateID"> <attribute> <entry>present</entry> <entry>autoDom</entry> </attribute> <domName> <entry>x</entry> <entry>y</entry> <entry>k</entry> </domName> <domSize> <entry>nx</entry> <entry>ny</entry> <entry>nz</entry> </domSize> </domainDependantTemplate> </domainDependantTemplates> </callGraph> """) return ImmutableDOMDocument(parseString(dummyCallGraphXML, immutable=False))
"referenceXML option is mandatory. Use '--help' for informations on how to use this module" ) sys.exit(1) ignoreAttributes = [] if (options.ignoreAttributes): ignoreAttributes = options.ignoreAttributes.split(",") #read in the xmls and compare them try: logging.debug("Starting comparison of %s to %s" % (options.inputXML, options.referenceXML)) inputXMLFile = open(str(options.inputXML), 'r') inputXMLData = inputXMLFile.read() inputXMLFile.close() inputXML = parseString(inputXMLData) referenceXMLFile = open(str(options.referenceXML), 'r') referenceXMLData = referenceXMLFile.read() referenceXMLFile.close() referenceXML = parseString(referenceXMLData) except Exception, e: logging.debug( "Returning False because of exception when opening either %s or %s" % (options.inputXML, options.referenceXML)) sys.exit(2) try: result = isEqualXML(inputXML, referenceXML, ignoreAttributes) logging.debug("Result of equality test (e.g. are they equal?): %s" % (result)) if result == True:
setupDeferredLogging('preprocessor.log', logging.DEBUG if options.debug else logging.INFO) if (not options.source): logging.error("sourceXML option is mandatory. Use '--help' for informations on how to use this module") sys.exit(1) appliesTo = "" if options.appliesTo and options.appliesTo.upper() != "CPU": appliesTo = options.appliesTo #read in working xml sys.stderr.write("Reading codebase meta information\n") srcFile = openFile(str(options.source),'r') data = srcFile.read() srcFile.close() doc = parseString(data) try: analyseParallelRegions(doc, appliesTo) except UsageError as e: logging.error('Error: %s' %(str(e))) sys.exit(1) except Exception as e: logging.critical('Error when analysing callgraph file %s: %s' %(str(options.source), str(e)) ) logging.info(traceback.format_exc()) sys.exit(1) if (options.pretty): sys.stdout.write(doc.toprettyxml())
) sys.exit(1) conversionOptions.debugPrint = options.debug filesInDir = dirEntries(str(options.sourceDir), True, 'h90') try: os.mkdir(options.outputDir) except OSError as e: #we want to handle if a directory exists. every other exception at this point is thrown again. if e.errno != errno.EEXIST: raise e pass # get the callgraph information cgDoc = parseString(getDataFromFile(options.callgraph), immutable=False) # build up implementationNamesByTemplateName implementationNamesByTemplateName = None try: implementationNamesByTemplateName = json.loads( getDataFromFile(options.implementation)) except ValueError as e: logging.critical('Error decoding implementation json (%s): %s' \ %(str(options.implementation), str(e)) ) sys.exit(1) except Exception as e: logging.critical( 'Could not interpret implementation parameter as json file to read. Trying to use it as an implementation name directly' )
parser.add_option("-i", "--input", dest="input", help="input callgraph to be analysed") parser.add_option("-d", "--debug", action="store_true", dest="debug", help="show debug print in standard error output") (options, args) = parser.parse_args() setupDeferredLogging('preprocessor.log', logging.DEBUG if options.debug else logging.INFO) if (not options.reference or not options.input): raise Exception("Missing options. Please use '-h' option to see usage.") inputXML = None referenceXML = None inputXMLFile = open(str(options.input),'r') inputXMLData = inputXMLFile.read() inputXMLFile.close() inputXML = parseString(inputXMLData) referenceXMLFile = None try: referenceXMLFile = open(str(options.reference),'r') except Exception: pass try: if referenceXMLFile != None: referenceXMLData = referenceXMLFile.read() referenceXMLFile.close() referenceXML = parseString(referenceXMLData) sourcesToUpdateKeyed = {} for source in getSourcesWithParallelRegionPositionChanges(inputXML, referenceXML): sourcesToUpdateKeyed[source] = None for source in getSourcesToUpdateForModuleSymbolChanges(inputXML, referenceXML): sourcesToUpdateKeyed[source] = None
if (not options.implementation): logging.error("implementation option is mandatory. Use '--help' for informations on how to use this module") sys.exit(1) filesInDir = dirEntries(str(options.sourceDir), True, 'h90') try: os.mkdir(options.outputDir) except OSError as e: #we want to handle if a directory exists. every other exception at this point is thrown again. if e.errno != errno.EEXIST: raise e pass # get the callgraph information cgDoc = parseString(getDataFromFile(options.callgraph), immutable=False) # build up implementationNamesByTemplateName implementationNamesByTemplateName = None try: implementationNamesByTemplateName = json.loads(getDataFromFile(options.implementation)) except ValueError as e: logging.critical('Error decoding implementation json (%s): %s' \ %(str(options.implementation), str(e)) ) sys.exit(1) except Exception as e: logging.critical('Could not interpret implementation parameter as json file to read. Trying to use it as an implementation name directly') implementationNamesByTemplateName = {'default':options.implementation} logging.debug('Initializing H90toF90Printer with the following implementations: %s' %(json.dumps(implementationNamesByTemplateName))) implementationsByTemplateName = {
##################### MAIN ############################## #get all program arguments parser = OptionParser() parser.add_option("-c", "--callgraph", dest="callgraph", help="analyzed callgraph XML file to read", metavar="XML") parser.add_option("-d", "--debug", action="store_true", dest="debug", help="show debug print in standard error output") (options, args) = parser.parse_args() setupDeferredLogging('preprocessor.log', logging.DEBUG if options.debug else logging.INFO) if (not options.callgraph): logging.error("callgraph option is mandatory. Use '--help' for informations on how to use this module") sys.exit(1) #read in callgraph xml cgFile = openFile(str(options.callgraph),'rw') data = cgFile.read() cgDoc = parseString(data) cgFile.close() try: templateNames = set([templateNode.getAttribute("name") for templateNode in cgDoc.getElementsByTagName("implementationTemplate")]) print " ".join(templateNames) except Exception, e: logging.critical('Error when trying to extract template names: %s%s\n' \ %(str(e), traceback.format_exc())) sys.exit(1)