예제 #1
0
    def gen_simd(self,fil,option="create") :
        """ auxilliary of create_function
        create the functor skel file for the common version
        and the cascade include files for each simd variants
        with the functor name at the proper spots
        """
        path = os.path.join(self.get_tb_path(),fil)
##        print(path)
##        print("---------")
##        print("gen_simd")
##        print("---------")
        l = fil.split('/')
        if l[2] == 'common' :
            arity = self.fct_dict[0]["functor"]["arity"]
            a = int(arity)
            sys = self.get_tb_style()
            name = self.get_fct_name()
            txt = [
                "#include <nt2/sdk/meta/as_real.hpp>",
                "",
                "/////////////////////////////////////////////////////////////////////////////",
                "// Implementation when type A0 is arithmetic_",
                "/////////////////////////////////////////////////////////////////////////////",
                "NT2_REGISTER_DISPATCH(tag::%s_, tag::cpu_,"% name,
                "                       (A0)(X),",
                "                       %s"% self.strlist('((simd_<arithmetic_<A0>,X>))',sep='',n=0,arity=a),
                "                      );",
                "",
                "namespace nt2 { namespace ext",
                "{",
                "  template<class X, class Dummy>",
                "  struct call<tag::%s_(%s),"% (name,self.strlist('tag::simd_<tag::arithmetic_, X>',n=0,sep=',',arity=a)),
                "              tag::cpu_, Dummy> : callable",
                "  {",
                "    template<class Sig> struct result;",
                "    template<class This,%s>" % self.strlist('class A%d',sep=',',arity=a),
                "    struct result<This(%s)> : meta::as_real<A0>{};" % self.strlist('A%d',sep=',',arity=a),
                "",
                "    NT2_FUNCTOR_CALL(%s)"%arity,
                "    {",
                "      typedef typename NT2_RETURN_TYPE(%s)::type type;"%arity,
                "      // CODE HERE",
                "      return WHATEVER",
                "    }",
                "  };",
                "} }",
                "",
                ]
        else :
            arch =Nt2_archis_struct.get_archi(l[2])
            rppath =Nt2_archis_struct.get_archi(l[2]).get_previous_path(l[2]+'/'+l[3])
##            print("path %s"%(l[2]+'/'+l[3]))
##            print("prev %s"%rppath)
            txt = ["#include <nt2/toolbox/%s/function/simd/%s/%s.hpp>" %(self.get_tb_name(),rppath,self.get_fct_name())]
        new_txt = Headers(self.get_nt2_rel_tb_path(self.get_tb_name())+fil[:-4],"",inner=txt).txt()
        self.finalize(path,new_txt,option)
예제 #2
0
 def __find_implanted_scalar_archis(self):
     rel = os.path.join("arithmetic", "include", "nt2", "toolbox",
                        "arithmetic", "function")
     return [
         s for s in Nt2_archis_struct.get_supported_archis_tags()
         if exist(os.path.join(self.get_toolboxes_path(), rel, s))
     ]
예제 #3
0
 def __str__(self):
     r = "nt2 is situated at %s" % self.get_nt2_path()
     r += "\ntoolboxes are in %s" % self.get_toolboxes_path()
     r += "\nsupported simd archis are %s " % str(Nt2_archis_struct.get_supported_archis_tags())
     r += "\nimplanted simd archis are %s " % self.get_implanted_simd_archis()
     r += "\nimplanted scalar archis are %s " % self.get_implanted_scalar_archis()
     r += "\nimplanted archis are %s " % self.get_implanted_archis()
     r += "\ntoolboxes list is"
     for t in self.get_toolbox_list():
         r += "\n  " + t
     r += "\ncurrent <<signature>> is %s " % self.get_author()
     return r
