Skip to content

Commit

Permalink
Backup
Browse files Browse the repository at this point in the history
  • Loading branch information
eeprude committed May 25, 2024
1 parent 5fcd22b commit 5af9da9
Show file tree
Hide file tree
Showing 3 changed files with 311 additions and 107 deletions.
44 changes: 21 additions & 23 deletions lapack/src/KokkosLapack_geqrf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace KokkosLapack {
///
/// \tparam ExecutionSpace The space where the kernel will run.
/// \tparam AMatrix Type of matrix A, as a 2-D Kokkos::View.
/// \tparam TArray Type of array Tau, as a 1-D Kokkos::View.
/// \tparam TauArray Type of array Tau, as a 1-D Kokkos::View.
/// \tparam InfoArray Type of array Info, as a 1-D Kokkos::View.
///
/// \param space [in] Execution space instance used to specified how to execute
Expand All @@ -48,19 +48,18 @@ namespace KokkosLapack {
/// is represented as a product of elementary reflectors
/// Q = H(1) H(2) . . . H(k), where k = min(M,N).
/// Each H(i) has the form
/// H(i) = I - Tau * v * v**H
/// where tau is a complex scalar, and v is a complex vector
/// with v(1:i-1) = 0 and v(i) = 1; v(i+1:M) is stored on
/// exit in A(i+1:M,i), and tau in Tau(i).
/// H(i) = I - Tau(i) * v * v**H,
/// where v is a vector with v(1:i-1) = 0 and v(i) = 1;
/// v(i+1:M) is stored on exit in A(i+1:M,i).
/// \param Tau [out] One-dimensional array of size min(M,N) that contains the
/// scalar factors of the elementary reflectors.
/// \param Info [out] One-dimensional array of integers and of size 1:
/// Info[0] = 0: successfull exit
/// Info[0] < 0: if equal to '-i', the i-th argument had an
/// illegal value
///
template <class ExecutionSpace, class AMatrix, class TArray, class InfoArray>
void geqrf(const ExecutionSpace& space, const AMatrix& A, const TArray& Tau,
template <class ExecutionSpace, class AMatrix, class TauArray, class InfoArray>
void geqrf(const ExecutionSpace& space, const AMatrix& A, const TauArray& Tau,
const InfoArray& Info) {
// NOTE: Currently, KokkosLapack::geqrf only supports LAPACK, MAGMA and
// rocSOLVER TPLs.
Expand All @@ -73,21 +72,21 @@ void geqrf(const ExecutionSpace& space, const AMatrix& A, const TArray& Tau,
typename AMatrix::memory_space>::accessible);
static_assert(
Kokkos::SpaceAccessibility<ExecutionSpace,
typename TArray::memory_space>::accessible);
typename TauArray::memory_space>::accessible);
static_assert(
Kokkos::SpaceAccessibility<ExecutionSpace,
typename InfoArray::memory_space>::accessible);

static_assert(Kokkos::is_view<AMatrix>::value,
"KokkosLapack::geqrf: A must be a Kokkos::View.");
static_assert(Kokkos::is_view<TArray>::value,
static_assert(Kokkos::is_view<TauArray>::value,
"KokkosLapack::geqrf: Tau must be Kokkos::View.");
static_assert(Kokkos::is_view<InfoArray>::value,
"KokkosLapack::geqrf: Info must be Kokkos::View.");

static_assert(static_cast<int>(AMatrix::rank) == 2,
"KokkosLapack::geqrf: A must have rank 2.");
static_assert(static_cast<int>(TArray::rank) == 1,
static_assert(static_cast<int>(TauArray::rank) == 1,
"KokkosLapack::geqrf: Tau must have rank 1.");
static_assert(static_cast<int>(InfoArray::rank) == 1,
"KokkosLapack::geqrf: Info must have rank 1.");
Expand Down Expand Up @@ -118,29 +117,29 @@ void geqrf(const ExecutionSpace& space, const AMatrix& A, const TArray& Tau,
using AMatrix_Internal = Kokkos::View<
typename AMatrix::non_const_value_type**, typename AMatrix::array_layout,
typename AMatrix::device_type, Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
using TArray_Internal =
Kokkos::View<typename TArray::non_const_value_type*,
typename TArray::array_layout, typename TArray::device_type,
using TauArray_Internal =
Kokkos::View<typename TauArray::non_const_value_type*,
typename TauArray::array_layout, typename TauArray::device_type,
Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
using InfoArray_Internal =
Kokkos::View<typename InfoArray::non_const_value_type*,
typename InfoArray::array_layout,
typename InfoArray::device_type,
Kokkos::MemoryTraits<Kokkos::Unmanaged>>;

AMatrix_Internal A_i = A;
TArray_Internal Tau_i = Tau;
AMatrix_Internal A_i = A;
TauArray_Internal Tau_i = Tau;
InfoArray_Internal Info_i = Info;

KokkosLapack::Impl::GEQRF<ExecutionSpace, AMatrix_Internal, TArray_Internal,
KokkosLapack::Impl::GEQRF<ExecutionSpace, AMatrix_Internal, TauArray_Internal,
InfoArray_Internal>::geqrf(space, A_i, Tau_i,
Info_i);
}

/// \brief Computes a QR factorization of a matrix A
///
/// \tparam AMatrix Type of matrix A, as a 2-D Kokkos::View.
/// \tparam TArray Type of array Tau, as a 1-D Kokkos::View.
/// \tparam TauArray Type of array Tau, as a 1-D Kokkos::View.
/// \tparam InfoArray Type of array Info, as a 1-D Kokkos::View.
///
/// \param A [in,out] On entry, the M-by-N matrix to be factorized.
Expand All @@ -152,19 +151,18 @@ void geqrf(const ExecutionSpace& space, const AMatrix& A, const TArray& Tau,
/// is represented as a product of elementary reflectors
/// Q = H(1) H(2) . . . H(k), where k = min(M,N).
/// Each H(i) has the form
/// H(i) = I - Tau * v * v**H
/// where tau is a complex scalar, and v is a complex vector
/// with v(1:i-1) = 0 and v(i) = 1; v(i+1:M) is stored on
/// exit in A(i+1:M,i), and tau in Tau(i).
/// H(i) = I - Tau(i) * v * v**H,
/// where v is a vector with v(1:i-1) = 0 and v(i) = 1;
/// v(i+1:M) is stored on exit in A(i+1:M,i).
/// \param Tau [out] One-dimensional array of size min(M,N) that contains the
/// scalar factors of the elementary reflectors.
/// \param Info [out] One-dimensional array of integers and of size 1:
/// Info[0] = 0: successfull exit
/// Info[0] < 0: if equal to '-i', the i-th argument had an
/// illegal value
///
template <class AMatrix, class TArray, class InfoArray>
void geqrf(const AMatrix& A, const TArray& Tau, const InfoArray& Info) {
template <class AMatrix, class TauArray, class InfoArray>
void geqrf(const AMatrix& A, const TauArray& Tau, const InfoArray& Info) {
typename AMatrix::execution_space space{};
geqrf(space, A, Tau, Info);
}
Expand Down
4 changes: 2 additions & 2 deletions lapack/tpls/KokkosLapack_geqrf_tpl_spec_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ KOKKOSLAPACK_GEQRF_LAPACK(Kokkos::complex<double>, Kokkos::LayoutLeft,
} // namespace KokkosLapack
#endif // KOKKOSKERNELS_ENABLE_TPL_LAPACK

#if 0 // AquiEEP
#if 0 // TO DO

// MAGMA
#ifdef KOKKOSKERNELS_ENABLE_TPL_MAGMA
Expand Down Expand Up @@ -270,7 +270,7 @@ KOKKOSLAPACK_GEQRF_MAGMA(Kokkos::complex<double>, Kokkos::LayoutLeft,
} // namespace KokkosLapack
#endif // KOKKOSKERNELS_ENABLE_TPL_MAGMA

#endif // AquiEEP
#endif // TO DO

// CUSOLVER
#ifdef KOKKOSKERNELS_ENABLE_TPL_CUSOLVER
Expand Down
Loading

0 comments on commit 5af9da9

Please sign in to comment.