Example #1
0
    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])
Example #2
0
    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])
Example #3
0
 def create_program(self, parent):
     return genkobj(parent, block_statements.Program, KERNEL_ID_0)
Example #4
0
 def create_tree(self):
     tree = genkobj(None, block_statements.BeginSource, KERNEL_ID_0)
     self._trees.append(tree)
     return tree
Example #5
0
    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])
Example #6
0
 def create_program(self, parent):
     return genkobj(parent, block_statements.Program, KERNEL_ID_0)
Example #7
0
 def create_tree(self):
     tree = genkobj(None, block_statements.BeginSource, KERNEL_ID_0)
     self._trees.append(tree)
     return tree