1 #ifndef VIENNACL_SCHEDULER_STATEMENT_HPP
2 #define VIENNACL_SCHEDULER_STATEMENT_HPP
42 statement_not_supported_exception(std::string message) : message_(
"ViennaCL: Internal error: The scheduler encountered a problem with the operation provided: " + message) {}
44 virtual const char*
what()
const throw() {
return message_.c_str(); }
317 template<>
struct numeric_type_id<unsigned char> {
enum { value =
UCHAR_TYPE }; };
318 template<>
struct numeric_type_id<short> {
enum { value =
SHORT_TYPE }; };
319 template<>
struct numeric_type_id<unsigned short> {
enum { value =
USHORT_TYPE }; };
320 template<>
struct numeric_type_id<int> {
enum { value =
INT_TYPE }; };
321 template<>
struct numeric_type_id<unsigned int> {
enum { value =
UINT_TYPE }; };
322 template<>
struct numeric_type_id<long> {
enum { value =
LONG_TYPE }; };
323 template<>
struct numeric_type_id<unsigned long> {
enum { value =
ULONG_TYPE }; };
324 template<>
struct numeric_type_id<float> {
enum { value =
FLOAT_TYPE }; };
325 template<>
struct numeric_type_id<double> {
enum { value =
DOUBLE_TYPE }; };
516 template<
typename LHS,
typename OP,
typename RHS>
517 statement(LHS & lhs, OP
const &, RHS
const & rhs) : array_(1 + result_of::num_nodes<RHS>::value)
746 template<
typename LHS,
typename RHS,
typename OP>
755 return add_node(next_free, next_free + 1, t);
758 template<
typename LHS,
typename RHS,
typename OP>
766 elem.node_index = next_free;
767 return add_node(next_free, next_free + 1, t);
770 template<
typename LHS,
typename RHS,
typename OP>
778 elem.node_index = next_free;
779 return add_node(next_free, next_free + 1, t);
788 return add_element(next_free, array_[current_index].lhs, t);
794 return add_element(next_free, array_[current_index].rhs, t);
799 template<
template<
typename,
typename,
typename>
class ExpressionT,
typename LHS,
typename RHS,
typename OP>
813 return add_lhs(current_index, next_free, proxy.lhs());
816 return add_rhs(current_index, add_lhs(current_index, next_free, proxy.lhs()), proxy.rhs());
Simple enable-if variant that uses the SFINAE pattern.
static void assign_element(lhs_rhs_element &elem, unsigned short const &t)
A tag class representing multiplication by a scalar.
A tag class representing the cosh() function.
viennacl::implicit_vector_base< float > * implicit_vector_float
A tag class representing equality.
A tag class representing the tan() function.
viennacl::scalar< float > * scalar_float
viennacl::vector_base< unsigned short > * vector_ushort
viennacl::implicit_vector_base< int > * implicit_vector_int
static void assign_element(lhs_rhs_element &elem, viennacl::implicit_vector_base< char > const &t)
static void assign_element(lhs_rhs_element &elem, viennacl::scalar< float > const &t)
viennacl::vector_base< unsigned int > * vector_uint
viennacl::implicit_vector_base< unsigned char > * implicit_vector_uchar
static void assign_element(lhs_rhs_element &elem, viennacl::implicit_vector_base< unsigned char > const &t)
viennacl::matrix_base< short > * matrix_short
A tag class representing less-than.
viennacl::vector_base< short > * vector_short
viennacl::scalar< short > * scalar_short
static void assign_element(lhs_rhs_element &elem, viennacl::matrix_base< short > const &t)
statement_node value_type
statement(LHS &lhs, OP const &, RHS const &rhs)
Generate the runtime statement from an expression template.
viennacl::matrix_base< char > * matrix_char
A tag class representing the extraction of a matrix column to a vector.
viennacl::implicit_matrix_base< unsigned long > * implicit_matrix_ulong
A tag class representing a matrix given by a vector placed on a certain (off-)diagonal.
static void assign_element(lhs_rhs_element &elem, char const &t)
static void assign_element(lhs_rhs_element &elem, double const &t)
A tag class representing subtraction.
static void assign_element(lhs_rhs_element &elem, viennacl::hyb_matrix< float > const &m)
A tag class representing assignment.
static void assign_element(lhs_rhs_element &elem, viennacl::matrix_base< unsigned char > const &t)
static void assign_element(lhs_rhs_element &elem, viennacl::implicit_matrix_base< unsigned long > const &t)
static void assign_element(lhs_rhs_element &elem, viennacl::implicit_matrix_base< short > const &t)
A tag class representing the modulus function for integers.
viennacl::vector_base< int > * vector_int
statement_node_subtype subtype
Expression template class for representing a tree of expressions which ultimately result in a matrix...
A tag class representing the ceil() function.
static void assign_element(lhs_rhs_element &elem, unsigned char const &t)
static void assign_element(lhs_rhs_element &elem, viennacl::vector_base< short > const &t)
viennacl::vcl_size_t size_type
T::ERROR_UNKNOWN_OP_TYPE error_type
viennacl::coordinate_matrix< double > * coordinate_matrix_double
static void assign_element(lhs_rhs_element &elem, viennacl::matrix_base< long > const &t)
This file provides the forward declarations for the main types used within ViennaCL.
viennacl::implicit_vector_base< long > * implicit_vector_long
statement_node_type_family type_family
static void assign_element(lhs_rhs_element &elem, viennacl::scalar< unsigned int > const &t)
viennacl::implicit_matrix_base< double > * implicit_matrix_double
static void assign_element(lhs_rhs_element &elem, viennacl::matrix_base< unsigned short > const &t)
static void assign_element(lhs_rhs_element &elem, viennacl::vector_base< unsigned short > const &t)
A tag class representing division.
static void assign_element(lhs_rhs_element &elem, viennacl::vector_base< double > const &t)
static void assign_element(lhs_rhs_element &elem, viennacl::implicit_matrix_base< long > const &t)
A class representing the 'data' for the LHS or RHS operand of the respective node.
viennacl::matrix_base< unsigned char > * matrix_uchar
container_type const & array() const
viennacl::scalar< unsigned int > * scalar_uint
static void assign_element(lhs_rhs_element &elem, viennacl::implicit_matrix_base< char > const &t)
viennacl::scalar< long > * scalar_long
statement_node_numeric_type
Encodes the type of a node in the statement tree.
static void assign_element(lhs_rhs_element &elem, float const &t)
A proxy for scalar expressions (e.g. from inner vector products)
An expression template class that represents a binary operation that yields a vector.
static viennacl::enable_if< viennacl::is_primitive_type< T >::value, vcl_size_t >::type add_element(vcl_size_t next_free, lhs_rhs_element &elem, T const &t)
static void assign_element(lhs_rhs_element &elem, viennacl::ell_matrix< float > const &m)
A tag class representing the log() function.
operation_node_type_family type_family
Struct for holding the type family as well as the type of an operation (could be addition, subtraction, norm, etc.)
static void assign_element(lhs_rhs_element &elem, viennacl::vector_base< char > const &t)
A tag class representing inplace addition.
static void assign_element(lhs_rhs_element &elem, viennacl::implicit_vector_base< unsigned int > const &t)
A tag class representing the tanh() function.
static vcl_size_t add_element(vcl_size_t next_free, lhs_rhs_element &elem, viennacl::matrix_base< T > const &t)
A tag class representing the fabs() function.
viennacl::matrix_base< double > * matrix_double
A tag class representing the maximum of a vector.
viennacl::hyb_matrix< double > * hyb_matrix_double
A tag class representing the (off-)diagonal of a matrix.
viennacl::implicit_matrix_base< unsigned int > * implicit_matrix_uint
A tag class representing the atan() function.
viennacl::scalar< unsigned long > * scalar_ulong
A tag class representing the sinh() function.
viennacl::implicit_vector_base< unsigned int > * implicit_vector_uint
static void assign_element(lhs_rhs_element &elem, viennacl::implicit_matrix_base< int > const &t)
static void assign_element(lhs_rhs_element &elem, viennacl::compressed_matrix< float > const &m)
statement_node_subtype
Encodes the type of a node in the statement tree.
std::vector< value_type > container_type
viennacl::matrix_base< long > * matrix_long
viennacl::matrix_base< unsigned short > * matrix_ushort
static vcl_size_t add_element(vcl_size_t next_free, lhs_rhs_element &elem, viennacl::ell_matrix< T > const &t)
viennacl::implicit_matrix_base< unsigned short > * implicit_matrix_ushort
viennacl::compressed_matrix< float > * compressed_matrix_float
static void assign_element(lhs_rhs_element &elem, viennacl::scalar< int > const &t)
A tag class representing the fmax() function.
static void assign_element(lhs_rhs_element &elem, viennacl::implicit_matrix_base< float > const &t)
static void assign_element(lhs_rhs_element &elem, viennacl::scalar< double > const &t)
A tag class representing the exp() function.
virtual ~statement_not_supported_exception()
A tag class representing greater-than-or-equal-to.
static void assign_element(lhs_rhs_element &elem, viennacl::implicit_vector_base< unsigned long > const &t)
static void assign_element(lhs_rhs_element &elem, viennacl::implicit_matrix_base< unsigned short > const &t)
static void assign_element(lhs_rhs_element &elem, viennacl::coordinate_matrix< float > const &m)
viennacl::implicit_matrix_base< unsigned char > * implicit_matrix_uchar
static vcl_size_t add_element(vcl_size_t next_free, lhs_rhs_element &elem, viennacl::implicit_vector_base< T > const &t)
statement_node_numeric_type numeric_type
viennacl::vector_base< unsigned long > * vector_ulong
static void assign_element(lhs_rhs_element &elem, viennacl::matrix_base< float > const &t)
static void assign_element(lhs_rhs_element &elem, viennacl::implicit_vector_base< double > const &t)
A tag class representing inequality.
viennacl::vector_base< float > * vector_float
A tag class representing less-than-or-equal-to.
static vcl_size_t add_element(vcl_size_t next_free, lhs_rhs_element &elem, viennacl::hyb_matrix< T > const &t)
static void assign_element(lhs_rhs_element &elem, viennacl::vector_base< unsigned int > const &t)
A tag class representing addition.
viennacl::matrix_base< float > * matrix_float
static void assign_element(lhs_rhs_element &elem, viennacl::implicit_vector_base< float > const &t)
viennacl::implicit_vector_base< char > * implicit_vector_char
A tag class representing the sqrt() function.
viennacl::implicit_vector_base< unsigned long > * implicit_vector_ulong
A tag class representing matrix-matrix products.
static void assign_element(lhs_rhs_element &elem, viennacl::ell_matrix< double > const &m)
viennacl::vector_base< double > * vector_double
viennacl::compressed_matrix< double > * compressed_matrix_double
viennacl::ell_matrix< double > * ell_matrix_double
viennacl::matrix_base< unsigned long > * matrix_ulong
viennacl::hyb_matrix< float > * hyb_matrix_float
viennacl::scalar< double > * scalar_double
static void assign_element(lhs_rhs_element &elem, viennacl::implicit_matrix_base< unsigned int > const &t)
viennacl::scalar< unsigned short > * scalar_ushort
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...
A tag class representing the minimum of a vector.
static void assign_element(lhs_rhs_element &elem, viennacl::scalar< unsigned char > const &t)
operation_node_type
Enumeration for identifying the possible operations.
static void assign_element(lhs_rhs_element &elem, viennacl::matrix_base< double > const &t)
viennacl::vector_base< char > * vector_char
viennacl::implicit_vector_base< short > * implicit_vector_short
statement(container_type const &custom_array)
A tag class representing the sin() function.
All the predicates used within ViennaCL. Checks for expressions to be vectors, etc.
static void assign_element(lhs_rhs_element &elem, viennacl::scalar< unsigned long > const &t)
static void assign_element(lhs_rhs_element &elem, viennacl::scalar< long > const &t)
Helper metafunction for obtaining the runtime type ID for a numerical type.
viennacl::scalar< unsigned char > * scalar_uchar
A tag class representing the fmin() function.
A tag class representing inplace subtraction.
static void assign_element(lhs_rhs_element &elem, viennacl::implicit_vector_base< short > const &t)
static void assign_element(lhs_rhs_element &elem, int const &t)
static vcl_size_t add_element(vcl_size_t next_free, lhs_rhs_element &elem, viennacl::vector_base< T > const &t)
static void assign_element(lhs_rhs_element &elem, viennacl::coordinate_matrix< double > const &m)
A tag class representing the 1-norm of a vector.
static void assign_element(lhs_rhs_element &elem, long const &t)
A tag class representing matrix-vector products and element-wise multiplications. ...
static void assign_element(lhs_rhs_element &elem, viennacl::vector_base< int > const &t)
static void assign_element(lhs_rhs_element &elem, viennacl::implicit_vector_base< unsigned short > const &t)
static void assign_element(lhs_rhs_element &elem, viennacl::scalar< unsigned short > const &t)
viennacl::vector_base< unsigned char > * vector_uchar
scheduler::lhs_rhs_element & lhs_rhs_element(scheduler::statement const &st, vcl_size_t idx, leaf_t leaf)
static void assign_element(lhs_rhs_element &elem, viennacl::matrix_base< unsigned long > const &t)
A tag class representing the floor() function.
viennacl::implicit_matrix_base< float > * implicit_matrix_float
A tag class representing the asin() function.
viennacl::ell_matrix< float > * ell_matrix_float
static vcl_size_t add_element(vcl_size_t next_free, lhs_rhs_element &elem, viennacl::compressed_matrix< T > const &t)
static void assign_element(lhs_rhs_element &elem, unsigned long const &t)
viennacl::scalar< int > * scalar_int
unsigned short host_ushort
viennacl::implicit_vector_base< double > * implicit_vector_double
static void assign_element(lhs_rhs_element &elem, viennacl::vector_base< unsigned long > const &t)
static void assign_element(lhs_rhs_element &elem, viennacl::compressed_matrix< double > const &m)
statement_not_supported_exception(std::string message)
static void assign_element(lhs_rhs_element &elem, unsigned int const &t)
A tag class for representing the argmax() function.
A tag class representing transposed matrices.
static void assign_element(lhs_rhs_element &elem, viennacl::implicit_matrix_base< unsigned char > const &t)
viennacl::implicit_vector_base< unsigned short > * implicit_vector_ushort
A tag class representing element-wise binary operations (like multiplication) on vectors or matrices...
The main class for representing a statement such as x = inner_prod(y,z); at runtime.
viennacl::scalar< char > * scalar_char
viennacl::implicit_matrix_base< short > * implicit_matrix_short
static vcl_size_t add_element(vcl_size_t next_free, lhs_rhs_element &elem, viennacl::implicit_matrix_base< T > const &t)
static void assign_element(lhs_rhs_element &elem, viennacl::matrix_base< unsigned int > const &t)
static void assign_element(lhs_rhs_element &elem, viennacl::matrix_base< int > const &t)
static vcl_size_t add_element(vcl_size_t next_free, lhs_rhs_element &elem, viennacl::scalar< T > const &t)
A tag class representing sign flips (for scalars only. Vectors and matrices use the standard multipli...
static void assign_element(lhs_rhs_element &elem, viennacl::implicit_vector_base< long > const &t)
A tag class representing the acos() function.
static void assign_element(lhs_rhs_element &elem, viennacl::vector_base< float > const &t)
static void assign_element(lhs_rhs_element &elem, viennacl::matrix_base< char > const &t)
A tag class representing inner products of two vectors.
A tag class representing the extraction of a matrix row to a vector.
A tag class representing the power function.
A tag class representing the inf-norm of a vector.
static void assign_element(lhs_rhs_element &elem, viennacl::implicit_matrix_base< double > const &t)
static void assign_element(lhs_rhs_element &elem, viennacl::implicit_vector_base< int > const &t)
A tag class representing the log10() function.
viennacl::matrix_base< int > * matrix_int
viennacl::implicit_matrix_base< long > * implicit_matrix_long
A tag class representing element-wise unary operations (like sin()) on vectors or matrices...
static vcl_size_t add_element(vcl_size_t next_free, lhs_rhs_element &elem, viennacl::coordinate_matrix< T > const &t)
A tag class representing the 2-norm of a vector.
viennacl::vector_base< long > * vector_long
A tag class for representing the argmin() function.
viennacl::coordinate_matrix< float > * coordinate_matrix_float
virtual const char * what() const
A tag class representing greater-than.
static void assign_element(lhs_rhs_element &elem, viennacl::hyb_matrix< double > const &m)
A tag class representing the cos() function.
statement_not_supported_exception()
viennacl::implicit_matrix_base< char > * implicit_matrix_char
static void assign_element(lhs_rhs_element &elem, viennacl::scalar< char > const &t)
static void assign_element(lhs_rhs_element &elem, viennacl::scalar< short > const &t)
Main datastructure for an node in the statement tree.
Exception for the case the scheduler is unable to deal with the operation.
Simple enable-if variant that uses the SFINAE pattern.
static void assign_element(lhs_rhs_element &elem, short const &t)
statement_node_type_family
Groups the type of a node in the statement tree. Used for faster dispatching.
viennacl::matrix_base< unsigned int > * matrix_uint
operation_node_type_family
Optimization enum for grouping operations into unary or binary operations. Just for optimization of l...
viennacl::implicit_matrix_base< int > * implicit_matrix_int
static void assign_element(lhs_rhs_element &elem, viennacl::vector_base< long > const &t)
static void assign_element(lhs_rhs_element &elem, viennacl::vector_base< unsigned char > const &t)
A tag class representing element-wise casting operations on vectors and matrices. ...