Any SIMD experts?
Martin Nowak via Digitalmars-d
digitalmars-d at puremagic.com
Mon Dec 8 08:32:34 PST 2014
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
More information about the Digitalmars-d
mailing list