Exemplo n.º 1
0
def gen_cfg(filename=None):
    if filename is None:
        curdir = os.path.dirname(os.path.abspath(__file__))
        filename = os.path.join(curdir, 'c_files', 'test.c')

    graph = cfg.CFG(filename)
    graph.make_cfg()

    # a new C file is generated at the same path of the given on, and it is
    # appending to its name "_dvfs" string
    cdvfs = cfg_cdvfs_generator.CFG_CDVFS()
    cdvfs.gen(graph)
Exemplo n.º 2
0
def run_cfg(filename):
    # create CFG
    graph = cfg.CFG(filename)
    graph.make_cfg()
    #cfg.show()

    # create graphml
    graphml = cfg2graphml.CFG2Graphml()
    graphml.make_graphml(graph, file_name='', yed_output=True)

    # generate DVFS-aware code
    cdvfs = cfg_cdvfs_generator.CFG_CDVFS()
Exemplo n.º 3
0
def run_cfg(filename):
    # create CFG
    graph = cfg.CFG(filename)
    ast = graph.make_cfg()
    DG = graph.get_DG()
    #cfg.show()

    # create graphml
    graphml = cfg2graphml.CFG2Graphml()
    #graphml.add_boundaries(graph, file_name='', yed_output=True, 1)
    graphml.make_graphml(graph, 2, file_name='', yed_output=True)

    # generate DVFS-aware code
    cdvfs = cfg_cdvfs_generator.CFG_CDVFS()
    #cdvfs.gen(graph)

    #CHANGED.  Added a print for the results.
    generator = c_generator.CGenerator()
    print(generator.visit(ast))
    return (cfg, ast, DG)
Exemplo n.º 4
0
    def test_dvfs_generator(self):
        test_name = self.test_dvfs_generator.__name__

        c_test_file = self._find_file(test_name + '.c')
        result_ok = self._find_file(test_name + '_ok_dvfs.c')
        result_check = self._find_file(test_name + '_check.c')

        graph = cfg.CFG(c_test_file)
        graph.make_cfg()

        cdvfs = cfg_cdvfs_generator.CFG_CDVFS()
        cdvfs.gen(graph, result_check)

        test_assert = False
        # '_dvfs' string is always appending to new file name
        result_check = self._find_file(test_name + '_check_dvfs.c')
        with open(result_check, 'rU') as check_file,\
                open(result_ok, 'rU') as ok_file:
            check = check_file.read()
            ok = ok_file.read()
            test_assert = (check == ok)

        self.assertTrue(test_assert)
        os.remove(result_check)