Exemplo n.º 1
0
 def replace(self):
     for f in self.get_list_cpps():
         full_f = os.path.join(self.get_unit_simd_path(), f)
         if self.ok(full_f):
             s = Rep_units_simd.Simd_unit
             s = sub_list("\$name\$", f[:-4], s)
             s = sub_list("\$tb_name\$", self.get_tb_name(), s)
             show(s)
             write(full_f, s, False)
Exemplo n.º 2
0
def set_one(fct,fct_name,arity,pname) :
    s = fct.read_functor(fct_name,'scalar')
    print "adding functor %s of arity %d" % (fct_name, arity) 
    src = os.path.join(pname,fct_name+'.hpp')
    d = read(src)
    v = get_validate(d)
    c = get_call(d)
    s = insert_validate_and_call(s,v,c,fct.get_tb_style(),fct.get_tb_name())
    show(s)
    fct.write_functor(fct_name,'scalar',s,False)
Exemplo n.º 3
0
    def replace_scalar_units(self) :
        fctrs = self.get_functor_list(self.get_tb_name())
        for name in fctrs :
            s = self.replace_scalar_unit(name)
##            print "----------------------------"
            show(s)
##            print "============================"
            p = os.path.join(self.get_tb_path(self.get_tb_name()),'unit/scalar',name+'.cpp')
            print p
            write(p,s,False)
Exemplo n.º 4
0
 def modify_tpl_defs(self) :
     for k in self.get_dict().keys() :
         if self.get_dict()[k][1] :
            p =  os.path.join(self.get_new_def_path(),k+'.hpp')
            s = read(p)
            pattern = " *NT2_FUNCTION_IMPLEMENTATION.*"
            rep = "  NT2_CRLIBM_FUNCTION_IMPLEMENTATION_TPL("+k+")"
            s = sub_list(pattern,rep,s)
            show(s)
            write(p,s,False)
Exemplo n.º 5
0
if __name__ == "__main__":
    from list_utils import show
    inner_text = [
        "",
        "SET( SOURCES",
        "# List of files for toolbox %s"% "gmp",
        "   )",
        "",
        "##****************************************************************************",
        "# For each filename",
        "##****************************************************************************",
        "FOREACH( EXAMPLE ${SOURCES})",
        "  ##**************************************************************************",
        "  ## Build the executable filename from the example source filename",
        "  ##**************************************************************************",
        '  STRING(REGEX REPLACE ".cpp" ".%s.scalar.bench" EXECUTABLE "${EXAMPLE}")'%("gmp",),
        '  STRING(REGEX REPLACE ".cpp" "-%s.scalar.bench" TEST "${EXAMPLE}")'%("gmp",),
        "",
        "  ##**************************************************************************",
        "  ## Add as a target",
        "  ##**************************************************************************",
        "  ADD_EXECUTABLE(${EXECUTABLE} ${EXAMPLE})",
        "  TARGET_LINK_LIBRARIES(${EXECUTABLE} nt2)",
        "  ADD_TEST(${TEST} ${CMAKE_CURRENT_BINARY_DIR}/${EXECUTABLE})",
        "ENDFOREACH()",
        ]
    l=sub_if_match_list(" *##", "\*", "#", inner_text)
    show(l)
   
Exemplo n.º 6
0
            l.extend(r)
        return l

    def create_txt(self,s,tb_name) :
        r = []
        for l in s :
            m= re.search('\#include <nt2/toolbox/'+tb_name+'/include/(.*)>',l)
            if m :
                fct_name =m.groups()[0][:-4]
                r.append(fct_name)
        return r    

    def get_simd_propers(self,arch,modes,fcts) :
        for tb_name in self.tb_list :
            for k in modes.keys()[1:] :
                for name in fcts :
                    src = os.path.join(self.absolute_path_to_mode(),tb_name,"function/simd",arch,k,name+'.hpp')
                    if  exist(src) and (os.path.getsize(src) > 1536) :
                        print "in toobox %s in mode %s functor %s has a proper implementation " % (tb_name, k, name)
            
       
if __name__ == "__main__":
    Mylogging.set_level('CRITICAL')
    f = Findintr()#["arithmetic"])
