inline std::string neutral_element(scheduler::op_element const & op){
   switch(op.type){
     case scheduler::OPERATION_BINARY_ADD_TYPE : return "0";
     case scheduler::OPERATION_BINARY_MULT_TYPE : return "1";
     case scheduler::OPERATION_BINARY_DIV_TYPE : return "1";
     case scheduler::OPERATION_BINARY_ELEMENT_FMAX_TYPE : return "-INFINITY";
     case scheduler::OPERATION_BINARY_ELEMENT_FMIN_TYPE : return "INFINITY";
     default: throw generator_not_supported_exception("Unsupported reduction operator : no neutral element known");
   }
 }
Exemple #2
0
 static std::string numeric_type_to_string(scheduler::statement_node_numeric_type const & type){
     switch(type){
         case scheduler::FLOAT_TYPE :
             return "float";
         case scheduler::DOUBLE_TYPE :
             return  "double";
         default :
             throw generator_not_supported_exception("Unsupported Scalartype");
     }
 }
Exemple #3
0
 static typename Fun::result_type call_on_vector(scheduler::lhs_rhs_element element, Fun const & fun){
     assert(element.type_family == scheduler::VECTOR_TYPE_FAMILY && bool("Must be called on a vector"));
     switch(element.numeric_type){
     case scheduler::FLOAT_TYPE :
         return fun(*element.vector_float);
     case scheduler::DOUBLE_TYPE :
         return fun(*element.vector_double);
     default :
         throw generator_not_supported_exception("Unsupported Scalartype");
     }
 }
Exemple #4
0
 static typename Fun::result_type call_on_implicit_matrix(scheduler::lhs_rhs_element element, Fun const & fun){
     assert(element.type_family == scheduler::MATRIX_TYPE_FAMILY   && bool("Must be called on a matrix_vector"));
     assert(element.subtype     == scheduler::IMPLICIT_MATRIX_TYPE && bool("Must be called on a matrix_vector"));
     switch(element.numeric_type){
     case scheduler::FLOAT_TYPE :
         return fun(*element.implicit_matrix_float);
     case scheduler::DOUBLE_TYPE :
         return fun(*element.implicit_matrix_double);
     default :
         throw generator_not_supported_exception("Unsupported Scalartype");
     }
 }
 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());
 }
Exemple #6
0
 static typename Fun::result_type call_on_element(scheduler::lhs_rhs_element const & element, Fun const & fun){
   switch(element.type_family){
     case scheduler::SCALAR_TYPE_FAMILY:
       if (element.subtype == scheduler::HOST_SCALAR_TYPE)
         return call_on_host_scalar(element, fun);
       else
         return call_on_scalar(element, fun);
     case scheduler::VECTOR_TYPE_FAMILY :
       if (element.subtype == scheduler::IMPLICIT_VECTOR_TYPE)
         return call_on_implicit_vector(element, fun);
       else
         return call_on_vector(element, fun);
     case scheduler::MATRIX_TYPE_FAMILY:
       if (element.subtype == scheduler::IMPLICIT_MATRIX_TYPE)
         return call_on_implicit_matrix(element, fun);
       else
         return call_on_matrix(element,fun);
     default:
       throw generator_not_supported_exception("Unsupported datastructure type : Not among {Scalar, Vector, Matrix}");
   }
 }