1 #ifndef VIENNACL_GENERATOR_MAP_GENERATE_PROTOTYPE_HPP
2 #define VIENNACL_GENERATOR_MAP_GENERATE_PROTOTYPE_HPP
48 std::string create_name(
unsigned int & current_arg, std::map<void *, vcl_size_t> & memory,
void *
handle)
const{
51 if(memory.insert(std::make_pair(handle, current_arg)).second)
60 map_functor(std::map<void *, vcl_size_t> & memory,
unsigned int & current_arg,
mapping_type & mapping) : memory_(memory), current_arg_(current_arg), mapping_(mapping){ }
65 T * p =
new T(
"float");
67 p->info_.statement = statement;
68 p->info_.root_node = root_node;
69 p->info_.mapping = mapping;
74 template<
class ScalarType>
77 p->name_ = create_name(current_arg_, memory_, NULL);
82 template<
class ScalarType>
85 p->
name_ = create_name(current_arg_, memory_, (
void*)&scal);
90 template<
class ScalarType>
93 p->
name_ = create_name(current_arg_, memory_, (
void*)&vec);
95 p->start_name_ = p->
name_ +
"_start";
97 p->stride_name_ = p->
name_ +
"_stride";
102 template<
class ScalarType>
107 p->value_name_ = create_name(current_arg_, memory_, NULL);
109 p->value_name_ = create_name(current_arg_, memory_, NULL);
114 template<
class ScalarType,
class Layout>
117 p->
name_ = create_name(current_arg_, memory_, (
void*)&mat);
120 p->start1_name_ = p->
name_ +
"_start1";
122 p->stride1_name_ = p->
name_ +
"_stride1";
124 p->start2_name_ = p->
name_ +
"_start2";
126 p->stride2_name_ = p->
name_ +
"_stride2";
131 template<
class ScalarType>
136 p->value_name_ = create_name(current_arg_, memory_, NULL);
143 const key_type key(root_node, node_type);
145 mapping_.insert(mapping_type::value_type(key, utils::call_on_element(root_node->
lhs, *
this)));
147 mapping_.insert(mapping_type::value_type(key, utils::call_on_element(root_node->
rhs, *
this)));
151 mapping_.insert(mapping_type::value_type(key, binary_leaf<mapped_scalar_reduction>(statement, root_node, &mapping_)));
153 mapping_.insert(mapping_type::value_type(key, binary_leaf<mapped_vector_reduction>(statement, root_node, &mapping_)));
155 mapping_.insert(mapping_type::value_type(key, binary_leaf<mapped_matrix_product>(statement, root_node, &mapping_)));
160 std::map<void *, vcl_size_t> & memory_;
161 unsigned int & current_arg_;
std::map< key_type, container_ptr_type > mapping_type
Definition: forwards.h:122
result_type operator()(implicit_matrix_base< ScalarType > const &mat) const
Implicit matrix mapping.
Definition: map_functor.hpp:132
void operator()(viennacl::scheduler::statement const *statement, viennacl::scheduler::statement_node const *root_node, detail::node_type node_type) const
Traversal functor.
Definition: map_functor.hpp:142
bool is_value_static() const
Definition: vector.hpp:64
Internal utils for a dynamic OpenCL kernel generation.
tools::shared_ptr< detail::mapped_object > container_ptr_type
Definition: forwards.h:121
Implementation of the dense matrix class.
This class represents a single scalar value on the GPU and behaves mostly like a built-in scalar type...
Definition: forwards.h:172
lhs_rhs_element lhs
Definition: forwards.h:422
Common base class for representing vectors where the entries are not all stored explicitly.
Definition: forwards.h:190
Helper metafunction for checking whether two types are the same.
Definition: utils.hpp:196
Helper struct for converting a numerical type to its string representation.
Definition: utils.hpp:213
Definition: forwards.h:114
size_type stride1() const
Returns the number of rows.
Definition: matrix.hpp:635
std::pair< viennacl::scheduler::statement_node const *, node_type > key_type
Definition: forwards.h:118
result_type operator()(implicit_vector_base< ScalarType > const &vec) const
Implicit vector mapping.
Definition: map_functor.hpp:103
Mapping of a matrix to a generator class.
Definition: mapped_objects.hpp:236
This file provides the forward declarations for the main types used within ViennaCL.
size_type start2() const
Returns the number of columns.
Definition: matrix.hpp:632
lhs_rhs_element rhs
Definition: forwards.h:424
size_type stride2() const
Returns the number of columns.
Definition: matrix.hpp:637
std::string name_
Definition: mapped_objects.hpp:172
Mapping of a scalar to a generator class.
Definition: mapped_objects.hpp:176
Implementation of a shared pointer class (cf. std::shared_ptr, boost::shared_ptr). Will be used until C++11 is widely available.
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
several code generation helpers
map_functor(std::map< void *, vcl_size_t > &memory, unsigned int ¤t_arg, mapping_type &mapping)
Definition: map_functor.hpp:60
Map ViennaCL objects to generator wrappers.
base functor class for traversing a statement
Definition: helpers.hpp:145
Base class for representing matrices where the individual entries are not all stored explicitly...
Definition: forwards.h:296
Definition: forwards.h:113
result_type operator()(matrix_base< ScalarType, Layout > const &mat) const
Matrix mapping.
Definition: map_functor.hpp:115
Functor to map the statements to the types defined in mapped_objects.hpp.
Definition: map_functor.hpp:47
result_type operator()(vector_base< ScalarType > const &vec) const
Vector mapping.
Definition: map_functor.hpp:91
bool is_value_static() const
Definition: matrix.hpp:57
Provides the datastructures for dealing with a single statement such as 'x = y + z;'.
Mapping of a vector to a generator class.
Definition: mapped_objects.hpp:205
operation_node_type
Enumeration for identifying the possible operations.
Definition: forwards.h:61
Mapping of a host scalar to a generator class.
Definition: mapped_objects.hpp:116
size_type start() const
Returns the offset within the buffer.
Definition: vector.hpp:845
node_type
Definition: forwards.h:112
Definition: forwards.h:115
size_type start1() const
Returns the number of rows.
Definition: matrix.hpp:630
Definition: forwards.h:96
result_type operator()(scalar< ScalarType > const &scal) const
Scalar mapping.
Definition: map_functor.hpp:83
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
Definition: forwards.h:95
result_type operator()(ScalarType const &) const
Definition: map_functor.hpp:75
std::string to_string(T const t)
Definition: utils.hpp:204
Definition: forwards.h:101
container_ptr_type result_type
Definition: map_functor.hpp:58
result_type binary_leaf(viennacl::scheduler::statement const *statement, viennacl::scheduler::statement_node const *root_node, mapping_type const *mapping) const
Binary leaf.
Definition: map_functor.hpp:64
statement_node_type_family type_family
Definition: forwards.h:269
The main class for representing a statement such as x = inner_prod(y,z); at runtime.
Definition: forwards.h:447
viennacl::backend::mem_handle & handle(T &obj)
Returns the generic memory handle of an object. Non-const version.
Definition: handle.hpp:41
Mapping of a implicit matrix to a generator class.
Definition: mapped_objects.hpp:310
op_element op
Definition: forwards.h:423
Main datastructure for an node in the statement tree.
Definition: forwards.h:420
size_type stride() const
Returns the stride within the buffer (in multiples of sizeof(SCALARTYPE))
Definition: vector.hpp:849
operation_node_type type
Definition: forwards.h:416
bool has_index() const
Definition: vector.hpp:68
Mapping of a implicit vector to a generator class.
Definition: mapped_objects.hpp:291
Definition: forwards.h:167