def gen_cfg(filename=None): if filename is None: curdir = os.path.dirname(__file__) filename = os.path.join(curdir, 'c_files', 'test.c') graph = cfg.CFG(filename) graph.make_cfg() graph.show()
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)
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()
def gen_cfg(filename=None): if filename is None: curdir = os.path.dirname(__file__) filename = os.path.join(curdir, 'c_files', 'test.c') graph = cfg.CFG(filename) graph.make_cfg() graph.show() # set file_name as empty to write graphml in stdout # set yed_output as true to write graphical information cfg2graph = cfg2graphml.CFG2Graphml() cfg2graph.make_graphml(graph, file_name='', yed_output=True)
def _set_simulation_config(self, simManager): """ Get task and environment information of a configuration file. Args: simManager (SimManager): simulation manager object config_file_name (string): configuration file name Returns: (float) task's WCEC (float) task's deadline (float) initial frequency to be used (dic) freqs_volt: dictionary where key is the frequency and supply voltage to use the given frequency is the value """ freqs = [] volts = [] freqs_volt = {} config_file = self._find_file('sim_preemp.config') with open(config_file, 'rU') as f: lines = f.readlines() try: for freq in lines[0].split(): freqs.append(float(freq)) for volt in lines[1].split(): volts.append(float(volt)) for i in range(0, len(freqs)): freqs_volt[freqs[i]] = volts[i] for task in lines[2:]: data = task.split() wcec = float(data[1]) deadline = float(data[2]) period = float(data[3]) jitter = float(data[4]) init_freq = float(data[5]) cfile = data[0] cfile = self._find_file(cfile) graph = cfg.CFG(cfile) graph.make_cfg() simManager.add_task_sim(graph, wcec, deadline, period, jitter, init_freq, freqs_volt, 0.15) except ValueError, IndexError: print 'Invalid data in config file' sys.exit(1)
def _init_data(self): """ Initialize simulation data such as: graph, task's information, path finding and simulation objects. """ # create CFG cfile = self._find_file('foo.c') self._graph = cfg.CFG(cfile) self._graph.make_cfg() # get and initialize data for simulation wcec, deadline, period, jit, init_freq, freqs_volt = \ self._read_config_file() self._cfgpaths = cfg_paths.CFGPaths() self._simulate = sim.SimDVFS( wcec, 0, deadline, period, jit, init_freq, freqs_volt)
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)
def test_while_graphml(self): test_name = self.test_while.__name__ c_test_file = self._find_file(test_name + '.c') result_ok = self._find_file(test_name + '.graphml') result_check = self._find_file(test_name + '_check.graphml') graph = cfg.CFG(c_test_file) graph.make_cfg() cfg2graph = cfg2graphml.CFG2Graphml() cfg2graph.make_graphml(graph, result_check, True) test_assert = False 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)
def test_while(self): test_name = self.test_while.__name__ c_test_file = self._find_file(test_name + '.c') result_ok = self._find_file(test_name + '.cfg') result_check = self._find_file(test_name + '_check.cfg') graph = cfg.CFG(c_test_file) graph.make_cfg() with open(result_check, 'w') as f: graph.show(buf=f) test_assert = False 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)
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)