Debian Codegraph @

packages/kokkos-kernels/batched/dense/impl/KokkosBatched_Eigendecomposition_TeamVector_Internal.hpp

raw
1 //@HEADER
2 // ************************************************************************
3 //
4 // Kokkos v. 4.0
5 // Copyright (2022) National Technology & Engineering
6 // Solutions of Sandia, LLC (NTESS).
7 //
8 // Under the terms of Contract DE-NA0003525 with NTESS,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions.
12 // See https://kokkos.org/LICENSE for license information.
13 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
14 //
15 //@HEADER
16 #ifndef KOKKOSBATCHED_EIGENDECOMPOSITION_TEAMVECTOR_INTERNAL_HPP
17 #define KOKKOSBATCHED_EIGENDECOMPOSITION_TEAMVECTOR_INTERNAL_HPP
18
19 /// \author Kyungjoo Kim ([email protected])
20
21 #include "KokkosBatched_Util.hpp"
22 #include "KokkosBatched_SetIdentity_Internal.hpp"
23 #include "KokkosBatched_SetTriangular_Internal.hpp"
24 #include "KokkosBatched_Normalize_Internal.hpp"
25
26 #include "KokkosBatched_Eigendecomposition_Serial_Internal.hpp"
27
28 // #include "KokkosBatched_Hessenberg_TeamVector_Internal.hpp"
29 // #include "KokkosBatched_ApplyQ_TeamVector_Internal.hpp"
30 // #include "KokkosBatched_Schur_TeamVector_Internal.hpp"
31 // #include "KokkosBatched_RightEigenvectorFromSchur_TeamVector_Internal.hpp"
32 // #include "KokkosBatched_LeftEigenvectorFromSchur_TeamVector_Internal.hpp"
33 // #include "KokkosBatched_Gemm_TeamVector_Internal.hpp"
34
35 namespace KokkosBatched {
36
37 ///
38 /// TeamVector Internal Impl
39 /// ====================
40
41 struct TeamVectorEigendecompositionInternal {
42 template <typename MemberType, typename RealType>
43 KOKKOS_INLINE_FUNCTION static int device_invoke(const MemberType &member, const int m, RealType *A, const int as0,
44 const int as1, RealType *er, const int ers, RealType *ei,
45 const int eis, RealType *UL, const int uls0, const int uls1,
46 RealType *UR, const int urs0, const int urs1, RealType *w,
47 const int wlen) {
48 /// not yet implemented
49 return 0;
50 }
51
52 /// Given a general nonsymmetric matrix A (m x m), it performs
53 /// eigendecomposition of the matrix.
54 ///
55 /// Parameters:
56 /// [in]m
57 /// A dimension of the square matrix H.
58 /// [in/out]A, [in]as0, [in]as1
59 /// Real general nonsymmetric matrix A(m x m) with strides as0 and as1.
60 /// A is first condensed to a upper Hessenberg form. Then, the Francis
61 /// double shift QR algorithm is applied to compute its Schur form.
62 /// On exit, A stores a quasi upper triangular matrix of the Schur
63 /// decomposition.
64 /// [out]er, [in]ers, [out]ei, [in]eis
65 /// A complex vector er(m)+ei(m)i with a stride ers and eis to store
66 /// computed eigenvalues. For a complex eigen pair, it stores a+bi and
67 /// a-bi consecutively.
68 /// [out]UL, [in]uls0, [in] uls1
69 /// Left eigenvectors UL(m x m) with strides uls0 and uls1. When UL is
70 /// NULL, the left eigenvectors are not computed.
71 /// [out]UR, [in]urs0, [in] urs1
72 /// Right eigenvectors UR(m x m) with strides urs0 and urs1. When UR is
73 /// NULL, the right eigenvectors are not computed.
74 /// [out]w, [in]wlen
75 /// Workspace
76 template <typename MemberType, typename RealType>
77 KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const int m, RealType *A, const int as0,
78 const int as1, RealType *er, const int ers, RealType *ei, const int eis,
79 RealType *UL, const int uls0, const int uls1, RealType *UR, const int urs0,
80 const int urs1, RealType *w, const int wlen) {
81 static_assert(false, "TeamVector eigendecomposition is not implemented yet.");
82 /*
83 // DO NOT USE
84 //
85 // #ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST
86 // <host code>
87 // #else
88 // <device code>
89 // #endif
90 //
91 // DO THIS INSTEAD
92 //
93 // KOKKOS_IF_ON_HOST((<host code>))
94 // KOKKOS_IF_ON_DEVICE((<device code>))
95 //
96 #if defined(KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST)
97 if (as0 == 1 || as1 == 1) {
98 /// column major or row major and it runs on host
99 /// potentially it can run tpls internally
100 Kokkos::single
101 (Kokkos::PerTeam(member),
102 [&]() {
103 SerialEigendecompositionInternal::host_invoke(m,
104 A, as0, as1,
105 er, ers,
106 ei, eis,
107 UL, uls0, uls1,
108 UR, urs0, urs1,
109 w, wlen);
110 });
111 } else {
112 /// arbitrary strides should be handled by native implementation
113 device_invoke(member, m,
114 A, as0, as1,
115 er, ers,
116 ei, eis,
117 UL, uls0, uls1,
118 UR, urs0, urs1,
119 w, wlen);
120 throw std::runtime_error("TeamVector eigendecomposition is not implemented
121 yet.");
122 }
123 #else
124 /// device code runs
125 device_invoke(member, m,
126 A, as0, as1,
127 er, ers,
128 ei, eis,
129 UL, uls0, uls1,
130 UR, urs0, urs1,
131 w, wlen);
132 #endif
133 */
134 return 0;
135 }
136 };
137
138 } // namespace KokkosBatched
139
140 #endif