ViennaCL - The Vienna Computing Library  1.5.0
viennacl/scheduler/execute_generic_dispatcher.hpp
Go to the documentation of this file.
00001 #ifndef VIENNACL_SCHEDULER_EXECUTE_GENERIC_DISPATCHER_HPP
00002 #define VIENNACL_SCHEDULER_EXECUTE_GENERIC_DISPATCHER_HPP
00003 
00004 /* =========================================================================
00005    Copyright (c) 2010-2013, Institute for Microelectronics,
00006                             Institute for Analysis and Scientific Computing,
00007                             TU Wien.
00008    Portions of this software are copyright by UChicago Argonne, LLC.
00009 
00010                             -----------------
00011                   ViennaCL - The Vienna Computing Library
00012                             -----------------
00013 
00014    Project Head:    Karl Rupp                   rupp@iue.tuwien.ac.at
00015 
00016    (A list of authors and contributors can be found in the PDF manual)
00017 
00018    License:         MIT (X11), see file LICENSE in the base directory
00019 ============================================================================= */
00020 
00021 
00026 #include <assert.h>
00027 
00028 #include "viennacl/forwards.h"
00029 #include "viennacl/scheduler/forwards.h"
00030 #include "viennacl/scheduler/execute_util.hpp"
00031 #include "viennacl/scheduler/execute_scalar_dispatcher.hpp"
00032 #include "viennacl/scheduler/execute_vector_dispatcher.hpp"
00033 #include "viennacl/scheduler/execute_matrix_dispatcher.hpp"
00034 
00035 namespace viennacl
00036 {
00037   namespace scheduler
00038   {
00039     namespace detail
00040     {
00041 
00043       template <typename ScalarType1>
00044       void ax(lhs_rhs_element & x1,
00045               lhs_rhs_element const & x2, ScalarType1 const & alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha)
00046       {
00047         assert(x1.type_family == x2.type_family && bool("Arguments are not of the same type family!"));
00048 
00049         switch (x1.type_family)
00050         {
00051         case SCALAR_TYPE_FAMILY:
00052           detail::as(x1, x2, alpha, len_alpha, reciprocal_alpha, flip_sign_alpha);
00053           break;
00054         case VECTOR_TYPE_FAMILY:
00055           detail::av(x1, x2, alpha, len_alpha, reciprocal_alpha, flip_sign_alpha);
00056           break;
00057         case MATRIX_TYPE_FAMILY:
00058           detail::am(x1, x2, alpha, len_alpha, reciprocal_alpha, flip_sign_alpha);
00059           break;
00060         default:
00061           throw statement_not_supported_exception("Invalid argument in scheduler ax() while dispatching.");
00062         }
00063       }
00064 
00066       template <typename ScalarType1, typename ScalarType2>
00067       void axbx(lhs_rhs_element & x1,
00068                 lhs_rhs_element const & x2, ScalarType1 const & alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha,
00069                 lhs_rhs_element const & x3, ScalarType2 const & beta,  vcl_size_t len_beta,  bool reciprocal_beta,  bool flip_sign_beta)
00070       {
00071         assert(   x1.type_family == x2.type_family
00072                && x2.type_family == x3.type_family
00073                && bool("Arguments are not of the same type family!"));
00074 
00075         switch (x1.type_family)
00076         {
00077         case SCALAR_TYPE_FAMILY:
00078           detail::asbs(x1,
00079                        x2, alpha, len_alpha, reciprocal_alpha, flip_sign_alpha,
00080                        x3, beta,  len_beta,  reciprocal_beta,  flip_sign_beta);
00081           break;
00082         case VECTOR_TYPE_FAMILY:
00083             detail::avbv(x1,
00084                          x2, alpha, len_alpha, reciprocal_alpha, flip_sign_alpha,
00085                          x3, beta,  len_beta,  reciprocal_beta,  flip_sign_beta);
00086           break;
00087         case MATRIX_TYPE_FAMILY:
00088             detail::ambm(x1,
00089                          x2, alpha, len_alpha, reciprocal_alpha, flip_sign_alpha,
00090                          x3, beta,  len_beta,  reciprocal_beta,  flip_sign_beta);
00091           break;
00092         default:
00093           throw statement_not_supported_exception("Invalid argument in scheduler ax() while dispatching.");
00094         }
00095       }
00096 
00098       template <typename ScalarType1, typename ScalarType2>
00099       void axbx_x(lhs_rhs_element & x1,
00100                   lhs_rhs_element const & x2, ScalarType1 const & alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha,
00101                   lhs_rhs_element const & x3, ScalarType2 const & beta,  vcl_size_t len_beta,  bool reciprocal_beta,  bool flip_sign_beta)
00102       {
00103         assert(   x1.type_family == x2.type_family
00104                && x2.type_family == x3.type_family
00105                && bool("Arguments are not of the same type family!"));
00106 
00107         switch (x1.type_family)
00108         {
00109         case SCALAR_TYPE_FAMILY:
00110           detail::asbs_s(x1,
00111                          x2, alpha, len_alpha, reciprocal_alpha, flip_sign_alpha,
00112                          x3, beta,  len_beta,  reciprocal_beta,  flip_sign_beta);
00113           break;
00114         case VECTOR_TYPE_FAMILY:
00115             detail::avbv_v(x1,
00116                            x2, alpha, len_alpha, reciprocal_alpha, flip_sign_alpha,
00117                            x3, beta,  len_beta,  reciprocal_beta,  flip_sign_beta);
00118           break;
00119         case MATRIX_TYPE_FAMILY:
00120             detail::ambm_m(x1,
00121                            x2, alpha, len_alpha, reciprocal_alpha, flip_sign_alpha,
00122                            x3, beta,  len_beta,  reciprocal_beta,  flip_sign_beta);
00123           break;
00124         default:
00125           throw statement_not_supported_exception("Invalid argument in scheduler ax() while dispatching.");
00126         }
00127       }
00128 
00129 
00130     } // namespace detail
00131   } // namespace scheduler
00132 } // namespace viennacl
00133 
00134 #endif
00135