Skip to content

Commit 88ef29f

Browse files
committed
Lapack - geqrf: applying clang-format and adding eti header
Signed-off-by: Luc Berger-Vergiat <[email protected]>
1 parent ed27f13 commit 88ef29f

File tree

8 files changed

+368
-568
lines changed

8 files changed

+368
-568
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2+
// SPDX-FileCopyrightText: Copyright Contributors to the Kokkos project
3+
4+
#ifndef KOKKOSLAPACK_GEQRF_ETI_SPEC_DECL_HPP_
5+
#define KOKKOSLAPACK_GEQRF_ETI_SPEC_DECL_HPP_
6+
namespace KokkosLapack {
7+
namespace Impl {
8+
@LAPACK_GEQRF_ETI_DECL_BLOCK@
9+
} //IMPL
10+
} //Kokkos
11+
#endif

lapack/impl/KokkosLapack_geqrf_spec.hpp

Lines changed: 37 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,17 @@ struct geqrf_eti_spec_avail {
4242
// We may spread out definitions (see _INST macro below) across one or
4343
// more .cpp files.
4444
//
45-
#define KOKKOSLAPACK_GEQRF_ETI_SPEC_AVAIL(SCALAR_TYPE, LAYOUT_TYPE, \
46-
EXEC_SPACE_TYPE, MEM_SPACE_TYPE) \
47-
template <> \
48-
struct geqrf_eti_spec_avail< \
49-
EXEC_SPACE_TYPE, \
50-
Kokkos::View<SCALAR_TYPE **, LAYOUT_TYPE, \
51-
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
52-
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
53-
Kokkos::View<SCALAR_TYPE *, LAYOUT_TYPE, \
54-
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
55-
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
56-
Kokkos::View<int *, LAYOUT_TYPE, \
57-
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
58-
Kokkos::MemoryTraits<Kokkos::Unmanaged>>> { \
59-
enum : bool { value = true }; \
45+
#define KOKKOSLAPACK_GEQRF_ETI_SPEC_AVAIL(SCALAR_TYPE, LAYOUT_TYPE, EXEC_SPACE_TYPE, MEM_SPACE_TYPE) \
46+
template <> \
47+
struct geqrf_eti_spec_avail< \
48+
EXEC_SPACE_TYPE, \
49+
Kokkos::View<SCALAR_TYPE **, LAYOUT_TYPE, Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
50+
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
51+
Kokkos::View<SCALAR_TYPE *, LAYOUT_TYPE, Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
52+
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
53+
Kokkos::View<int *, LAYOUT_TYPE, Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
54+
Kokkos::MemoryTraits<Kokkos::Unmanaged>>> { \
55+
enum : bool { value = true }; \
6056
};
6157

6258
// Include the actual specialization declarations
@@ -67,25 +63,20 @@ namespace KokkosLapack {
6763
namespace Impl {
6864

6965
// Unification layer
70-
template <
71-
class ExecutionSpace, class AMatrix, class TWArray, class RType,
72-
bool tpl_spec_avail =
73-
geqrf_tpl_spec_avail<ExecutionSpace, AMatrix, TWArray, RType>::value,
74-
bool eti_spec_avail =
75-
geqrf_eti_spec_avail<ExecutionSpace, AMatrix, TWArray, RType>::value>
66+
template <class ExecutionSpace, class AMatrix, class TWArray, class RType,
67+
bool tpl_spec_avail = geqrf_tpl_spec_avail<ExecutionSpace, AMatrix, TWArray, RType>::value,
68+
bool eti_spec_avail = geqrf_eti_spec_avail<ExecutionSpace, AMatrix, TWArray, RType>::value>
7669
struct GEQRF {
77-
static void geqrf(const ExecutionSpace &space, const AMatrix &A,
78-
const TWArray &Tau, const TWArray &Work, const RType &R);
70+
static void geqrf(const ExecutionSpace &space, const AMatrix &A, const TWArray &Tau, const TWArray &Work,
71+
const RType &R);
7972
};
8073

8174
#if !defined(KOKKOSKERNELS_ETI_ONLY) || KOKKOSKERNELS_IMPL_COMPILE_LIBRARY
8275
// Unification layer
8376
template <class ExecutionSpace, class AMatrix, class TWArray, class RType>
84-
struct GEQRF<ExecutionSpace, AMatrix, TWArray, RType, false,
85-
KOKKOSKERNELS_IMPL_COMPILE_LIBRARY> {
86-
static void geqrf(const ExecutionSpace & /* space */, const AMatrix & /* A */,
87-
const TWArray & /* Tau */, const TWArray & /* Work */,
88-
const RType & /* R */) {
77+
struct GEQRF<ExecutionSpace, AMatrix, TWArray, RType, false, KOKKOSKERNELS_IMPL_COMPILE_LIBRARY> {
78+
static void geqrf(const ExecutionSpace & /* space */, const AMatrix & /* A */, const TWArray & /* Tau */,
79+
const TWArray & /* Work */, const RType & /* R */) {
8980
// NOTE: Might add the implementation of KokkosLapack::geqrf later
9081
throw std::runtime_error(
9182
"No fallback implementation of GEQRF (general QR factorization) "
@@ -104,35 +95,26 @@ struct GEQRF<ExecutionSpace, AMatrix, TWArray, RType, false,
10495
// We may spread out definitions (see _DEF macro below) across one or
10596
// more .cpp files.
10697
//
107-
#define KOKKOSLAPACK_GEQRF_ETI_SPEC_DECL(SCALAR_TYPE, LAYOUT_TYPE, \
108-
EXEC_SPACE_TYPE, MEM_SPACE_TYPE) \
109-
extern template struct GEQRF< \
110-
EXEC_SPACE_TYPE, \
111-
Kokkos::View<SCALAR_TYPE **, LAYOUT_TYPE, \
112-
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
113-
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
114-
Kokkos::View<SCALAR_TYPE *, LAYOUT_TYPE, \
115-
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
116-
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
117-
Kokkos::View<int *, LAYOUT_TYPE, \
118-
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
119-
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
98+
#define KOKKOSLAPACK_GEQRF_ETI_SPEC_DECL(SCALAR_TYPE, LAYOUT_TYPE, EXEC_SPACE_TYPE, MEM_SPACE_TYPE) \
99+
extern template struct GEQRF< \
100+
EXEC_SPACE_TYPE, \
101+
Kokkos::View<SCALAR_TYPE **, LAYOUT_TYPE, Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
102+
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
103+
Kokkos::View<SCALAR_TYPE *, LAYOUT_TYPE, Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
104+
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
105+
Kokkos::View<int *, LAYOUT_TYPE, Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
106+
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
120107
false, true>;
121108

122-
#define KOKKOSLAPACK_GEQRF_ETI_SPEC_INST(SCALAR_TYPE, LAYOUT_TYPE, \
123-
EXEC_SPACE_TYPE, MEM_SPACE_TYPE) \
124-
template struct GEQRF< \
125-
EXEC_SPACE_TYPE, \
126-
Kokkos::View<SCALAR_TYPE **, LAYOUT_TYPE, \
127-
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
128-
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
129-
Kokkos::View<SCALAR_TYPE *, LAYOUT_TYPE, \
130-
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
131-
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
132-
Kokkos::View<int *, LAYOUT_TYPE, \
133-
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
134-
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
135-
false, true>;
109+
#define KOKKOSLAPACK_GEQRF_ETI_SPEC_INST(SCALAR_TYPE, LAYOUT_TYPE, EXEC_SPACE_TYPE, MEM_SPACE_TYPE) \
110+
template struct GEQRF<EXEC_SPACE_TYPE, \
111+
Kokkos::View<SCALAR_TYPE **, LAYOUT_TYPE, Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
112+
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
113+
Kokkos::View<SCALAR_TYPE *, LAYOUT_TYPE, Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
114+
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
115+
Kokkos::View<int *, LAYOUT_TYPE, Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
116+
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
117+
false, true>;
136118

137119
#include <KokkosLapack_geqrf_tpl_spec_decl.hpp>
138120

lapack/src/KokkosLapack_geqrf.hpp

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -59,37 +59,24 @@ namespace KokkosLapack {
5959
/// illegal value
6060
///
6161
template <class ExecutionSpace, class AMatrix, class TauArray, class InfoArray>
62-
void geqrf(const ExecutionSpace& space, const AMatrix& A, const TauArray& Tau,
63-
const InfoArray& Info) {
62+
void geqrf(const ExecutionSpace& space, const AMatrix& A, const TauArray& Tau, const InfoArray& Info) {
6463
// NOTE: Currently, KokkosLapack::geqrf only supports LAPACK, MAGMA and
6564
// rocSOLVER TPLs.
6665
// MAGMA/rocSOLVER TPL should be enabled to call the MAGMA/rocSOLVER GPU
6766
// interface for device views LAPACK TPL should be enabled to call the
6867
// LAPACK interface for host views
6968

70-
static_assert(
71-
Kokkos::SpaceAccessibility<ExecutionSpace,
72-
typename AMatrix::memory_space>::accessible);
73-
static_assert(
74-
Kokkos::SpaceAccessibility<ExecutionSpace,
75-
typename TauArray::memory_space>::accessible);
76-
static_assert(
77-
Kokkos::SpaceAccessibility<ExecutionSpace,
78-
typename InfoArray::memory_space>::accessible);
79-
80-
static_assert(Kokkos::is_view<AMatrix>::value,
81-
"KokkosLapack::geqrf: A must be a Kokkos::View.");
82-
static_assert(Kokkos::is_view<TauArray>::value,
83-
"KokkosLapack::geqrf: Tau must be Kokkos::View.");
84-
static_assert(Kokkos::is_view<InfoArray>::value,
85-
"KokkosLapack::geqrf: Info must be Kokkos::View.");
86-
87-
static_assert(static_cast<int>(AMatrix::rank) == 2,
88-
"KokkosLapack::geqrf: A must have rank 2.");
89-
static_assert(static_cast<int>(TauArray::rank) == 1,
90-
"KokkosLapack::geqrf: Tau must have rank 1.");
91-
static_assert(static_cast<int>(InfoArray::rank) == 1,
92-
"KokkosLapack::geqrf: Info must have rank 1.");
69+
static_assert(Kokkos::SpaceAccessibility<ExecutionSpace, typename AMatrix::memory_space>::accessible);
70+
static_assert(Kokkos::SpaceAccessibility<ExecutionSpace, typename TauArray::memory_space>::accessible);
71+
static_assert(Kokkos::SpaceAccessibility<ExecutionSpace, typename InfoArray::memory_space>::accessible);
72+
73+
static_assert(Kokkos::is_view<AMatrix>::value, "KokkosLapack::geqrf: A must be a Kokkos::View.");
74+
static_assert(Kokkos::is_view<TauArray>::value, "KokkosLapack::geqrf: Tau must be Kokkos::View.");
75+
static_assert(Kokkos::is_view<InfoArray>::value, "KokkosLapack::geqrf: Info must be Kokkos::View.");
76+
77+
static_assert(static_cast<int>(AMatrix::rank) == 2, "KokkosLapack::geqrf: A must have rank 2.");
78+
static_assert(static_cast<int>(TauArray::rank) == 1, "KokkosLapack::geqrf: Tau must have rank 1.");
79+
static_assert(static_cast<int>(InfoArray::rank) == 1, "KokkosLapack::geqrf: Info must have rank 1.");
9380

9481
static_assert(std::is_same_v<typename InfoArray::non_const_value_type, int>,
9582
"KokkosLapack::geqrf: Info must be an array of integers.");
@@ -114,25 +101,19 @@ void geqrf(const ExecutionSpace& space, const AMatrix& A, const TauArray& Tau,
114101
KokkosKernels::Impl::throw_runtime_exception(os.str());
115102
}
116103

117-
using AMatrix_Internal = Kokkos::View<
118-
typename AMatrix::non_const_value_type**, typename AMatrix::array_layout,
119-
typename AMatrix::device_type, Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
120-
using TauArray_Internal = Kokkos::View<
121-
typename TauArray::non_const_value_type*, typename TauArray::array_layout,
122-
typename TauArray::device_type, Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
123-
using InfoArray_Internal =
124-
Kokkos::View<typename InfoArray::non_const_value_type*,
125-
typename InfoArray::array_layout,
126-
typename InfoArray::device_type,
127-
Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
104+
using AMatrix_Internal = Kokkos::View<typename AMatrix::non_const_value_type**, typename AMatrix::array_layout,
105+
typename AMatrix::device_type, Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
106+
using TauArray_Internal = Kokkos::View<typename TauArray::non_const_value_type*, typename TauArray::array_layout,
107+
typename TauArray::device_type, Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
108+
using InfoArray_Internal = Kokkos::View<typename InfoArray::non_const_value_type*, typename InfoArray::array_layout,
109+
typename InfoArray::device_type, Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
128110

129111
AMatrix_Internal A_i = A;
130112
TauArray_Internal Tau_i = Tau;
131113
InfoArray_Internal Info_i = Info;
132114

133-
KokkosLapack::Impl::GEQRF<ExecutionSpace, AMatrix_Internal, TauArray_Internal,
134-
InfoArray_Internal>::geqrf(space, A_i, Tau_i,
135-
Info_i);
115+
KokkosLapack::Impl::GEQRF<ExecutionSpace, AMatrix_Internal, TauArray_Internal, InfoArray_Internal>::geqrf(
116+
space, A_i, Tau_i, Info_i);
136117
}
137118

138119
/// \brief Computes a QR factorization of a matrix A

0 commit comments

Comments
 (0)