ViennaCL - The Vienna Computing Library  1.7.1
Free open-source GPU-accelerated linear algebra and solver library.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
execute_generic_dispatcher.hpp
Go to the documentation of this file.
1 #ifndef VIENNACL_SCHEDULER_EXECUTE_GENERIC_DISPATCHER_HPP
2 #define VIENNACL_SCHEDULER_EXECUTE_GENERIC_DISPATCHER_HPP
3 
4 /* =========================================================================
5  Copyright (c) 2010-2016, Institute for Microelectronics,
6  Institute for Analysis and Scientific Computing,
7  TU Wien.
8  Portions of this software are copyright by UChicago Argonne, LLC.
9 
10  -----------------
11  ViennaCL - The Vienna Computing Library
12  -----------------
13 
14  Project Head: Karl Rupp rupp@iue.tuwien.ac.at
15 
16  (A list of authors and contributors can be found in the manual)
17 
18  License: MIT (X11), see file LICENSE in the base directory
19 ============================================================================= */
20 
21 
26 #include <assert.h>
27 
28 #include "viennacl/forwards.h"
34 
35 namespace viennacl
36 {
37 namespace scheduler
38 {
39 namespace detail
40 {
41 
43 template<typename ScalarType1>
44 void ax(lhs_rhs_element & x1,
45  lhs_rhs_element const & x2, ScalarType1 const & alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha)
46 {
47  assert(x1.type_family == x2.type_family && bool("Arguments are not of the same type family!"));
48 
49  switch (x1.type_family)
50  {
51  case SCALAR_TYPE_FAMILY:
52  detail::as(x1, x2, alpha, len_alpha, reciprocal_alpha, flip_sign_alpha);
53  break;
54  case VECTOR_TYPE_FAMILY:
55  detail::av(x1, x2, alpha, len_alpha, reciprocal_alpha, flip_sign_alpha);
56  break;
57  case MATRIX_TYPE_FAMILY:
58  detail::am(x1, x2, alpha, len_alpha, reciprocal_alpha, flip_sign_alpha);
59  break;
60  default:
61  throw statement_not_supported_exception("Invalid argument in scheduler ax() while dispatching.");
62  }
63 }
64 
66 template<typename ScalarType1, typename ScalarType2>
68  lhs_rhs_element const & x2, ScalarType1 const & alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha,
69  lhs_rhs_element const & x3, ScalarType2 const & beta, vcl_size_t len_beta, bool reciprocal_beta, bool flip_sign_beta)
70 {
71  assert( x1.type_family == x2.type_family
72  && x2.type_family == x3.type_family
73  && bool("Arguments are not of the same type family!"));
74 
75  switch (x1.type_family)
76  {
77  case SCALAR_TYPE_FAMILY:
78  detail::asbs(x1,
79  x2, alpha, len_alpha, reciprocal_alpha, flip_sign_alpha,
80  x3, beta, len_beta, reciprocal_beta, flip_sign_beta);
81  break;
82  case VECTOR_TYPE_FAMILY:
83  detail::avbv(x1,
84  x2, alpha, len_alpha, reciprocal_alpha, flip_sign_alpha,
85  x3, beta, len_beta, reciprocal_beta, flip_sign_beta);
86  break;
87  case MATRIX_TYPE_FAMILY:
88  detail::ambm(x1,
89  x2, alpha, len_alpha, reciprocal_alpha, flip_sign_alpha,
90  x3, beta, len_beta, reciprocal_beta, flip_sign_beta);
91  break;
92  default:
93  throw statement_not_supported_exception("Invalid argument in scheduler ax() while dispatching.");
94  }
95 }
96 
98 template<typename ScalarType1, typename ScalarType2>
100  lhs_rhs_element const & x2, ScalarType1 const & alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha,
101  lhs_rhs_element const & x3, ScalarType2 const & beta, vcl_size_t len_beta, bool reciprocal_beta, bool flip_sign_beta)
102 {
103  assert( x1.type_family == x2.type_family
104  && x2.type_family == x3.type_family
105  && bool("Arguments are not of the same type family!"));
106 
107  switch (x1.type_family)
108  {
109  case SCALAR_TYPE_FAMILY:
110  detail::asbs_s(x1,
111  x2, alpha, len_alpha, reciprocal_alpha, flip_sign_alpha,
112  x3, beta, len_beta, reciprocal_beta, flip_sign_beta);
113  break;
114  case VECTOR_TYPE_FAMILY:
115  detail::avbv_v(x1,
116  x2, alpha, len_alpha, reciprocal_alpha, flip_sign_alpha,
117  x3, beta, len_beta, reciprocal_beta, flip_sign_beta);
118  break;
119  case MATRIX_TYPE_FAMILY:
120  detail::ambm_m(x1,
121  x2, alpha, len_alpha, reciprocal_alpha, flip_sign_alpha,
122  x3, beta, len_beta, reciprocal_beta, flip_sign_beta);
123  break;
124  default:
125  throw statement_not_supported_exception("Invalid argument in scheduler ax() while dispatching.");
126  }
127 }
128 
129 } // namespace detail
130 } // namespace scheduler
131 } // namespace viennacl
132 
133 #endif
134 
Provides wrappers for av(), avbv(), avbv_v(), etc. in viennacl/linalg/vector_operations.hpp such that scheduler logic is not cluttered with numeric type decutions.
void asbs(lhs_rhs_element &s1, lhs_rhs_element const &s2, ScalarType1 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha, lhs_rhs_element const &s3, ScalarType2 const &beta, vcl_size_t len_beta, bool reciprocal_beta, bool flip_sign_beta)
Wrapper for viennacl::linalg::avbv(), taking care of the argument unwrapping.
void ambm(lhs_rhs_element &mat1, lhs_rhs_element const &mat2, ScalarType1 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha, lhs_rhs_element const &mat3, ScalarType2 const &beta, vcl_size_t len_beta, bool reciprocal_beta, bool flip_sign_beta)
Wrapper for viennacl::linalg::avbv(), taking care of the argument unwrapping.
Provides wrappers for am(), ambm(), ambm_m(), etc. in viennacl/linalg/matrix_operations.hpp such that scheduler logic is not cluttered with numeric type decutions.
void as(lhs_rhs_element &s1, lhs_rhs_element const &s2, ScalarType1 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha)
Wrapper for viennacl::linalg::av(), taking care of the argument unwrapping.
This file provides the forward declarations for the main types used within ViennaCL.
statement_node_type_family type_family
Definition: forwards.h:339
A class representing the 'data' for the LHS or RHS operand of the respective node.
Definition: forwards.h:337
void asbs_s(lhs_rhs_element &s1, lhs_rhs_element const &s2, ScalarType1 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha, lhs_rhs_element const &s3, ScalarType2 const &beta, vcl_size_t len_beta, bool reciprocal_beta, bool flip_sign_beta)
Wrapper for viennacl::linalg::avbv_v(), taking care of the argument unwrapping.
void am(lhs_rhs_element &mat1, lhs_rhs_element const &mat2, ScalarType1 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha)
Wrapper for viennacl::linalg::av(), taking care of the argument unwrapping.
void avbv(lhs_rhs_element &vec1, lhs_rhs_element const &vec2, ScalarType1 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha, lhs_rhs_element const &vec3, ScalarType2 const &beta, vcl_size_t len_beta, bool reciprocal_beta, bool flip_sign_beta)
Wrapper for viennacl::linalg::avbv(), taking care of the argument unwrapping.
void axbx(lhs_rhs_element &x1, lhs_rhs_element const &x2, ScalarType1 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha, lhs_rhs_element const &x3, ScalarType2 const &beta, vcl_size_t len_beta, bool reciprocal_beta, bool flip_sign_beta)
Wrapper for viennacl::linalg::avbv(), taking care of the argument unwrapping.
void ambm_m(lhs_rhs_element &mat1, lhs_rhs_element const &mat2, ScalarType1 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha, lhs_rhs_element const &mat3, ScalarType2 const &beta, vcl_size_t len_beta, bool reciprocal_beta, bool flip_sign_beta)
Wrapper for viennacl::linalg::avbv_v(), taking care of the argument unwrapping.
std::size_t vcl_size_t
Definition: forwards.h:75
void avbv_v(lhs_rhs_element &vec1, lhs_rhs_element const &vec2, ScalarType1 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha, lhs_rhs_element const &vec3, ScalarType2 const &beta, vcl_size_t len_beta, bool reciprocal_beta, bool flip_sign_beta)
Wrapper for viennacl::linalg::avbv_v(), taking care of the argument unwrapping.
Provides the datastructures for dealing with a single statement such as 'x = y + z;'.
void ax(lhs_rhs_element &x1, lhs_rhs_element const &x2, ScalarType1 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha)
Wrapper for viennacl::linalg::av(), taking care of the argument unwrapping.
void av(lhs_rhs_element &vec1, lhs_rhs_element const &vec2, ScalarType1 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha)
Wrapper for viennacl::linalg::av(), taking care of the argument unwrapping.
Provides wrappers for as(), asbs(), asbs_s(), etc. in viennacl/linalg/scalar_operations.hpp such that scheduler logic is not cluttered with numeric type decutions.
Provides various utilities for implementing the execution of statements.
void axbx_x(lhs_rhs_element &x1, lhs_rhs_element const &x2, ScalarType1 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha, lhs_rhs_element const &x3, ScalarType2 const &beta, vcl_size_t len_beta, bool reciprocal_beta, bool flip_sign_beta)
Wrapper for viennacl::linalg::avbv_v(), taking care of the argument unwrapping.
Exception for the case the scheduler is unable to deal with the operation.
Definition: forwards.h:38