You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[ESIMD] Add writeable subsript operator for simd_view (#4384)
The primary goal for this patch is to allow writing through
simd_view subscript operator, e.g.:
```
simd<int, 4> v = 1;
auto vv = v.select<2, 1>(0);
vv[0] = 42;
```
All the other changes are required to make that happen:
1. One more specialization for nested simd_view class with len=1.
2. Added explicit definition of BINOP for simd_view_impl with
a scalar value because of the following code:
```
simd<ushort, 64> s = 0;
auto g = s.bit_cast_view<ushort, 4, 16>();
auto x = g.row(1) - (g.row(1))[0];
```
Here `g.row(1)` return simd_view and `(g.row(1))[0]` returns
simd_view of size 1. To use any binops defined in simd_view_impl
before this patch we would need to implicitly convert RHS to
scalar and then convert scalar to vector type. Two implicit
conversions are not allowed according to C++ language rules,
hence new BINOP operator definition for simd_view_impl.
3. I also added additional template parameter for simd_view
specialization for lenght=1 to support the following code:
```
simd<int, 1> s = 0;
float f = s.bit_cast_view<float>();
```
This code is OK. The result of bit_cast_view should be mapped
to specialization of simd_view with length 1, so conversion to
scalar is allowed. To enable such mapping, I fixed the definition
of region_base_1. Previously we had zeros for StrideY and StrideX
but in fact, we don't care about their values, they can take any
values.
0 commit comments