def create_bench(tb_name, fct_list=None, modes=('scalar', 'simd'), show=True, write_files=False, check_on_write=True, backup_on_write=True, simd_type='sse'): bg = Nt2_modules() ## print(bg.get_module_style(tb_name)) if bg.get_module_style(tb_name) == 'usr': modes = ['scalar'] if fct_list is None: fcts = Nt2_tb_props(tb_name).get_fcts_list() elif isinstance(fct_list, str): fcts = [fct_list] else: fcts = fct_list if isinstance(modes, str): modes = [modes] for fct in fcts: for mode in modes: ## print("fct=%s,mode=%s"%(fct,mode)) r = create_one_bench(tb_name, fct, mode, simd_type) if r is None: print('error for %s' % fct) elif len(r) == 0: print( 'no regeneration possible for %s %s-tests, please do it manually' % (fct, mode)) else: just = "just" if show and not write_files else "" if show: print("%s showing text of %s.cpp for %s-test" % (just, fct, mode)) print("<" + "=" * 40) PrettyPrinter().pprint(r) print("=" * 40 + ">") if write_files: print("writing text of %s.cpp for %s-test" % (fct, mode)) write_bench(tb_name, fct, mode, r, check=check_on_write, backup=backup_on_write)
while True: pi = p + '.' + str(i) + '.bak' if not (exist(pi)): break i += 1 if self.verbose: print("to %s" % pi) shutil.copy(p, pi) elif self.verbose: print "writing to %s" % p write(p, s, self.check_on_write) p1 = os.path.join(os.path.split(p)[0], 'CMakeLists.txt') addline = Add_line(p1, fct_name) addline.update_file("SET\( *SOURCES") elif self.verbose: print("%s directory\n does not exist " % os.path.split(p)[0]) if __name__ == "__main__": tb_name = "operator" fcts = Nt2_tb_props(tb_name).get_fcts_list() fcts = ["splat"] ct = Create_tests(tb_name, fcts, modes=['scalar', 'simd'], parts=["unit"], show=True, write_files=False, check_on_write=True, backup_on_write=True, verbose=False) ct.create_units()