ViennaCL - The Vienna Computing Library  1.5.2
misc_operations.hpp
Go to the documentation of this file.
1 #ifndef VIENNACL_LINALG_HOST_BASED_MISC_OPERATIONS_HPP_
2 #define VIENNACL_LINALG_HOST_BASED_MISC_OPERATIONS_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 <list>
26 
27 #include "viennacl/forwards.h"
28 #include "viennacl/scalar.hpp"
29 #include "viennacl/vector.hpp"
30 #include "viennacl/tools/tools.hpp"
32 
33 namespace viennacl
34 {
35  namespace linalg
36  {
37  namespace host_based
38  {
39  namespace detail
40  {
41  template <typename ScalarType>
43  viennacl::backend::mem_handle const & row_index_array,
44  viennacl::backend::mem_handle const & row_buffer,
45  viennacl::backend::mem_handle const & col_buffer,
46  viennacl::backend::mem_handle const & element_buffer,
47  vcl_size_t num_rows
48  )
49  {
50  ScalarType * vec_buf = viennacl::linalg::host_based::detail::extract_raw_pointer<ScalarType>(vec.handle());
51 
52  unsigned int const * elim_row_index = viennacl::linalg::host_based::detail::extract_raw_pointer<unsigned int>(row_index_array);
53  unsigned int const * elim_row_buffer = viennacl::linalg::host_based::detail::extract_raw_pointer<unsigned int>(row_buffer);
54  unsigned int const * elim_col_buffer = viennacl::linalg::host_based::detail::extract_raw_pointer<unsigned int>(col_buffer);
55  ScalarType const * elim_elements = viennacl::linalg::host_based::detail::extract_raw_pointer<ScalarType>(element_buffer);
56 
57 #ifdef VIENNACL_WITH_OPENMP
58  #pragma omp parallel for
59 #endif
60  for (long row=0; row < static_cast<long>(num_rows); ++row)
61  {
62  unsigned int eq_row = elim_row_index[row];
63  ScalarType vec_entry = vec_buf[eq_row];
64  unsigned int row_end = elim_row_buffer[row+1];
65 
66  for (vcl_size_t j = elim_row_buffer[row]; j < row_end; ++j)
67  vec_entry -= vec_buf[elim_col_buffer[j]] * elim_elements[j];
68 
69  vec_buf[eq_row] = vec_entry;
70  }
71 
72  }
73  }
74 
75  } // namespace host_based
76  } //namespace linalg
77 } //namespace viennacl
78 
79 
80 #endif
std::size_t vcl_size_t
Definition: forwards.h:58
Various little tools used here and there in ViennaCL.
This file provides the forward declarations for the main types used within ViennaCL.
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
Definition: cpu_ram.hpp:29
void level_scheduling_substitute(vector< ScalarType > &vec, viennacl::backend::mem_handle const &row_index_array, viennacl::backend::mem_handle const &row_buffer, viennacl::backend::mem_handle const &col_buffer, viennacl::backend::mem_handle const &element_buffer, vcl_size_t num_rows)
Definition: misc_operations.hpp:42
vector_expression< const matrix_base< NumericT, F >, const unsigned int, op_row > row(const matrix_base< NumericT, F > &A, unsigned int i)
Definition: matrix.hpp:910
Common routines for single-threaded or OpenMP-enabled execution on CPU.
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
const handle_type & handle() const
Returns the memory handle.
Definition: vector.hpp:856
Main abstraction class for multiple memory domains. Represents a buffer in either main RAM...
Definition: mem_handle.hpp:62
Implementation of the ViennaCL scalar class.