コード例 #1
0
ファイル: rm_functor.py プロジェクト: pesterie/nt2
 def __init__(self, tb_name, fct_name, no_simd=False):
     Base_gen.__init__(self, tb_name, fct_name, 'scalar')
     Nt2_tb_struct.__init__(self)
     self.tb_files = self.get_rel_tb_unique_files(tb_name)
     self.fct_files = self.get_rel_tb_fcts_files(tb_name, fct_name)
     self.unique_files = self.get_rel_tb_unique_files(tb_name)
     self.no_simd = no_simd
コード例 #2
0
ファイル: rm_functor.py プロジェクト: timblechmann/nt2
 def __init__(self,tb_name,fct_name,no_simd=False) :
     Base_gen.__init__(self, tb_name, fct_name, 'scalar')
     Nt2_tb_struct.__init__(self)
     self.tb_files  = self.get_rel_tb_unique_files(tb_name)
     self.fct_files = self.get_rel_tb_fcts_files(tb_name,fct_name)
     self.unique_files = self.get_rel_tb_unique_files(tb_name)
     self.no_simd = no_simd
コード例 #3
0
ファイル: bench_creation.py プロジェクト: francescog/nt2
def create_one_bench(tb_name,
                     fct_name,
                     mode) :
    print("tb %s fct %s with %s mode"%(tb_name,fct_name,mode))
    bg = Base_gen(tb_name,fct_name,mode)
    print(bg.get_module_style(tb_name))
    bbg =  Bench_gen(bg)
    return bbg.get_gen_result()
コード例 #4
0
def create_one_bench(tb_name, fct_name, mode, simd_type):
    print("tb %s -> fct -> %s with %s mode -> simd_type %s" %
          (tb_name, fct_name, mode, simd_type))
    bg = Base_gen(tb_name, fct_name, mode)
    ##    print(bg.get_module_style(tb_name))
    bbg = Bench_gen(bg, simd_type)
    return bbg.get_gen_result()
コード例 #5
0
def create_one_exhaustive(tb_name,
                          fct_name,
                          mode = 'simd') :
    print("tb %s -> fct -> %s with %s mode"%(tb_name,fct_name,mode))
    bg = Base_gen(tb_name,fct_name,mode)

##    print(bg.get_module_style(tb_name))
    bbg =  Exhaustive_gen(bg)
    return bbg.get_gen_result()
コード例 #6
0
    def create_one_unit(self, fct_name, mode, part, platform):

        #     if self.verbose :
        print("%s with %s with %s" % (fct_name, mode, part))
        bg = Base_gen(self.tb_name, fct_name, mode)
        ghg = Global_header_gen(bg, part)
        r = ghg.get_gen_result()
        dl = bg.get_fct_dict_list()
        for rank, d in enumerate(dl):

            df = d.get('functor', False)
            if not df: df = self.Default_df
            if df.get('no_simd_tests', False): return []

            types = []
            if mode == 'simd':
                types = bg.recover('simd_types', df, [])
            if len(types) == 0:
                types = bg.recover('types', df, ['real_'])

            ret_arity = int(df["ret_arity"])
            d_unit = d.get("unit", {})
            for typ in types:
                thg = Type_header_test_gen(bg, d, typ, rank)
                r += thg.get_gen_beg()
                if self.verbose: print("part = %s" % part)
                if ("unit" == part) and d_unit.get("specific_values", None):
                    svt = Specific_values_test_gen(bg, d, typ, ret_arity,
                                                   platform)
                    s = svt.get_gen_result()
                    ##                    print(s)
                    ##                    raise SystemExit
                    ##                    if not s : return False
                    r += s
                if ("cover" == part) and d_unit.get("verif_test", None):
                    vtg = Random_verif_test_gen(bg, d, typ, platform)
                    s = vtg.get_gen_result()
                    ##                    print(s)
                    ##                    raise SystemExit
                    ##                    if not s : return False
                    r += s
                r += thg.get_gen_end()
        return r
コード例 #7
0
ファイル: unit_creation.py プロジェクト: KWMalik/nt2
    def create_one_unit(self, fct_name, mode, part,platform) :

   #     if self.verbose :
        print("%s with %s with %s"%(fct_name,mode,part))
        bg = Base_gen(self.tb_name,fct_name,mode)
        ghg = Global_header_gen(bg,part)
        r = ghg.get_gen_result()
        dl = bg.get_fct_dict_list()
        for rank,d in enumerate(dl) :
            
            df = d.get('functor',False)
            if not df : df = self.Default_df
            if df.get('no_simd_tests',False) : return []
            
            types = []
            if mode == 'simd':
                types = bg.recover('simd_types',df,[])
            if len(types) == 0:
                types = bg.recover('types',df,['real_'])
            
            ret_arity = int(df["ret_arity"])
            d_unit = d.get("unit",{})
            for typ in types :
                thg = Type_header_test_gen(bg,d,typ,rank)
                r+=thg.get_gen_beg()
                if self.verbose : print("part = %s"%part)
                if ("unit"==part) and d_unit.get("specific_values",None) :
                    svt = Specific_values_test_gen(bg,d,typ,ret_arity,platform)
                    s = svt.get_gen_result()
