1 #ifndef VIENNACL_LINALG_DETAIL_ILU_COMMON_HPP_
2 #define VIENNACL_LINALG_DETAIL_ILU_COMMON_HPP_
50 template<
typename NumericT,
unsigned int AlignmentV>
53 std::list<viennacl::backend::mem_handle> & row_index_arrays,
54 std::list<viennacl::backend::mem_handle> & row_buffers,
55 std::list<viennacl::backend::mem_handle> & col_buffers,
56 std::list<viennacl::backend::mem_handle> & element_buffers,
57 std::list<vcl_size_t> & row_elimination_num_list,
60 NumericT const * diagonal_buf = viennacl::linalg::host_based::detail::extract_raw_pointer<NumericT>(diagonal_LU.
handle());
61 NumericT const * elements = viennacl::linalg::host_based::detail::extract_raw_pointer<NumericT>(LU.
handle());
62 unsigned int const * row_buffer = viennacl::linalg::host_based::detail::extract_raw_pointer<unsigned int>(LU.
handle1());
63 unsigned int const * col_buffer = viennacl::linalg::host_based::detail::extract_raw_pointer<unsigned int>(LU.
handle2());
68 std::vector<vcl_size_t> row_elimination(LU.
size1());
69 std::map<vcl_size_t, std::map<vcl_size_t, vcl_size_t> > row_entries_per_elimination_step;
79 for (
vcl_size_t i = row_begin; i < row_end; ++i)
81 unsigned int col = col_buffer[i];
82 if ( (!setup_U && col < row) || (setup_U && col >
row) )
84 elimination_index = std::max<vcl_size_t>(elimination_index, row_elimination[col]);
85 row_entries_per_elimination_step[row_elimination[col]][
row] += 1;
88 row_elimination[
row] = elimination_index + 1;
89 max_elimination_runs = std::max<vcl_size_t>(max_elimination_runs, elimination_index + 1);
104 for (
vcl_size_t elimination_run = 1; elimination_run <= max_elimination_runs; ++elimination_run)
106 std::map<vcl_size_t, vcl_size_t>
const & current_elimination_info = row_entries_per_elimination_step[elimination_run];
109 vcl_size_t num_tainted_cols = current_elimination_info.size();
112 for (std::map<vcl_size_t, vcl_size_t>::const_iterator it = current_elimination_info.begin();
113 it != current_elimination_info.end();
115 num_entries += it->second;
120 if (num_tainted_cols > 0)
136 std::vector<NumericT> elim_elements_buffer(num_entries);
138 row_elimination_num_list.push_back(num_tainted_cols);
142 elim_row_buffer.set(0, 0);
144 for (std::map<vcl_size_t, vcl_size_t>::const_iterator it = current_elimination_info.begin();
145 it != current_elimination_info.end();
150 elim_row_index_array.set(k, row);
154 for (
vcl_size_t i = row_begin; i < row_end; ++i)
156 unsigned int col = col_buffer[i];
157 if ( (!setup_U && col < row) || (setup_U && col > row) )
159 if (row_elimination[col] == elimination_run)
161 elim_col_buffer.set(nnz_index, col);
162 elim_elements_buffer[nnz_index] = setup_U ? elements[i] / diagonal_buf[it->first] : elements[i];
168 elim_row_buffer.set(++k, nnz_index);
190 template<
typename NumericT,
unsigned int AlignmentV>
193 std::list<viennacl::backend::mem_handle> & row_index_arrays,
194 std::list<viennacl::backend::mem_handle> & row_buffers,
195 std::list<viennacl::backend::mem_handle> & col_buffers,
196 std::list<viennacl::backend::mem_handle> & element_buffers,
197 std::list<vcl_size_t> & row_elimination_num_list)
199 level_scheduling_setup_impl(LU, diagonal_LU, row_index_arrays, row_buffers, col_buffers, element_buffers, row_elimination_num_list,
false);
207 template<
typename NumericT,
unsigned int AlignmentV>
210 std::list<viennacl::backend::mem_handle> & row_index_arrays,
211 std::list<viennacl::backend::mem_handle> & row_buffers,
212 std::list<viennacl::backend::mem_handle> & col_buffers,
213 std::list<viennacl::backend::mem_handle> & element_buffers,
214 std::list<vcl_size_t> & row_elimination_num_list)
216 level_scheduling_setup_impl(LU, diagonal_LU, row_index_arrays, row_buffers, col_buffers, element_buffers, row_elimination_num_list,
true);
223 template<
typename NumericT>
225 std::list<viennacl::backend::mem_handle>
const & row_index_arrays,
226 std::list<viennacl::backend::mem_handle>
const & row_buffers,
227 std::list<viennacl::backend::mem_handle>
const & col_buffers,
228 std::list<viennacl::backend::mem_handle>
const & element_buffers,
229 std::list<vcl_size_t>
const & row_elimination_num_list)
231 typedef typename std::list< viennacl::backend::mem_handle >::const_iterator ListIterator;
232 ListIterator row_index_array_it = row_index_arrays.begin();
233 ListIterator row_buffers_it = row_buffers.begin();
234 ListIterator col_buffers_it = col_buffers.begin();
235 ListIterator element_buffers_it = element_buffers.begin();
236 typename std::list< vcl_size_t>::const_iterator row_elimination_num_it = row_elimination_num_list.begin();
237 for (
vcl_size_t i=0; i<row_index_arrays.size(); ++i)
241 ++row_index_array_it;
244 ++element_buffers_it;
245 ++row_elimination_num_it;
Helper class implementing an array on the host. Default case: No conversion necessary.
const vcl_size_t & size1() const
Returns the number of rows.
This file provides the forward declarations for the main types used within ViennaCL.
void level_scheduling_setup_U(viennacl::compressed_matrix< NumericT, AlignmentV > const &LU, viennacl::vector< NumericT > const &diagonal_LU, std::list< viennacl::backend::mem_handle > &row_index_arrays, std::list< viennacl::backend::mem_handle > &row_buffers, std::list< viennacl::backend::mem_handle > &col_buffers, std::list< viennacl::backend::mem_handle > &element_buffers, std::list< vcl_size_t > &row_elimination_num_list)
void level_scheduling_substitute(viennacl::vector< NumericT > &vec, std::list< viennacl::backend::mem_handle > const &row_index_arrays, std::list< viennacl::backend::mem_handle > const &row_buffers, std::list< viennacl::backend::mem_handle > const &col_buffers, std::list< viennacl::backend::mem_handle > const &element_buffers, std::list< vcl_size_t > const &row_elimination_num_list)
const handle_type & handle() const
Returns the OpenCL handle to the matrix entry array.
const handle_type & handle1() const
Returns the OpenCL handle to the row index array.
void level_scheduling_setup_impl(viennacl::compressed_matrix< NumericT, AlignmentV > const &LU, viennacl::vector< NumericT > const &diagonal_LU, std::list< viennacl::backend::mem_handle > &row_index_arrays, std::list< viennacl::backend::mem_handle > &row_buffers, std::list< viennacl::backend::mem_handle > &col_buffers, std::list< viennacl::backend::mem_handle > &element_buffers, std::list< vcl_size_t > &row_elimination_num_list, bool setup_U)
const handle_type & handle2() const
Returns the OpenCL handle to the column index array.
Common routines for single-threaded or OpenMP-enabled execution on CPU.
vector_expression< const matrix_base< NumericT, F >, const unsigned int, op_row > row(const matrix_base< NumericT, F > &A, unsigned int i)
viennacl::context context(T const &t)
Returns an ID for the currently active memory domain of an object.
Main abstraction class for multiple memory domains. Represents a buffer in either main RAM...
void level_scheduling_setup_L(viennacl::compressed_matrix< NumericT, AlignmentV > const &LU, viennacl::vector< NumericT > const &diagonal_LU, std::list< viennacl::backend::mem_handle > &row_index_arrays, std::list< viennacl::backend::mem_handle > &row_buffers, std::list< viennacl::backend::mem_handle > &col_buffers, std::list< viennacl::backend::mem_handle > &element_buffers, std::list< vcl_size_t > &row_elimination_num_list)
A sparse square matrix in compressed sparse rows format.
void memory_create(mem_handle &handle, vcl_size_t size_in_bytes, viennacl::context const &ctx, const void *host_ptr=NULL)
Creates an array of the specified size. If the second argument is provided, the buffer is initialized...
const handle_type & handle() const
Returns the memory handle.
Implementations of miscellaneous operations.
Main interface routines for memory management.