#    l = f.get_list()
#    show(f.get_list())
    show(f.get_simd_propers("sse",Sse.Variants,f.get_list()))
#    show(f.get_includes())
#    show(f.get_unexpected())

Exemplo n.º 7
0
                beg = i-1
        else :
           m1 = re.search("({)",l)
           m2 = re.search("(})",l)
           nbl = len(m1.groups()) if m1 else 0
           nbr = len(m2.groups()) if m2 else 0
           nb += nbl-nbr
           if not nb :
               end = i+1
               return s[beg:end]

           
if __name__ == "__main__" :
    Mylogging.set_level('CRITICAL')
    length = len(sys.argv)
    if length >= 2 :
        fct_name = sys.argv[1]
        pname = os.path.join('/home/jt/DevC++/dev_lasmea/docnt4/nt2-cleanup/nt2/core/numeric/function/details/scalar',fct_name+'.hpp')
        s = read(pname)
        v =get_validate(s)
        show(v)
        print "*********************"
        c = get_call(s)
        show(c)
    else :
        print __doc__
sys.path.pop(0)
           
       

Exemplo n.º 8
0
 def write_def_impl(self,fct_name,s) :
     p = os.path.join(self.get_def_path(),fct_name+'.hpp')
     #write(p,s,False)
     show(s)
     return s
Exemplo n.º 9
0
 def write_Cmake_txt(self,s) :
     p = os.path.join(self.get_bench_path(),'CMakeLists.txt')
     #write(p,s,False)
     show(s)
     return s
Exemplo n.º 10
0
        "function/simd/common",
        "function/simd/vmx", 
        "function/simd/vmx/common",
        "function/simd/vmx/altivec",
        "function/simd/vmx/spu",
        "function/simd/sse",
        "function/simd/sse/common",
        "function/simd/sse/sse2",
        "function/simd/sse/sse3",
        "function/simd/sse/ssse3",
        "function/simd/sse/sse4_1",
        "function/simd/sse/sse4_2",
        "function/simd/sse/avx",
        "function/simd/sse/sse4a",
        "function/simd/sse/xop",
        "function/simd/sse/fma4",
        ]
    from list_utils import show
    Mylogging.set_level('ALWAYS')
    name = "pipo"
    path = "/home/jt/DevC++/dev_lasmea/github/nt2/include/nt2/toolbox"
    tb = Tb_tree(name,path,a_tree)
    print "get_root_name()      %s   "%tb.get_root_name()        
    print "get_rel_tree()       %s   "%tb.get_rel_tree()    
    print "get_root_abs_path()  %s   "%tb.get_root_abs_path()             
##    tb.show_tb_tree()
##    tb.create_tb_tree()
##    tb.remove_tb_tree()
##    show(tb.get_tree_lack())
    show(tb.get_rel_tree())
Exemplo n.º 11
0
        "FOREACH( EXAMPLE ${SOURCES})",
        "  ##**************************************************************************",
        "  ## Build the executable filename from the example source filename",
        "  ##**************************************************************************",
        '  STRING(REGEX REPLACE ".cpp" ".%s.scalar.bench" EXECUTABLE "${EXAMPLE}")' % ("gmp",),
        '  STRING(REGEX REPLACE ".cpp" "-%s.scalar.bench" TEST "${EXAMPLE}")' % ("gmp",),
        "",
        "  ##**************************************************************************",
        "  ## Add as a target",
        "  ##**************************************************************************",
        "  ADD_EXECUTABLE(${EXECUTABLE} ${EXAMPLE})",
        "  TARGET_LINK_LIBRARIES(${EXECUTABLE} nt2)",
        "  ADD_TEST(${TEST} ${CMAKE_CURRENT_BINARY_DIR}/${EXECUTABLE})",
        "ENDFOREACH()",
    ]
    l = sub_if_match_list(" *##", "\*", "#", inner_text)
    text = [
        "function y = acosd(x)",
        "%ACOSD  Inverse cosine, result in degrees.",
        "%   ACOSD(X) is the inverse cosine, expressed in degrees,",
        "%   of the elements of X.",
        "%",
        "%   Class support for input X:",
        "%      float: double, single",
        "%",
        "%   See also COSD, ACOS.",
    ]
    r = sup_list("% *Class support *", text, 2)

    show(r)
