32 #ifndef REMORA_KERNELS_CLBLAST_GEMV_HPP 33 #define REMORA_KERNELS_CLBLAST_GEMV_HPP 35 #include "../../expression_types.hpp" 36 #include "../../detail/traits.hpp" 38 namespace remora{
namespace kernels{
41 template <
typename MatA,
typename VecX,
typename VecV>
43 matrix_expression<MatA, gpu_tag>
const& A,
44 vector_expression<VecX, gpu_tag>
const& x,
45 vector_expression<VecV, gpu_tag>& v,
46 typename VecV::value_type
const& alpha
48 REMORA_SIZE_CHECK(A().size1() == v().size());
49 REMORA_SIZE_CHECK(A().size2() == x().size());
51 static_assert(std::is_same<typename MatA::value_type, typename VecX::value_type>::value,
"[gemv] Arguments do not have same element type");
52 static_assert(std::is_same<typename MatA::value_type, typename VecV::value_type>::value,
"[gemv] Arguments do not have same element type");
53 static_assert(std::is_same<typename MatA::evaluation_category::tag, dense_tag>::value,
"[gemv] A is not dense");
54 static_assert(std::is_same<typename VecX::evaluation_category::tag, dense_tag>::value,
"[gemv] x is not dense");
55 static_assert(std::is_base_of<dense_tag, typename VecV::storage_type::storage_tag>::value,
"[gemv] v does not have dense storage layout");
58 auto const& Aeval = eval_expression(A);
59 auto const& xeval = eval_expression(x);
62 using namespace clblast;
65 auto layout = std::is_same<typename MatA::orientation::orientation, row_major>::value? Layout::kRowMajor: Layout::kColMajor;
66 std::size_t m = A().size1();
67 std::size_t n = A().size2();
70 auto storageA = Aeval.raw_storage();
71 auto storagex = xeval.raw_storage();
72 auto storagev = v().raw_storage();
74 cl_event*
event =
nullptr;
75 auto code = Gemv(layout, Transpose::kNo,
77 storageA.buffer.get(), storageA.offset, storageA.leading_dimension,
78 storagex.buffer.get(), storagex.offset, storagex.stride,
79 typename VecV::value_type(1),
80 storagev.buffer.get(), storagev.offset, storagev.stride,
81 &v().queue().get(), event
83 assert(code == StatusCode::kSuccess);