32 #ifndef REMORA_KERNELS_CLBLAST_TRMM_HPP 33 #define REMORA_KERNELS_CLBLAST_TRMM_HPP 35 #include "../../expression_types.hpp" 36 #include "../../detail/traits.hpp" 38 namespace remora{
namespace kernels{
41 template <
bool Upper,
bool Unit,
typename MatA,
typename MatC>
43 matrix_expression<MatA, gpu_tag>
const& A,
44 matrix_expression<MatC, gpu_tag>& C
46 REMORA_SIZE_CHECK(A().size1() == A().size2());
47 REMORA_SIZE_CHECK(A().size2() == C().size1());
49 static_assert(std::is_same<typename MatA::value_type, typename MatC::value_type>::value,
"[trmm] Arguments do not have same element type");
50 static_assert(std::is_same<typename MatA::evaluation_category::tag, dense_tag>::value,
"[trmm] A is not dense");
51 static_assert(std::is_base_of<dense_tag, typename MatC::storage_type::storage_tag>::value,
"[trmm] C does not have dense storage layout");
54 auto const& Aeval = eval_expression(A);
56 using namespace clblast;
59 auto transA = std::is_same<typename MatA::orientation,typename MatC::orientation>::value? Transpose::kNo : Transpose::kYes;
60 auto layout = std::is_same<typename MatC::orientation::orientation, row_major>::value? Layout::kRowMajor : Layout::kColMajor;
61 auto diagonal = Unit? Diagonal::kUnit : Diagonal::kNonUnit;
62 auto triangular = Upper? Triangle::kUpper : Triangle::kLower;
63 if(transA == Transpose::kYes){
64 triangular = Upper? Triangle::kLower : Triangle::kUpper;
66 std::size_t m = C().size1();
67 std::size_t n = C().size2();
70 auto storageA = Aeval.raw_storage();
71 auto storageC = C().raw_storage();
73 cl_event*
event =
nullptr;
74 auto code = Trmm(layout, Side::kLeft, triangular, transA, diagonal,
75 m, n,
typename MatC::value_type(1),
76 storageA.buffer.get(), storageA.offset, storageA.leading_dimension,
77 storageC.buffer.get(), storageC.offset, storageC.leading_dimension,
78 &C().queue().get(), event
80 assert(code == StatusCode::kSuccess);