Skip to content

BLAS::gesv

Vinh Dang edited this page Feb 19, 2020 · 3 revisions

KokkosBlas::gesv()

Header File: KokkosBlas_gesv.hpp

Usage: KokkosBlas::gesv (A, B, IPIV);

Solves a dense linear equation system with multiple right-hand sides using LU factorization A*X = B (partial pivoting variant and no pivoting variant).

MultiVector Interface only

template <class AMatrix,
          class BXMV,
          class IPIVV>
void
gesv (const AMatrix& A,
      const BXMV&    B,
      const IPIVV&   IPIV)

Parameters:

  • AMatrix: 2-D Kokkos::View
  • BXMV: 1-D or 2-D Kokkos::View
  • IPIVV: 1-D Kokkos::View

Arguments:

  • A [in,out] On entry, the N-by-N matrix to be solved. On exit, the factors L and U from the factorization A = PLU; the unit diagonal elements of L are not stored.
  • B [in,out] On entry, the right hand side (multi)vector B. On exit, the solution (multi)vector X.
  • IPIV [out] On exit, the pivot indices (for partial pivoting). If the View extents are zero and its data pointer is NULL, pivoting is not used.

Requirements:

  • The dimensions of the matrices A and B must match for linear system solve.
  • The dimension of IPIV must match dimensions of A and B (for partial pivoting) or IPIV is zero-extent 1-D view (no pivoting case). Note: TPL BLAS does not support no pivoting case.

Example

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

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

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

   using ViewType  = Kokkos::View<double**>;
   using Scalar    = typename ViewType::value_type;
   using ViewTypeP = Kokkos::View<int*, Kokkos::LayoutLeft, Kokkos::HostSpace>;

   ViewType  A("A", N, N);
   ViewType  B("B", N, NRHS);
   ViewTypeP IPIV("IPIV", 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));

   KokkosBlas::gesv(A, B, IPIV);

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