ViennaCL - The Vienna Computing Library  1.6.0
Free open-source GPU-accelerated linear algebra and solver library.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
matrix_proxy.hpp
Go to the documentation of this file.
1 #ifndef VIENNACL_MATRIX_PROXY_HPP_
2 #define VIENNACL_MATRIX_PROXY_HPP_
3 
4 /* =========================================================================
5  Copyright (c) 2010-2014, 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 PDF manual)
17 
18  License: MIT (X11), see file LICENSE in the base directory
19 ============================================================================= */
20 
25 #include "viennacl/forwards.h"
26 #include "viennacl/range.hpp"
27 #include "viennacl/slice.hpp"
29 
30 namespace viennacl
31 {
32 
37 template<typename MatrixType>
38 class matrix_range : public matrix_base<typename MatrixType::cpu_value_type>
39 {
40  typedef matrix_base<typename MatrixType::cpu_value_type> base_type;
41  typedef matrix_range<MatrixType> self_type;
42 
43 public:
44  typedef typename MatrixType::value_type value_type;
50  typedef const value_type & const_reference;
51 
52 
53  matrix_range(MatrixType const & A,
54  range const & row_range,
55  range const & col_range) : base_type(const_cast<handle_type &>(A.handle()),
56  row_range.size(), row_range.start() * A.stride1() + A.start1(), A.stride1(), A.internal_size1(),
57  col_range.size(), col_range.start() * A.stride2() + A.start2(), A.stride2(), A.internal_size2(),
58  A.row_major()) {}
59 
61  range const & row_range,
62  range const & col_range) : base_type(const_cast<handle_type &>(A.handle()),
63  row_range.size(), row_range.start() * A.stride1() + A.start1(), A.stride1(), A.internal_size1(),
64  col_range.size(), col_range.start() * A.stride2() + A.start2(), A.stride2(), A.internal_size2(),
65  A.row_major()) {}
66 
67 
68  matrix_range(self_type const & other) : base_type(const_cast<handle_type &>(other.handle()),
69  other.size1(), other.start1(), other.stride1(), other.internal_size1(),
70  other.size2(), other.start2(), other.stride2(), other.internal_size2(),
71  other.row_major()) {}
72 
73  using base_type::operator=;
74 
75 };
76 
77 template<typename MatrixType>
78 class matrix_range<matrix_range<MatrixType> > : public matrix_base<typename MatrixType::cpu_value_type>
79 {
81 public:
83 
84  matrix_range(MatrixType const & A,
85  range const & row_range,
86  range const & col_range) : base_type(const_cast<handle_type &>(A.handle()),
87  row_range.size(), row_range.start() * A.stride1() + A.start1(), A.stride1(), A.internal_size1(),
88  col_range.size(), col_range.start() * A.stride2() + A.start2(), A.stride2(), A.internal_size2(),
89  A.row_major()) {}
90 
92  range const & row_range,
93  range const & col_range) : base_type(const_cast<handle_type &>(A.handle()),
94  row_range.size(), row_range.start() * A.stride1() + A.start1(), A.stride1(), A.internal_size1(),
95  col_range.size(), col_range.start() * A.stride2() + A.start2(), A.stride2(), A.internal_size2(),
96  A.row_major()) {}
97 };
98 
102 
103 //row_major:
104 template<typename CPUMatrixT, typename NumericT>
105 void copy(const CPUMatrixT & cpu_matrix,
106  matrix_range<matrix<NumericT, row_major, 1> > & gpu_matrix_range )
107 {
108  assert( (cpu_matrix.size1() == gpu_matrix_range.size1())
109  && (cpu_matrix.size2() == gpu_matrix_range.size2())
110  && bool("Matrix size mismatch!"));
111 
112  if ( gpu_matrix_range.start2() != 0)
113  {
114  std::vector<NumericT> entries(gpu_matrix_range.size2());
115 
116  //copy each stride separately:
117  for (vcl_size_t i=0; i < gpu_matrix_range.size1(); ++i)
118  {
119  for (vcl_size_t j=0; j < gpu_matrix_range.size2(); ++j)
120  entries[j] = cpu_matrix(i,j);
121 
122  vcl_size_t start_offset = (gpu_matrix_range.start1() + i) * gpu_matrix_range.internal_size2() + gpu_matrix_range.start2();
123  vcl_size_t num_entries = gpu_matrix_range.size2();
124  viennacl::backend::memory_write(gpu_matrix_range.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
125  //std::cout << "Strided copy worked!" << std::endl;
126  }
127  }
128  else
129  {
130  //full block can be copied:
131  std::vector<NumericT> entries(gpu_matrix_range.size1()*gpu_matrix_range.internal_size2());
132 
133  //copy each stride separately:
134  for (vcl_size_t i=0; i < gpu_matrix_range.size1(); ++i)
135  for (vcl_size_t j=0; j < gpu_matrix_range.size2(); ++j)
136  entries[i*gpu_matrix_range.internal_size2() + j] = cpu_matrix(i,j);
137 
138  vcl_size_t start_offset = gpu_matrix_range.start1() * gpu_matrix_range.internal_size2();
139  vcl_size_t num_entries = gpu_matrix_range.size1() * gpu_matrix_range.internal_size2();
140  viennacl::backend::memory_write(gpu_matrix_range.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
141  //std::cout << "Block copy worked!" << std::endl;
142  }
143 }
144 
145 //column_major:
146 template<typename CPUMatrixT, typename NumericT>
147 void copy(const CPUMatrixT & cpu_matrix,
148  matrix_range<matrix<NumericT, column_major, 1> > & gpu_matrix_range )
149 {
150  assert( (cpu_matrix.size1() == gpu_matrix_range.size1())
151  && (cpu_matrix.size2() == gpu_matrix_range.size2())
152  && bool("Matrix size mismatch!"));
153 
154  if ( gpu_matrix_range.start1() != 0 || gpu_matrix_range.size1() != gpu_matrix_range.size1())
155  {
156  std::vector<NumericT> entries(gpu_matrix_range.size1());
157 
158  //copy each stride separately:
159  for (vcl_size_t j=0; j < gpu_matrix_range.size2(); ++j)
160  {
161  for (vcl_size_t i=0; i < gpu_matrix_range.size1(); ++i)
162  entries[i] = cpu_matrix(i,j);
163 
164  vcl_size_t start_offset = (gpu_matrix_range.start2() + j) * gpu_matrix_range.internal_size1() + gpu_matrix_range.start1();
165  vcl_size_t num_entries = gpu_matrix_range.size1();
166  viennacl::backend::memory_write(gpu_matrix_range.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
167  //std::cout << "Strided copy worked!" << std::endl;
168  }
169  }
170  else
171  {
172  //full block can be copied:
173  std::vector<NumericT> entries(gpu_matrix_range.internal_size1()*gpu_matrix_range.size2());
174 
175  //copy each stride separately:
176  for (vcl_size_t i=0; i < gpu_matrix_range.size1(); ++i)
177  for (vcl_size_t j=0; j < gpu_matrix_range.size2(); ++j)
178  entries[i + j*gpu_matrix_range.internal_size1()] = cpu_matrix(i,j);
179 
180  vcl_size_t start_offset = gpu_matrix_range.start2() * gpu_matrix_range.internal_size1();
181  vcl_size_t num_entries = gpu_matrix_range.internal_size1() * gpu_matrix_range.size2();
182  viennacl::backend::memory_write(gpu_matrix_range.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
183  //std::cout << "Block copy worked!" << std::endl;
184  }
185 
186 }
187 
188 
192 
193 
194 //row_major:
195 template<typename CPUMatrixT, typename NumericT>
196 void copy(matrix_range<matrix<NumericT, row_major, 1> > const & gpu_matrix_range,
197  CPUMatrixT & cpu_matrix)
198 {
199  assert( (cpu_matrix.size1() == gpu_matrix_range.size1())
200  && (cpu_matrix.size2() == gpu_matrix_range.size2())
201  && bool("Matrix size mismatch!"));
202 
203  if ( gpu_matrix_range.start2() != 0)
204  {
205  std::vector<NumericT> entries(gpu_matrix_range.size2());
206 
207  //copy each stride separately:
208  for (vcl_size_t i=0; i < gpu_matrix_range.size1(); ++i)
209  {
210  vcl_size_t start_offset = (gpu_matrix_range.start1() + i) * gpu_matrix_range.internal_size2() + gpu_matrix_range.start2();
211  vcl_size_t num_entries = gpu_matrix_range.size2();
212  viennacl::backend::memory_read(gpu_matrix_range.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
213  //std::cout << "Strided copy worked!" << std::endl;
214 
215  for (vcl_size_t j=0; j < gpu_matrix_range.size2(); ++j)
216  cpu_matrix(i,j) = entries[j];
217  }
218  }
219  else
220  {
221  //full block can be copied:
222  std::vector<NumericT> entries(gpu_matrix_range.size1()*gpu_matrix_range.internal_size2());
223 
224  vcl_size_t start_offset = gpu_matrix_range.start1() * gpu_matrix_range.internal_size2();
225  viennacl::backend::memory_read(gpu_matrix_range.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*entries.size(), &(entries[0]));
226  //std::cout << "Block copy worked!" << std::endl;
227 
228  for (vcl_size_t i=0; i < gpu_matrix_range.size1(); ++i)
229  for (vcl_size_t j=0; j < gpu_matrix_range.size2(); ++j)
230  cpu_matrix(i,j) = entries[i*gpu_matrix_range.internal_size2() + j];
231  }
232 
233 }
234 
235 
236 //column_major:
237 template<typename CPUMatrixT, typename NumericT>
238 void copy(matrix_range<matrix<NumericT, column_major, 1> > const & gpu_matrix_range,
239  CPUMatrixT & cpu_matrix)
240 {
241  assert( (cpu_matrix.size1() == gpu_matrix_range.size1())
242  && (cpu_matrix.size2() == gpu_matrix_range.size2())
243  && bool("Matrix size mismatch!"));
244 
245  if ( gpu_matrix_range.start1() != 0)
246  {
247  std::vector<NumericT> entries(gpu_matrix_range.size1());
248 
249  //copy each stride separately:
250  for (vcl_size_t j=0; j < gpu_matrix_range.size2(); ++j)
251  {
252  vcl_size_t start_offset = (gpu_matrix_range.start2() + j) * gpu_matrix_range.internal_size1() + gpu_matrix_range.start1();
253  vcl_size_t num_entries = gpu_matrix_range.size1();
254  viennacl::backend::memory_read(gpu_matrix_range.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
255  //std::cout << "Strided copy worked!" << std::endl;
256 
257  for (vcl_size_t i=0; i < gpu_matrix_range.size1(); ++i)
258  cpu_matrix(i,j) = entries[i];
259  }
260  }
261  else
262  {
263  //full block can be copied:
264  std::vector<NumericT> entries(gpu_matrix_range.internal_size1()*gpu_matrix_range.size2());
265 
266  //copy each stride separately:
267  vcl_size_t start_offset = gpu_matrix_range.start2() * gpu_matrix_range.internal_size1();
268  vcl_size_t num_entries = gpu_matrix_range.internal_size1() * gpu_matrix_range.size2();
269  viennacl::backend::memory_read(gpu_matrix_range.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
270  //std::cout << "Block copy worked!" << std::endl;
271 
272  for (vcl_size_t i=0; i < gpu_matrix_range.size1(); ++i)
273  for (vcl_size_t j=0; j < gpu_matrix_range.size2(); ++j)
274  cpu_matrix(i,j) = entries[i + j*gpu_matrix_range.internal_size1()];
275  }
276 
277 }
278 
279 
280 //
281 // Convenience function
282 //
283 template<typename MatrixType>
284 matrix_range<MatrixType> project(MatrixType const & A, viennacl::range const & r1, viennacl::range const & r2)
285 {
286  assert(r1.size() <= A.size1() && r2.size() <= A.size2() && bool("Size of range invalid!"));
287 
288  return matrix_range<MatrixType>(A, r1, r2);
289 }
290 
291 
292 template<typename MatrixType>
294 {
295  assert(r1.size() <= A.size1() && r2.size() <= A.size2() && bool("Size of range invalid!"));
296 
297  return matrix_range<MatrixType>(A, r1, r2);
298 }
299 
300 
301 
302 
303 //
304 //
305 //
307 //
308 //
309 //
310 
311 
312 
313 
314 
319 template<typename MatrixType>
320 class matrix_slice : public matrix_base<typename MatrixType::cpu_value_type>
321 {
322  typedef matrix_base<typename MatrixType::cpu_value_type> base_type;
323  typedef matrix_slice<MatrixType> self_type;
324 
325 public:
326 
327  typedef typename MatrixType::value_type value_type;
333  typedef const value_type & const_reference;
334 
335  matrix_slice(MatrixType const & A,
336  slice const & row_slice,
337  slice const & col_slice) : base_type(const_cast<handle_type &>(A.handle()),
338  row_slice.size(), row_slice.start() * A.stride1() + A.start1(), row_slice.stride() * A.stride1(), A.internal_size1(),
339  col_slice.size(), col_slice.start() * A.stride2() + A.start2(), col_slice.stride() * A.stride2(), A.internal_size2(),
340  A.row_major()) {}
341 
343  slice const & row_slice,
344  slice const & col_slice) : base_type(const_cast<handle_type &>(A.handle()),
345  row_slice.size(), row_slice.start() * A.stride1() + A.start1(), row_slice.stride() * A.stride1(), A.internal_size1(),
346  col_slice.size(), col_slice.start() * A.stride2() + A.start2(), col_slice.stride() * A.stride2(), A.internal_size2(),
347  A.row_major()) {}
348 
349 
350  matrix_slice(self_type const & other) : base_type(const_cast<handle_type &>(other.handle()),
351  other.size1(), other.start1(), other.stride1(), other.internal_size1(),
352  other.size2(), other.start2(), other.stride2(), other.internal_size2(),
353  other.row_major()) {}
354 
355  using base_type::operator=;
356 
357 };
358 
359 template<typename MatrixType>
360 class matrix_slice<matrix_range<MatrixType> > : public matrix_base<typename MatrixType::cpu_value_type>
361 {
363 public:
365 
366  matrix_slice(MatrixType const & A,
367  slice const & row_slice,
368  slice const & col_slice) : base_type(const_cast<handle_type &>(A.handle()),
369  row_slice.size(), row_slice.start() * A.stride1() + A.start1(), row_slice.stride() * A.stride1(), A.internal_size1(),
370  col_slice.size(), col_slice.start() * A.stride2() + A.start2(), col_slice.stride() * A.stride2(), A.internal_size2(),
371  A.row_major()) {}
372 
374  slice const & row_slice,
375  slice const & col_slice) : base_type(const_cast<handle_type &>(A.handle()),
376  row_slice.size(), row_slice.start() * A.stride1() + A.start1(), row_slice.stride() * A.stride1(), A.internal_size1(),
377  col_slice.size(), col_slice.start() * A.stride2() + A.start2(), col_slice.stride() * A.stride2(), A.internal_size2(),
378  A.row_major()) {}
379 };
380 
381 
385 
386 //row_major:
387 template<typename CPUMatrixT, typename NumericT>
388 void copy(const CPUMatrixT & cpu_matrix,
389  matrix_slice<matrix<NumericT, row_major, 1> > & gpu_matrix_slice )
390 {
391  assert( (cpu_matrix.size1() == gpu_matrix_slice.size1())
392  && (cpu_matrix.size2() == gpu_matrix_slice.size2())
393  && bool("Matrix size mismatch!"));
394 
395  if ( (gpu_matrix_slice.size1() > 0) && (gpu_matrix_slice.size1() > 0) )
396  {
397  vcl_size_t num_entries = gpu_matrix_slice.size2() * gpu_matrix_slice.stride2(); //no. of entries per stride
398 
399  std::vector<NumericT> entries(num_entries);
400 
401  //copy each stride separately:
402  for (vcl_size_t i=0; i < gpu_matrix_slice.size1(); ++i)
403  {
404  vcl_size_t start_offset = (gpu_matrix_slice.start1() + i * gpu_matrix_slice.stride1()) * gpu_matrix_slice.internal_size2() + gpu_matrix_slice.start2();
405  viennacl::backend::memory_read(gpu_matrix_slice.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
406 
407  for (vcl_size_t j=0; j < gpu_matrix_slice.size2(); ++j)
408  entries[j * gpu_matrix_slice.stride2()] = cpu_matrix(i,j);
409 
410  viennacl::backend::memory_write(gpu_matrix_slice.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
411  }
412  }
413 }
414 
415 //column_major:
416 template<typename CPUMatrixT, typename NumericT>
417 void copy(const CPUMatrixT & cpu_matrix,
418  matrix_slice<matrix<NumericT, column_major, 1> > & gpu_matrix_slice )
419 {
420  assert( (cpu_matrix.size1() == gpu_matrix_slice.size1())
421  && (cpu_matrix.size2() == gpu_matrix_slice.size2())
422  && bool("Matrix size mismatch!"));
423 
424 
425  if ( (gpu_matrix_slice.size1() > 0) && (gpu_matrix_slice.size1() > 0) )
426  {
427  vcl_size_t num_entries = gpu_matrix_slice.size1() * gpu_matrix_slice.stride1(); //no. of entries per stride
428 
429  std::vector<NumericT> entries(num_entries);
430 
431  //copy each column stride separately:
432  for (vcl_size_t j=0; j < gpu_matrix_slice.size2(); ++j)
433  {
434  vcl_size_t start_offset = gpu_matrix_slice.start1() + (gpu_matrix_slice.start2() + j * gpu_matrix_slice.stride2()) * gpu_matrix_slice.internal_size1();
435 
436  viennacl::backend::memory_read(gpu_matrix_slice.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
437 
438  for (vcl_size_t i=0; i < gpu_matrix_slice.size1(); ++i)
439  entries[i * gpu_matrix_slice.stride1()] = cpu_matrix(i,j);
440 
441  viennacl::backend::memory_write(gpu_matrix_slice.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
442  }
443  }
444 
445 }
446 
447 
451 
452 
453 //row_major:
454 template<typename CPUMatrixT, typename NumericT>
455 void copy(matrix_slice<matrix<NumericT, row_major, 1> > const & gpu_matrix_slice,
456  CPUMatrixT & cpu_matrix)
457 {
458  assert( (cpu_matrix.size1() == gpu_matrix_slice.size1())
459  && (cpu_matrix.size2() == gpu_matrix_slice.size2())
460  && bool("Matrix size mismatch!"));
461 
462  if ( (gpu_matrix_slice.size1() > 0) && (gpu_matrix_slice.size1() > 0) )
463  {
464  vcl_size_t num_entries = gpu_matrix_slice.size2() * gpu_matrix_slice.stride2(); //no. of entries per stride
465 
466  std::vector<NumericT> entries(num_entries);
467 
468  //copy each stride separately:
469  for (vcl_size_t i=0; i < gpu_matrix_slice.size1(); ++i)
470  {
471  vcl_size_t start_offset = (gpu_matrix_slice.start1() + i * gpu_matrix_slice.stride1()) * gpu_matrix_slice.internal_size2() + gpu_matrix_slice.start2();
472 
473  viennacl::backend::memory_read(gpu_matrix_slice.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
474 
475  for (vcl_size_t j=0; j < gpu_matrix_slice.size2(); ++j)
476  cpu_matrix(i,j) = entries[j * gpu_matrix_slice.stride2()];
477  }
478  }
479 
480 }
481 
482 
483 //column_major:
484 template<typename CPUMatrixT, typename NumericT>
485 void copy(matrix_slice<matrix<NumericT, column_major, 1> > const & gpu_matrix_slice,
486  CPUMatrixT & cpu_matrix)
487 {
488  assert( (cpu_matrix.size1() == gpu_matrix_slice.size1())
489  && (cpu_matrix.size2() == gpu_matrix_slice.size2())
490  && bool("Matrix size mismatch!"));
491 
492  if ( (gpu_matrix_slice.size1() > 0) && (gpu_matrix_slice.size1() > 0) )
493  {
494  vcl_size_t num_entries = gpu_matrix_slice.size1() * gpu_matrix_slice.stride1(); //no. of entries per stride
495 
496  std::vector<NumericT> entries(num_entries);
497 
498  //copy each column stride separately:
499  for (vcl_size_t j=0; j < gpu_matrix_slice.size2(); ++j)
500  {
501  vcl_size_t start_offset = gpu_matrix_slice.start1() + (gpu_matrix_slice.start2() + j * gpu_matrix_slice.stride2()) * gpu_matrix_slice.internal_size1();
502 
503  viennacl::backend::memory_read(gpu_matrix_slice.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
504 
505  for (vcl_size_t i=0; i < gpu_matrix_slice.size1(); ++i)
506  cpu_matrix(i,j) = entries[i * gpu_matrix_slice.stride1()];
507  }
508  }
509 
510 }
511 
512 
513 //
514 // Convenience function
515 //
516 template<typename MatrixType>
517 matrix_slice<MatrixType> project(MatrixType const & A, viennacl::slice const & r1, viennacl::slice const & r2)
518 {
519  assert(r1.size() <= A.size1() && r2.size() <= A.size2() && bool("Size of slice invalid!"));
520 
521  return matrix_slice<MatrixType>(A, r1, r2);
522 }
523 
524 template<typename MatrixType>
526 {
527  assert(r1.size() <= A.size1() && r2.size() <= A.size2() && bool("Size of slice invalid!"));
528 
529  return matrix_slice<MatrixType>(A, r1, r2);
530 }
531 
532 template<typename MatrixType>
534 {
535  assert(r1.size() <= A.size1() && r2.size() <= A.size2() && bool("Size of slice invalid!"));
536 
537  return matrix_slice<MatrixType>(A, r1, r2);
538 }
539 
540 // TODO: Allow mix of range/slice
541 
542 }
543 
544 #endif
viennacl::tools::shared_ptr< char > handle_type
Definition: cpu_ram.hpp:35
matrix_slice(MatrixType const &A, slice const &row_slice, slice const &col_slice)
DistanceT difference_type
Definition: range.hpp:43
void memory_write(mem_handle &dst_buffer, vcl_size_t dst_offset, vcl_size_t bytes_to_write, const void *ptr, bool async=false)
Writes data from main RAM identified by 'ptr' to the buffer identified by 'dst_buffer'.
Definition: memory.hpp:220
matrix_range(matrix_range< MatrixType > const &A, range const &row_range, range const &col_range)
Class for representing strided submatrices of a bigger matrix A.
Definition: forwards.h:442
size_type size() const
Definition: slice.hpp:56
range::size_type size_type
MatrixType::value_type value_type
matrix_range(MatrixType const &A, range const &row_range, range const &col_range)
MatrixType::handle_type handle_type
size_type stride2() const
Returns the number of columns.
Definition: matrix_def.hpp:225
result_of::size_type< viennacl::vector_base< T > >::type stride(viennacl::vector_base< T > const &s)
Definition: stride.hpp:45
This file provides the forward declarations for the main types used within ViennaCL.
A dense matrix class.
Definition: forwards.h:374
void memory_read(mem_handle const &src_buffer, vcl_size_t src_offset, vcl_size_t bytes_to_read, void *ptr, bool async=false)
Reads data from a buffer back to main RAM.
Definition: memory.hpp:261
range::difference_type difference_type
Forward declaration of dense matrix classes.
viennacl::result_of::cpu_value_type< value_type >::type cpu_value_type
matrix_slice(self_type const &other)
MatrixType::value_type value_type
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
Definition: size.hpp:144
range::size_type size_type
matrix_range(self_type const &A, range const &row_range, range const &col_range)
result_of::size_type< T >::type start(T const &obj)
Definition: start.hpp:44
matrix_slice(MatrixType const &A, slice const &row_slice, slice const &col_slice)
range::difference_type difference_type
const value_type & const_reference
size_type stride1() const
Returns the number of rows.
Definition: matrix_def.hpp:223
matrix_range< MatrixType > project(MatrixType const &A, viennacl::range const &r1, viennacl::range const &r2)
matrix_range(self_type const &other)
std::size_t vcl_size_t
Definition: forwards.h:74
size_type size2() const
Returns the number of columns.
Definition: matrix_def.hpp:217
handle_type & handle()
Returns the OpenCL handle, non-const-version.
Definition: matrix_def.hpp:235
T::ERROR_CANNOT_DEDUCE_CPU_SCALAR_TYPE_FOR_T type
Definition: result_of.hpp:238
size_type size1() const
Returns the number of rows.
Definition: matrix_def.hpp:215
MatrixType::handle_type handle_type
matrix_slice(self_type const &A, slice const &row_slice, slice const &col_slice)
void copy(std::vector< NumericT > &cpu_vec, circulant_matrix< NumericT, AlignmentV > &gpu_mat)
Copies a circulant matrix from the std::vector to the OpenCL device (either GPU or multi-core CPU) ...
Implementation of a slice object for use with proxy objects.
A range class that refers to an interval [start, stop), where 'start' is included, and 'stop' is excluded.
Definition: forwards.h:423
Implementation of a range object for use with proxy objects.
size_type start2() const
Returns the number of columns.
Definition: matrix_def.hpp:221
size_type internal_size2() const
Returns the internal number of columns. Usually required for launching OpenCL kernels only...
Definition: matrix_def.hpp:231
Class for representing non-strided submatrices of a bigger matrix A.
Definition: forwards.h:439
size_type internal_size1() const
Returns the internal number of rows. Usually required for launching OpenCL kernels only...
Definition: matrix_def.hpp:229
viennacl::result_of::cpu_value_type< value_type >::type cpu_value_type
const value_type & const_reference
A slice class that refers to an interval [start, stop), where 'start' is included, and 'stop' is excluded.
Definition: forwards.h:428
A tag for row-major storage of a dense matrix.
Definition: forwards.h:303
matrix_range(MatrixType const &A, range const &row_range, range const &col_range)
size_type start1() const
Returns the number of rows.
Definition: matrix_def.hpp:219
size_type size() const
Definition: range.hpp:56
matrix_slice(matrix_slice< MatrixType > const &A, slice const &row_slice, slice const &col_slice)