ViennaCL - The Vienna Computing Library: viennacl/scheduler/execute_generic_dispatcher.hpp Source File

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"
29 #include "viennacl/scheduler/forwards.h"
30 #include "viennacl/scheduler/execute_util.hpp"
31 #include "viennacl/scheduler/execute_scalar_dispatcher.hpp"
32 #include "viennacl/scheduler/execute_vector_dispatcher.hpp"
33 #include "viennacl/scheduler/execute_matrix_dispatcher.hpp"
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>
67 void axbx(lhs_rhs_element & x1,
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>
99 void axbx_x(lhs_rhs_element & x1,
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
execute_vector_dispatcher.hpp
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.
viennacl::scheduler::detail::asbs
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.
Definition: execute_scalar_dispatcher.hpp:68
viennacl::scheduler::detail::ambm
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.
Definition: execute_matrix_dispatcher.hpp:73
execute_matrix_dispatcher.hpp
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.
viennacl::scheduler::detail::as
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.
Definition: execute_scalar_dispatcher.hpp:42
viennacl::scheduler::MATRIX_TYPE_FAMILY
Definition: forwards.h:260
viennacl::scheduler::SCALAR_TYPE_FAMILY
Definition: forwards.h:254
forwards.h
This file provides the forward declarations for the main types used within ViennaCL.
viennacl::scheduler::lhs_rhs_element::type_family
statement_node_type_family type_family
Definition: forwards.h:339
viennacl::scheduler::lhs_rhs_element
A class representing the 'data' for the LHS or RHS operand of the respective node.
Definition: forwards.h:337
viennacl::scheduler::detail::asbs_s
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.
Definition: execute_scalar_dispatcher.hpp:98
viennacl::scheduler::detail::am
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.
Definition: execute_matrix_dispatcher.hpp:42
viennacl::scheduler::detail::avbv
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.
Definition: execute_vector_dispatcher.hpp:68
viennacl::scheduler::detail::axbx
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.
Definition: execute_generic_dispatcher.hpp:67
viennacl::scheduler::detail::ambm_m
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.
Definition: execute_matrix_dispatcher.hpp:114
viennacl::vcl_size_t
std::size_t vcl_size_t
Definition: forwards.h:75
viennacl::scheduler::detail::avbv_v
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.
Definition: execute_vector_dispatcher.hpp:98
forwards.h
Provides the datastructures for dealing with a single statement such as 'x = y + z;'.
viennacl::scheduler::detail::ax
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.
Definition: execute_generic_dispatcher.hpp:44
viennacl::scheduler::detail::av
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.
Definition: execute_vector_dispatcher.hpp:42
execute_scalar_dispatcher.hpp
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.
viennacl::scheduler::VECTOR_TYPE_FAMILY
Definition: forwards.h:257
execute_util.hpp
Provides various utilities for implementing the execution of statements.
viennacl::scheduler::detail::axbx_x
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.
Definition: execute_generic_dispatcher.hpp:99
viennacl::scheduler::statement_not_supported_exception
Exception for the case the scheduler is unable to deal with the operation.
Definition: forwards.h:38