@@ -39,11 +39,12 @@ struct scal_eti_spec_avail {
39
39
40
40
//
41
41
// Macro for declaration of full specialization availability
42
- // KokkosBlas::Impl::Scal for rank == 1. This is NOT for users!!! All
42
+ // KokkosBlas::Impl::Scal for rank == 1 R and X . This is NOT for users!!! All
43
43
// the declarations of full specializations go in this header file.
44
44
// We may spread out definitions (see _INST macro below) across one or
45
45
// more .cpp files.
46
46
//
47
+ // Alpha can either be scalar or rank 0
47
48
#define KOKKOSBLAS1_SCAL_ETI_SPEC_AVAIL (SCALAR, LAYOUT, EXEC_SPACE, MEM_SPACE ) \
48
49
template <> \
49
50
struct scal_eti_spec_avail < \
@@ -56,15 +57,28 @@ struct scal_eti_spec_avail {
56
57
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
57
58
1 > { \
58
59
enum : bool { value = true }; \
60
+ }; \
61
+ template <> \
62
+ struct scal_eti_spec_avail < \
63
+ EXEC_SPACE, \
64
+ Kokkos::View<SCALAR*, LAYOUT, Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
65
+ Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
66
+ Kokkos::View<SCALAR, LAYOUT, Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
67
+ Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
68
+ Kokkos::View<const SCALAR*, LAYOUT, \
69
+ Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
70
+ Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
71
+ 1 > { \
72
+ enum : bool { value = true }; \
59
73
};
60
-
61
74
//
62
75
// Macro for declaration of full specialization availability
63
- // KokkosBlas::Impl::Scal for rank == 2. This is NOT for users!!! All
76
+ // KokkosBlas::Impl::Scal for rank == 2 R and X. This is NOT for users!!! All
64
77
// the declarations of full specializations go in this header file.
65
78
// We may spread out definitions (see _DEF macro below) across one or
66
79
// more .cpp files.
67
80
//
81
+ // Alpha can either be rank 1, rank 0, or scalar
68
82
#define KOKKOSBLAS1_SCAL_MV_ETI_SPEC_AVAIL (SCALAR, LAYOUT, EXEC_SPACE, \
69
83
MEM_SPACE) \
70
84
template <> \
@@ -82,6 +96,20 @@ struct scal_eti_spec_avail {
82
96
enum : bool { value = true }; \
83
97
}; \
84
98
template <> \
99
+ struct scal_eti_spec_avail < \
100
+ EXEC_SPACE, \
101
+ Kokkos::View<SCALAR**, LAYOUT, Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
102
+ Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
103
+ Kokkos::View<const SCALAR, LAYOUT, \
104
+ Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
105
+ Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
106
+ Kokkos::View<const SCALAR**, LAYOUT, \
107
+ Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
108
+ Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
109
+ 2 > { \
110
+ enum : bool { value = true }; \
111
+ }; \
112
+ template <> \
85
113
struct scal_eti_spec_avail < \
86
114
EXEC_SPACE, \
87
115
Kokkos::View<SCALAR**, LAYOUT, Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
@@ -151,7 +179,7 @@ struct Scal<execution_space, RV, typename XV::non_const_value_type, XV, 1,
151
179
typeid (RV).name (), typeid (AV).name (), typeid (XV).name ());
152
180
#endif
153
181
154
- const size_type numRows = X. extent ( 0 );
182
+
155
183
KokkosKernels::Impl::ScalarHint alphaHint = KokkosKernels::Impl::ScalarHint::none;
156
184
if (alpha == ATA::zero ()) {
157
185
alphaHint = KokkosKernels::Impl::ScalarHint::zero;
@@ -161,25 +189,22 @@ struct Scal<execution_space, RV, typename XV::non_const_value_type, XV, 1,
161
189
alphaHint = KokkosKernels::Impl::ScalarHint::pos_one;
162
190
}
163
191
192
+ const size_type numRows = X.extent (0 );
164
193
if (numRows < static_cast <size_type>(INT_MAX)) {
165
- typedef int index_type;
166
- V_Scal_Generic<execution_space, RV, AV, XV, index_type>(space, R, alpha,
167
- X, 0 , alphaHint);
194
+ V_Scal_Generic<int >(space, R, alpha, X, alphaHint);
168
195
} else {
169
- typedef typename XV::size_type index_type;
170
- V_Scal_Generic<execution_space, RV, AV, XV, index_type>(space, R, alpha,
171
- X, 0 , alphaHint);
196
+ V_Scal_Generic<typename XV::size_type>(space, R, alpha, X, alphaHint);
172
197
}
173
198
Kokkos::Profiling::popRegion ();
174
199
}
175
200
};
176
201
177
- // / \brief Partial specialization of Scal for 2-D Views and 1-D View AV.
202
+ // / \brief Partial specialization of Scal for 2-D Views and 1-D, 0-D, or scalar AV.
178
203
// /
179
204
// / Compute any of the following:
180
- // /
181
- // / 1 . R(i,j) = a* X(i,j) for a in -1,0,1
182
- // / 2 . R(i,j) = alpha (j)* X(i,j)
205
+ // / 1. R(i,j) = av * X(i,j)
206
+ // / 2 . R(i,j) = av() * X(i,j)
207
+ // / 3 . R(i,j) = av (j) * X(i,j)
183
208
template <class execution_space , class RMV , class AV , class XMV >
184
209
struct Scal <execution_space, RMV, AV, XMV, 2 , false ,
185
210
KOKKOSKERNELS_IMPL_COMPILE_LIBRARY> {
@@ -189,6 +214,9 @@ struct Scal<execution_space, RMV, AV, XMV, 2, false,
189
214
190
215
static void scal (const execution_space& space, const RMV& R, const AV& av,
191
216
const XMV& X) {
217
+
218
+ // TODO: assert some things about AV
219
+
192
220
static_assert (Kokkos::is_view<RMV>::value,
193
221
" KokkosBlas::Impl::"
194
222
" Scal<2-D>: RMV is not a Kokkos::View." );
@@ -201,9 +229,6 @@ struct Scal<execution_space, RMV, AV, XMV, 2, false,
201
229
static_assert (RMV::rank == 2 ,
202
230
" KokkosBlas::Impl::Scal<2-D>: "
203
231
" RMV is not rank 2." );
204
- static_assert (AV::rank == 1 ,
205
- " KokkosBlas::Impl::Scal<2-D>: "
206
- " AV is not rank 1." );
207
232
static_assert (XMV::rank == 2 ,
208
233
" KokkosBlas::Impl::Scal<2-D>: "
209
234
" XMV is not rank 2." );
@@ -312,17 +337,29 @@ struct Scal<execution_space, RMV, typename XMV::non_const_value_type, XMV, 2,
312
337
313
338
//
314
339
// Macro for declaration of full specialization of
315
- // KokkosBlas::Impl::Scal for rank == 2 . This is NOT for users!!! All
340
+ // KokkosBlas::Impl::Scal for rank == 1 . This is NOT for users!!! All
316
341
// the declarations of full specializations go in this header file.
317
342
// We may spread out definitions (see _DEF macro below) across one or
318
343
// more .cpp files.
319
344
//
345
+ // alpha can be either scalar or rank 0
320
346
#define KOKKOSBLAS1_SCAL_ETI_SPEC_DECL (SCALAR, LAYOUT, EXEC_SPACE, MEM_SPACE ) \
321
347
extern template struct Scal < \
322
348
EXEC_SPACE, \
323
349
Kokkos::View<SCALAR*, LAYOUT, Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
324
350
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
325
351
SCALAR, \
352
+ Kokkos::View<const SCALAR*, LAYOUT, \
353
+ Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
354
+ Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
355
+ 1 , false , true >; \
356
+ extern template struct Scal < \
357
+ EXEC_SPACE, \
358
+ Kokkos::View<SCALAR*, LAYOUT, Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
359
+ Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
360
+ Kokkos::View<const SCALAR, LAYOUT, \
361
+ Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
362
+ Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
326
363
Kokkos::View<const SCALAR*, LAYOUT, \
327
364
Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
328
365
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
@@ -334,6 +371,17 @@ struct Scal<execution_space, RMV, typename XMV::non_const_value_type, XMV, 2,
334
371
Kokkos::View<SCALAR*, LAYOUT, Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
335
372
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
336
373
SCALAR, \
374
+ Kokkos::View<const SCALAR*, LAYOUT, \
375
+ Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
376
+ Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
377
+ 1 , false , true >; \
378
+ template struct Scal < \
379
+ EXEC_SPACE, \
380
+ Kokkos::View<SCALAR*, LAYOUT, Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
381
+ Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
382
+ Kokkos::View<const SCALAR, LAYOUT, \
383
+ Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
384
+ Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
337
385
Kokkos::View<const SCALAR*, LAYOUT, \
338
386
Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
339
387
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
0 commit comments