Exemplo n.º 12
0
    for fct_name in s :
#        print "fct_name : %s"% fct_name
        p1=os.path.join(p,fct_name+'.hpp')
#        print "p1 : %s" %p1
        arity = get_arity(p1)
#        print arity
        if arity !="" :
            r.append(fct_name+(30-len(fct_name))*' '+arity)
    return r    


if __name__ == "__main__" :
    Mylogging.set_level('CRITICAL')
    length = len(sys.argv)
    if length >= 2 :
        tb_name = sys.argv[1]
        if length == 2 :
            p = '/home/jt/DevC++/dev_lasmea/docnt4/nt2-cleanup/nt2/core/numeric/function/'
        else :
            p = os.path.join('/home/jt/DevC++/dev_lasmea/docnt4/nt2-cleanup/nt2/toolbox',tb_name,'function')
        print "p %s" % p    
        s = create_txt(tb_name,p)
        show(s)
        write(tb_name+'.txt',s)
    else :
        print __doc__
sys.path.pop(0)
           
       

Exemplo n.º 13
0
 def get_Cmake_benches_txt(self) :
     p = os.path.join(self.get_bench_path(),'CMakeLists.txt')
     s = read(p)
     show(s)
     return s
Exemplo n.º 14
0
    def get_fctors_dict(self) :
        l = {}
        p0 = self.get_path()
        for name in os.listdir(p0) :
            if name[-4:]=='.hpp' :
                h = name[:-4]
                p = os.path.join(p0,h+'/py_data.py')
                if exist(p) :
                    s = ' '.join(read(p))
                    l[h] ='usr' if s.find('usr') > 0 else 'sys' 
        return l

    def get_usr_tb_list(self) :
         return [l for l in self.__dictio.keys() if self.__dictio[l]=='usr']
    def get_sys_tb_list(self) :
         return [l for l in self.__dictio.keys() if self.__dictio[l]=='sys']


if __name__ == "__main__" :
    Mylogging.set_level('CRITICAL')
    ts =Toolboxes()
#    show(ts.get_fctors_dict)
    show(ts.get_usr_tb_list())
    print "------------"
    show(ts.get_sys_tb_list())
    
sys.path.pop(0)
           
       

Exemplo n.º 15
0
        for l in s :
            m= re.search('\#include <nt2/core/numeric/function/(.*)>',l)
            if m :
                fct_name =m.groups()[0][:-4]
                r.append(fct_name)
        return r    

    def get_includes(self) :
        l = []
        for name in os.listdir(Find.Pname) :
            if name[-4:]=='.hpp' :
                h = name[:-4]
                l.append(h)
        return l

    def get_unexpected(self) :
        u=[]
        expected = self.get_list()
        for l in self.get_includes() :
            if not l in expected :
                u.append(l)
        return u
       
if __name__ == "__main__":
    Mylogging.set_level('CRITICAL')
    f = Find()
#    show(f.get_list())
#    show(f.get_includes())
    show(f.get_unexpected())
sys.path.pop(0)
Exemplo n.º 16
0
        for l in s :
            r.append(l.split('/')[-1])
        return r

    def get_functors_datas(self) :
        pathes = self.get_functors_abs_path()
        dr = {}
        for p in pathes :
            d= {}
            lp = p.split('/')
            lp[-2]= 'function'
            name = lp[-1][:-4]
            s = read('/'.join(lp))
            r = []
            for l in s :
                m= re.search('([0-9]+)\) *$',l)
                if m : r.append(int(m.groups()[0]))
            d["arity"]=r
            dr[name]=d    
        return dr   
            
if __name__ == "__main__":
    from list_utils import show
    Mylogging.set_level('ERROR')
    tb = Fctr_list("pipo1")
    show(tb.get_functors_rel_path())
    show(tb.get_functors_abs_path())
    show(tb.get_functors_names())
    show(tb.get_functors_datas())