def transform(self): # init plugin framework init_plugins([KERNEL_ID_0]) # construct a generation tree for filepath, (srcobj, mods_used, units_used) in State.srcfiles.iteritems(): if srcobj.tree == State.topblock['stmt'].top: callsite_sfile = gensobj(None, srcobj.tree, KERNEL_ID_0) self.genfiles.append((callsite_sfile, filepath)) State.used_srcfiles[filepath] = (srcobj, mods_used, units_used) # process each nodes in the tree for plugin_name in event_register.keys(): for obj, filepath in self.genfiles: obj.created([plugin_name]) for tree in self._trees: tree.created([plugin_name]) for obj, filepath in self.genfiles: obj.process([plugin_name]) for tree in self._trees: tree.process([plugin_name]) for obj, filepath in self.genfiles: obj.finalize([plugin_name]) for tree in self._trees: tree.finalize([plugin_name]) for obj, filepath in self.genfiles: obj.flatten(KERNEL_ID_0, [plugin_name]) for tree in self._trees: tree.flatten(KERNEL_ID_0, [plugin_name])
def transform(self): # generate kgen_driver.f90 in kernel directory self.driver = self.create_tree() program = self.create_program(self.driver) program.name = self.kernel_name self.append_program_in_tree(self.driver, program) # init plugin framework init_plugins([KERNEL_ID_0]) # construct a generation tree for filepath, (srcobj, mods_used, units_used) in State.srcfiles.iteritems(): if hasattr(srcobj.tree, 'geninfo') and KGGenType.has_state( srcobj.tree.geninfo): kfile = genkobj(None, srcobj.tree, KERNEL_ID_0) sfile = gensobj(None, srcobj.tree, KERNEL_ID_0) if kfile is None or sfile is None: raise ProgramException( 'Kernel source file is not generated for %s.' % filepath) self.genfiles.append((kfile, sfile, filepath)) State.used_srcfiles[filepath] = (srcobj, mods_used, units_used) # process each nodes in the tree for plugin_name in event_register.keys(): for kfile, sfile, filepath in self.genfiles: kfile.created([plugin_name]) sfile.created([plugin_name]) for tree in self._trees: tree.created([plugin_name]) for kfile, sfile, filepath in self.genfiles: kfile.process([plugin_name]) sfile.process([plugin_name]) for tree in self._trees: tree.process([plugin_name]) for kfile, sfile, filepath in self.genfiles: kfile.finalize([plugin_name]) sfile.finalize([plugin_name]) for tree in self._trees: tree.finalize([plugin_name]) for kfile, sfile, filepath in self.genfiles: kfile.flatten(KERNEL_ID_0, [plugin_name]) sfile.flatten(KERNEL_ID_0, [plugin_name]) for tree in self._trees: tree.flatten(KERNEL_ID_0, [plugin_name])
def main(self): Logger.info('Starting KExt', stdout=True) # create state directories if not os.path.exists(Config.path['state']): os.makedirs(Config.path['state']) # create kernel directories if not os.path.exists(Config.path['kernel']): os.makedirs(Config.path['kernel']) os.system('rm -f %s/kgen_statefile.lst' % Config.path['kernel']) os.system('rm -f %s/done.*' % Config.path['kernel']) preprocess() Logger.info('Pre-processing is done', stdout=True) analyze() Logger.info('Program is analyzed', stdout=True) # generate kgen_driver.f90 in kernel directory self.driver = self.create_tree() program = self.create_program(self.driver) program.name = self.kernel_name self.append_program_in_tree(self.driver, program) # init plugin framework init_plugins([KERNEL_ID_0]) # construct a generation tree for filepath, (srcobj, mods_used, units_used) in State.srcfiles.iteritems(): if hasattr(srcobj.tree, 'geninfo') and KGGenType.has_state( srcobj.tree.geninfo): kfile = genkobj(None, srcobj.tree, KERNEL_ID_0) sfile = gensobj(None, srcobj.tree, KERNEL_ID_0) if kfile is None or sfile is None: raise ProgramException( 'Kernel source file is not generated for %s.' % filepath) self.genfiles.append((kfile, sfile, filepath)) State.used_srcfiles[filepath] = (srcobj, mods_used, units_used) # process each nodes in the tree for plugin_name in event_register.keys(): for kfile, sfile, filepath in self.genfiles: kfile.created([plugin_name]) sfile.created([plugin_name]) for tree in self._trees: tree.created([plugin_name]) for kfile, sfile, filepath in self.genfiles: kfile.process([plugin_name]) sfile.process([plugin_name]) for tree in self._trees: tree.process([plugin_name]) for kfile, sfile, filepath in self.genfiles: kfile.finalize([plugin_name]) sfile.finalize([plugin_name]) for tree in self._trees: tree.finalize([plugin_name]) for kfile, sfile, filepath in self.genfiles: kfile.flatten(KERNEL_ID_0, [plugin_name]) sfile.flatten(KERNEL_ID_0, [plugin_name]) for tree in self._trees: tree.flatten(KERNEL_ID_0, [plugin_name])
def main(self): Logger.info('Starting KExt', stdout=True) # create state directories if not os.path.exists(Config.path['state']): os.makedirs(Config.path['state']) # create kernel directories if not os.path.exists(Config.path['kernel']): os.makedirs(Config.path['kernel']) os.system('rm -f %s/kgen_statefile.lst'%Config.path['kernel']) os.system('rm -f %s/done.*'%Config.path['kernel']) preprocess() Logger.info('Pre-processing is done', stdout=True) analyze() Logger.info('Program is analyzed', stdout=True) # generate kgen_driver.f90 in kernel directory self.driver = self.create_tree() program = self.create_program(self.driver) program.name = self.kernel_name self.append_program_in_tree(self.driver, program) # init plugin framework init_plugins([KERNEL_ID_0]) # construct a generation tree for filepath, (srcobj, mods_used, units_used) in State.srcfiles.iteritems(): if hasattr(srcobj.tree, 'geninfo') and KGGenType.has_state(srcobj.tree.geninfo): kfile = genkobj(None, srcobj.tree, KERNEL_ID_0) sfile = gensobj(None, srcobj.tree, KERNEL_ID_0) if kfile is None or sfile is None: raise ProgramException('Kernel source file is not generated for %s.'%filepath) self.genfiles.append((kfile, sfile, filepath)) State.used_srcfiles[filepath] = (srcobj, mods_used, units_used) # process each nodes in the tree for plugin_name in event_register.keys(): for kfile, sfile, filepath in self.genfiles: kfile.created([plugin_name]) sfile.created([plugin_name]) for tree in self._trees: tree.created([plugin_name]) for kfile, sfile, filepath in self.genfiles: kfile.process([plugin_name]) sfile.process([plugin_name]) for tree in self._trees: tree.process([plugin_name]) for kfile, sfile, filepath in self.genfiles: kfile.finalize([plugin_name]) sfile.finalize([plugin_name]) for tree in self._trees: tree.finalize([plugin_name]) for kfile, sfile, filepath in self.genfiles: kfile.flatten(KERNEL_ID_0, [plugin_name]) sfile.flatten(KERNEL_ID_0, [plugin_name]) for tree in self._trees: tree.flatten(KERNEL_ID_0, [plugin_name])