1 #ifndef VIENNACL_LINALG_DETAIL_ILU0_HPP_
2 #define VIENNACL_LINALG_DETAIL_ILU0_HPP_
61 ilu0_tag(
bool with_level_scheduling =
false) : use_level_scheduling_(with_level_scheduling) {}
67 bool use_level_scheduling_;
77 template<
typename NumericT>
84 NumericT * elements = viennacl::linalg::host_based::detail::extract_raw_pointer<NumericT>(A.
handle());
85 unsigned int const * row_buffer = viennacl::linalg::host_based::detail::extract_raw_pointer<unsigned int>(A.
handle1());
86 unsigned int const * col_buffer = viennacl::linalg::host_based::detail::extract_raw_pointer<unsigned int>(A.
handle2());
92 unsigned int row_i_begin = row_buffer[i];
93 unsigned int row_i_end = row_buffer[i+1];
94 for (
unsigned int buf_index_k = row_i_begin; buf_index_k < row_i_end; ++buf_index_k)
96 unsigned int k = col_buffer[buf_index_k];
100 unsigned int row_k_begin = row_buffer[k];
101 unsigned int row_k_end = row_buffer[k+1];
105 for (
unsigned int buf_index_akk = row_k_begin; buf_index_akk < row_k_end; ++buf_index_akk)
107 if (col_buffer[buf_index_akk] == k)
109 a_kk = elements[buf_index_akk];
114 NumericT & a_ik = elements[buf_index_k];
117 for (
unsigned int buf_index_j = row_i_begin; buf_index_j < row_i_end; ++buf_index_j)
119 unsigned int j = col_buffer[buf_index_j];
125 for (
unsigned int buf_index_akj = row_k_begin; buf_index_akj < row_k_end; ++buf_index_akj)
127 if (col_buffer[buf_index_akj] == j)
129 a_kj = elements[buf_index_akj];
135 elements[buf_index_j] -= a_ik * a_kj;
145 template<
typename MatrixT>
148 typedef typename MatrixT::value_type NumericType;
159 template<
typename VectorT>
162 unsigned int const * row_buffer = viennacl::linalg::host_based::detail::extract_raw_pointer<unsigned int>(LU_.
handle1());
163 unsigned int const * col_buffer = viennacl::linalg::host_based::detail::extract_raw_pointer<unsigned int>(LU_.
handle2());
164 NumericType
const * elements = viennacl::linalg::host_based::detail::extract_raw_pointer<NumericType>(LU_.
handle());
166 viennacl::linalg::host_based::detail::csr_inplace_solve<NumericType>(row_buffer, col_buffer, elements, vec, LU_.
size2(),
unit_lower_tag());
167 viennacl::linalg::host_based::detail::csr_inplace_solve<NumericType>(row_buffer, col_buffer, elements, vec, LU_.
size2(),
upper_tag());
171 void init(MatrixT
const & mat)
189 template<
typename NumericT,
unsigned int AlignmentV>
214 multifrontal_L_row_index_arrays_,
215 multifrontal_L_row_buffers_,
216 multifrontal_L_col_buffers_,
217 multifrontal_L_element_buffers_,
218 multifrontal_L_row_elimination_num_list_);
223 multifrontal_U_row_index_arrays_,
224 multifrontal_U_row_buffers_,
225 multifrontal_U_col_buffers_,
226 multifrontal_U_element_buffers_,
227 multifrontal_U_row_elimination_num_list_);
244 multifrontal_L_row_index_arrays_,
245 multifrontal_L_row_buffers_,
246 multifrontal_L_col_buffers_,
247 multifrontal_L_element_buffers_,
248 multifrontal_L_row_elimination_num_list_);
253 multifrontal_U_row_index_arrays_,
254 multifrontal_U_row_buffers_,
255 multifrontal_U_col_buffers_,
256 multifrontal_U_element_buffers_,
257 multifrontal_U_row_elimination_num_list_);
270 void init(MatrixType
const & mat)
282 multifrontal_U_diagonal_.resize(LU_.
size1(),
false);
286 multifrontal_U_diagonal_,
287 multifrontal_L_row_index_arrays_,
288 multifrontal_L_row_buffers_,
289 multifrontal_L_col_buffers_,
290 multifrontal_L_element_buffers_,
291 multifrontal_L_row_elimination_num_list_);
295 multifrontal_U_diagonal_,
296 multifrontal_U_row_index_arrays_,
297 multifrontal_U_row_buffers_,
298 multifrontal_U_col_buffers_,
299 multifrontal_U_element_buffers_,
300 multifrontal_U_row_elimination_num_list_);
307 for (
typename std::list< viennacl::backend::mem_handle >::iterator it = multifrontal_L_row_index_arrays_.begin();
308 it != multifrontal_L_row_index_arrays_.end();
312 for (
typename std::list< viennacl::backend::mem_handle >::iterator it = multifrontal_L_row_buffers_.begin();
313 it != multifrontal_L_row_buffers_.end();
317 for (
typename std::list< viennacl::backend::mem_handle >::iterator it = multifrontal_L_col_buffers_.begin();
318 it != multifrontal_L_col_buffers_.end();
322 for (
typename std::list< viennacl::backend::mem_handle >::iterator it = multifrontal_L_element_buffers_.begin();
323 it != multifrontal_L_element_buffers_.end();
332 for (
typename std::list< viennacl::backend::mem_handle >::iterator it = multifrontal_U_row_index_arrays_.begin();
333 it != multifrontal_U_row_index_arrays_.end();
337 for (
typename std::list< viennacl::backend::mem_handle >::iterator it = multifrontal_U_row_buffers_.begin();
338 it != multifrontal_U_row_buffers_.end();
342 for (
typename std::list< viennacl::backend::mem_handle >::iterator it = multifrontal_U_col_buffers_.begin();
343 it != multifrontal_U_col_buffers_.end();
347 for (
typename std::list< viennacl::backend::mem_handle >::iterator it = multifrontal_U_element_buffers_.begin();
348 it != multifrontal_U_element_buffers_.end();
357 std::list<viennacl::backend::mem_handle> multifrontal_L_row_index_arrays_;
358 std::list<viennacl::backend::mem_handle> multifrontal_L_row_buffers_;
359 std::list<viennacl::backend::mem_handle> multifrontal_L_col_buffers_;
360 std::list<viennacl::backend::mem_handle> multifrontal_L_element_buffers_;
361 std::list<vcl_size_t> multifrontal_L_row_elimination_num_list_;
364 std::list<viennacl::backend::mem_handle> multifrontal_U_row_index_arrays_;
365 std::list<viennacl::backend::mem_handle> multifrontal_U_row_buffers_;
366 std::list<viennacl::backend::mem_handle> multifrontal_U_col_buffers_;
367 std::list<viennacl::backend::mem_handle> multifrontal_U_element_buffers_;
368 std::list<vcl_size_t> multifrontal_U_row_elimination_num_list_;
const vcl_size_t & size2() const
Returns the number of columns.
ilu0_precond(MatrixType const &mat, ilu0_tag const &tag)
viennacl::vector_expression< const vector_base< T >, const vector_base< T >, op_element_binary< op_div > > element_div(vector_base< T > const &v1, vector_base< T > const &v2)
void inplace_solve(const matrix_base< NumericT > &A, matrix_base< NumericT > &B, SolverTagT)
Direct inplace solver for triangular systems with multiple right hand sides, i.e. A \ B (MATLAB notat...
ilu0_precond(MatrixT const &mat, ilu0_tag const &tag)
ILU0 preconditioner class, can be supplied to solve()-routines.
const vcl_size_t & size1() const
Returns the number of rows.
vcl_size_t size1(MatrixType const &mat)
Generic routine for obtaining the number of rows of a matrix (ViennaCL, uBLAS, etc.)
A tag for incomplete LU factorization with static pattern (ILU0)
void precondition(viennacl::compressed_matrix< NumericT > &A, ilu0_tag const &)
Implementation of a ILU-preconditioner with static pattern. Optimized version for CSR matrices...
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)
result_of::size_type< MatrixType >::type size2(MatrixType const &mat)
Generic routine for obtaining the number of columns of a matrix (ViennaCL, uBLAS, etc...
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.
Represents a generic 'context' similar to an OpenCL context, but is backend-agnostic and thus also su...
A tag class representing an upper triangular matrix.
Implementation of the compressed_matrix class.
const handle_type & handle2() const
Returns the OpenCL handle to the column index array.
vcl_size_t levels() const
Common routines for single-threaded or OpenMP-enabled execution on CPU.
void apply(VectorT &vec) const
void use_level_scheduling(bool b)
viennacl::context context(T const &t)
Returns an ID for the currently active memory domain of an object.
bool use_level_scheduling() const
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) ...
A tag class representing a lower triangular matrix with unit diagonal.
void row_info(compressed_matrix< NumericT, AlignmentV > const &mat, vector_base< NumericT > &vec, viennacl::linalg::detail::row_info_types info_selector)
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)
Common routines used within ILU-type preconditioners.
void apply(viennacl::vector< NumericT > &vec) const
const handle_type & handle() const
Returns the memory handle.
Main interface routines for memory management.
ilu0_tag(bool with_level_scheduling=false)
memory_types get_active_handle_id() const
Returns an ID for the currently active memory buffer. Other memory buffers might contain old or no da...
void switch_memory_context(T &obj, viennacl::context new_ctx)
Generic convenience routine for migrating data of an object to a new memory domain.