1 #ifndef VIENNACL_VECTOR_PROXY_HPP_
2 #define VIENNACL_VECTOR_PROXY_HPP_
31 template <
typename VectorType>
46 range const & entry_range) : v_(v), entry_range_(entry_range) {}
51 template <
typename LHS,
typename RHS,
typename OP>
56 assert(
false &&
"Not implemented!");
70 VectorType &
get() {
return v_; }
71 const VectorType &
get()
const {
return v_; }
79 template<
typename VectorType>
80 std::ostream & operator<<(std::ostream & s, vector_range<VectorType>
const & proxy)
82 typedef typename VectorType::value_type ScalarType;
83 std::vector<ScalarType> temp(proxy.size());
87 VectorType temp2(temp.size());
101 template <
typename VectorType,
typename SCALARTYPE>
102 void copy(
const VectorType & cpu_vector,
105 assert(cpu_vector.end() - cpu_vector.begin() >= 0);
107 if (cpu_vector.end() - cpu_vector.begin() > 0)
110 std::vector<SCALARTYPE> temp_buffer(cpu_vector.end() - cpu_vector.begin());
111 std::copy(cpu_vector.begin(), cpu_vector.end(), temp_buffer.begin());
113 gpu_vector_range.get().
handle(), CL_TRUE,
sizeof(SCALARTYPE)*gpu_vector_range.start(),
114 sizeof(SCALARTYPE)*temp_buffer.size(),
115 &(temp_buffer[0]), 0, NULL, NULL);
126 template <
typename VectorType,
typename SCALARTYPE>
128 VectorType & cpu_vector)
130 assert(cpu_vector.end() - cpu_vector.begin() >= 0);
132 if (cpu_vector.end() > cpu_vector.begin())
134 std::vector<SCALARTYPE> temp_buffer(cpu_vector.end() - cpu_vector.begin());
136 gpu_vector_range.get().
handle(), CL_TRUE,
sizeof(SCALARTYPE)*gpu_vector_range.start(),
137 sizeof(SCALARTYPE)*temp_buffer.size(),
138 &(temp_buffer[0]), 0, NULL, NULL);
143 std::copy(temp_buffer.begin(), temp_buffer.end(), cpu_vector.begin());