1 #ifndef VIENNACL_LINALG_OPENCL_AMG_OPERATIONS_HPP
2 #define VIENNACL_LINALG_OPENCL_AMG_OPERATIONS_HPP
47 template<
typename NumericT>
70 template<
typename NumericT>
75 (void)A; (void)amg_context; (void)tag;
76 throw std::runtime_error(
"amg_influence_advanced() not implemented for OpenCL yet");
81 template<
typename NumericT>
103 unsigned int coarse_id = 0;
106 coarse_ids.set(i, coarse_id);
127 template<
typename NumericT>
137 unsigned int *random_weights_ptr = viennacl::linalg::host_based::detail::extract_raw_pointer<unsigned int>(random_weights.handle());
138 for (std::size_t i=0; i<random_weights.size(); ++i)
139 random_weights_ptr[i] = static_cast<unsigned int>(rand()) % static_cast<unsigned int>(A.
size1());
151 unsigned int num_undecided =
static_cast<unsigned int>(A.
size1());
160 unsigned int pmis_iters = 0;
161 while (num_undecided > 0)
178 for (
unsigned int r = 0; r < 2; ++r)
182 work_state2, work_random2, work_index2,
189 work_state = work_state2;
190 work_random = work_random2;
191 work_index = work_index2;
207 for (std::size_t i=0; i<undecided_buffer.
size(); ++i)
208 num_undecided += undecided_buffer_host[i];
223 template<
typename NumericT>
239 throw std::runtime_error(
"Only MIS2 coarsening implemented. Selected coarsening not available with OpenCL backend!");
285 template<
typename InternalT1>
293 default:
throw std::runtime_error(
"not implemented yet");
310 template<
typename NumericT>
326 P.
handle().opencl_handle(),
342 template<
typename NumericT>
362 A.
handle().opencl_handle(),
365 Jacobi.handle1().opencl_handle(),
366 Jacobi.handle2().opencl_handle(),
367 Jacobi.handle().opencl_handle(),
374 P.generate_row_block_information();
384 template<
typename MatrixT>
394 default:
throw std::runtime_error(
"Not implemented yet!");
399 template<
typename NumericT,
unsigned int AlignmentV>
409 viennacl::traits::opencl_handle(B),
426 template<
typename NumericT>
438 for (
unsigned int i=0; i<iterations; ++i)
444 viennacl::traits::opencl_handle(x_backup),
445 viennacl::traits::opencl_handle(x),
446 viennacl::traits::opencl_handle(rhs_smooth),
447 static_cast<cl_uint
>(rhs_smooth.
size())));
Main kernel class for generating OpenCL kernels for compressed_matrix.
Helper class implementing an array on the host. Default case: No conversion necessary.
void amg_influence(compressed_matrix< NumericT > const &A, viennacl::linalg::detail::amg::amg_level_context &amg_context, viennacl::linalg::amg_tag &tag)
Dispatcher for influence processing.
amg_coarsening_method get_coarsening_method() const
Returns the current coarsening strategy.
void amg_influence_trivial(compressed_matrix< NumericT > const &A, viennacl::linalg::detail::amg::amg_level_context &amg_context, viennacl::linalg::amg_tag &tag)
Routine for taking all connections in the matrix as strong.
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'.
result_of::size_type< matrix_base< NumericT > >::type stride1(matrix_base< NumericT > const &s)
void amg_coarse_ag(compressed_matrix< NumericT > const &A, viennacl::linalg::detail::amg::amg_level_context &amg_context, viennacl::linalg::amg_tag &tag)
AG (aggregation based) coarsening. Partially single-threaded version (VIENNACL_AMG_COARSE_AG) ...
const vcl_size_t & size1() const
Returns the number of rows.
Represents an OpenCL kernel within ViennaCL.
vcl_size_t internal_size1(matrix_base< NumericT > const &mat)
Helper routine for obtaining the internal number of entries per row of a ViennaCL matrix...
vcl_size_t size1(MatrixType const &mat)
Generic routine for obtaining the number of rows of a matrix (ViennaCL, uBLAS, etc.)
Manages an OpenCL context and provides the respective convenience functions for creating buffers...
double get_jacobi_weight() const
Returns the Jacobi smoother weight (damping).
vcl_size_t internal_size2(matrix_base< NumericT > const &mat)
Helper routine for obtaining the internal number of entries per column of a ViennaCL matrix...
OpenCL kernel file for operations related to algebraic multigrid.
result_of::size_type< T >::type start1(T const &obj)
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.
void amg_interpol_ag(compressed_matrix< NumericT > const &A, compressed_matrix< NumericT > &P, viennacl::linalg::detail::amg::amg_level_context &amg_context, viennacl::linalg::amg_tag &tag)
AG (aggregation based) interpolation. Multi-Threaded! (VIENNACL_INTERPOL_SA)
result_of::size_type< MatrixType >::type size2(MatrixType const &mat)
Generic routine for obtaining the number of columns of a matrix (ViennaCL, uBLAS, etc...
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.
Common implementations shared by OpenCL-based operations.
const vcl_size_t & nnz() const
Returns the number of nonzero entries.
void assign_to_dense(viennacl::compressed_matrix< NumericT, AlignmentV > const &A, viennacl::matrix_base< NumericT > &B)
VectorT prod(std::vector< std::vector< T, A1 >, A2 > const &matrix, VectorT const &vector)
void generate_row_block_information()
Builds the row block information needed for fast sparse matrix-vector multiplications.
void enumerate_coarse_points(viennacl::linalg::detail::amg::amg_level_context &amg_context)
Assign IDs to coarse points.
result_of::size_type< T >::type start2(T const &obj)
Main kernel class for generating OpenCL kernels for compressed_matrix (except solvers).
void amg_interpol(MatrixT const &A, MatrixT &P, viennacl::linalg::detail::amg::amg_level_context &amg_context, viennacl::linalg::amg_tag &tag)
Dispatcher for building the interpolation matrix.
viennacl::ocl::kernel & get_kernel(std::string const &program_name, std::string const &kernel_name)
Convenience function for retrieving the kernel of a program directly from the context.
const handle_type & handle2() const
Returns the OpenCL handle to the column index array.
void amg_influence_advanced(compressed_matrix< NumericT > const &A, viennacl::linalg::detail::amg::amg_level_context &amg_context, viennacl::linalg::amg_tag &tag)
Routine for extracting strongly connected points considering a user-provided threshold value...
result_of::size_type< matrix_base< NumericT > >::type stride2(matrix_base< NumericT > const &s)
static void init(viennacl::ocl::context &ctx)
A tag for algebraic multigrid (AMG). Used to transport information from the user to the implementatio...
void smooth_jacobi(unsigned int iterations, compressed_matrix< NumericT > const &A, vector< NumericT > &x, vector< NumericT > &x_backup, vector< NumericT > const &rhs_smooth, NumericT weight)
Jacobi Smoother (OpenCL version)
viennacl::context context(T const &t)
Returns an ID for the currently active memory domain of an object.
void enqueue(KernelType &k, viennacl::ocl::command_queue const &queue)
Enqueues a kernel in the provided queue.
static void init(viennacl::ocl::context &ctx)
size_type size() const
Returns the length of the vector (cf. std::vector)
viennacl::vector< unsigned int > point_types_
amg_interpolation_method get_interpolation_method() const
Returns the current interpolation method.
vcl_size_t raw_size() const
Returns the number of bytes of the currently active buffer.
void amg_coarse(InternalT1 &A, viennacl::linalg::detail::amg::amg_level_context &amg_context, viennacl::linalg::amg_tag &tag)
Calls the right coarsening procedure.
Helper classes and functions for the AMG preconditioner. Experimental.
viennacl::vector< unsigned int > coarse_id_
const handle_type & handle() const
Returns the memory handle.
viennacl::vector< unsigned int > influence_values_
void amg_coarse_ag_stage1_mis2(compressed_matrix< NumericT > const &A, viennacl::linalg::detail::amg::amg_level_context &amg_context, viennacl::linalg::amg_tag &tag)
AG (aggregation based) coarsening, single-threaded version of stage 1.
void amg_interpol_sa(compressed_matrix< NumericT > const &A, compressed_matrix< NumericT > &P, viennacl::linalg::detail::amg::amg_level_context &amg_context, viennacl::linalg::amg_tag &tag)
Smoothed aggregation interpolation. (VIENNACL_INTERPOL_SA)
viennacl::vector< unsigned int > influence_ids_
void switch_memory_context(viennacl::context new_ctx)
viennacl::vector< unsigned int > influence_jumper_