ViennaCL - The Vienna Computing Library  1.7.0
Free open-source GPU-accelerated linear algebra and solver library.
execute_scalar_dispatcher.hpp
Go to the documentation of this file.
1 #ifndef VIENNACL_SCHEDULER_EXECUTE_SCALAR_DISPATCHER_HPP
2 #define VIENNACL_SCHEDULER_EXECUTE_SCALAR_DISPATCHER_HPP
3 
4 /* =========================================================================
5  Copyright (c) 2010-2015, 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"
32 
33 namespace viennacl
34 {
35 namespace scheduler
36 {
37 namespace detail
38 {
39 
41 template<typename ScalarType1>
43  lhs_rhs_element const & s2, ScalarType1 const & alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha)
44 {
47  && bool("Arguments are not vector types!"));
48 
49  switch (s1.numeric_type)
50  {
51  case FLOAT_TYPE:
52  assert(s2.numeric_type == FLOAT_TYPE && bool("Vectors do not have the same scalar type"));
54  *s2.vector_float, convert_to_float(alpha), len_alpha, reciprocal_alpha, flip_sign_alpha);
55  break;
56  case DOUBLE_TYPE:
57  assert(s2.numeric_type == DOUBLE_TYPE && bool("Vectors do not have the same scalar type"));
59  *s2.vector_double, convert_to_double(alpha), len_alpha, reciprocal_alpha, flip_sign_alpha);
60  break;
61  default:
62  throw statement_not_supported_exception("Invalid arguments in scheduler when calling av()");
63  }
64 }
65 
67 template<typename ScalarType1, typename ScalarType2>
69  lhs_rhs_element const & s2, ScalarType1 const & alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha,
70  lhs_rhs_element const & s3, ScalarType2 const & beta, vcl_size_t len_beta, bool reciprocal_beta, bool flip_sign_beta)
71 {
75  && bool("Arguments are not vector types!"));
76 
77  switch (s1.numeric_type)
78  {
79  case FLOAT_TYPE:
80  assert(s2.numeric_type == FLOAT_TYPE && s3.numeric_type == FLOAT_TYPE && bool("Vectors do not have the same scalar type"));
82  *s2.vector_float, convert_to_float(alpha), len_alpha, reciprocal_alpha, flip_sign_alpha,
83  *s3.vector_float, convert_to_float(beta), len_beta, reciprocal_beta, flip_sign_beta);
84  break;
85  case DOUBLE_TYPE:
86  assert(s2.numeric_type == DOUBLE_TYPE && s3.numeric_type == DOUBLE_TYPE && bool("Vectors do not have the same scalar type"));
88  *s2.vector_double, convert_to_double(alpha), len_alpha, reciprocal_alpha, flip_sign_alpha,
89  *s3.vector_double, convert_to_double(beta), len_beta, reciprocal_beta, flip_sign_beta);
90  break;
91  default:
92  throw statement_not_supported_exception("Invalid arguments in scheduler when calling avbv()");
93  }
94 }
95 
97 template<typename ScalarType1, typename ScalarType2>
99  lhs_rhs_element const & s2, ScalarType1 const & alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha,
100  lhs_rhs_element const & s3, ScalarType2 const & beta, vcl_size_t len_beta, bool reciprocal_beta, bool flip_sign_beta)
101 {
105  && bool("Arguments are not vector types!"));
106 
107  switch (s1.numeric_type)
108  {
109  case FLOAT_TYPE:
110  assert(s2.numeric_type == FLOAT_TYPE && s3.numeric_type == FLOAT_TYPE && bool("Vectors do not have the same scalar type"));
112  *s2.vector_float, convert_to_float(alpha), len_alpha, reciprocal_alpha, flip_sign_alpha,
113  *s3.vector_float, convert_to_float(beta), len_beta, reciprocal_beta, flip_sign_beta);
114  break;
115  case DOUBLE_TYPE:
116  assert(s2.numeric_type == DOUBLE_TYPE && s3.numeric_type == DOUBLE_TYPE && bool("Vectors do not have the same scalar type"));
118  *s2.vector_double, convert_to_double(alpha), len_alpha, reciprocal_alpha, flip_sign_alpha,
119  *s3.vector_double, convert_to_double(beta), len_beta, reciprocal_beta, flip_sign_beta);
120  break;
121  default:
122  throw statement_not_supported_exception("Invalid arguments in scheduler when calling avbv_v()");
123  }
124 }
125 
126 } // namespace detail
127 } // namespace scheduler
128 } // namespace viennacl
129 
130 #endif
131 
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.
Implementations of scalar operations.
void avbv_v(vector_base< T > &vec1, vector_base< T > const &vec2, ScalarType1 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha, vector_base< T > const &vec3, ScalarType2 const &beta, vcl_size_t len_beta, bool reciprocal_beta, bool flip_sign_beta)
double convert_to_double(float d)
statement_node_subtype subtype
Definition: forwards.h:340
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.
viennacl::scalar< int > s2
viennacl::scalar< float > s1
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
Definition: cpu_ram.hpp:34
Definition: blas3.hpp:36
statement_node_numeric_type numeric_type
Definition: forwards.h:341
viennacl::vector_base< float > * vector_float
Definition: forwards.h:385
std::size_t vcl_size_t
Definition: forwards.h:75
viennacl::vector_base< double > * vector_double
Definition: forwards.h:386
Provides the datastructures for dealing with a single statement such as 'x = y + z;'.
void avbv(vector_base< T > &vec1, vector_base< T > const &vec2, ScalarType1 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha, vector_base< T > const &vec3, ScalarType2 const &beta, vcl_size_t len_beta, bool reciprocal_beta, bool flip_sign_beta)
void av(vector_base< T > &vec1, vector_base< T > const &vec2, ScalarType1 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha)
float convert_to_float(float f)
Provides various utilities for implementing the execution of statements.
Exception for the case the scheduler is unable to deal with the operation.
Definition: forwards.h:38