##                    print(s)
##                    raise SystemExit
##                    if not s : return False
                    r += s    
                if ("cover" == part) and d_unit.get("verif_test",None) :
                    vtg = Random_verif_test_gen(bg,d,typ,platform)
                    s = vtg.get_gen_result()
##                    print(s)
##                    raise SystemExit
##                    if not s : return False
                    r += s    
                r+=thg.get_gen_end()
        return r
コード例 #8
0
def create_unit(tb_name,fct_name,mode) :
    bg = Base_gen(tb_name,fct_name,mode)
    ghg = Global_header_gen(bg)
    r = ghg.get_gen_result()
    dl = bg.get_fct_dict_list()
    for d in dl :
        types = bg.recover("types",d["functor"],[])
        d_unit = d["unit"]
        for typ in types :
            thg = Type_header_test_gen(bg,d,typ)
            r+=thg.get_gen_beg()
            if d_unit.get("specific_values",None) :
                print("specific")
                svt = Specific_values_test_gen(bg,d,typ)
                r += svt. get_gen_result()
            if d_unit.get("verif_test",None) :
                print("verif")
                vtg = Random_verif_test_gen(bg,d,typ)
                r += vtg. get_gen_result()
            r+=thg.get_gen_end()
    return r
コード例 #9
0
ファイル: add_functor.py プロジェクト: pesterie/nt2
def create_unit(tb_name, fct_name, mode):
    bg = Base_gen(tb_name, fct_name, mode)
    ghg = Global_header_gen(bg)
    r = ghg.get_gen_result()
    if True:  #    try :
        dl = bg.get_fct_dict_list()
        for rank, d in enumerate(dl):
            origin = "types" if mode == 'scalar' else 'simd_types'
            types = bg.recover(origin, d["functor"], ["real_convert_"])
            ret_arity = int(d["functor"]["ret_arity"])
            d_unit = d["unit"]
            for typ in types:
                thg = Type_header_test_gen(bg, d, typ, rank)
                r += thg.get_gen_beg()
                if d_unit.get("specific_values", None):
                    svt = Specific_values_test_gen(bg, d, typ, ret_arity, mode)
                    r += svt.get_gen_result()
                if d_unit.get("verif_test", None):
                    vtg = Random_verif_test_gen(bg, d, typ, mode)
                    r += vtg.get_gen_result()
                r += thg.get_gen_end()
        return r
コード例 #10
0
ファイル: pydoc2unit.py プロジェクト: timblechmann/nt2
def create_unit(tb_name,fct_name,mode,parts =["verif","values"]) :
    bg = Base_gen(tb_name,fct_name,mode)
    ghg = Global_header_gen(bg)
    r = ghg.get_gen_result()
    if True:#    try :
        dl = bg.get_fct_dict_list()
        for rank, d in enumerate(dl) :
            origin ="types" if mode == 'scalar' else 'simd_types'
            types = bg.recover(origin,d["functor"],["real_convert_"])
            ret_arity = int(d["functor"]["ret_arity"])
            d_unit = d["unit"]
            for typ in types :
                thg = Type_header_test_gen(bg,d,typ,rank)
                r+=thg.get_gen_beg()
                if ("values" in parts) and d_unit.get("specific_values",None) :
                    svt = Specific_values_test_gen(bg,d,typ,ret_arity,mode)
                    r += svt. get_gen_result()
                if ("verif" in parts) and d_unit.get("verif_test",None) :
                    vtg = Random_verif_test_gen(bg,d,typ,mode)
                    r += vtg. get_gen_result()
                r+=thg.get_gen_end()
        return r
コード例 #11
0
ファイル: py_doc.py プロジェクト: pesterie/nt2
    def __init__(self,
                 tb_name=None,
                 fct_name=None,
                 mode=None,
                 d=None,
                 bg=None,
                 index=0,
                 arity=None,
                 repfunc=None,
                 repinclude=None):
        self.bg = bg if tb_name is None else Base_gen(tb_name, fct_name, mode)
        self.name = self.bg.get_fct_name()
        self.tb_name = self.bg.get_tb_name()
        self.mode = self.bg.get_fct_mode()
        self.d = self.__get_dict(d, index, arity)
        self.typs = self.get_types()
        self.types_str = stringize(self.typs)

        ##        self.repfunc = self.bg.get_fct_name()+'_rn' if repfunc is None else repfunc
        ##        self.repinclude = "#include <nt2/toolbox/crlibm/functions/"+self.repfunc+'.hpp>' if repinclude is None else repinclude
        self.prefix = "nt2" if self.bg.get_tb_name().find(
            '.') == -1 else '::'.join(self.bg.get_tb_name().split('.')[0:-1])
