@@ -18,29 +18,30 @@ namespace sycl {
18
18
namespace INTEL {
19
19
namespace gpu {
20
20
21
- //
22
- // The simd vector class.
23
- //
24
- // This is a wrapper class for llvm vector values. Additionally this class
25
- // supports region operations that map to Intel GPU regions. The type of
26
- // a region select or format operation is of simd_view type, which models
27
- // read-update-write semantics.
28
- //
21
+ // / The simd vector class.
22
+ // /
23
+ // / This is a wrapper class for llvm vector values. Additionally this class
24
+ // / supports region operations that map to Intel GPU regions. The type of
25
+ // / a region select or format operation is of simd_view type, which models
26
+ // / read-update-write semantics.
27
+ // /
28
+ // / \ingroup sycl_esimd
29
29
template <typename Ty, int N> class simd {
30
30
public:
31
- // The underlying builtin data type.
31
+ // / The underlying builtin data type.
32
32
using vector_type = vector_type_t <Ty, N>;
33
33
34
- // The element type of this simd object.
34
+ // / The element type of this simd object.
35
35
using element_type = Ty;
36
36
37
- // The number of elements in this simd object.
37
+ // / The number of elements in this simd object.
38
38
static constexpr int length = N;
39
39
40
40
// TODO @rolandschulz
41
41
// Provide examples why constexpr is needed here.
42
42
//
43
- // Constructors.
43
+ // / @{
44
+ // / Constructors.
44
45
constexpr simd () = default;
45
46
constexpr simd (const simd &other) { set (other.data ()); }
46
47
constexpr simd (simd &&other) { set (other.data ()); }
@@ -72,7 +73,7 @@ template <typename Ty, int N> class simd {
72
73
}
73
74
}
74
75
75
- // Initialize a simd with an initial value and step.
76
+ // / Initialize a simd with an initial value and step.
76
77
constexpr simd (Ty Val, Ty Step = Ty()) noexcept {
77
78
if (Step == Ty ())
78
79
M_data = Val;
@@ -84,6 +85,7 @@ template <typename Ty, int N> class simd {
84
85
}
85
86
}
86
87
}
88
+ // / @}
87
89
88
90
operator const vector_type &() const & { return M_data; }
89
91
operator vector_type &() & { return M_data; }
@@ -96,14 +98,16 @@ template <typename Ty, int N> class simd {
96
98
#endif
97
99
}
98
100
99
- // Whole region read and write .
101
+ // / Whole region read.
100
102
simd read () const { return data (); }
103
+
104
+ // / Whole region write.
101
105
simd &write (const simd &Val) {
102
106
set (Val.data ());
103
107
return *this ;
104
108
}
105
109
106
- // whole region update with predicates
110
+ // / Whole region update with predicates.
107
111
void merge (const simd &Val, const mask_type_t <N> &Mask) {
108
112
set (__esimd_wrregion<element_type, N, N, 0 /* VS*/ , N, 1 , N>(
109
113
data (), Val.data (), 0 , Mask));
@@ -113,11 +117,13 @@ template <typename Ty, int N> class simd {
113
117
set (Val2.data ());
114
118
}
115
119
116
- // Assignment operators.
120
+ // / {@
121
+ // / Assignment operators.
117
122
constexpr simd &operator =(const simd &) & = default ;
118
123
constexpr simd &operator =(simd &&) & = default ;
124
+ // / @}
119
125
120
- // View this simd object in a different element type.
126
+ // / View this simd object in a different element type.
121
127
template <typename EltTy> auto format () & {
122
128
using TopRegionTy = compute_format_type_t <simd, EltTy>;
123
129
using RetTy = simd_view<simd, TopRegionTy>;
@@ -127,40 +133,32 @@ template <typename Ty, int N> class simd {
127
133
128
134
// TODO @Ruyk, @iburyl - should renamed to bit_cast similar to std::bit_cast.
129
135
//
130
- // View as a 2-dimensional simd_view.
136
+ // / View as a 2-dimensional simd_view.
131
137
template <typename EltTy, int Height, int Width> auto format () & {
132
138
using TopRegionTy = compute_format_type_2d_t <simd, EltTy, Height, Width>;
133
139
using RetTy = simd_view<simd, TopRegionTy>;
134
140
TopRegionTy R (0 , 0 );
135
141
return RetTy{*this , R};
136
142
}
137
143
138
- // \brief 1D region select, apply a region on top of this LValue object.
139
- //
140
- // @param Size the number of elements to be selected.
141
- //
142
- // @param Stride the element distance between two consecutive elements.
143
- //
144
- // @param Offset the starting element offset.
145
- //
146
- // @return the representing region object.
147
- //
144
+ // / 1D region select, apply a region on top of this LValue object.
145
+ // /
146
+ // / \tparam Size is the number of elements to be selected.
147
+ // / \tparam Stride is the element distance between two consecutive elements.
148
+ // / \param Offset is the starting element offset.
149
+ // / \return the representing region object.
148
150
template <int Size, int Stride>
149
151
simd_view<simd, region1d_t <Ty, Size, Stride>> select (uint16_t Offset = 0 ) & {
150
152
region1d_t <Ty, Size, Stride> Reg (Offset);
151
153
return {*this , Reg};
152
154
}
153
155
154
- // \brief 1D region select, apply a region on top of this RValue object.
155
- //
156
- // @param Size the number of elements to be selected.
157
- //
158
- // @param Stride the element distance between two consecutive elements.
159
- //
160
- // @param Offset the starting element offset.
161
- //
162
- // @return the value this region object refers to.
163
- //
156
+ // / 1D region select, apply a region on top of this RValue object.
157
+ // /
158
+ // / \tparam Size is the number of elements to be selected.
159
+ // / \tparam Stride is the element distance between two consecutive elements.
160
+ // / \param Offset is the starting element offset.
161
+ // / \return the value this region object refers to.
164
162
template <int Size, int Stride>
165
163
simd<Ty, Size> select (uint16_t Offset = 0 ) && {
166
164
simd<Ty, N> &&Val = *this ;
@@ -176,7 +174,7 @@ template <typename Ty, int N> class simd {
176
174
// This would allow you to use the subscript operator to write to an
177
175
// element.
178
176
// {/quote}
179
- // Read a single element, by value only.
177
+ // / Read a single element, by value only.
180
178
Ty operator [](int i) const { return data ()[i]; }
181
179
182
180
// TODO
@@ -278,28 +276,30 @@ template <typename Ty, int N> class simd {
278
276
return Ret;
279
277
}
280
278
281
- // \brief replicate operation, replicate simd instance given a region
282
- //
283
- // @param Rep number of times region has to be replicated
284
- //
285
- // @param Offset offset in number of elements in src region
286
- //
287
- // @param VS vertical stride of src region to replicate
288
- //
289
- // @param W width of src region to replicate
290
- //
291
- // @param HS horizontal stride of src region to replicate
292
- //
293
- // @return replicated simd instance
279
+ // / \name Replicate
280
+ // / Replicate simd instance given a region.
281
+ // / @{
282
+ // /
294
283
284
+ // / \tparam Rep is number of times region has to be replicated.
285
+ // / \return replicated simd instance.
295
286
template <int Rep> simd<Ty, Rep * N> replicate () {
296
287
return replicate<Rep, N>(0 );
297
288
}
298
289
290
+ // / \tparam Rep is number of times region has to be replicated.
291
+ // / \tparam W is width of src region to replicate.
292
+ // / \param Offset is offset in number of elements in src region.
293
+ // / \return replicated simd instance.
299
294
template <int Rep, int W> simd<Ty, Rep * W> replicate (uint16_t Offset) {
300
295
return replicate<Rep, W, W, 1 >(Offset);
301
296
}
302
297
298
+ // / \tparam Rep is number of times region has to be replicated.
299
+ // / \tparam VS vertical stride of src region to replicate.
300
+ // / \tparam W is width of src region to replicate.
301
+ // / \param Offset is offset in number of elements in src region.
302
+ // / \return replicated simd instance.
303
303
template <int Rep, int VS, int W>
304
304
simd<Ty, Rep * W> replicate (uint16_t Offset) {
305
305
return replicate<Rep, VS, W, 1 >(Offset);
@@ -318,35 +318,40 @@ template <typename Ty, int N> class simd {
318
318
// s.replicate<R>(i).width<W>().vstride<VS>().hstride<HS>()
319
319
// {/quote}
320
320
// @jasonsewall-intel +1 for this
321
+ // / \tparam Rep is number of times region has to be replicated.
322
+ // / \tparam VS vertical stride of src region to replicate.
323
+ // / \tparam W is width of src region to replicate.
324
+ // / \tparam HS horizontal stride of src region to replicate.
325
+ // / \param Offset is offset in number of elements in src region.
326
+ // / \return replicated simd instance.
321
327
template <int Rep, int VS, int W, int HS>
322
328
simd<Ty, Rep * W> replicate (uint16_t Offset) {
323
329
return __esimd_rdregion<element_type, N, Rep * W, VS, W, HS, N>(
324
330
data (), Offset * sizeof (Ty));
325
331
}
332
+ // /@}
326
333
327
- // \brief any operation
328
- //
329
- // @return 1 if any element is set, 0 otherwise
330
-
334
+ // / Any operation.
335
+ // /
336
+ // / \return 1 if any element is set, 0 otherwise.
331
337
template <
332
338
typename T1 = element_type, typename T2 = Ty,
333
339
typename = sycl::detail::enable_if_t <std::is_integral<T1>::value, T2>>
334
340
uint16_t any () {
335
341
return __esimd_any<Ty, N>(data ());
336
342
}
337
343
338
- // \brief all operation
339
- //
340
- // @return 1 if all elements are set, 0 otherwise
341
-
344
+ // / All operation.
345
+ // /
346
+ // / \return 1 if all elements are set, 0 otherwise.
342
347
template <
343
348
typename T1 = element_type, typename T2 = Ty,
344
349
typename = sycl::detail::enable_if_t <std::is_integral<T1>::value, T2>>
345
350
uint16_t all () {
346
351
return __esimd_all<Ty, N>(data ());
347
352
}
348
353
349
- // \brief write a simd-vector into a basic region of a simd object
354
+ // / Write a simd-vector into a basic region of a simd object.
350
355
template <typename RTy>
351
356
ESIMD_INLINE void writeRegion (
352
357
RTy Region,
@@ -373,7 +378,7 @@ template <typename Ty, int N> class simd {
373
378
}
374
379
}
375
380
376
- // \brief write a simd-vector into a nested region of a simd object
381
+ // / Write a simd-vector into a nested region of a simd object.
377
382
template <typename TR, typename UR>
378
383
ESIMD_INLINE void
379
384
writeRegion (std::pair<TR, UR> Region,
0 commit comments