コード例 #1
0
ファイル: traverse.hpp プロジェクト: GnsP/viennacl-dev
      static void traverse(scheduler::statement const & statement, scheduler::statement_node const & root_node, Fun const & fun, bool recurse_structurewise_function /* see forwards.h for default argument */){
        bool recurse = recurse_structurewise_function || root_node.op.type_subfamily!=scheduler::OPERATION_FUNCTION_TYPE_SUBFAMILY;

        fun.call_before_expansion(&root_node);

        //Lhs:
        if(recurse){
          if(root_node.lhs.type_family==scheduler::COMPOSITE_OPERATION_FAMILY)
            traverse(statement, statement.array()[root_node.lhs.node_index], fun, recurse_structurewise_function);
          if(root_node.lhs.type_family != scheduler::INVALID_TYPE_FAMILY)
            fun(&statement, &root_node, LHS_NODE_TYPE);
        }

        //Self:
        fun(&statement, &root_node, PARENT_NODE_TYPE);

        //Rhs:
        if(recurse){
          if(root_node.rhs.type_family==scheduler::COMPOSITE_OPERATION_FAMILY)
            traverse(statement, statement.array()[root_node.rhs.node_index], fun, recurse_structurewise_function);
          if(root_node.rhs.type_family != scheduler::INVALID_TYPE_FAMILY)
            fun(&statement, &root_node, RHS_NODE_TYPE);
        }

        fun.call_after_expansion(&root_node);


      }
コード例 #2
0
 vcl_size_t get_vector_size(scheduler::statement const & statement) const
 {
   scheduler::statement_node const & root = statement.array()[statement.root()];
   if(root.lhs.type_family==scheduler::COMPOSITE_OPERATION_FAMILY)
   {
     scheduler::statement_node lhs = statement.array()[root.lhs.node_index];
     if(lhs.op.type==scheduler::OPERATION_BINARY_MATRIX_DIAG_TYPE)
     {
       vcl_size_t size1 = up_to_internal_size_?utils::call_on_matrix(lhs.lhs, utils::internal_size1_fun()): utils::call_on_matrix(lhs.lhs, utils::size1_fun());
       vcl_size_t size2 = up_to_internal_size_?utils::call_on_matrix(lhs.lhs, utils::internal_size2_fun()): utils::call_on_matrix(lhs.lhs, utils::size2_fun());
       return std::min(size1, size2);
     }
     throw generator_not_supported_exception("Vector AXPY : Unimplemented LHS size deduction");
   }
   return up_to_internal_size_?utils::call_on_vector(root.lhs, utils::internal_size_fun()): utils::call_on_vector(root.lhs, utils::size_fun());
 }