Skip to content

BLAS 3::trmm

Evan Harvey edited this page Apr 20, 2020 · 2 revisions

KokkosBlas::trmm()

Header File: KokkosBlas3_trmm.hpp

Usage: KokkosBlas::trmm(side, uplo, trans, diag, alpha, A, B);

Triangular matrix multiply:

B = alpha*op(A)*B if side == "L" or "l"

B = alpha*B*op(A) if side == "R" or "r"

MultiVector Interface only

template<class AViewType,
         class BViewType>
void
trmm (const char side[],
      const char uplo[],
      const char trans[],
      const char diag[],
      typename BViewType::const_value_type& alpha,
      const AViewType& A,
      const BViewType& B)

Parameters:

  • AViewType: 2-D Kokkos::View
  • BViewType: 2-D Kokkos::View

Arguments:

  • side [in] "L" or "l" indicates matrix A is on the left of B, "R" or "r" indicates matrix A is on the right of B.
  • uplo [in] "U" or "u" indicates matrix A is an upper triangular matrix, "L" or "l" indicates matrix A is a lower triangular matrix.
  • trans [in] "N" or "n" for non-transpose, "T" or "t" for transpose, "C" or "c" for conjugate transpose. Specifies what op does to A.
  • diag [in] "U" or "u" indicates the diagonal of A is assumed to be unit, "N" or "n" indicated the diagonal of A is assumed to be non-unit.
  • alpha [in] Input coefficient used for multiplication with B.
  • A [in] Input matrix, as a 2-D Kokkos::View. If side == "L" or "l", matrix A is a M-by-M triangular matrix; otherwise, matrix A is a N-by-N triangular matrix.
  • B [in,out] Input/Output matrix, as a 2-D Kokkos::View. On entry, M-by-N matrix. On exit, overwritten with the solution.

Requirements:

  • For a given set of side, uplo, trans, and diag, the dimensions of the matrices must align as necessary for triangular matrix multiply.

Example

#include<Kokkos_Core.hpp>
#include<Kokkos_Random.hpp>
#include<KokkosBlas3_trmm.hpp>

int main(int argc, char* argv[]) {
   Kokkos::initialize();

   int M = atoi(argv[1]);
   int N = atoi(argv[2]);
   int K = N;

   using ViewType = Kokkos::View<double**>;
   using Scalar   = typename ViewType::value_type;

   ViewType A("A",K,K);
   ViewType B("B",M,N);

   Kokkos::Random_XorShift64_Pool<typename ViewType::device_type::execution_space> rand_pool(13718);
   Kokkos::fill_random(A,rand_pool,Scalar(10));
   Kokkos::fill_random(B,rand_pool,Scalar(10));

   const Scalar alpha = 1.0;
   
   KokkosBlas::trmm("R","L","T","N",alpha,A,B);

   Kokkos::finalize();
}
Clone this wiki locally