Skip to content

Commit

Permalink
MIC: gatherImplementation requires a non-Segment type
Browse files Browse the repository at this point in the history
The SimdArray::gather/scatter implementation would forward a Segment
index argument to the underlying Vector objects. This works for all but
MIC, since they simply use the subscript operators for gather and
scatter. MIC, OTOH requires a SimdArray<int, 8> instead, so ensure that
any Segment index argument is turned into a SimdArray on forward to the
Vector member.

Signed-off-by: Matthias Kretz <kretz@kde.org>
  • Loading branch information
mattkretz committed Sep 15, 2016
1 parent 15aa101 commit 39ff0de
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions common/simdarray.h
Expand Up @@ -471,21 +471,29 @@ Vc_INTRINSIC const VectorType &internal_data(const SimdArray<T, N, VectorType, N
return x.data;
}

// unpackIfSegment {{{2
template <typename T> T unpackIfSegment(T &&x) { return std::forward<T>(x); }
template <typename T, size_t Pieces, size_t Index>
auto unpackIfSegment(Common::Segment<T, Pieces, Index> &&x) -> decltype(x.asSimdArray())
{
return x.asSimdArray();
}

// gatherImplementation {{{2
template <typename T, std::size_t N, typename VectorType>
template <typename MT, typename IT>
inline void SimdArray<T, N, VectorType, N>::gatherImplementation(const MT *mem,
IT &&indexes)
{
data.gather(mem, std::forward<IT>(indexes));
data.gather(mem, unpackIfSegment(std::forward<IT>(indexes)));
}
template <typename T, std::size_t N, typename VectorType>
template <typename MT, typename IT>
inline void SimdArray<T, N, VectorType, N>::gatherImplementation(const MT *mem,
IT &&indexes,
MaskArgument mask)
{
data.gather(mem, std::forward<IT>(indexes), mask);
data.gather(mem, unpackIfSegment(std::forward<IT>(indexes)), mask);
}

// scatterImplementation {{{2
Expand All @@ -494,15 +502,15 @@ template <typename MT, typename IT>
inline void SimdArray<T, N, VectorType, N>::scatterImplementation(MT *mem,
IT &&indexes) const
{
data.scatter(mem, std::forward<IT>(indexes));
data.scatter(mem, unpackIfSegment(std::forward<IT>(indexes)));
}
template <typename T, std::size_t N, typename VectorType>
template <typename MT, typename IT>
inline void SimdArray<T, N, VectorType, N>::scatterImplementation(MT *mem,
IT &&indexes,
MaskArgument mask) const
{
data.scatter(mem, std::forward<IT>(indexes), mask);
data.scatter(mem, unpackIfSegment(std::forward<IT>(indexes)), mask);
}

// generic SimdArray {{{1
Expand Down

0 comments on commit 39ff0de

Please sign in to comment.