コード例 #12
0
        dd = d.get("call_types", None)
        if dd is None:
            return "T"
        elif type(dd) is str:
            return dd
        else:
            return dd[i]


if __name__ == "__main__":
    from pprint import PrettyPrinter
    from unit_base_gen import Base_gen
    from unit_type_header_gen import Type_header_test_gen
    from unit_specific_values_gen import Specific_values_test_gen
    print __doc__
    bg = Base_gen("exponential", 'pipo', 'scalar')
    dl = bg.get_fct_dict_list()
##    r = []
##    for d in dl :
##        types = bg.recover("types",d["functor"],[])
##        d_unit = d["unit"]
##        for typ in types :
##            thg = Type_header_test_gen(bg,d,typ,0)
##            r+=thg.get_gen_beg()
##            if d_unit.get("specific_values",None) :
##                svt = Specific_values_test_gen(bg,d,typ,ret_arity,mode)
##                r += svt. get_gen_result()
##            if d_unit.get("random_tuple_test",None) :
##                rtg = Random_tuple_test_gen(bg,d,typ,mode)
##                r += rtg. get_gen_result()
##            r+=thg.get_gen_end()
コード例 #13
0
            for i in range(0, ret_arity):
                s1 = re.sub("\$i\$", str(i), Call)
                s1 = re.sub("\$call_param_res\$", rep[i], s1)
                s1 = re.sub("\$specific_thresh\$", thr[i], s1)
                if self.mode == 'simd':
                    s1 = re.sub("T", "vT", s1)
                r.append(s1)
            r.append("  }")
        return r

if __name__ == "__main__":
    from pprint import PrettyPrinter
    from unit_base_gen import Base_gen
    from unit_type_header_gen import Type_header_test_gen
    ##    print (__doc__)
    bg = Base_gen("exponential", 'pipo', 'scalar')
    dl = bg.get_fct_dict_list()
    r = []
    for d in dl:
        types = bg.recover("types", d["functor"], [])
        d_unit = d["unit"]
        for typ in types:
            thg = Type_header_test_gen(bg, d, typ)
            r += thg.get_gen_beg()
            if d_unit.get("specific_values", None):
                svt = Specific_values_test_gen(bg, d, typ)
                r += svt.get_gen_result()
            r += thg.get_gen_end()
    PrettyPrinter().pprint(r)

sys.path.pop(0)
コード例 #14
0
ファイル: unit_tuple_random_gen.py プロジェクト: KWMalik/nt2
        dd = d.get("call_types",None)
        if dd is None :
            return "T"
        elif type(dd) is str :
            return dd
        else :
            return dd[i]


if __name__ == "__main__" :
    from pprint        import PrettyPrinter
    from unit_base_gen import Base_gen
    from unit_type_header_gen import Type_header_test_gen
    from unit_specific_values_gen import Specific_values_test_gen
    print __doc__
    bg = Base_gen("exponential",'pipo','scalar')
    dl = bg.get_fct_dict_list()
##    r = []
##    for d in dl :
##        types = bg.recover("types",d["functor"],[])
##        d_unit = d["unit"]
##        for typ in types :
##            thg = Type_header_test_gen(bg,d,typ,0)
##            r+=thg.get_gen_beg()
##            if d_unit.get("specific_values",None) :
##                svt = Specific_values_test_gen(bg,d,typ,ret_arity,mode)
##                r += svt. get_gen_result()
##            if d_unit.get("random_tuple_test",None) :
##                rtg = Random_tuple_test_gen(bg,d,typ,mode)
##                r += rtg. get_gen_result()
##            r+=thg.get_gen_end()
コード例 #15
0
                                if calls[j][0] == 'i':
                                    param += tpl % (iprefix + calls[j], rge[0],
                                                    rge[1])
                                elif calls[j][0] == 's':
                                    param += tpl % (calls[j][1:], rge[0],
                                                    rge[1])
                                else:
                                    param += tpl % (prefix + calls[j], rge[0],
                                                    rge[1])
                            r.append(call % param)
                        r += ["}"]

        txt += r + txtf
        if tb_name.find('.') != -1:
            for i, l in enumerate(txt):
                txt[i] = re.sub('nt2::', 'boost::simd::', l)
        h = Headers(os.path.join(self.bg.get_nt2_rel_tb_path(tb_name), 'bench',
                                 mode),
                    name,
                    inner=txt,
                    guard_begin=[],
                    guard_end=[]).txt()
        return h.split('\n')

