Skip to content

Commit

Permalink
Backup
Browse files Browse the repository at this point in the history
  • Loading branch information
eeprude committed May 23, 2024
1 parent 36ddd9a commit 0b4f34a
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 97 deletions.
10 changes: 6 additions & 4 deletions lapack/impl/KokkosLapack_geqrf_spec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ struct geqrf_eti_spec_avail {
Kokkos::View<SCALAR_TYPE *, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
Kokkos::View<int, Kokkos::LayoutRight, Kokkos::HostSpace, \
Kokkos::View<int*, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>> { \
enum : bool { value = true }; \
};
Expand All @@ -78,7 +79,6 @@ struct GEQRF {
};

#if !defined(KOKKOSKERNELS_ETI_ONLY) || KOKKOSKERNELS_IMPL_COMPILE_LIBRARY
//! Full specialization of geqrf for multi vectors.
// Unification layer
template <class ExecutionSpace, class AMatrix, class TWArray, class RType>
struct GEQRF<ExecutionSpace, AMatrix, TWArray, RType, false,
Expand Down Expand Up @@ -114,7 +114,8 @@ struct GEQRF<ExecutionSpace, AMatrix, TWArray, RType, false,
Kokkos::View<SCALAR_TYPE *, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
Kokkos::View<int, Kokkos::LayoutRight, Kokkos::HostSpace, \
Kokkos::View<int*, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
false, true>;

Expand All @@ -128,7 +129,8 @@ struct GEQRF<ExecutionSpace, AMatrix, TWArray, RType, false,
Kokkos::View<SCALAR_TYPE *, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
Kokkos::View<int, Kokkos::LayoutRight, Kokkos::HostSpace, \
Kokkos::View<int*, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
false, true>;

Expand Down
42 changes: 22 additions & 20 deletions lapack/src/KokkosLapack_geqrf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//@HEADER

/// \file KokkosLapack_geqrf.hpp
/// \brief Local dense linear solve
/// \brief QR factorization
///
/// This file provides KokkosLapack::geqrf. This function performs a
/// local (no MPI) QR factorization of a M-by-N matrix A.
Expand Down Expand Up @@ -118,31 +118,33 @@ int geqrf(const ExecutionSpace& space, const AMatrix& A, const TWArray& Tau,
}
}

typedef Kokkos::View<
using RetArray = Kokkos::View<int*, typename TWArray::array_layout, typename TWArray::device_type>;
RetArray rc("rc", 1);

using AMatrix_Internal = Kokkos::View<
typename AMatrix::non_const_value_type**, typename AMatrix::array_layout,
typename AMatrix::device_type, Kokkos::MemoryTraits<Kokkos::Unmanaged> >
AMatrix_Internal;
typedef Kokkos::View<
typename AMatrix::device_type, Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
using TWArray_Internal = Kokkos::View<
typename TWArray::non_const_value_type*, typename TWArray::array_layout,
typename TWArray::device_type, Kokkos::MemoryTraits<Kokkos::Unmanaged> >
TWArray_Internal;
AMatrix_Internal A_i = A;
TWArray_Internal Tau_i = Tau;
TWArray_Internal Work_i = Work;

// This is the return value type and should always reside on host
using RViewInternalType =
Kokkos::View<int, Kokkos::LayoutRight, Kokkos::HostSpace,
Kokkos::MemoryTraits<Kokkos::Unmanaged> >;
typename TWArray::device_type, Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
using RetArray_Internal = Kokkos::View<
int*, typename TWArray::array_layout,
typename TWArray::device_type, Kokkos::MemoryTraits<Kokkos::Unmanaged>>;

int result;
RViewInternalType R = RViewInternalType(&result);
AMatrix_Internal A_i = A;
TWArray_Internal Tau_i = Tau;
TWArray_Internal Work_i = Work;
RetArray_Internal rc_i = rc;

KokkosLapack::Impl::GEQRF<ExecutionSpace, AMatrix_Internal, TWArray_Internal,
RViewInternalType>::geqrf(space, A_i, Tau_i, Work_i,
R);
RetArray_Internal>::geqrf(space, A_i, Tau_i, Work_i,
rc_i);

typename RetArray_Internal::HostMirror h_rc = Kokkos::create_mirror_view(rc_i);

Kokkos::deep_copy(h_rc, rc_i);

return result;
return h_rc[0];
}

/// \brief Computes a QR factorization of a matrix A
Expand Down
6 changes: 3 additions & 3 deletions lapack/tpls/KokkosLapack_geqrf_tpl_spec_avail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct geqrf_tpl_spec_avail {
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
Kokkos::View<SCALAR*, LAYOUT, Kokkos::Device<ExecSpace, MEMSPACE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
Kokkos::View<int, Kokkos::LayoutRight, Kokkos::HostSpace, \
Kokkos::View<int*, LAYOUT, Kokkos::Device<ExecSpace, MEMSPACE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>> { \
enum : bool { value = true }; \
};
Expand Down Expand Up @@ -95,7 +95,7 @@ namespace Impl {
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
Kokkos::View<SCALAR*, LAYOUT, Kokkos::Device<Kokkos::Cuda, MEMSPACE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
Kokkos::View<int, Kokkos::LayoutRight, Kokkos::HostSpace, \
Kokkos::View<int*, LAYOUT, Kokkos::Device<Kokkos::Cuda, MEMSPACE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>> { \
enum : bool { value = true }; \
};
Expand Down Expand Up @@ -142,7 +142,7 @@ namespace Impl {
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
Kokkos::View<SCALAR*, LAYOUT, Kokkos::Device<Kokkos::HIP, MEMSPACE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
Kokkos::View<int, Kokkos::LayoutRight, Kokkos::HostSpace, \
Kokkos::View<int*, LAYOUT, Kokkos::Device<Kokkos::HIP, MEMSPACE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>> { \
enum : bool { value = true }; \
};
Expand Down
Loading

0 comments on commit 0b4f34a

Please sign in to comment.