All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sparse_matrix_operations.hpp
Go to the documentation of this file.
#ifndef VIENNACL_LINALG_OPENCL_SPARSE_MATRIX_OPERATIONS_HPP_
#define VIENNACL_LINALG_OPENCL_SPARSE_MATRIX_OPERATIONS_HPP_
/* =========================================================================
Copyright (c) 2010-2016, Institute for Microelectronics,
Institute for Analysis and Scientific Computing,
TU Wien.
Portions of this software are copyright by UChicago Argonne, LLC.
-----------------
ViennaCL - The Vienna Computing Library
-----------------
Project Head: Karl Rupp rupp@iue.tuwien.ac.at
(A list of authors and contributors can be found in the manual)
License: MIT (X11), see file LICENSE in the base directory
============================================================================= */
#include "viennacl/forwards.h"
#include "viennacl/ocl/device.hpp"
#include "viennacl/ocl/handle.hpp"
#include "viennacl/ocl/kernel.hpp"
#include "viennacl/scalar.hpp"
#include "viennacl/vector.hpp"
#include "viennacl/tools/tools.hpp"
#include "viennacl/linalg/host_based/common.hpp"
#include "viennacl/linalg/opencl/kernels/compressed_matrix.hpp"
#include "viennacl/linalg/opencl/kernels/coordinate_matrix.hpp"
#include "viennacl/linalg/opencl/kernels/ell_matrix.hpp"
#include "viennacl/linalg/opencl/kernels/sliced_ell_matrix.hpp"
#include "viennacl/linalg/opencl/kernels/hyb_matrix.hpp"
#include "viennacl/linalg/opencl/kernels/compressed_compressed_matrix.hpp"
#include "viennacl/linalg/opencl/common.hpp"
#include "viennacl/linalg/opencl/vector_operations.hpp"
namespace viennacl
{
namespace linalg
{
namespace opencl
{
//
// Compressed matrix
//
namespace detail
{
template<typename NumericT, unsigned int AlignmentV>
void row_info(compressed_matrix<NumericT, AlignmentV> const & A,
vector_base<NumericT> & x,
viennacl::linalg::detail::row_info_types info_selector)
{
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(A).context());
viennacl::linalg::opencl::kernels::compressed_matrix<NumericT>::init(ctx);
viennacl::ocl::kernel & row_info_kernel = ctx.get_kernel(viennacl::linalg::opencl::kernels::compressed_matrix<NumericT>::program_name(), "row_info_extractor");
viennacl::ocl::enqueue(row_info_kernel(A.handle1().opencl_handle(), A.handle2().opencl_handle(), A.handle().opencl_handle(),
viennacl::traits::opencl_handle(x),
cl_uint(A.size1()),
cl_uint(info_selector)
)
);
}
}
template<typename NumericT, unsigned int AlignmentV>
void prod_impl(const viennacl::compressed_matrix<NumericT, AlignmentV> & A,
const viennacl::vector_base<NumericT> & x,
NumericT alpha,
viennacl::vector_base<NumericT> & y,
NumericT beta)
{
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(A).context());
viennacl::linalg::opencl::kernels::compressed_matrix<NumericT>::init(ctx);
bool use_nvidia_specific = AlignmentV == 1 && ctx.current_device().vendor_id() == viennacl::ocl::nvidia_id && (double(A.nnz()) / double(A.size1()) > 12.0);
bool with_alpha_beta = (alpha < NumericT(1) || alpha > NumericT(1)) || (beta < 0 || beta > 0);
std::stringstream ss;
ss << "vec_mul";
unsigned int alignment = AlignmentV; //prevent unreachable code warnings below
if (use_nvidia_specific)
ss << "_nvidia";
else
{
if (alignment == 4)
ss << "4";
if (alignment == 8)
ss << "8";
}
if (with_alpha_beta)
ss << "_alpha_beta";
viennacl::ocl::kernel & k = ctx.get_kernel(viennacl::linalg::opencl::kernels::compressed_matrix<NumericT>::program_name(), ss.str());
viennacl::ocl::packed_cl_uint layout_x;
layout_x.start = cl_uint(viennacl::traits::start(x));
layout_x.stride = cl_uint(viennacl::traits::stride(x));
layout_x.size = cl_uint(viennacl::traits::size(x));
layout_x.internal_size = cl_uint(viennacl::traits::internal_size(x));
viennacl::ocl::packed_cl_uint layout_y;
layout_y.start = cl_uint(viennacl::traits::start(y));
layout_y.stride = cl_uint(viennacl::traits::stride(y));
layout_y.size = cl_uint(viennacl::traits::size(y));
layout_y.internal_size = cl_uint(viennacl::traits::internal_size(y));
if (alignment == 4 || alignment == 8)
{
if (with_alpha_beta)
viennacl::ocl::enqueue(k(A.handle1().opencl_handle(), A.handle2().opencl_handle(), A.handle().opencl_handle(),
x, layout_x,
alpha,
y, layout_y,
beta
));
else
viennacl::ocl::enqueue(k(A.handle1().opencl_handle(), A.handle2().opencl_handle(), A.handle().opencl_handle(),
x, layout_x,
y, layout_y
));
}
else
{
if (ctx.current_device().max_work_group_size() >= 256)
k.local_work_size(0, 256);
if (use_nvidia_specific)
{
k.global_work_size(0, 512 * k.local_work_size(0));
if (with_alpha_beta)
viennacl::ocl::enqueue(k(A.handle1().opencl_handle(), A.handle2().opencl_handle(), A.handle3().opencl_handle(), A.handle().opencl_handle(), cl_uint(A.blocks1()),
x, layout_x,
alpha,
y, layout_y,
beta
));
else
viennacl::ocl::enqueue(k(A.handle1().opencl_handle(), A.handle2().opencl_handle(), A.handle3().opencl_handle(), A.handle().opencl_handle(), cl_uint(A.blocks1()),
x, layout_x,
y, layout_y
));
}
else // use CSR adaptive:
{
k.global_work_size(0, A.blocks1() * k.local_work_size(0));
if (with_alpha_beta)
viennacl::ocl::enqueue(k(A.handle1().opencl_handle(), A.handle2().opencl_handle(), A.handle3().opencl_handle(), A.handle().opencl_handle(), cl_uint(A.blocks1()),
x, layout_x,
alpha,
y, layout_y,
beta
));
else
viennacl::ocl::enqueue(k(A.handle1().opencl_handle(), A.handle2().opencl_handle(), A.handle3().opencl_handle(), A.handle().opencl_handle(), cl_uint(A.blocks1()),
x, layout_x,
y, layout_y
));
}
}
}
template< typename NumericT, unsigned int AlignmentV>
void prod_impl(const viennacl::compressed_matrix<NumericT, AlignmentV> & sp_A,
const viennacl::matrix_base<NumericT> & d_A,
viennacl::matrix_base<NumericT> & y) {
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(sp_A).context());
viennacl::linalg::opencl::kernels::compressed_matrix<NumericT>::init(ctx);
viennacl::ocl::kernel & k = ctx.get_kernel(viennacl::linalg::opencl::kernels::compressed_matrix<NumericT>::program_name(),
detail::sparse_dense_matmult_kernel_name(false, d_A.row_major(), y.row_major()));
viennacl::ocl::enqueue(k(sp_A.handle1().opencl_handle(), sp_A.handle2().opencl_handle(), sp_A.handle().opencl_handle(),
viennacl::traits::opencl_handle(d_A),
cl_uint(viennacl::traits::start1(d_A)), cl_uint(viennacl::traits::start2(d_A)),
cl_uint(viennacl::traits::stride1(d_A)), cl_uint(viennacl::traits::stride2(d_A)),
cl_uint(viennacl::traits::size1(d_A)), cl_uint(viennacl::traits::size2(d_A)),
cl_uint(viennacl::traits::internal_size1(d_A)), cl_uint(viennacl::traits::internal_size2(d_A)),
viennacl::traits::opencl_handle(y),
cl_uint(viennacl::traits::start1(y)), cl_uint(viennacl::traits::start2(y)),
cl_uint(viennacl::traits::stride1(y)), cl_uint(viennacl::traits::stride2(y)),
cl_uint(viennacl::traits::size1(y)), cl_uint(viennacl::traits::size2(y)),
cl_uint(viennacl::traits::internal_size1(y)), cl_uint(viennacl::traits::internal_size2(y)) ));
}
template<typename NumericT, unsigned int AlignmentV>
void prod_impl(viennacl::compressed_matrix<NumericT, AlignmentV> const & sp_A,
viennacl::matrix_expression< const viennacl::matrix_base<NumericT>,
const viennacl::matrix_base<NumericT>,
viennacl::op_trans > const & d_A,
viennacl::matrix_base<NumericT> & y) {
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(sp_A).context());
viennacl::linalg::opencl::kernels::compressed_matrix<NumericT>::init(ctx);
viennacl::ocl::kernel & k = ctx.get_kernel(viennacl::linalg::opencl::kernels::compressed_matrix<NumericT>::program_name(),
detail::sparse_dense_matmult_kernel_name(true, d_A.lhs().row_major(), y.row_major()));
viennacl::ocl::enqueue(k(sp_A.handle1().opencl_handle(), sp_A.handle2().opencl_handle(), sp_A.handle().opencl_handle(),
viennacl::traits::opencl_handle(d_A.lhs()),
cl_uint(viennacl::traits::start1(d_A.lhs())), cl_uint(viennacl::traits::start2(d_A.lhs())),
cl_uint(viennacl::traits::stride1(d_A.lhs())), cl_uint(viennacl::traits::stride2(d_A.lhs())),
cl_uint(viennacl::traits::size1(d_A.lhs())), cl_uint(viennacl::traits::size2(d_A.lhs())),
cl_uint(viennacl::traits::internal_size1(d_A.lhs())), cl_uint(viennacl::traits::internal_size2(d_A.lhs())),
viennacl::traits::opencl_handle(y),
cl_uint(viennacl::traits::start1(y)), cl_uint(viennacl::traits::start2(y)),
cl_uint(viennacl::traits::stride1(y)), cl_uint(viennacl::traits::stride2(y)),
cl_uint(viennacl::traits::size1(y)), cl_uint(viennacl::traits::size2(y)),
cl_uint(viennacl::traits::internal_size1(y)), cl_uint(viennacl::traits::internal_size2(y)) ) );
}
template<typename NumericT, unsigned int AlignmentV>
void prod_impl(viennacl::compressed_matrix<NumericT, AlignmentV> const & A,
viennacl::compressed_matrix<NumericT, AlignmentV> const & B,
viennacl::compressed_matrix<NumericT, AlignmentV> & C)
{
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(A).context());
viennacl::linalg::opencl::kernels::compressed_matrix<NumericT>::init(ctx);
/*
* Stage 1: Analyze sparsity pattern in order to properly allocate temporary arrays
*
* - Upper bound for the row lengths in C
*/
viennacl::vector<unsigned int> upper_bound_nonzeros_per_row_A(256, ctx); // upper bound for the nonzeros per row encountered for each work group
viennacl::ocl::kernel & k1 = ctx.get_kernel(viennacl::linalg::opencl::kernels::compressed_matrix<NumericT>::program_name(), "spgemm_stage1");
viennacl::ocl::enqueue(k1(A.handle1().opencl_handle(), A.handle2().opencl_handle(), cl_uint(A.size1()),
viennacl::traits::opencl_handle(upper_bound_nonzeros_per_row_A)
) );
upper_bound_nonzeros_per_row_A.switch_memory_context(viennacl::context(MAIN_MEMORY));
unsigned int * upper_bound_nonzeros_per_row_A_ptr = viennacl::linalg::host_based::detail::extract_raw_pointer<unsigned int>(upper_bound_nonzeros_per_row_A.handle());
unsigned int max_nnz_per_row_A = 0;
for (std::size_t i=0; i<upper_bound_nonzeros_per_row_A.size(); ++i)
max_nnz_per_row_A = std::max(max_nnz_per_row_A, upper_bound_nonzeros_per_row_A_ptr[i]);
if (max_nnz_per_row_A > 32)
{
// determine augmented size:
unsigned int max_entries_in_G = 32;
if (max_nnz_per_row_A <= 256)
max_entries_in_G = 16;
if (max_nnz_per_row_A <= 64)
max_entries_in_G = 8;
viennacl::vector<unsigned int> exclusive_scan_helper(A.size1() + 1, viennacl::traits::context(A));
viennacl::ocl::kernel & k_decompose_1 = ctx.get_kernel(viennacl::linalg::opencl::kernels::compressed_matrix<NumericT>::program_name(), "spgemm_decompose_1");
viennacl::ocl::enqueue(k_decompose_1(A.handle1().opencl_handle(), cl_uint(A.size1()),
cl_uint(max_entries_in_G),
viennacl::traits::opencl_handle(exclusive_scan_helper)
) );
// exclusive scan of helper array to find new size:
viennacl::linalg::exclusive_scan(exclusive_scan_helper);
unsigned int augmented_size = exclusive_scan_helper[A.size1()];
// split A = A2 * G1
viennacl::compressed_matrix<NumericT, AlignmentV> A2(A.size1(), augmented_size, augmented_size, viennacl::traits::context(A));
viennacl::compressed_matrix<NumericT, AlignmentV> G1(augmented_size, A.size2(), A.nnz(), viennacl::traits::context(A));
// fill A2:
viennacl::ocl::kernel & k_fill_A2 = ctx.get_kernel(viennacl::linalg::opencl::kernels::compressed_matrix<NumericT>::program_name(), "spgemm_A2");
viennacl::ocl::enqueue(k_fill_A2(A2.handle1().opencl_handle(), A2.handle2().opencl_handle(), A2.handle().opencl_handle(), cl_uint(A2.size1()),
viennacl::traits::opencl_handle(exclusive_scan_helper)
) );
// fill G1:
viennacl::ocl::kernel & k_fill_G1 = ctx.get_kernel(viennacl::linalg::opencl::kernels::compressed_matrix<NumericT>::program_name(), "spgemm_G1");
viennacl::ocl::enqueue(k_fill_G1(G1.handle1().opencl_handle(), G1.handle2().opencl_handle(), G1.handle().opencl_handle(), cl_uint(G1.size1()),
A.handle1().opencl_handle(), A.handle2().opencl_handle(), A.handle().opencl_handle(), cl_uint(A.size1()), cl_uint(A.nnz()),
cl_uint(max_entries_in_G),
viennacl::traits::opencl_handle(exclusive_scan_helper)
) );
// compute tmp = G1 * B;
// C = A2 * tmp;
viennacl::compressed_matrix<NumericT, AlignmentV> tmp(G1.size1(), B.size2(), 0, viennacl::traits::context(A));
prod_impl(G1, B, tmp); // this runs a standard RMerge without decomposition of G1
prod_impl(A2, tmp, C); // this may split A2 again
return;
}
/*
* Stage 2: Determine sparsity pattern of C
*/
C.resize(A.size1(), B.size2(), false);
viennacl::ocl::kernel & k2 = ctx.get_kernel(viennacl::linalg::opencl::kernels::compressed_matrix<NumericT>::program_name(), "spgemm_stage2");
k2.local_work_size(0, 32); // run with one warp/wavefront
k2.global_work_size(0, 256*256*32); // make sure enough warps/wavefronts are in flight
viennacl::ocl::enqueue(k2(A.handle1().opencl_handle(), A.handle2().opencl_handle(), cl_uint(A.size1()),
B.handle1().opencl_handle(), B.handle2().opencl_handle(), cl_uint(B.size2()),
C.handle1().opencl_handle()
) );
// exclusive scan on host to obtain row start indices:
viennacl::backend::typesafe_host_array<unsigned int> row_buffer(C.handle1(), C.size1() + 1);
viennacl::backend::memory_read(C.handle1(), 0, row_buffer.raw_size(), row_buffer.get());
unsigned int current_offset = 0;
for (std::size_t i=0; i<C.size1(); ++i)
{
unsigned int tmp = row_buffer[i];
row_buffer.set(i, current_offset);
current_offset += tmp;
}
row_buffer.set(C.size1(), current_offset);
viennacl::backend::memory_write(C.handle1(), 0, row_buffer.raw_size(), row_buffer.get());
/*
* Stage 3: Compute entries in C
*/
C.reserve(current_offset, false);
viennacl::ocl::kernel & k3 = ctx.get_kernel(viennacl::linalg::opencl::kernels::compressed_matrix<NumericT>::program_name(), "spgemm_stage3");
k3.local_work_size(0, 32); // run with one warp/wavefront
k3.global_work_size(0, 256*256*32); // make sure enough warps/wavefronts are in flight
viennacl::ocl::enqueue(k3(A.handle1().opencl_handle(), A.handle2().opencl_handle(), A.handle().opencl_handle(), cl_uint(A.size1()),
B.handle1().opencl_handle(), B.handle2().opencl_handle(), B.handle().opencl_handle(), cl_uint(B.size2()),
C.handle1().opencl_handle(), C.handle2().opencl_handle(), C.handle().opencl_handle()
) );
}
// triangular solvers
template<typename NumericT, unsigned int MAT_AlignmentV>
void inplace_solve(compressed_matrix<NumericT, MAT_AlignmentV> const & L,
vector_base<NumericT> & x,
viennacl::linalg::unit_lower_tag)
{
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(L).context());
viennacl::linalg::opencl::kernels::compressed_matrix_solve<NumericT>::init(ctx);
viennacl::ocl::kernel & k = ctx.get_kernel(viennacl::linalg::opencl::kernels::compressed_matrix_solve<NumericT>::program_name(), "unit_lu_forward");
k.local_work_size(0, 128);
k.global_work_size(0, k.local_work_size());
viennacl::ocl::enqueue(k(L.handle1().opencl_handle(), L.handle2().opencl_handle(), L.handle().opencl_handle(),
viennacl::traits::opencl_handle(x),
cl_uint(L.size1())
)
);
}
template<typename NumericT, unsigned int AlignmentV>
void inplace_solve(compressed_matrix<NumericT, AlignmentV> const & L,
vector_base<NumericT> & x,
viennacl::linalg::lower_tag)
{
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(L).context());
viennacl::linalg::opencl::kernels::compressed_matrix_solve<NumericT>::init(ctx);
viennacl::ocl::kernel & k = ctx.get_kernel(viennacl::linalg::opencl::kernels::compressed_matrix_solve<NumericT>::program_name(), "lu_forward");
k.local_work_size(0, 128);
k.global_work_size(0, k.local_work_size());
viennacl::ocl::enqueue(k(L.handle1().opencl_handle(), L.handle2().opencl_handle(), L.handle().opencl_handle(),
viennacl::traits::opencl_handle(x),
cl_uint(L.size1())
)
);
}
template<typename NumericT, unsigned int AlignmentV>
void inplace_solve(compressed_matrix<NumericT, AlignmentV> const & U,
vector_base<NumericT> & x,
viennacl::linalg::unit_upper_tag)
{
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(U).context());
viennacl::linalg::opencl::kernels::compressed_matrix_solve<NumericT>::init(ctx);
viennacl::ocl::kernel & k = ctx.get_kernel(viennacl::linalg::opencl::kernels::compressed_matrix_solve<NumericT>::program_name(), "unit_lu_backward");
k.local_work_size(0, 128);
k.global_work_size(0, k.local_work_size());
viennacl::ocl::enqueue(k(U.handle1().opencl_handle(), U.handle2().opencl_handle(), U.handle().opencl_handle(),
viennacl::traits::opencl_handle(x),
cl_uint(U.size1())
)
);
}
template<typename NumericT, unsigned int AlignmentV>
void inplace_solve(compressed_matrix<NumericT, AlignmentV> const & U,
vector_base<NumericT> & x,
viennacl::linalg::upper_tag)
{
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(U).context());
viennacl::linalg::opencl::kernels::compressed_matrix_solve<NumericT>::init(ctx);
viennacl::ocl::kernel & k = ctx.get_kernel(viennacl::linalg::opencl::kernels::compressed_matrix_solve<NumericT>::program_name(), "lu_backward");
k.local_work_size(0, 128);
k.global_work_size(0, k.local_work_size());
viennacl::ocl::enqueue(k(U.handle1().opencl_handle(), U.handle2().opencl_handle(), U.handle().opencl_handle(),
viennacl::traits::opencl_handle(x),
cl_uint(U.size1())
)
);
}
// transposed triangular solvers
namespace detail
{
//
// block solves
//
template<typename NumericT, unsigned int AlignmentV>
void block_inplace_solve(const matrix_expression<const compressed_matrix<NumericT, AlignmentV>,
const compressed_matrix<NumericT, AlignmentV>,
op_trans> & L,
viennacl::backend::mem_handle const & block_indices, vcl_size_t num_blocks,
vector_base<NumericT> const & /* L_diagonal */, //ignored
vector_base<NumericT> & x,
viennacl::linalg::unit_lower_tag)
{
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(L.lhs()).context());
viennacl::linalg::opencl::kernels::compressed_matrix_solve<NumericT>::init(ctx);
viennacl::ocl::kernel & block_solve_kernel = ctx.get_kernel(viennacl::linalg::opencl::kernels::compressed_matrix_solve<NumericT>::program_name(), "block_trans_unit_lu_forward");
block_solve_kernel.global_work_size(0, num_blocks * block_solve_kernel.local_work_size(0));
viennacl::ocl::enqueue(block_solve_kernel(L.lhs().handle1().opencl_handle(),
L.lhs().handle2().opencl_handle(),
L.lhs().handle().opencl_handle(),
block_indices.opencl_handle(),
x,
static_cast<cl_uint>(x.size())));
}
template<typename NumericT, unsigned int AlignmentV>
void block_inplace_solve(matrix_expression<const compressed_matrix<NumericT, AlignmentV>,
const compressed_matrix<NumericT, AlignmentV>,
op_trans> const & U,
viennacl::backend::mem_handle const & block_indices, vcl_size_t num_blocks,
vector_base<NumericT> const & U_diagonal,
vector_base<NumericT> & x,
viennacl::linalg::upper_tag)
{
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(U.lhs()).context());
viennacl::linalg::opencl::kernels::compressed_matrix_solve<NumericT>::init(ctx);
viennacl::ocl::kernel & block_solve_kernel = ctx.get_kernel(viennacl::linalg::opencl::kernels::compressed_matrix_solve<NumericT>::program_name(), "block_trans_lu_backward");
block_solve_kernel.global_work_size(0, num_blocks * block_solve_kernel.local_work_size(0));
viennacl::ocl::enqueue(block_solve_kernel(U.lhs().handle1().opencl_handle(),
U.lhs().handle2().opencl_handle(),
U.lhs().handle().opencl_handle(),
U_diagonal,
block_indices.opencl_handle(),
x,
static_cast<cl_uint>(x.size())));
}
}
template<typename NumericT, unsigned int AlignmentV>
void inplace_solve(matrix_expression< const compressed_matrix<NumericT, AlignmentV>,
const compressed_matrix<NumericT, AlignmentV>,
op_trans> const & proxy_L,
vector_base<NumericT> & x,
viennacl::linalg::unit_lower_tag)
{
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(proxy_L.lhs()).context());
viennacl::linalg::opencl::kernels::compressed_matrix_solve<NumericT>::init(ctx);
viennacl::ocl::kernel & k = ctx.get_kernel(viennacl::linalg::opencl::kernels::compressed_matrix_solve<NumericT>::program_name(), "trans_unit_lu_forward");
k.local_work_size(0, 128);
k.global_work_size(0, k.local_work_size());
viennacl::ocl::enqueue(k(proxy_L.lhs().handle1().opencl_handle(), proxy_L.lhs().handle2().opencl_handle(), proxy_L.lhs().handle().opencl_handle(),
viennacl::traits::opencl_handle(x),
cl_uint(proxy_L.lhs().size1())
)
);
}
template<typename NumericT, unsigned int AlignmentV>
void inplace_solve(matrix_expression< const compressed_matrix<NumericT, AlignmentV>,
const compressed_matrix<NumericT, AlignmentV>,
op_trans> const & proxy_L,
vector_base<NumericT> & x,
viennacl::linalg::lower_tag)
{
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(proxy_L.lhs()).context());
viennacl::linalg::opencl::kernels::compressed_matrix_solve<NumericT>::init(ctx);
viennacl::vector<NumericT> diagonal(x.size());
detail::row_info(proxy_L.lhs(), diagonal, viennacl::linalg::detail::SPARSE_ROW_DIAGONAL);
viennacl::ocl::kernel & k = ctx.get_kernel(viennacl::linalg::opencl::kernels::compressed_matrix_solve<NumericT>::program_name(), "trans_lu_forward");
k.local_work_size(0, 128);
k.global_work_size(0, k.local_work_size());
viennacl::ocl::enqueue(k(proxy_L.lhs().handle1().opencl_handle(), proxy_L.lhs().handle2().opencl_handle(), proxy_L.lhs().handle().opencl_handle(),
viennacl::traits::opencl_handle(diagonal),
viennacl::traits::opencl_handle(x),
cl_uint(proxy_L.lhs().size1())
)
);
}
template<typename NumericT, unsigned int AlignmentV>
void inplace_solve(matrix_expression< const compressed_matrix<NumericT, AlignmentV>,
const compressed_matrix<NumericT, AlignmentV>,
op_trans> const & proxy_U,
vector_base<NumericT> & x,
viennacl::linalg::unit_upper_tag)
{
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(proxy_U.lhs()).context());
viennacl::linalg::opencl::kernels::compressed_matrix_solve<NumericT>::init(ctx);
viennacl::ocl::kernel & k = ctx.get_kernel(viennacl::linalg::opencl::kernels::compressed_matrix_solve<NumericT>::program_name(), "trans_unit_lu_backward");
k.local_work_size(0, 128);
k.global_work_size(0, k.local_work_size());
viennacl::ocl::enqueue(k(proxy_U.lhs().handle1().opencl_handle(), proxy_U.lhs().handle2().opencl_handle(), proxy_U.lhs().handle().opencl_handle(),
viennacl::traits::opencl_handle(x),
cl_uint(proxy_U.lhs().size1())
)
);
}
template<typename NumericT, unsigned int AlignmentV>
void inplace_solve(matrix_expression< const compressed_matrix<NumericT, AlignmentV>,
const compressed_matrix<NumericT, AlignmentV>,
op_trans> const & proxy_U,
vector_base<NumericT> & x,
viennacl::linalg::upper_tag)
{
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(proxy_U.lhs()).context());
viennacl::linalg::opencl::kernels::compressed_matrix_solve<NumericT>::init(ctx);
viennacl::vector<NumericT> diagonal(x.size());
detail::row_info(proxy_U.lhs(), diagonal, viennacl::linalg::detail::SPARSE_ROW_DIAGONAL);
viennacl::ocl::kernel & k = ctx.get_kernel(viennacl::linalg::opencl::kernels::compressed_matrix_solve<NumericT>::program_name(), "trans_lu_backward");
k.local_work_size(0, 128);
k.global_work_size(0, k.local_work_size());
viennacl::ocl::enqueue(k(proxy_U.lhs().handle1().opencl_handle(), proxy_U.lhs().handle2().opencl_handle(), proxy_U.lhs().handle().opencl_handle(),
viennacl::traits::opencl_handle(diagonal),
viennacl::traits::opencl_handle(x),
cl_uint(proxy_U.lhs().size1())
)
);
}
//
// Compressed Compressed matrix
//
template<typename NumericT>
void prod_impl(viennacl::compressed_compressed_matrix<NumericT> const & A,
viennacl::vector_base<NumericT> const & x,
NumericT alpha,
viennacl::vector_base<NumericT> & y,
NumericT beta)
{
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(A).context());
viennacl::linalg::opencl::kernels::compressed_compressed_matrix<NumericT>::init(ctx);
viennacl::ocl::kernel & k = ctx.get_kernel(viennacl::linalg::opencl::kernels::compressed_compressed_matrix<NumericT>::program_name(), "vec_mul");
if (beta < 0 || beta > 0) // multiply by beta
viennacl::linalg::opencl::av(y, y, beta, 1, false, false);
else
y.clear();
viennacl::ocl::packed_cl_uint layout_x;
layout_x.start = cl_uint(viennacl::traits::start(x));
layout_x.stride = cl_uint(viennacl::traits::stride(x));
layout_x.size = cl_uint(viennacl::traits::size(x));
layout_x.internal_size = cl_uint(viennacl::traits::internal_size(x));
viennacl::ocl::packed_cl_uint layout_y;
layout_y.start = cl_uint(viennacl::traits::start(y));
layout_y.stride = cl_uint(viennacl::traits::stride(y));
layout_y.size = cl_uint(viennacl::traits::size(y));
layout_y.internal_size = cl_uint(viennacl::traits::internal_size(y));
viennacl::ocl::enqueue(k(A.handle1().opencl_handle(), A.handle3().opencl_handle(), A.handle2().opencl_handle(), A.handle().opencl_handle(), cl_uint(A.nnz1()),
x, layout_x,
alpha,
y, layout_y,
beta
));
}
//
// Coordinate matrix
//
namespace detail
{
template<typename NumericT, unsigned int AlignmentV>
void row_info(coordinate_matrix<NumericT, AlignmentV> const & A,
vector_base<NumericT> & x,
viennacl::linalg::detail::row_info_types info_selector)
{
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(A).context());
viennacl::linalg::opencl::kernels::coordinate_matrix<NumericT>::init(ctx);
viennacl::ocl::kernel & row_info_kernel = ctx.get_kernel(viennacl::linalg::opencl::kernels::coordinate_matrix<NumericT>::program_name(), "row_info_extractor");
unsigned int thread_num = 128; //k.local_work_size(0);
row_info_kernel.local_work_size(0, thread_num);
row_info_kernel.global_work_size(0, 64 * thread_num); //64 work groups are hard-coded for now. Gives reasonable performance in most cases
viennacl::ocl::enqueue(row_info_kernel(A.handle12().opencl_handle(), A.handle().opencl_handle(), A.handle3().opencl_handle(),
viennacl::traits::opencl_handle(x),
cl_uint(info_selector),
viennacl::ocl::local_mem(sizeof(cl_uint)*thread_num),
viennacl::ocl::local_mem(sizeof(NumericT)*thread_num)) );
}
}
template<typename NumericT, unsigned int AlignmentV>
void prod_impl(viennacl::coordinate_matrix<NumericT, AlignmentV> const & A,
viennacl::vector_base<NumericT> const & x,
NumericT alpha,
viennacl::vector_base<NumericT> & y,
NumericT beta)
{
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(A).context());
viennacl::linalg::opencl::kernels::coordinate_matrix<NumericT>::init(ctx);
if (beta < 0 || beta > 0) // multiply by beta
viennacl::linalg::opencl::av(y, y, beta, 1, false, false);
else
y.clear();
viennacl::ocl::packed_cl_uint layout_x;
layout_x.start = cl_uint(viennacl::traits::start(x));
layout_x.stride = cl_uint(viennacl::traits::stride(x));
layout_x.size = cl_uint(viennacl::traits::size(x));
layout_x.internal_size = cl_uint(viennacl::traits::internal_size(x));
viennacl::ocl::packed_cl_uint layout_y;
layout_y.start = cl_uint(viennacl::traits::start(y));
layout_y.stride = cl_uint(viennacl::traits::stride(y));
layout_y.size = cl_uint(viennacl::traits::size(y));
layout_y.internal_size = cl_uint(viennacl::traits::internal_size(y));
//std::cout << "prod(coordinate_matrix" << AlignmentV << ", vector) called with internal_nnz=" << A.internal_nnz() << std::endl;
viennacl::ocl::kernel & k = ctx.get_kernel(viennacl::linalg::opencl::kernels::coordinate_matrix<NumericT>::program_name(), "vec_mul");
unsigned int thread_num = 128; //k.local_work_size(0);
k.local_work_size(0, thread_num);
k.global_work_size(0, 64 * thread_num); //64 work groups are hard-coded for now. Gives reasonable performance in most cases
//k.global_work_size(0, thread_num); //Only one work group
viennacl::ocl::enqueue(k(A.handle12().opencl_handle(), A.handle().opencl_handle(), A.handle3().opencl_handle(),
viennacl::traits::opencl_handle(x),
layout_x,
alpha,
viennacl::traits::opencl_handle(y),
layout_y,
beta,
viennacl::ocl::local_mem(sizeof(cl_uint)*thread_num),
viennacl::ocl::local_mem(sizeof(NumericT)*thread_num)) );
}
template<typename NumericT, unsigned int AlignmentV>
void prod_impl(viennacl::coordinate_matrix<NumericT, AlignmentV> const & A,
viennacl::matrix_base<NumericT> const & d_A,
viennacl::matrix_base<NumericT> & y)
{
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(A).context());
viennacl::linalg::opencl::kernels::coordinate_matrix<NumericT>::init(ctx);
viennacl::ocl::kernel & k = ctx.get_kernel(viennacl::linalg::opencl::kernels::coordinate_matrix<NumericT>::program_name(),
detail::sparse_dense_matmult_kernel_name(false, d_A.row_major(), y.row_major()));
y.clear();
unsigned int thread_num = 128; //k.local_work_size(0);
k.local_work_size(0, thread_num);
k.global_work_size(0, 64 * thread_num); //64 work groups are hard-coded for now. Gives reasonable performance in most cases
viennacl::ocl::enqueue(k(A.handle12().opencl_handle(), A.handle().opencl_handle(), A.handle3().opencl_handle(),
viennacl::traits::opencl_handle(d_A),
cl_uint(viennacl::traits::start1(d_A)), cl_uint(viennacl::traits::start2(d_A)),
cl_uint(viennacl::traits::stride1(d_A)), cl_uint(viennacl::traits::stride2(d_A)),
cl_uint(viennacl::traits::size1(d_A)), cl_uint(viennacl::traits::size2(d_A)),
cl_uint(viennacl::traits::internal_size1(d_A)), cl_uint(viennacl::traits::internal_size2(d_A)),
viennacl::traits::opencl_handle(y),
cl_uint(viennacl::traits::start1(y)), cl_uint(viennacl::traits::start2(y)),
cl_uint(viennacl::traits::stride1(y)), cl_uint(viennacl::traits::stride2(y)),
cl_uint(viennacl::traits::size1(y)), cl_uint(viennacl::traits::size2(y)),
cl_uint(viennacl::traits::internal_size1(y)), cl_uint(viennacl::traits::internal_size2(y)),
viennacl::ocl::local_mem(sizeof(cl_uint)*k.local_work_size(0)),
viennacl::ocl::local_mem(sizeof(NumericT)*k.local_work_size(0))) );
}
template<typename NumericT, unsigned int AlignmentV>
void prod_impl(viennacl::coordinate_matrix<NumericT, AlignmentV> const & A,
viennacl::matrix_expression< const viennacl::matrix_base<NumericT>,
const viennacl::matrix_base<NumericT>,
viennacl::op_trans > const & d_A,
viennacl::matrix_base<NumericT> & y)
{
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(A).context());
viennacl::linalg::opencl::kernels::coordinate_matrix<NumericT>::init(ctx);
viennacl::ocl::kernel & k = ctx.get_kernel(viennacl::linalg::opencl::kernels::coordinate_matrix<NumericT>::program_name(),
detail::sparse_dense_matmult_kernel_name(true, d_A.lhs().row_major(), y.row_major()));
y.clear();
unsigned int thread_num = 128; //k.local_work_size(0);
k.local_work_size(0, thread_num);
k.global_work_size(0, 64 * thread_num); //64 work groups are hard-coded for now. Gives reasonable performance in most cases
viennacl::ocl::enqueue(k(A.handle12().opencl_handle(), A.handle().opencl_handle(), A.handle3().opencl_handle(),
viennacl::traits::opencl_handle(d_A),
cl_uint(viennacl::traits::start1(d_A.lhs())), cl_uint(viennacl::traits::start2(d_A.lhs())),
cl_uint(viennacl::traits::stride1(d_A.lhs())), cl_uint(viennacl::traits::stride2(d_A.lhs())),
cl_uint(viennacl::traits::size1(d_A.lhs())), cl_uint(viennacl::traits::size2(d_A.lhs())),
cl_uint(viennacl::traits::internal_size1(d_A.lhs())), cl_uint(viennacl::traits::internal_size2(d_A.lhs())),
viennacl::traits::opencl_handle(y),
cl_uint(viennacl::traits::start1(y)), cl_uint(viennacl::traits::start2(y)),
cl_uint(viennacl::traits::stride1(y)), cl_uint(viennacl::traits::stride2(y)),
cl_uint(viennacl::traits::size1(y)), cl_uint(viennacl::traits::size2(y)),
cl_uint(viennacl::traits::internal_size1(y)), cl_uint(viennacl::traits::internal_size2(y)),
viennacl::ocl::local_mem(sizeof(cl_uint)*k.local_work_size(0)),
viennacl::ocl::local_mem(sizeof(NumericT)*k.local_work_size(0))) );
}
//
// ELL Matrix
//
template<typename NumericT, unsigned int AlignmentV>
void prod_impl(viennacl::ell_matrix<NumericT, AlignmentV> const & A,
viennacl::vector_base<NumericT> const & x,
NumericT alpha,
viennacl::vector_base<NumericT> & y,
NumericT beta)
{
assert(A.size1() == y.size());
assert(A.size2() == x.size());
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(A).context());
viennacl::linalg::opencl::kernels::ell_matrix<NumericT>::init(ctx);
bool with_alpha_beta = (alpha < NumericT(1) || alpha > NumericT(1)) || (beta < 0 || beta > 0);
viennacl::ocl::packed_cl_uint layout_x;
layout_x.start = cl_uint(viennacl::traits::start(x));
layout_x.stride = cl_uint(viennacl::traits::stride(x));
layout_x.size = cl_uint(viennacl::traits::size(x));
layout_x.internal_size = cl_uint(viennacl::traits::internal_size(x));
viennacl::ocl::packed_cl_uint layout_y;
layout_y.start = cl_uint(viennacl::traits::start(y));
layout_y.stride = cl_uint(viennacl::traits::stride(y));
layout_y.size = cl_uint(viennacl::traits::size(y));
layout_y.internal_size = cl_uint(viennacl::traits::internal_size(y));
std::stringstream ss;
ss << "vec_mul_" << 1;//(AlignmentV != 1?4:1);
viennacl::ocl::kernel& k = ctx.get_kernel(viennacl::linalg::opencl::kernels::ell_matrix<NumericT>::program_name(), with_alpha_beta ? "vec_mul_alpha_beta" : "vec_mul");
unsigned int thread_num = 128;
unsigned int group_num = 256;
k.local_work_size(0, thread_num);
k.global_work_size(0, thread_num * group_num);
if (with_alpha_beta)
viennacl::ocl::enqueue(k(A.handle2().opencl_handle(),
A.handle().opencl_handle(),
viennacl::traits::opencl_handle(x),
layout_x,
alpha,
viennacl::traits::opencl_handle(y),
layout_y,
beta,
cl_uint(A.size1()),
cl_uint(A.size2()),
cl_uint(A.internal_size1()),
cl_uint(A.maxnnz()),
cl_uint(A.internal_maxnnz())
)
);
else
viennacl::ocl::enqueue(k(A.handle2().opencl_handle(),
A.handle().opencl_handle(),
viennacl::traits::opencl_handle(x),
layout_x,
viennacl::traits::opencl_handle(y),
layout_y,
cl_uint(A.size1()),
cl_uint(A.size2()),
cl_uint(A.internal_size1()),
cl_uint(A.maxnnz()),
cl_uint(A.internal_maxnnz())
)
);
}
template<typename NumericT, unsigned int AlignmentV>
void prod_impl(viennacl::ell_matrix<NumericT, AlignmentV> const & sp_A,
viennacl::matrix_base<NumericT> const & d_A,
viennacl::matrix_base<NumericT> & y) {
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(sp_A).context());
viennacl::linalg::opencl::kernels::ell_matrix<NumericT>::init(ctx);
viennacl::ocl::kernel & k = ctx.get_kernel(viennacl::linalg::opencl::kernels::ell_matrix<NumericT>::program_name(),
detail::sparse_dense_matmult_kernel_name(false, d_A.row_major(), y.row_major()));
//unsigned int thread_num = 128;
//unsigned int group_num = 256;
//
//k.local_work_size(0, thread_num);
//k.global_work_size(0, thread_num * group_num);
viennacl::ocl::enqueue(k(sp_A.handle2().opencl_handle(), sp_A.handle().opencl_handle(),
cl_uint(sp_A.size1()),
cl_uint(sp_A.size2()),
cl_uint(sp_A.internal_size1()),
cl_uint(sp_A.maxnnz()),
cl_uint(sp_A.internal_maxnnz()),
viennacl::traits::opencl_handle(d_A),
cl_uint(viennacl::traits::start1(d_A)), cl_uint(viennacl::traits::start2(d_A)),
cl_uint(viennacl::traits::stride1(d_A)), cl_uint(viennacl::traits::stride2(d_A)),
cl_uint(viennacl::traits::size1(d_A)), cl_uint(viennacl::traits::size2(d_A)),
cl_uint(viennacl::traits::internal_size1(d_A)), cl_uint(viennacl::traits::internal_size2(d_A)),
viennacl::traits::opencl_handle(y),
cl_uint(viennacl::traits::start1(y)), cl_uint(viennacl::traits::start2(y)),
cl_uint(viennacl::traits::stride1(y)), cl_uint(viennacl::traits::stride2(y)),
cl_uint(viennacl::traits::size1(y)), cl_uint(viennacl::traits::size2(y)),
cl_uint(viennacl::traits::internal_size1(y)), cl_uint(viennacl::traits::internal_size2(y))
)
);
}
template<typename NumericT, unsigned int AlignmentV>
void prod_impl(viennacl::ell_matrix<NumericT, AlignmentV> const & sp_A,
viennacl::matrix_expression< const viennacl::matrix_base<NumericT>,
const viennacl::matrix_base<NumericT>,
viennacl::op_trans > const & d_A,
viennacl::matrix_base<NumericT> & y) {
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(sp_A).context());
viennacl::linalg::opencl::kernels::ell_matrix<NumericT>::init(ctx);
viennacl::ocl::kernel & k = ctx.get_kernel(viennacl::linalg::opencl::kernels::ell_matrix<NumericT>::program_name(),
detail::sparse_dense_matmult_kernel_name(true, d_A.lhs().row_major(), y.row_major()));
//unsigned int thread_num = 128;
//unsigned int group_num = 256;
//
//k.local_work_size(0, thread_num);
//k.global_work_size(0, thread_num * group_num);
viennacl::ocl::enqueue(k(sp_A.handle2().opencl_handle(), sp_A.handle().opencl_handle(),
cl_uint(sp_A.size1()),
cl_uint(sp_A.size2()),
cl_uint(sp_A.internal_size1()),
cl_uint(sp_A.maxnnz()),
cl_uint(sp_A.internal_maxnnz()),
viennacl::traits::opencl_handle(d_A.lhs()),
cl_uint(viennacl::traits::start1(d_A.lhs())), cl_uint(viennacl::traits::start2(d_A.lhs())),
cl_uint(viennacl::traits::stride1(d_A.lhs())), cl_uint(viennacl::traits::stride2(d_A.lhs())),
cl_uint(viennacl::traits::size1(d_A.lhs())), cl_uint(viennacl::traits::size2(d_A.lhs())),
cl_uint(viennacl::traits::internal_size1(d_A.lhs())), cl_uint(viennacl::traits::internal_size2(d_A.lhs())),
viennacl::traits::opencl_handle(y),
cl_uint(viennacl::traits::start1(y)), cl_uint(viennacl::traits::start2(y)),
cl_uint(viennacl::traits::stride1(y)), cl_uint(viennacl::traits::stride2(y)),
cl_uint(viennacl::traits::size1(y)), cl_uint(viennacl::traits::size2(y)),
cl_uint(viennacl::traits::internal_size1(y)), cl_uint(viennacl::traits::internal_size2(y))
)
);
}
//
// SELL-C-\sigma Matrix
//
template<typename ScalarT, typename IndexT>
void prod_impl(viennacl::sliced_ell_matrix<ScalarT, IndexT> const & A,
viennacl::vector_base<ScalarT> const & x,
ScalarT alpha,
viennacl::vector_base<ScalarT> & y,
ScalarT beta)
{
assert(A.size1() == y.size());
assert(A.size2() == x.size());
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(A).context());
viennacl::linalg::opencl::kernels::sliced_ell_matrix<ScalarT, unsigned int>::init(ctx);
bool with_alpha_beta = (alpha < ScalarT(1) || alpha > ScalarT(1)) || (beta < 0 || beta > 0);
viennacl::ocl::packed_cl_uint layout_x;
layout_x.start = cl_uint(viennacl::traits::start(x));
layout_x.stride = cl_uint(viennacl::traits::stride(x));
layout_x.size = cl_uint(viennacl::traits::size(x));
layout_x.internal_size = cl_uint(viennacl::traits::internal_size(x));
viennacl::ocl::packed_cl_uint layout_y;
layout_y.start = cl_uint(viennacl::traits::start(y));
layout_y.stride = cl_uint(viennacl::traits::stride(y));
layout_y.size = cl_uint(viennacl::traits::size(y));
layout_y.internal_size = cl_uint(viennacl::traits::internal_size(y));
std::stringstream ss;
ss << "vec_mul_" << 1;//(AlignmentV != 1?4:1);
viennacl::ocl::kernel& k = ctx.get_kernel(viennacl::linalg::opencl::kernels::sliced_ell_matrix<ScalarT, IndexT>::program_name(), with_alpha_beta ? "vec_mul_alpha_beta" : "vec_mul");
vcl_size_t thread_num = std::max(A.rows_per_block(), static_cast<vcl_size_t>(128));
unsigned int group_num = 256;
if (ctx.current_device().vendor_id() == viennacl::ocl::nvidia_id)
thread_num = 256;
k.local_work_size(0, thread_num);
k.global_work_size(0, thread_num * group_num);
if (with_alpha_beta)
viennacl::ocl::enqueue(k(A.handle1().opencl_handle(),
A.handle2().opencl_handle(),
A.handle3().opencl_handle(),
A.handle().opencl_handle(),
viennacl::traits::opencl_handle(x),
layout_x,
alpha,
viennacl::traits::opencl_handle(y),
layout_y,
beta,
cl_uint(A.rows_per_block()))
);
else
viennacl::ocl::enqueue(k(A.handle1().opencl_handle(),
A.handle2().opencl_handle(),
A.handle3().opencl_handle(),
A.handle().opencl_handle(),
viennacl::traits::opencl_handle(x),
layout_x,
viennacl::traits::opencl_handle(y),
layout_y,
cl_uint(A.rows_per_block()))
);
}
//
// Hybrid Matrix
//
template<typename NumericT, unsigned int AlignmentV>
void prod_impl(viennacl::hyb_matrix<NumericT, AlignmentV> const & A,
viennacl::vector_base<NumericT> const & x,
NumericT alpha,
viennacl::vector_base<NumericT> & y,
NumericT beta)
{
assert(A.size1() == y.size());
assert(A.size2() == x.size());
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(A).context());
viennacl::linalg::opencl::kernels::hyb_matrix<NumericT>::init(ctx);
bool with_alpha_beta = (alpha < NumericT(1) || alpha > NumericT(1)) || (beta < 0 || beta > 0);
viennacl::ocl::packed_cl_uint layout_x;
layout_x.start = cl_uint(viennacl::traits::start(x));
layout_x.stride = cl_uint(viennacl::traits::stride(x));
layout_x.size = cl_uint(viennacl::traits::size(x));
layout_x.internal_size = cl_uint(viennacl::traits::internal_size(x));
viennacl::ocl::packed_cl_uint layout_y;
layout_y.start = cl_uint(viennacl::traits::start(y));
layout_y.stride = cl_uint(viennacl::traits::stride(y));
layout_y.size = cl_uint(viennacl::traits::size(y));
layout_y.internal_size = cl_uint(viennacl::traits::internal_size(y));
viennacl::ocl::kernel& k = ctx.get_kernel(viennacl::linalg::opencl::kernels::hyb_matrix<NumericT>::program_name(), with_alpha_beta ? "vec_mul_alpha_beta" : "vec_mul");
if (with_alpha_beta)
viennacl::ocl::enqueue(k(A.handle2().opencl_handle(),
A.handle().opencl_handle(),
A.handle3().opencl_handle(),
A.handle4().opencl_handle(),
A.handle5().opencl_handle(),
viennacl::traits::opencl_handle(x),
layout_x,
alpha,
viennacl::traits::opencl_handle(y),
layout_y,
beta,
cl_uint(A.size1()),
cl_uint(A.internal_size1()),
cl_uint(A.ell_nnz()),
cl_uint(A.internal_ellnnz())
)
);
else
viennacl::ocl::enqueue(k(A.handle2().opencl_handle(),
A.handle().opencl_handle(),
A.handle3().opencl_handle(),
A.handle4().opencl_handle(),
A.handle5().opencl_handle(),
viennacl::traits::opencl_handle(x),
layout_x,
viennacl::traits::opencl_handle(y),
layout_y,
cl_uint(A.size1()),
cl_uint(A.internal_size1()),
cl_uint(A.ell_nnz()),
cl_uint(A.internal_ellnnz())
)
);
}
template<typename NumericT, unsigned int AlignmentV>
void prod_impl(viennacl::hyb_matrix<NumericT, AlignmentV> const & A,
viennacl::matrix_base<NumericT> const & d_A,
viennacl::matrix_base<NumericT> & y)
{
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(A).context());
viennacl::linalg::opencl::kernels::hyb_matrix<NumericT>::init(ctx);
viennacl::ocl::kernel & k = ctx.get_kernel(viennacl::linalg::opencl::kernels::hyb_matrix<NumericT>::program_name(),
detail::sparse_dense_matmult_kernel_name(false, d_A.row_major(), y.row_major()));
viennacl::ocl::enqueue(k(A.handle2().opencl_handle(),
A.handle().opencl_handle(),
A.handle3().opencl_handle(),
A.handle4().opencl_handle(),
A.handle5().opencl_handle(),
cl_uint(A.size1()),
cl_uint(A.internal_size1()),
cl_uint(A.ell_nnz()),
cl_uint(A.internal_ellnnz()),
viennacl::traits::opencl_handle(d_A),
cl_uint(viennacl::traits::start1(d_A)), cl_uint(viennacl::traits::start2(d_A)),
cl_uint(viennacl::traits::stride1(d_A)), cl_uint(viennacl::traits::stride2(d_A)),
cl_uint(viennacl::traits::size1(d_A)), cl_uint(viennacl::traits::size2(d_A)),
cl_uint(viennacl::traits::internal_size1(d_A)), cl_uint(viennacl::traits::internal_size2(d_A)),
viennacl::traits::opencl_handle(y),
cl_uint(viennacl::traits::start1(y)), cl_uint(viennacl::traits::start2(y)),
cl_uint(viennacl::traits::stride1(y)), cl_uint(viennacl::traits::stride2(y)),
cl_uint(viennacl::traits::size1(y)), cl_uint(viennacl::traits::size2(y)),
cl_uint(viennacl::traits::internal_size1(y)), cl_uint(viennacl::traits::internal_size2(y))
)
);
}
template<typename NumericT, unsigned int AlignmentV>
void prod_impl(viennacl::hyb_matrix<NumericT, AlignmentV> const & A,
viennacl::matrix_expression< const viennacl::matrix_base<NumericT>,
const viennacl::matrix_base<NumericT>,
viennacl::op_trans > const & d_A,
viennacl::matrix_base<NumericT> & y)
{
viennacl::ocl::context & ctx = const_cast<viennacl::ocl::context &>(viennacl::traits::opencl_handle(A).context());
viennacl::linalg::opencl::kernels::hyb_matrix<NumericT>::init(ctx);
viennacl::ocl::kernel & k = ctx.get_kernel(viennacl::linalg::opencl::kernels::hyb_matrix<NumericT>::program_name(),
detail::sparse_dense_matmult_kernel_name(true, d_A.lhs().row_major(), y.row_major()));
viennacl::ocl::enqueue(k(A.handle2().opencl_handle(),
A.handle().opencl_handle(),
A.handle3().opencl_handle(),
A.handle4().opencl_handle(),
A.handle5().opencl_handle(),
cl_uint(A.size1()),
cl_uint(A.internal_size1()),
cl_uint(A.ell_nnz()),
cl_uint(A.internal_ellnnz()),
viennacl::traits::opencl_handle(d_A.lhs()),
cl_uint(viennacl::traits::start1(d_A.lhs())), cl_uint(viennacl::traits::start2(d_A.lhs())),
cl_uint(viennacl::traits::stride1(d_A.lhs())), cl_uint(viennacl::traits::stride2(d_A.lhs())),
cl_uint(viennacl::traits::size1(d_A.lhs())), cl_uint(viennacl::traits::size2(d_A.lhs())),
cl_uint(viennacl::traits::internal_size1(d_A.lhs())), cl_uint(viennacl::traits::internal_size2(d_A.lhs())),
viennacl::traits::opencl_handle(y),
cl_uint(viennacl::traits::start1(y)), cl_uint(viennacl::traits::start2(y)),
cl_uint(viennacl::traits::stride1(y)), cl_uint(viennacl::traits::stride2(y)),
cl_uint(viennacl::traits::size1(y)), cl_uint(viennacl::traits::size2(y)),
cl_uint(viennacl::traits::internal_size1(y)), cl_uint(viennacl::traits::internal_size2(y))
)
);
}
} // namespace opencl
} //namespace linalg
} //namespace viennacl
#endif
viennacl::compressed_matrix::size2
const vcl_size_t & size2() const
Returns the number of columns.
Definition: compressed_matrix.hpp:929
viennacl::hyb_matrix::internal_ellnnz
vcl_size_t internal_ellnnz() const
Definition: hyb_matrix.hpp:101
viennacl::hyb_matrix
Sparse matrix class using a hybrid format composed of the ELL and CSR format for storing the nonzeros...
Definition: forwards.h:406
viennacl::ocl::packed_cl_uint::stride
cl_uint stride
Increment between integers.
Definition: kernel.hpp:50
viennacl::linalg::opencl::kernels::coordinate_matrix::init
static void init(viennacl::ocl::context &ctx)
Definition: coordinate_matrix.hpp:373
viennacl::sliced_ell_matrix::handle2
handle_type & handle2()
Definition: sliced_ell_matrix.hpp:112
viennacl::ell_matrix::size1
vcl_size_t size1() const
Definition: ell_matrix.hpp:91
viennacl::ocl::context::current_device
viennacl::ocl::device const & current_device() const
Returns the current device.
Definition: context.hpp:112
viennacl::backend::typesafe_host_array
Helper class implementing an array on the host. Default case: No conversion necessary.
Definition: util.hpp:92
viennacl::ocl::packed_cl_uint
Helper class for packing four cl_uint numbers into a uint4 type for access inside an OpenCL kernel...
Definition: kernel.hpp:45
viennacl::backend::memory_write
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
viennacl::ell_matrix::handle2
handle_type & handle2()
Definition: ell_matrix.hpp:103
device.hpp
Represents an OpenCL device within ViennaCL.
viennacl::traits::stride1
result_of::size_type< matrix_base< NumericT > >::type stride1(matrix_base< NumericT > const &s)
Definition: stride.hpp:55
viennacl::linalg::detail::row_info_types
row_info_types
Definition: forwards.h:837
vector_operations.hpp
Implementations of NMF operations using OpenCL.
viennacl::linalg::opencl::prod_impl
void prod_impl(const matrix_base< NumericT > &mat, bool trans_A, const vector_base< NumericT > &vec, vector_base< NumericT > &result)
Carries out matrix-vector multiplication.
Definition: matrix_operations.hpp:620
viennacl::hyb_matrix::handle3
const handle_type & handle3() const
Definition: hyb_matrix.hpp:107
viennacl::compressed_matrix::size1
const vcl_size_t & size1() const
Returns the number of rows.
Definition: compressed_matrix.hpp:927
viennacl::compressed_compressed_matrix::handle2
const handle_type & handle2() const
Returns the OpenCL handle to the column index array.
Definition: compressed_compressed_matrix.hpp:471
viennacl::ocl::kernel
Represents an OpenCL kernel within ViennaCL.
Definition: kernel.hpp:58
viennacl::ocl::packed_cl_uint::start
cl_uint start
Starting value of the integer stride.
Definition: kernel.hpp:48
viennacl::compressed_compressed_matrix::handle1
const handle_type & handle1() const
Returns the OpenCL handle to the row index array.
Definition: compressed_compressed_matrix.hpp:469
tools.hpp
Various little tools used here and there in ViennaCL.
viennacl::hyb_matrix::handle
const handle_type & handle() const
Definition: hyb_matrix.hpp:105
viennacl::traits::internal_size1
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...
Definition: size.hpp:386
viennacl::ocl::kernel::local_work_size
size_type local_work_size(int index=0) const
Returns the local work size at the respective dimension.
Definition: kernel.hpp:742
viennacl::coordinate_matrix::handle12
const handle_type & handle12() const
Returns the OpenCL handle to the (row, column) index array.
Definition: coordinate_matrix.hpp:366
viennacl::traits::size1
vcl_size_t size1(MatrixType const &mat)
Generic routine for obtaining the number of rows of a matrix (ViennaCL, uBLAS, etc.)
Definition: size.hpp:163
viennacl::linalg::opencl::detail::sparse_dense_matmult_kernel_name
std::string sparse_dense_matmult_kernel_name(bool B_transposed, bool B_row_major, bool C_row_major)
Returns the OpenCL kernel string for the operation C = A * B with A sparse, B, C dense matrices...
Definition: common.hpp:49
viennacl::ocl::nvidia_id
Definition: device_utils.hpp:49
viennacl::linalg::lower_tag
A tag class representing a lower triangular matrix.
Definition: forwards.h:849
viennacl::ocl::context
Manages an OpenCL context and provides the respective convenience functions for creating buffers...
Definition: context.hpp:55
viennacl::linalg::opencl::kernels::coordinate_matrix
Main kernel class for generating OpenCL kernels for coordinate_matrix.
Definition: coordinate_matrix.hpp:366
viennacl::hyb_matrix::internal_size1
vcl_size_t internal_size1() const
Definition: hyb_matrix.hpp:95
viennacl::traits::internal_size2
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...
Definition: size.hpp:394
viennacl::matrix_base< NumericT >
viennacl::matrix_expression
Expression template class for representing a tree of expressions which ultimately result in a matrix...
Definition: forwards.h:341
viennacl::traits::stride
result_of::size_type< viennacl::vector_base< T > >::type stride(viennacl::vector_base< T > const &s)
Definition: stride.hpp:45
forwards.h
This file provides the forward declarations for the main types used within ViennaCL.
viennacl::ell_matrix::size2
vcl_size_t size2() const
Definition: ell_matrix.hpp:92
viennacl::traits::start1
result_of::size_type< T >::type start1(T const &obj)
Definition: start.hpp:65
viennacl::backend::memory_read
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
viennacl::hyb_matrix::handle4
const handle_type & handle4() const
Definition: hyb_matrix.hpp:108
viennacl::ocl::device::vendor_id
cl_uint vendor_id() const
A unique device vendor identifier. An example of a unique device identifier could be the PCIe ID...
Definition: device.hpp:917
viennacl::traits::internal_size
vcl_size_t internal_size(vector_base< NumericT > const &vec)
Helper routine for obtaining the buffer length of a ViennaCL vector.
Definition: size.hpp:375
viennacl::linalg::detail::max
T max(const T &lhs, const T &rhs)
Maximum.
Definition: util.hpp:59
viennacl::sliced_ell_matrix::rows_per_block
vcl_size_t rows_per_block() const
Definition: sliced_ell_matrix.hpp:104
viennacl::traits::size2
result_of::size_type< MatrixType >::type size2(MatrixType const &mat)
Generic routine for obtaining the number of columns of a matrix (ViennaCL, uBLAS, etc...
Definition: size.hpp:201
viennacl::compressed_matrix::handle
const handle_type & handle() const
Returns the OpenCL handle to the matrix entry array.
Definition: compressed_matrix.hpp:942
viennacl::compressed_matrix::handle1
const handle_type & handle1() const
Returns the OpenCL handle to the row index array.
Definition: compressed_matrix.hpp:936
viennacl::ocl::packed_cl_uint::internal_size
cl_uint internal_size
Internal length of the buffer. Might be larger than 'size' due to padding.
Definition: kernel.hpp:54
viennacl::ell_matrix::internal_size1
vcl_size_t internal_size1() const
Definition: ell_matrix.hpp:88
common.hpp
Common implementations shared by OpenCL-based operations.
viennacl::compressed_matrix::nnz
const vcl_size_t & nnz() const
Returns the number of nonzero entries.
Definition: compressed_matrix.hpp:931
viennacl::sliced_ell_matrix::handle
handle_type & handle()
Definition: sliced_ell_matrix.hpp:118
NumericT
float NumericT
Definition: bisect.cpp:40
viennacl::linalg::opencl::kernels::ell_matrix
Main kernel class for generating OpenCL kernels for ell_matrix.
Definition: ell_matrix.hpp:181
viennacl::context
Represents a generic 'context' similar to an OpenCL context, but is backend-agnostic and thus also su...
Definition: context.hpp:39
viennacl::hyb_matrix::handle2
const handle_type & handle2() const
Definition: hyb_matrix.hpp:106
viennacl::compressed_compressed_matrix::handle
const handle_type & handle() const
Returns the OpenCL handle to the matrix entry array.
Definition: compressed_compressed_matrix.hpp:475
viennacl::traits::size
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
Definition: size.hpp:239
viennacl::traits::start2
result_of::size_type< T >::type start2(T const &obj)
Definition: start.hpp:84
viennacl::ocl::local_mem
A class representing local (shared) OpenCL memory. Typically used as kernel argument.
Definition: local_mem.hpp:33
viennacl::linalg::opencl::kernels::compressed_matrix
Main kernel class for generating OpenCL kernels for compressed_matrix (except solvers).
Definition: compressed_matrix.hpp:1599
viennacl::ell_matrix
Sparse matrix class using the ELLPACK format for storing the nonzeros.
Definition: ell_matrix.hpp:53
viennacl::ocl::context::get_kernel
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.
Definition: context.hpp:605
viennacl::linalg::opencl::kernels::compressed_compressed_matrix::init
static void init(viennacl::ocl::context &ctx)
Definition: compressed_compressed_matrix.hpp:79
compressed_matrix.hpp
OpenCL kernel file for compressed_matrix operations.
viennacl::linalg::upper_tag
A tag class representing an upper triangular matrix.
Definition: forwards.h:854
ell_matrix.hpp
OpenCL kernel file for ell_matrix operations.
viennacl::sliced_ell_matrix
Sparse matrix class using the sliced ELLPACK with parameters C, .
Definition: forwards.h:403
viennacl::matrix_base::clear
void clear()
Resets all entries to zero.
Definition: matrix.hpp:634
viennacl::compressed_compressed_matrix::handle3
const handle_type & handle3() const
Returns the OpenCL handle to the row index array.
Definition: compressed_compressed_matrix.hpp:473
handle.hpp
Implementation of a smart-pointer-like class for handling OpenCL handles.
viennacl::traits::start
result_of::size_type< T >::type start(T const &obj)
Definition: start.hpp:44
viennacl::compressed_compressed_matrix
A sparse square matrix in compressed sparse rows format optimized for the case that only a few rows c...
Definition: compressed_compressed_matrix.hpp:265
viennacl::linalg::opencl::av
void av(vector_base< T > &vec1, vector_base< T > const &vec2, ScalarType1 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha)
Definition: vector_operations.hpp:76
viennacl::compressed_matrix::handle2
const handle_type & handle2() const
Returns the OpenCL handle to the column index array.
Definition: compressed_matrix.hpp:938
viennacl::hyb_matrix::size2
vcl_size_t size2() const
Definition: hyb_matrix.hpp:99
viennacl::vector_base< NumericT >
viennacl::linalg::opencl::kernels::compressed_matrix_solve::init
static void init(viennacl::ocl::context &ctx)
Definition: compressed_matrix.hpp:1660
viennacl::vcl_size_t
std::size_t vcl_size_t
Definition: forwards.h:75
viennacl::sliced_ell_matrix::size1
vcl_size_t size1() const
Definition: sliced_ell_matrix.hpp:101
viennacl::linalg::opencl::kernels::compressed_matrix_solve
Main kernel class for triangular solver OpenCL kernels for compressed_matrix.
Definition: compressed_matrix.hpp:1653
viennacl::linalg::opencl::kernels::sliced_ell_matrix
Main kernel class for generating OpenCL kernels for ell_matrix.
Definition: sliced_ell_matrix.hpp:93
common.hpp
Common routines for single-threaded or OpenMP-enabled execution on CPU.
viennacl::vector< unsigned int >
sliced_ell_matrix.hpp
OpenCL kernel file for sliced_ell_matrix operations.
viennacl::ell_matrix::maxnnz
vcl_size_t maxnnz() const
Definition: ell_matrix.hpp:95
viennacl::traits::stride2
result_of::size_type< matrix_base< NumericT > >::type stride2(matrix_base< NumericT > const &s)
Definition: stride.hpp:65
viennacl::coordinate_matrix::handle3
const handle_type & handle3() const
Returns the OpenCL handle to the group start index array.
Definition: coordinate_matrix.hpp:370
hyb_matrix.hpp
OpenCL kernel file for hyb_matrix operations.
viennacl::ell_matrix::handle
handle_type & handle()
Definition: ell_matrix.hpp:100
viennacl::MAIN_MEMORY
Definition: forwards.h:348
viennacl::compressed_matrix::reserve
void reserve(vcl_size_t new_nonzeros, bool preserve=true)
Allocate memory for the supplied number of nonzeros in the matrix. Old values are preserved...
Definition: compressed_matrix.hpp:794
viennacl::linalg::opencl::inplace_solve
void inplace_solve(matrix_base< NumericT > const &A, matrix_base< NumericT > &B, SolverTagT)
Direct inplace solver for dense triangular systems. Matlab notation: A \ B.
Definition: direct_solve.hpp:77
viennacl::compressed_matrix::handle3
const handle_type & handle3() const
Returns the OpenCL handle to the row block array.
Definition: compressed_matrix.hpp:940
viennacl::vector_base::clear
void clear()
Resets all entries to zero. Does not change the size of the vector.
Definition: vector.hpp:875
viennacl::traits::context
viennacl::context context(T const &t)
Returns an ID for the currently active memory domain of an object.
Definition: context.hpp:40
viennacl::coordinate_matrix::handle
const handle_type & handle() const
Returns the OpenCL handle to the matrix entry array.
Definition: coordinate_matrix.hpp:368
viennacl::ocl::enqueue
void enqueue(KernelType &k, viennacl::ocl::command_queue const &queue)
Enqueues a kernel in the provided queue.
Definition: enqueue.hpp:50
kernel.hpp
Representation of an OpenCL kernel in ViennaCL.
vector.hpp
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
viennacl::sliced_ell_matrix::handle3
handle_type & handle3()
Definition: sliced_ell_matrix.hpp:115
viennacl::matrix_base::row_major
bool row_major() const
Definition: matrix_def.hpp:248
viennacl::linalg::detail::SPARSE_ROW_DIAGONAL
Definition: forwards.h:842
viennacl::linalg::opencl::kernels::compressed_matrix::init
static void init(viennacl::ocl::context &ctx)
Definition: compressed_matrix.hpp:1606
compressed_compressed_matrix.hpp
OpenCL kernel file for vector operations.
viennacl::backend::typesafe_host_array::set
void set(vcl_size_t index, U value)
Definition: util.hpp:115
viennacl::vector_base::size
size_type size() const
Returns the length of the vector (cf. std::vector)
Definition: vector_def.hpp:118
viennacl::compressed_compressed_matrix::nnz1
const vcl_size_t & nnz1() const
Returns the number of nonzero entries.
Definition: compressed_compressed_matrix.hpp:464
viennacl::hyb_matrix::ell_nnz
vcl_size_t ell_nnz() const
Definition: hyb_matrix.hpp:102
viennacl::linalg::unit_lower_tag
A tag class representing a lower triangular matrix with unit diagonal.
Definition: forwards.h:859
viennacl::ocl::kernel::global_work_size
size_type global_work_size(int index=0) const
Returns the global work size at the respective dimension.
Definition: kernel.hpp:751
coordinate_matrix.hpp
OpenCL kernel file for coordinate_matrix operations.
viennacl::backend::mem_handle
Main abstraction class for multiple memory domains. Represents a buffer in either main RAM...
Definition: mem_handle.hpp:89
viennacl::op_trans
A tag class representing transposed matrices.
Definition: forwards.h:220
viennacl::backend::mem_handle::raw_size
vcl_size_t raw_size() const
Returns the number of bytes of the currently active buffer.
Definition: mem_handle.hpp:230
viennacl::compressed_matrix
A sparse square matrix in compressed sparse rows format.
Definition: compressed_matrix.hpp:559
viennacl::linalg::exclusive_scan
void exclusive_scan(vector_base< NumericT > &vec1, vector_base< NumericT > &vec2)
This function implements an exclusive scan.
Definition: vector_operations.hpp:1240
viennacl::hyb_matrix::handle5
const handle_type & handle5() const
Definition: hyb_matrix.hpp:109
viennacl::hyb_matrix::size1
vcl_size_t size1() const
Definition: hyb_matrix.hpp:98
viennacl::linalg::opencl::detail::block_inplace_solve
void block_inplace_solve(const matrix_expression< const compressed_matrix< NumericT, AlignmentV >, const compressed_matrix< NumericT, AlignmentV >, op_trans > &L, viennacl::backend::mem_handle const &block_indices, vcl_size_t num_blocks, vector_base< NumericT > const &, vector_base< NumericT > &x, viennacl::linalg::unit_lower_tag)
Definition: sparse_matrix_operations.hpp:483
viennacl::linalg::opencl::kernels::hyb_matrix::init
static void init(viennacl::ocl::context &ctx)
Definition: hyb_matrix.hpp:208
viennacl::compressed_matrix::blocks1
const vcl_size_t & blocks1() const
Returns the internal number of row blocks for an adaptive SpMV.
Definition: compressed_matrix.hpp:933
viennacl::ell_matrix::internal_maxnnz
vcl_size_t internal_maxnnz() const
Definition: ell_matrix.hpp:94
viennacl::sliced_ell_matrix::size2
vcl_size_t size2() const
Definition: sliced_ell_matrix.hpp:102
viennacl::sliced_ell_matrix::handle1
handle_type & handle1()
Definition: sliced_ell_matrix.hpp:109
scalar.hpp
Implementation of the ViennaCL scalar class.
viennacl::compressed_matrix::resize
void resize(vcl_size_t new_size1, vcl_size_t new_size2, bool preserve=true)
Resize the matrix.
Definition: compressed_matrix.hpp:829
viennacl::vector_base::handle
const handle_type & handle() const
Returns the memory handle.
Definition: vector_def.hpp:128
viennacl::linalg::opencl::kernels::ell_matrix::init
static void init(viennacl::ocl::context &ctx)
Definition: ell_matrix.hpp:188
viennacl::ocl::device::max_work_group_size
size_t max_work_group_size() const
Maximum number of work-items in a work-group executing a kernel using the data parallel execution mod...
Definition: device.hpp:483
viennacl::linalg::unit_upper_tag
A tag class representing an upper triangular matrix with unit diagonal.
Definition: forwards.h:864
viennacl::linalg::opencl::kernels::compressed_compressed_matrix
Main kernel class for generating OpenCL kernels for compressed_compressed_matrix. ...
Definition: compressed_compressed_matrix.hpp:72
viennacl::ocl::packed_cl_uint::size
cl_uint size
Number of values in the stride.
Definition: kernel.hpp:52
viennacl::linalg::opencl::kernels::hyb_matrix
Main kernel class for generating OpenCL kernels for hyb_matrix.
Definition: hyb_matrix.hpp:201
viennacl::coordinate_matrix
A sparse square matrix, where entries are stored as triplets (i,j, val), where i and j are the row an...
Definition: coordinate_matrix.hpp:186
viennacl::vector::switch_memory_context
void switch_memory_context(viennacl::context new_ctx)
Definition: vector.hpp:1064
viennacl::linalg::opencl::detail::row_info
void row_info(compressed_matrix< NumericT, AlignmentV > const &A, vector_base< NumericT > &x, viennacl::linalg::detail::row_info_types info_selector)
Definition: sparse_matrix_operations.hpp:56