if __name__ == "__main__":
    print __doc__
    from pprint import PrettyPrinter
    bg = Base_gen("exponential", 'pipo', 'simd')
    bbg = Bench_gen(bg)
    PrettyPrinter().pprint(bbg.get_gen_result())
コード例 #16
0
        if self.stampit:
            st = d.get("stamp", "")
            st = re.sub("\d+/\d+/\d+",
                        datetime.datetime.now().strftime("%d/%m/%Y"), st)
            s = re.sub("\$stamp\$", '/// ' + st, s)
        else:
            s = re.sub("\$stamp\$", '/// ', s)
        fs = d.get("first_stamp", "")
        fs = re.sub("modified", "created", fs)
        s = re.sub("\$first_stamp\$", '/// ' + fs, s)
        s = re.sub("\$no_ulp\$",
                   "" if d.get("no_ulp", False) != True else "no_ulp_", s)
        m = re.search('\$notes\$', s)
        if m:
            s = []
            beg = '/// '
            n = d.get("notes", [])
            for l in n:
                ll = l.split('\n')
                for lll in ll:
                    s.append(beg + lll.lstrip())
        return s


if __name__ == "__main__":
    print __doc__
    from pprint import PrettyPrinter
    bg = Base_gen("exponential", 'exp', 'scalar')
    ghg = Global_header_gen(bg, 'cover')
    PrettyPrinter().pprint(ghg.get_gen_result())
コード例 #17
0
            r.append("  }")
        return r

    def __add(s, r):
        if isinstance(s, str):
            return r.append(s)
        elif isinstance(s, list):
            return r.extend(s)
        return r

if __name__ == "__main__":
    from pprint import PrettyPrinter
    from unit_base_gen import Base_gen
    from unit_type_header_gen import Type_header_test_gen
    ##    print (__doc__)
    bg = Base_gen("arithmetic", 'abs', 'scalar')
    dl = bg.get_fct_dict_list()
    r = []
    for d in dl:
        ret_arity = int(extract(d, "", "", "functor", "ret_arity"))
        types = bg.recover("types", d["functor"], [])
        d_unit = d["unit"]
        for typ in types:
            thg = Type_header_test_gen(bg, d, typ, 0)
            r += thg.get_gen_beg()
            if d_unit.get("specific_values", None):
                svt = Specific_values_test_gen(bg, d, typ, ret_arity, 'scalar')
                r += svt.get_gen_result()
            r += thg.get_gen_end()
    PrettyPrinter().pprint(r)
コード例 #18
0
        s=re.sub("\$rturn\$", d["functor"]["rturn"].get(typ,d["functor"]["rturn"]["default"]),s)
        m = re.match("( *)\$type_defs\$.*",s)
        if m :
            s = []
            beg = m.groups()[0]
            tpdefs = d["functor"].get("type_defs",None)
            if tpdefs is not None :
                for l in tpdefs :
                    s.append( beg+l)
            else :
                s= ""
        return s

if __name__ == "__main__" :
    from pprint        import PrettyPrinter
    from unit_base_gen import Base_gen
    print __doc__
    bg = Base_gen("exponential",'pipo','scalar')
    dl = bg.get_fct_dict_list()
    r = []
    for d in dl :
        types = bg.recover("types",d["functor"],[])
        for typ in types :
            thg = Type_header_test_gen(bg,d,typ)
            r+=thg.get_gen_beg()
            r+=thg.get_gen_end()
    PrettyPrinter().pprint(r)

sys.path.pop(0)
sys.path.pop(0)
コード例 #19
0
        types = self.types if types is None else listify(types)
        dictres = {}
        main = self.get_fct_exhaustive_main_path(self.mode)
        dictres[main] = self.gen_main_file()
        for typ in types:
            path = self.get_fct_exhaustive_include_path(self.mode, typ)
            dictres[path] = self.gen_include_file(path, typ)
        return dictres

    def create_main_and_includes(self, types=None, wr=False):
        dictres = self.dgen_main_and_includes(types)
        for path in dictres.keys():
            print(path)
            self.write_file(path,
                            dictres[path],
                            check=False,
                            backup=True,
                            wr=wr)


if __name__ == "__main__":
    print __doc__
    from pprint import PrettyPrinter
    bg = Base_gen("trigonometric", 'sin', 'simd')
    bbg = Exhaustive_gen(bg)
    ##    PrettyPrinter().pprint(bbg.gen_global_header().split('\n'))
    ##    PrettyPrinter().pprint(bbg.gen_test_func_forwarding().split('\n'))
    ##    PrettyPrinter().pprint(bbg.gen_test_func('float').split('\n'))
    ##    PrettyPrinter().pprint(bbg.gen_main_func().split('\n'))
    machin = bbg.create_main_and_includes(wr=True)