Skip to content

BLAS 2::gemv

Nathan Ellingwood edited this page Nov 12, 2019 · 2 revisions

KokkosBlas::gemv()

Header File: KokkosBlas2_gemv.hpp

Usage: KokkosBlas::gemv (mode, alpha, A, x, beta, y);

Matrix Vector Multiplication y[i] = beta * y[i] + alpha * SUM_j(A[i,j] * x[j])

Interface Single Vector only

template<class AViewType,
         class XViewType,
         class YViewType>
void
gemv (const char trans[],
      typename AViewType::const_value_type& alpha,
      const AViewType& A,
      const XViewType& x,
      typename YViewType::const_value_type& beta,
      const YViewType& y)

Parameters:

  • AViewType: A rank-2 Kokkos::View
  • XViewType: A rank-1 Kokkos::View
  • YViewType: A rank-1 Kokkos::View

Arguments:

  • trans [in] "N" for non-transpose, "T" for transpose, "C" for conjugate transpose. All characters after the first are ignored. This works just like the BLAS routines.
  • alpha [in] Input coefficient of A*x
  • A [in] Input matrix, as a 2-D Kokkos::View
  • x [in] Input vector, as a 1-D Kokkos::View
  • beta [in] Input coefficient of y
  • y [in/out] Output vector, as a nonconst 1-D Kokkos::View

Requirements:

  • If mode == "N": A.extent(0) == y.extent(0) && A.extent(1) == x.extent(0)
  • If mode == "C" || mode == "T": A.extent(1) == y.extent(0) && A.extent(0) == x.extent(0)

Example

#include<Kokkos_Core.hpp>
#include<KokkosBlas2_gemv.hpp>

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

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

   Kokkos::View<double**> A("A",M,N);
   Kokkos::View<double*> x("X",N);
   Kokkos::View<double*> y("Y",N);
   
   Kokkos::deep_copy(A,1.0);
   Kokkos::deep_copy(x,3.0);

   const double alpha = double(1.0);
   const double beta = double(0.0);
   
   KokkosBlas::gemv("N",alpha,A,x,beta,y);

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