1 #ifndef VIENNACL_SCHEDULER_EXECUTE_MATRIX_PROD_HPP
2 #define VIENNACL_SCHEDULER_EXECUTE_MATRIX_PROD_HPP
69 #define VIENNACL_SCHEDULER_GENERATE_MATRIX_MATRIX_PROD(LAYOUTA, MEMBERA, LAYOUTB, MEMBERB, LAYOUTC, MEMBERC)\
70 if (A.subtype == LAYOUTA && B.subtype == LAYOUTB && result.subtype == LAYOUTC)\
72 switch (result.numeric_type)\
75 viennacl::linalg::prod_impl(*A.matrix_##MEMBERA##_float, *B.matrix_##MEMBERB##_float, *result.matrix_##MEMBERC##_float, static_cast<float>(alpha), static_cast<float>(beta)); break;\
77 viennacl::linalg::prod_impl(*A.matrix_##MEMBERA##_double, *B.matrix_##MEMBERB##_double, *result.matrix_##MEMBERC##_double, alpha, beta); break;\
79 throw statement_not_supported_exception("Invalid numeric type in matrix-matrix multiplication");\
95 #undef VIENNACL_SCHEDULER_GENERATE_MATRIX_MATRIX_PROD
105 #define VIENNACL_SCHEDULER_GENERATE_MATRIX_MATRIX_PROD(LAYOUTA, MEMBERA, LAYOUTB, MEMBERB, MAJORB, LAYOUTC, MEMBERC)\
106 if (A.subtype == LAYOUTA && leaf.lhs.subtype == LAYOUTB && result.subtype == LAYOUTC)\
108 switch (result.numeric_type)\
111 viennacl::linalg::prod_impl(*A.matrix_##MEMBERA##_float, \
112 viennacl::matrix_expression< const matrix_base<float, MAJORB>,\
113 const matrix_base<float, MAJORB>,\
114 op_trans> (*(leaf.lhs.matrix_##MEMBERB##_float), *(leaf.lhs.matrix_##MEMBERB##_float)), \
115 *result.matrix_##MEMBERC##_float, static_cast<float>(alpha), static_cast<float>(beta)); break;\
117 viennacl::linalg::prod_impl(*A.matrix_##MEMBERA##_double,\
118 viennacl::matrix_expression< const matrix_base<double, MAJORB>,\
119 const matrix_base<double, MAJORB>,\
120 op_trans>(*(leaf.lhs.matrix_##MEMBERB##_double), *(leaf.lhs.matrix_##MEMBERB##_double)), \
121 *result.matrix_##MEMBERC##_double, alpha, beta); break;\
123 throw statement_not_supported_exception("Invalid numeric type in matrix-matrix multiplication");\
139 #undef VIENNACL_SCHEDULER_GENERATE_MATRIX_MATRIX_PROD
149 #define VIENNACL_SCHEDULER_GENERATE_MATRIX_MATRIX_PROD(LAYOUTA, MEMBERA, MAJORA, LAYOUTB, MEMBERB, LAYOUTC, MEMBERC)\
150 if (leaf.lhs.subtype == LAYOUTA && B.subtype == LAYOUTB && result.subtype == LAYOUTC)\
152 switch (result.numeric_type)\
155 viennacl::linalg::prod_impl(viennacl::matrix_expression< const matrix_base<float, MAJORA>,\
156 const matrix_base<float, MAJORA>,\
157 op_trans>(*leaf.lhs.matrix_##MEMBERA##_float, *leaf.lhs.matrix_##MEMBERA##_float), \
158 *B.matrix_##MEMBERB##_float,\
159 *result.matrix_##MEMBERC##_float, static_cast<float>(alpha), static_cast<float>(beta)); break;\
161 viennacl::linalg::prod_impl(viennacl::matrix_expression< const matrix_base<double, MAJORA>,\
162 const matrix_base<double, MAJORA>,\
163 op_trans>(*leaf.lhs.matrix_##MEMBERA##_double, *leaf.lhs.matrix_##MEMBERA##_double), \
164 *B.matrix_##MEMBERB##_double,\
165 *result.matrix_##MEMBERC##_double, alpha, beta); break;\
167 throw statement_not_supported_exception("Invalid numeric type in matrix-matrix multiplication");\
183 #undef VIENNACL_SCHEDULER_GENERATE_MATRIX_MATRIX_PROD
195 #define VIENNACL_SCHEDULER_GENERATE_MATRIX_MATRIX_PROD(LAYOUTA, MEMBERA, MAJORA, LAYOUTB, MEMBERB, MAJORB, LAYOUTC, MEMBERC)\
196 if (leafA.lhs.subtype == LAYOUTA && leafB.lhs.subtype == LAYOUTB && result.subtype == LAYOUTC)\
198 switch (result.numeric_type)\
201 viennacl::linalg::prod_impl(viennacl::matrix_expression< const matrix_base<float, MAJORA>,\
202 const matrix_base<float, MAJORA>,\
203 op_trans>(*leafA.lhs.matrix_##MEMBERA##_float, *leafA.lhs.matrix_##MEMBERA##_float), \
204 viennacl::matrix_expression< const matrix_base<float, MAJORB>,\
205 const matrix_base<float, MAJORB>,\
206 op_trans>(*leafB.lhs.matrix_##MEMBERB##_float, *leafB.lhs.matrix_##MEMBERB##_float), \
207 *result.matrix_##MEMBERC##_float, static_cast<float>(alpha), static_cast<float>(beta)); break;\
209 viennacl::linalg::prod_impl(viennacl::matrix_expression< const matrix_base<double, MAJORA>,\
210 const matrix_base<double, MAJORA>,\
211 op_trans>(*leafA.lhs.matrix_##MEMBERA##_double, *leafA.lhs.matrix_##MEMBERA##_double), \
212 viennacl::matrix_expression< const matrix_base<double, MAJORB>,\
213 const matrix_base<double, MAJORB>,\
214 op_trans>(*leafB.lhs.matrix_##MEMBERB##_double, *leafB.lhs.matrix_##MEMBERB##_double), \
215 *result.matrix_##MEMBERC##_double, alpha, beta); break;\
217 throw statement_not_supported_exception("Invalid numeric type in matrix-matrix multiplication");\
233 #undef VIENNACL_SCHEDULER_GENERATE_MATRIX_MATRIX_PROD
386 std::cout <<
"A.subtype: " << A.
subtype << std::endl;
406 if (lhs_needs_temporary)
408 std::cout <<
"Temporary for LHS!" << std::endl;
425 if (rhs_needs_temporary)
469 y, 1.0, 1,
false,
false,
470 new_root_z.
lhs, alpha, 1,
false,
false);
487 if (lhs_needs_temporary)
490 if (rhs_needs_temporary)
statement_node_subtype subtype
Definition: forwards.h:270
viennacl::hyb_matrix< float > * hyb_matrix_float
Definition: forwards.h:406
viennacl::matrix_base< float > * matrix_row_float
Definition: forwards.h:339
#define VIENNACL_SCHEDULER_GENERATE_MATRIX_MATRIX_PROD(LAYOUTA, MEMBERA, LAYOUTB, MEMBERB, LAYOUTC, MEMBERC)
Definition: forwards.h:83
Definition: forwards.h:182
Implementations of dense matrix related operations including matrix-vector products.
vcl_size_t node_index
Definition: forwards.h:276
void new_element(lhs_rhs_element &new_elem, lhs_rhs_element const &old_element)
Definition: execute_util.hpp:102
void execute_matrix_prod(statement const &s, statement_node const &root_node)
Definition: execute_matrix_prod.hpp:393
Implementations of vector operations.
lhs_rhs_element lhs
Definition: forwards.h:422
Definition: forwards.h:176
Definition: forwards.h:217
Definition: forwards.h:196
viennacl::coordinate_matrix< float > * coordinate_matrix_float
Definition: forwards.h:384
Definition: forwards.h:190
This file provides the forward declarations for the main types used within ViennaCL.
void matrix_vector_prod(statement const &s, lhs_rhs_element result, lhs_rhs_element const &A, lhs_rhs_element const &x)
Definition: execute_matrix_prod.hpp:239
A class representing the 'data' for the LHS or RHS operand of the respective node.
Definition: forwards.h:267
operation_node_type_family type_family
Definition: forwards.h:415
viennacl::compressed_matrix< double > * compressed_matrix_double
Definition: forwards.h:374
Provides unified wrappers for the common routines {as(), asbs(), asbs_s()}, {av(), avbv(), avbv_v()}, and {am(), ambm(), ambm_m()} such that scheduler logic is not cluttered with numeric type decutions.
lhs_rhs_element rhs
Definition: forwards.h:424
Implementation of the coordinate_matrix class.
viennacl::matrix_base< float, viennacl::column_major > * matrix_col_float
Definition: forwards.h:351
void delete_element(lhs_rhs_element &elem)
Definition: execute_util.hpp:179
A dense matrix class.
Definition: forwards.h:290
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
Definition: cpu_ram.hpp:29
Definition: forwards.h:197
viennacl::matrix_base< double, viennacl::column_major > * matrix_col_double
Definition: forwards.h:352
viennacl::vector_base< float > * vector_float
Definition: forwards.h:315
Implementation of the hyb_matrix class.
statement_node_numeric_type numeric_type
Definition: forwards.h:271
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::coordinate_matrix< double > * coordinate_matrix_double
Definition: forwards.h:385
viennacl::vector_base< double > * vector_double
Definition: forwards.h:316
Definition: forwards.h:92
Implementation of the compressed_matrix class.
Implementations of operations using sparse matrices.
Definition: forwards.h:173
Definition: forwards.h:205
Implementation of the ell_matrix class.
Expression template class for representing a tree of expressions which ultimately result in a matrix...
Definition: forwards.h:283
Provides the datastructures for dealing with a single statement such as 'x = y + z;'.
viennacl::compressed_matrix< float > * compressed_matrix_float
Definition: forwards.h:373
Definition: forwards.h:194
vector_expression< const matrix_base< NumericT, F >, const unsigned int, op_row > row(const matrix_base< NumericT, F > &A, unsigned int i)
Definition: matrix.hpp:910
Definition: forwards.h:90
container_type const & array() const
Definition: forwards.h:473
void execute_composite(statement const &s, statement_node const &root_node)
Deals with x = RHS where RHS is an expression and x is either a scalar, a vector, or a matrix...
Definition: execute.hpp:41
A tag class representing transposed matrices.
Definition: forwards.h:165
viennacl::matrix_base< double > * matrix_row_double
Definition: forwards.h:340
A tag for column-major storage of a dense matrix.
Definition: forwards.h:263
statement_node_type_family type_family
Definition: forwards.h:269
void prod_impl(const matrix_base< NumericT, F > &mat, const vector_base< NumericT > &vec, vector_base< NumericT > &result)
Carries out matrix-vector multiplication.
Definition: matrix_operations.hpp:350
The main class for representing a statement such as x = inner_prod(y,z); at runtime.
Definition: forwards.h:447
void matrix_matrix_prod(statement const &s, lhs_rhs_element result, lhs_rhs_element const &A, lhs_rhs_element const &B, double alpha, double beta)
Definition: execute_matrix_prod.hpp:57
viennacl::ell_matrix< float > * ell_matrix_float
Definition: forwards.h:395
Definition: forwards.h:57
viennacl::ell_matrix< double > * ell_matrix_double
Definition: forwards.h:396
Definition: forwards.h:187
op_element op
Definition: forwards.h:423
A tag for row-major storage of a dense matrix.
Definition: forwards.h:246
bool matrix_prod_temporary_required(statement const &s, lhs_rhs_element const &elem)
Definition: execute_matrix_prod.hpp:44
Definition: forwards.h:216
Definition: forwards.h:91
Provides various utilities for implementing the execution of statements.
Main datastructure for an node in the statement tree.
Definition: forwards.h:420
Exception for the case the scheduler is unable to deal with the operation.
Definition: forwards.h:36
Definition: forwards.h:195
operation_node_type type
Definition: forwards.h:416
Definition: forwards.h:191
viennacl::hyb_matrix< double > * hyb_matrix_double
Definition: forwards.h:407
Definition: forwards.h:167