Boost logo

Boost :

Subject: Re: [boost] [SIMD] Pre-review questions
From: Artyom Beilis (artyom.beilis_at_[hidden])
Date: 2017-03-26 13:28:27


On Sun, Mar 26, 2017 at 3:05 PM, Joel FALCOU via Boost
<boost_at_[hidden]> wrote:
> On 26/03/2017 08:37, Artyom Beilis via Boost wrote:
>> 2. I can't find in documentation how to performs casts between
>> different types: I see in docs split_low (actually after I grepped for
>> _mm_unpacklo) but I failed to find how to use one - there is no
>> documentation regarding conversion/casting operation or at least I
>> failed to find one.
>
>
> The function you look for is pack_cast
>
> https://developer.numscale.com/boost.simd/documentation/develop/group__group-bitwise_gade4bdae8c35c470224d94ba3b87ea36c.html#gade4bdae8c35c470224d94ba3b87ea36c
>
> pack<float,8>
>

Still do you have examples or documentation for:

How do I cast for example low part or high part something like:

pack<unsigned byte,16> v;
pack<unsigned short,8> v1=cast_low(v); // note sometimes I indeed need
only low or only high part - not both
pack<unsigned short,8> v2=cast_high(v);
...
v=join_cast(v1,v2); // short to byte

What is saturation policy: if I have unsigned short of value 257
casted to unsigned char would it cast to 1 or to 255?
How can I control the policy?

>> 3. Is there more convenient way to perform basic saturated operation
>> for example if I want to calc abs diff of two bs::pack<unsigned
>> char,16> values a,b I need to write
>>
>> bs::saturated_(be::minus)(a,b) + bs::saturated_(bs::minus)(b,a)
>>
>> It is quite inconvenient especially when most of operations you want
>> to do are saturated.
>
>
> All functions in Boost.SIMD are function object. Decorators just wrap them
> in a proper layer. So
>
> auto sm = bs::saturated_(be::minus);
> sm(a,b) + sm(b,a);
>
> is the recommended way to do it.
>

I see

> Then in your specific example, you can use dist that do the proper
> computation without calling the saturated costly version of minus. IF you
> really want to handle saturation, in case of handling INT_MAX and INT_MIN
> then call saturated_(dist).
>
> Usually, we strongly advice the use of the highest-level possible function
> instead of trying to just rewrite an old SSE* code using one-for-one
> intrinsic mapping. Boost.SIMD wraps a lot of well known tricks and
> optimization in high level version of said function in order to give access
> to those to all users.

I agree I searched for something like absdiff but didn't found the
"dist" function - but indeed it is better.

Thanks,
  Artyom


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk