Any SIMD experts?

John Colvin via Digitalmars-d digitalmars-d at puremagic.com
Mon Dec 8 08:55:17 PST 2014


On Monday, 8 December 2014 at 16:32:50 UTC, Martin Nowak wrote:
> I want to do bounds checking of 2 (4 on avx) ulongs (64-bit) at 
> a time.
>
> ulong2 vval = [v0, v1];
> ulong2 vlow = [low, low];
> ulong2 vhigh = [high, high];
>
> int res = PMOVMSKB(vval >= vlow & vval < vhigh);
>
> I figured out sort of a solution, but it seems way too 
> complicated, because there is only signed comparison.
>
> Usually (scalar) I'd use this, which makes use of unsigned wrap 
> to safe one conditional
>
> immutable size = cast(ulong)(vhigh - vlow);
> if (cast(ulong)(v0 - vlow) < size) {}
> if (cast(ulong)(v1 - vlow) < size) {}
>
> over
>
> if (v0 >= vlow && v0 < vhigh) {}
>
> Maybe this can be used on SIMD too (saturated sub or so)?
>
> -Martin

I don't quite understand what you mean by "save one conditional".


More information about the Digitalmars-d mailing list