예제 #4
0
 def __str__(self):
     r = "nt2 is situated at %s" % self.get_nt2_path()
     r += "\ntoolboxes are in %s" % self.get_toolboxes_path()
     r += "\nsupported simd archis are %s " % str(
         Nt2_archis_struct.get_supported_archis_tags())
     r += "\nimplanted simd archis are %s " % self.get_implanted_simd_archis(
     )
     r += "\nimplanted scalar archis are %s " % self.get_implanted_scalar_archis(
     )
     r += "\nimplanted archis are %s " % self.get_implanted_archis()
     r += "\ntoolboxes list is"
     for t in self.get_toolbox_list():
         r += "\n  " + t
     r += "\ncurrent <<signature>> is %s " % self.get_author()
     return r
예제 #5
0
파일: add_functor.py 프로젝트: pesterie/nt2
 def gen_simd(self, fil, option="create"):
     """ auxilliary of create_function
     create the functor skel file for the common version
     and the cascade include files for each simd variants
     with the functor name at the proper spots
     """
     path = os.path.join(self.get_tb_path(), fil)
     ##        print(path)
     ##        print("---------")
     ##        print("gen_simd")
     ##        print("---------")
     l = fil.split('/')
     if l[2] == 'common':
         arity = self.fct_dict[0]["functor"]["arity"]
         a = int(arity)
         sys = self.get_tb_style()
         name = self.get_fct_name()
         txt = [
             "#include <nt2/sdk/meta/as_real.hpp>",
             "",
             "/////////////////////////////////////////////////////////////////////////////",
             "// Implementation when type A0 is arithmetic_",
             "/////////////////////////////////////////////////////////////////////////////",
             "NT2_REGISTER_DISPATCH(tag::%s_, tag::cpu_," % name,
             "                       (A0)(X),",
             "                       %s" % self.strlist(
                 '((simd_<arithmetic_<A0>,X>))', sep='', n=0, arity=a),
             "                      );",
             "",
             "namespace nt2 { namespace ext",
             "{",
             "  template<class X, class Dummy>",
             "  struct call<tag::%s_(%s)," %
             (name,
              self.strlist(
                  'tag::simd_<tag::arithmetic_, X>', n=0, sep=',',
                  arity=a)),
             "              tag::cpu_, Dummy> : callable",
             "  {",
             "    template<class Sig> struct result;",
             "    template<class This,%s>" %
             self.strlist('class A%d', sep=',', arity=a),
             "    struct result<This(%s)> : meta::as_real<A0>{};" %
             self.strlist('A%d', sep=',', arity=a),
             "",
             "    NT2_FUNCTOR_CALL(%s)" % arity,
             "    {",
             "      typedef typename NT2_RETURN_TYPE(%s)::type type;" %
             arity,
             "      // CODE HERE",
             "      return WHATEVER",
             "    }",
             "  };",
             "} }",
             "",
         ]
     else:
         arch = Nt2_archis_struct.get_archi(l[2])
         rppath = Nt2_archis_struct.get_archi(
             l[2]).get_previous_path(l[2] + '/' + l[3])
         ##            print("path %s"%(l[2]+'/'+l[3]))
         ##            print("prev %s"%rppath)
         txt = [
             "#include <nt2/toolbox/%s/function/simd/%s/%s.hpp>" %
             (self.get_tb_name(), rppath, self.get_fct_name())
         ]
     new_txt = Headers(self.get_nt2_rel_tb_path(self.get_tb_name()) +
                       fil[:-4],
                       "",
                       inner=txt).txt()
     self.finalize(path, new_txt, option)
예제 #6
0
 def __find_implanted_scalar_archis(self):
     return [
         s
         for s in Nt2_archis_struct.get_supported_archis_tags()
         if exist(os.path.join(self.get_toolboxes_path(), "arithmetic/function/", s))
     ]
예제 #7
0
 def __find_implanted_scalar_archis(self) :
     rel= os.path.join("arithmetic","include","nt2","toolbox","arithmetic","function")
     return [s for s in  Nt2_archis_struct.get_supported_archis_tags()
             if exist(os.path.join(self.get_toolboxes_path(),rel,s))
             ]