|
49 | 49 |
|
50 | 50 | namespace KokkosBlas {
|
51 | 51 |
|
52 |
| -/// |
53 |
| -/// NT |
54 |
| -/// |
55 |
| - |
56 |
| -template <> |
57 |
| -struct TeamGemv<Trans::NoTranspose, Algo::Gemv::Unblocked> { |
58 |
| - template <typename MemberType, typename ScalarType, typename AViewType, |
59 |
| - typename xViewType, typename yViewType> |
60 |
| - KOKKOS_INLINE_FUNCTION static int invoke( |
61 |
| - const MemberType& member, const ScalarType alpha, const AViewType& A, |
62 |
| - const xViewType& x, const ScalarType beta, const yViewType& y) { |
63 |
| - static_assert(AViewType::Rank == 2, |
64 |
| - "Blas TeamGemv requires rank-2 A matrix"); |
65 |
| - return Impl::TeamGemvInternal<Algo::Gemv::Unblocked>::invoke( |
66 |
| - member, A.extent(0), A.extent(1), alpha, A.data(), A.stride_0(), |
67 |
| - A.stride_1(), x.data(), x.stride_0(), beta, y.data(), y.stride_0()); |
68 |
| - } |
69 |
| -}; |
70 |
| - |
71 |
| -template <> |
72 |
| -struct TeamGemv<Trans::NoTranspose, Algo::Gemv::Blocked> { |
73 |
| - template <typename MemberType, typename ScalarType, typename AViewType, |
74 |
| - typename xViewType, typename yViewType> |
75 |
| - KOKKOS_INLINE_FUNCTION static int invoke( |
76 |
| - const MemberType& member, const ScalarType alpha, const AViewType& A, |
77 |
| - const xViewType& x, const ScalarType beta, const yViewType& y) { |
78 |
| - static_assert(AViewType::Rank == 2, |
79 |
| - "Blas TeamGemv requires rank-2 A matrix"); |
80 |
| - return Impl::TeamGemvInternal<Algo::Gemv::Blocked>::invoke( |
81 |
| - member, A.extent(0), A.extent(1), alpha, A.data(), A.stride_0(), |
82 |
| - A.stride_1(), x.data(), x.stride_0(), beta, y.data(), y.stride_0()); |
83 |
| - } |
84 |
| -}; |
85 |
| - |
86 |
| -/// |
87 |
| -/// T |
88 |
| -/// |
89 |
| - |
90 |
| -template <> |
91 |
| -struct TeamGemv<Trans::Transpose, Algo::Gemv::Unblocked> { |
92 |
| - template <typename MemberType, typename ScalarType, typename AViewType, |
93 |
| - typename xViewType, typename yViewType> |
94 |
| - KOKKOS_INLINE_FUNCTION static int invoke( |
95 |
| - const MemberType& member, const ScalarType alpha, const AViewType& A, |
96 |
| - const xViewType& x, const ScalarType beta, const yViewType& y) { |
97 |
| - static_assert(AViewType::Rank == 2, |
98 |
| - "BLAS TeamGemv requires rank-2 A matrix"); |
99 |
| - return Impl::TeamGemvInternal<Algo::Gemv::Unblocked>::invoke( |
100 |
| - member, A.extent(1), A.extent(0), alpha, A.data(), A.stride_1(), |
101 |
| - A.stride_0(), x.data(), x.stride_0(), beta, y.data(), y.stride_0()); |
102 |
| - } |
103 |
| -}; |
104 |
| - |
105 |
| -template <> |
106 |
| -struct TeamGemv<Trans::Transpose, Algo::Gemv::Blocked> { |
107 |
| - template <typename MemberType, typename ScalarType, typename AViewType, |
108 |
| - typename xViewType, typename yViewType> |
109 |
| - KOKKOS_INLINE_FUNCTION static int invoke( |
110 |
| - const MemberType& member, const ScalarType alpha, const AViewType& A, |
111 |
| - const xViewType& x, const ScalarType beta, const yViewType& y) { |
112 |
| - static_assert(AViewType::Rank == 2, |
113 |
| - "BLAS TeamGemv requires rank-2 A matrix"); |
114 |
| - return Impl::TeamGemvInternal<Algo::Gemv::Blocked>::invoke( |
115 |
| - member, A.extent(1), A.extent(0), alpha, A.data(), A.stride_1(), |
116 |
| - A.stride_0(), x.data(), x.stride_0(), beta, y.data(), y.stride_0()); |
117 |
| - } |
118 |
| -}; |
119 |
| - |
120 |
| -/// |
121 |
| -/// CT |
122 |
| -/// |
123 |
| - |
124 |
| -template <> |
125 |
| -struct TeamGemv<Trans::ConjTranspose, Algo::Gemv::Unblocked> { |
126 |
| - template <typename MemberType, typename ScalarType, typename AViewType, |
127 |
| - typename xViewType, typename yViewType> |
128 |
| - KOKKOS_INLINE_FUNCTION static int invoke( |
129 |
| - const MemberType& member, const ScalarType alpha, const AViewType& A, |
130 |
| - const xViewType& x, const ScalarType beta, const yViewType& y) { |
131 |
| - static_assert(AViewType::Rank == 2, |
132 |
| - "BLAS TeamGemv requires rank-2 A matrix"); |
133 |
| - return Impl::TeamGemvInternal<Algo::Gemv::Unblocked>::invoke( |
134 |
| - member, Impl::OpConj{}, A.extent(1), A.extent(0), alpha, A.data(), |
135 |
| - A.stride_1(), A.stride_0(), x.data(), x.stride_0(), beta, y.data(), |
136 |
| - y.stride_0()); |
137 |
| - } |
138 |
| -}; |
139 |
| - |
140 |
| -template <> |
141 |
| -struct TeamGemv<Trans::ConjTranspose, Algo::Gemv::Blocked> { |
142 |
| - template <typename MemberType, typename ScalarType, typename AViewType, |
143 |
| - typename xViewType, typename yViewType> |
144 |
| - KOKKOS_INLINE_FUNCTION static int invoke( |
145 |
| - const MemberType& member, const ScalarType alpha, const AViewType& A, |
146 |
| - const xViewType& x, const ScalarType beta, const yViewType& y) { |
147 |
| - static_assert(AViewType::Rank == 2, |
148 |
| - "BLAS TeamGemv requires rank-2 A matrix"); |
149 |
| - return Impl::TeamGemvInternal<Algo::Gemv::Blocked>::invoke( |
150 |
| - member, Impl::OpConj{}, A.extent(1), A.extent(0), alpha, A.data(), |
151 |
| - A.stride_1(), A.stride_0(), x.data(), x.stride_0(), beta, y.data(), |
152 |
| - y.stride_0()); |
153 |
| - } |
154 |
| -}; |
155 |
| - |
156 |
| -/// |
157 |
| -/// NT |
158 |
| -/// |
159 |
| - |
160 |
| -template <> |
161 |
| -struct TeamVectorGemv<Trans::NoTranspose, Algo::Gemv::Unblocked> { |
162 |
| - template <typename MemberType, typename ScalarType, typename AViewType, |
163 |
| - typename xViewType, typename yViewType> |
164 |
| - KOKKOS_INLINE_FUNCTION static int invoke( |
165 |
| - const MemberType& member, const ScalarType alpha, const AViewType& A, |
166 |
| - const xViewType& x, const ScalarType beta, const yViewType& y) { |
167 |
| - static_assert(AViewType::Rank == 2, |
168 |
| - "Blas TeamVectorGemv requires rank-2 A matrix"); |
169 |
| - return Impl::TeamVectorGemvInternal<Algo::Gemv::Unblocked>::invoke( |
170 |
| - member, A.extent(0), A.extent(1), alpha, A.data(), A.stride_0(), |
171 |
| - A.stride_1(), x.data(), x.stride_0(), beta, y.data(), y.stride_0()); |
172 |
| - } |
173 |
| -}; |
174 |
| - |
175 |
| -/// |
176 |
| -/// T |
177 |
| -/// |
178 |
| - |
179 |
| -template <> |
180 |
| -struct TeamVectorGemv<Trans::Transpose, Algo::Gemv::Unblocked> { |
181 |
| - template <typename MemberType, typename ScalarType, typename AViewType, |
182 |
| - typename xViewType, typename yViewType> |
183 |
| - KOKKOS_INLINE_FUNCTION static int invoke( |
184 |
| - const MemberType& member, const ScalarType alpha, const AViewType& A, |
185 |
| - const xViewType& x, const ScalarType beta, const yViewType& y) { |
186 |
| - static_assert(AViewType::Rank == 2, |
187 |
| - "Blas TeamVectorGemv requires rank-2 A matrix"); |
188 |
| - return Impl::TeamVectorGemvInternal<Algo::Gemv::Unblocked>::invoke( |
189 |
| - member, A.extent(1), A.extent(0), alpha, A.data(), A.stride_1(), |
190 |
| - A.stride_0(), x.data(), x.stride_0(), beta, y.data(), y.stride_0()); |
191 |
| - } |
192 |
| -}; |
193 |
| - |
194 |
| -/// |
195 |
| -/// CT |
196 |
| -/// |
197 |
| - |
198 |
| -template <> |
199 |
| -struct TeamVectorGemv<Trans::ConjTranspose, Algo::Gemv::Unblocked> { |
200 |
| - template <typename MemberType, typename ScalarType, typename AViewType, |
201 |
| - typename xViewType, typename yViewType> |
202 |
| - KOKKOS_INLINE_FUNCTION static int invoke( |
203 |
| - const MemberType& member, const ScalarType alpha, const AViewType& A, |
204 |
| - const xViewType& x, const ScalarType beta, const yViewType& y) { |
205 |
| - static_assert(AViewType::Rank == 2, |
206 |
| - "Blas TeamVectorGemv requires rank-2 A matrix"); |
207 |
| - return Impl::TeamVectorGemvInternal<Algo::Gemv::Unblocked>::invoke( |
208 |
| - member, Impl::OpConj{}, A.extent(1), A.extent(0), alpha, A.data(), |
209 |
| - A.stride_1(), A.stride_0(), x.data(), x.stride_0(), beta, y.data(), |
210 |
| - y.stride_0()); |
211 |
| - } |
212 |
| -}; |
| 52 | +template <typename ArgTrans, typename ArgAlgo> |
| 53 | +template <typename MemberType, typename ScalarType, typename AViewType, |
| 54 | + typename xViewType, typename yViewType> |
| 55 | +KOKKOS_INLINE_FUNCTION int TeamGemv<ArgTrans, ArgAlgo>::invoke( |
| 56 | + const MemberType& member, const ScalarType alpha, const AViewType& A, |
| 57 | + const xViewType& x, const ScalarType beta, const yViewType& y) { |
| 58 | + static_assert(std::is_same<ArgAlgo, Algo::Gemv::Unblocked>::value || |
| 59 | + std::is_same<ArgAlgo, Algo::Gemv::Blocked>::value, |
| 60 | + "Algorithm not supported"); |
| 61 | + static_assert(AViewType::Rank == 2, |
| 62 | + "KokkosBlas::TeamGemv requires rank-2 A matrix"); |
| 63 | + |
| 64 | + using TransA = Impl::MatrixModeInfo<ArgTrans>; |
| 65 | + const auto ae0 = TransA::extent(A, 0); |
| 66 | + const auto ae1 = TransA::extent(A, 1); |
| 67 | + const auto as0 = TransA::stride_0(A); |
| 68 | + const auto as1 = TransA::stride_1(A); |
| 69 | + |
| 70 | + return Impl::TeamGemvInternal<ArgAlgo>::invoke( |
| 71 | + member, ae0, ae1, alpha, A.data(), as0, as1, x.data(), x.stride_0(), beta, |
| 72 | + y.data(), y.stride_0()); |
| 73 | +} |
| 74 | + |
| 75 | +template <typename ArgTrans, typename ArgAlgo> |
| 76 | +template <typename MemberType, typename ScalarType, typename AViewType, |
| 77 | + typename xViewType, typename yViewType> |
| 78 | +KOKKOS_INLINE_FUNCTION int TeamVectorGemv<ArgTrans, ArgAlgo>::invoke( |
| 79 | + const MemberType& member, const ScalarType alpha, const AViewType& A, |
| 80 | + const xViewType& x, const ScalarType beta, const yViewType& y) { |
| 81 | + static_assert(std::is_same<ArgAlgo, Algo::Gemv::Unblocked>::value, |
| 82 | + "Algorithm not supported"); |
| 83 | + static_assert(AViewType::Rank == 2, |
| 84 | + "KokkosBlas::TeamVectorGemv requires rank-2 A matrix"); |
| 85 | + |
| 86 | + using TransA = Impl::MatrixModeInfo<ArgTrans>; |
| 87 | + const auto ae0 = TransA::extent(A, 0); |
| 88 | + const auto ae1 = TransA::extent(A, 1); |
| 89 | + const auto as0 = TransA::stride_0(A); |
| 90 | + const auto as1 = TransA::stride_1(A); |
| 91 | + |
| 92 | + return Impl::TeamVectorGemvInternal<Algo::Gemv::Unblocked>::invoke( |
| 93 | + member, ae0, ae1, alpha, A.data(), as0, as1, x.data(), x.stride_0(), beta, |
| 94 | + y.data(), y.stride_0()); |
| 95 | +} |
213 | 96 |
|
214 | 97 | } // namespace KokkosBlas
|
215 | 98 |
|
|
0 commit comments