Skip to content

BLAS 2::ger

Luc Berger edited this page Apr 23, 2024 · 1 revision

KokkosBlas::ger()

Header File: KokkosBlas2_ger.hpp

Usage: KokkosBlas::ger (space, mode, alpha, x, y, A);

Matrix Rank 1 update: A = A + alpha * x * y^{T,H}

Interface

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

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

Template Parameters:

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

Arguments:

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

Requirements:

  • x and y are rank-1 views
  • A is a rank-2 view
  • x, y and A have memory space accessible from ExecutionSpace
  • A.extent(0) == x.extent(0) && A.extent(1) == y.extent(0)

Example

#include <Kokkos_Core.hpp>
#include <KokkosBlas2_ger.hpp>

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

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

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

    Kokkos::deep_copy(A, 1.0);
    Kokkos::deep_copy(x, 3.0);
    Kokkos::deep_copy(y, 1.3);

    const double alpha = double(1.0);

    KokkosBlas::ger("T", alpha, x, y, A);

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