1 #ifndef VIENNACL_DEVICE_SPECIFIC_UTILS_HPP
2 #define VIENNACL_DEVICE_SPECIFIC_UTILS_HPP
44 namespace device_specific
52 std::string res = opencl_src;
114 switch (element.numeric_type)
126 default :
throw generator_not_supported_exception(
"Unsupported Scalartype");
133 switch (element.numeric_type)
145 default :
throw generator_not_supported_exception(
"Unsupported Scalartype");
152 switch (element.numeric_type)
164 default :
throw generator_not_supported_exception(
"Unsupported Scalartype");
172 switch (element.numeric_type)
184 default :
throw generator_not_supported_exception(
"Unsupported Scalartype");
191 switch (element.numeric_type)
203 default :
throw generator_not_supported_exception(
"Unsupported Scalartype");
211 switch (element.numeric_type)
223 default :
throw generator_not_supported_exception(
"Unsupported Scalartype");
229 switch (element.type_family)
233 return call_on_host_scalar(element, fun);
235 return call_on_scalar(element, fun);
238 return call_on_implicit_vector(element, fun);
240 return call_on_vector(element, fun);
243 return call_on_implicit_matrix(element, fun);
245 return call_on_matrix(element,fun);
247 throw generator_not_supported_exception(
"Unsupported datastructure type : Not among {Scalar, Vector, Matrix}");
355 template<
class T,
class U>
406 class kgenstream :
public std::stringbuf
409 kgenstream(std::ostringstream& osstream,
unsigned int const & tab_count) : oss_(osstream), tab_count_(tab_count){ }
411 for (
unsigned int i=0; i<tab_count_;++i)
417 #if defined(_MSC_VER)
418 ~kgenstream()
throw() { pubsync(); }
420 ~kgenstream() { pubsync(); }
424 unsigned int const & tab_count_;
429 #if defined(_MSC_VER)
435 std::string
str(){
return oss.str(); }
439 unsigned int tab_count_;
440 std::ostringstream oss;
445 using namespace scheduler;
464 using namespace scheduler;
478 using namespace scheduler;
527 using namespace tree_parsing;
536 using namespace scheduler;
558 inline std::string
append_width(std::string
const & str,
unsigned int width)
result_type operator()(T const &t) const
~kernel_generation_stream()
This file provides the forward declarations for the OpenCL layer of ViennaCL.
static const char * value()
result_of::size_type< matrix_base< NumericT > >::type stride1(matrix_base< NumericT > const &s)
Exception for the case the generator is unable to deal with the operation.
Generic size and resize functionality for different vector and matrix types.
result_type operator()(T const &t) const
result_type operator()(T const &t) const
vcl_size_t internal_size1(matrix_base< NumericT > const &mat)
Helper routine for obtaining the internal number of entries per row of a ViennaCL matrix...
result_type operator()(T const &t) const
result_type operator()(T const &t) const
vcl_size_t size1(MatrixType const &mat)
Generic routine for obtaining the number of rows of a matrix (ViennaCL, uBLAS, etc.)
vcl_size_t internal_size2(matrix_base< NumericT > const &mat)
Helper routine for obtaining the internal number of entries per column of a ViennaCL matrix...
bool elementwise_operator(scheduler::op_element const &op)
static const char * value()
result_type operator()(T const &t) const
static const char * value()
result_of::size_type< viennacl::vector_base< T > >::type stride(viennacl::vector_base< T > const &s)
result_of::size_type< T >::type start1(T const &obj)
A class representing the 'data' for the LHS or RHS operand of the respective node.
container_type const & array() const
vcl_size_t internal_size(vector_base< NumericT > const &vec)
Helper routine for obtaining the buffer length of a ViennaCL vector.
statement_node_numeric_type
Encodes the type of a node in the statement tree.
bool node_leaf(scheduler::op_element const &op)
Forward declaration of dense matrix classes.
std::string opencl_source_to_cuda_source(std::string const &opencl_src)
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.)
result_of::size_type< MatrixType >::type size2(MatrixType const &mat)
Generic routine for obtaining the number of columns of a matrix (ViennaCL, uBLAS, etc...
result_type operator()(float const &) const
result_type operator()(T const &t) const
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
result_of::size_type< T >::type start2(T const &obj)
bool elementwise_function(scheduler::op_element const &op)
static const char * value()
static const char * value()
result_type operator()(T const &) const
static const char * value()
static const char * value()
result_type operator()(double const &) const
result_type operator()(T const &t) const
bool is_reduction(scheduler::statement_node const &node)
Determines whether a given expression has a row-major matrix layout.
result_type operator()(T const &t) const
Provides the datastructures for dealing with a single statement such as 'x = y + z;'.
static const char * value()
T::ERROR_CANNOT_DEDUCE_CPU_SCALAR_TYPE_FOR_T type
result_of::size_type< matrix_base< NumericT > >::type stride2(matrix_base< NumericT > const &s)
kernel_generation_stream()
result_type operator()(T const &t) const
scheduler::lhs_rhs_element & lhs_rhs_element(scheduler::statement const &st, vcl_size_t idx, leaf_t leaf)
bool row_major(T const &)
static const char * value()
bool is_index_reduction(scheduler::op_element const &op)
The main class for representing a statement such as x = inner_prod(y,z); at runtime.
Forward declarations of the implicit_vector_base, vector_base class.
result_type operator()(T const &t) const
Extracts the underlying OpenCL handle from a vector, a matrix, an expression etc. ...
result_type operator()(T const &t) const
result_type operator()(T const &t) const
static const char * value()
Main datastructure for an node in the statement tree.
unsigned int size_of(scheduler::statement_node_numeric_type type)
result_type operator()(T const &t) const
result_type operator()(T const &t) const
std::string append_width(std::string const &str, unsigned int width)