agenium-scale/boost.simd

Regression ?

otristan opened this issue · 6 comments

Hi Guys,

The following code used to work in a version from the end of january but update to the latest trunk broke it

void InterpolateMonoSSE2Unroll4(const short* pSrc, double playpos, double incr, size_t count, float *pDst)
{
    using vF = bs::pack<float, 4>;

    const float fratio = 1.f / 32768.f;
    vF ratio{ fratio };
    vF play{ playpos, playpos + incr, playpos + 2 * incr, playpos + 3 * incr };
    vF pulse{ vF::static_size * incr };
    const size_t n = count / vF::static_size; // unroll by N

    float *pOutput = pDst;

      for (size_t i = 0; i < n; ++i)
      {
        auto index_ = bs::floor(play);
        auto frac = play - index_;
        auto index = bs::toint(index_);
        bs::pack<int32_t, 4> src(*(const int32_t *)(pSrc + index[0]), *(const int32_t *)(pSrc + index[1]), *(const int32_t *)(pSrc + index[2]), *(const int32_t *)(pSrc + index[3]));
        auto src16 = bs::bitwise_cast<bs::pack<int16_t, 8>>(src);
        auto src16S = bs::shuffle<0, 2, 4, 6, 1, 3, 5, 7>(src16);
        auto a = bs::tofloat(bs::split_low(src16S));
        auto b = bs::tofloat(bs::split_high(src16S));
        auto out = (a + (b - a) * frac) * ratio;
        bs::aligned_store(out, pOutput);
        play += pulse;
        pOutput += vF::static_size;
      }
}

Visual C++ 2015 now states

C:\Users\otristan\code\boost\boost/simd/detail/pack_proxy_base.hpp(85): error C2440: 'static_cast': cannot convert from 'const short *const ' to 'int'
1> C:\Users\otristan\code\boost\boost/simd/detail/pack_proxy_base.hpp(85): note: There is no context in which this conversion is possible

The code is a linear interpolation of 16 bits integer to float

Is there a cleaner way to do this ?

This is induced by changes to how proxy values out of pack are handled. This has probably inserted by the change to make iterators more flexible by sharing code with them. I think the fix is easy, gimme a day or two to have a look at that.

casting to int index[0..3] fixes the issue FWIW

the pack_proxy operator need to use auto->decltype instead of fixing the type inside. I'll make a PR for that.

Care to see if bracnh fix-issue-535 fixes the issue ?

Look like it does on ym side. Merged as of now.

That does the trick on my end as well.
Was in the middle of something so sorry for not testing the branch.