GPR mask testing
This commit is contained in:
parent
efd79881cb
commit
5f85305f43
@ -28,11 +28,11 @@ equal{W, X}(w:*void, x:*void, l:u64, d:u64) : u1 = {
|
||||
def bulk = 4
|
||||
f0:= broadcast{T, 0.0}
|
||||
f1:= broadcast{T, 1.0}
|
||||
maskedLoop{bulk, l, {i, M} => {
|
||||
maskedLoopPositive{bulk, l, {i, M} => {
|
||||
cw:= load{*u8 ~~ w, i>>1} >> cast_i{u8, 4*(i&1)}
|
||||
cx:= load{*T ~~ x, i}
|
||||
wu:= blend{f0, f1, broadcast{[4]u64, cw} << make{[4]u64,63,62,61,60}}
|
||||
if (anyne{wu, cx, M}) return{0}
|
||||
if (anynePositive{wu, cx, M}) return{0}
|
||||
}}
|
||||
} else { # bitarr ≡ i8/i16/i32arr
|
||||
def T = [256/width{X}]X
|
||||
@ -54,12 +54,12 @@ equal{W, X}(w:*void, x:*void, l:u64, d:u64) : u1 = {
|
||||
def ww{gw, E} = [gw/width{E}]E
|
||||
def fac = width{X}/width{W}
|
||||
|
||||
maskedLoop{bulk, l, {i, M} => {
|
||||
maskedLoopPositive{bulk, l, {i, M} => {
|
||||
# TODO update this to modern mask stuff
|
||||
cw:= load{*ww{tern{fac==1, 256, 128}, W} ~~ (w + i*32/fac)}
|
||||
cx:= load{*ww{256, X} ~~ x, i}
|
||||
cwc:= cvt{W, ww{256, X}, cw}
|
||||
if (anyne{cwc,cx,M}) return{0}
|
||||
if (anynePositive{cwc,cx,M}) return{0}
|
||||
}}
|
||||
}
|
||||
1
|
||||
|
||||
@ -19,6 +19,9 @@ def anyne{x:T, y:T, M & M{0}==0 & anyInt{x}} = x!=y
|
||||
def anyne{x:T, y:T, M & M{0}==1 & anyInt{x}} = M{x^y} != 0
|
||||
def anyneBit{x:T, y:T, M} = ~M{x^y, 'all bits zeroes'}
|
||||
|
||||
def anynePositive{x:T, y:T, M & M{0}==0} = anyne{x, y, M}
|
||||
def anynePositive{x:T, y:T, M & M{0}==1 & isvec{T}} = (promote{u32,~getmask{x==y}} << (32-M{'count'})) != 0
|
||||
|
||||
def maskNone{x} = x
|
||||
def maskNone{x, mode=='all bits zeroes'} = andIsZero{x, x}
|
||||
def maskAfter{n} = {
|
||||
@ -84,3 +87,12 @@ def maskedLoop{bulk, i0, l, step} = {
|
||||
left:= l & (bulk-1)
|
||||
if (left!=0) step{m, maskAfter{left}}
|
||||
}
|
||||
|
||||
def maskedLoopPositive{bulk, l:L, step} = {
|
||||
i:L = 0
|
||||
while(i < (l-1)/bulk) {
|
||||
step{i, maskNone}
|
||||
i = i + 1
|
||||
}
|
||||
step{i, maskAfter{l - i*bulk}}
|
||||
}
|
||||
@ -121,7 +121,7 @@ def __sub{a:T,b:T & w128i{T, 64}} = emit{T, '_mm_sub_epi64', a, b}
|
||||
|
||||
|
||||
# mask stuff
|
||||
def getmask{x:T & w128{T, 8}} = emit{u32, '_mm_movemask_epi8', x}
|
||||
def getmask{x:T & w128{T, 8}} = emit{u16, '_mm_movemask_epi8', x}
|
||||
def getmask{x:T & w128{T, 16}} = getmask{emit{[16]u8, '_mm_packs_epi16', x, broadcast{[8]u16, 0}}}
|
||||
def getmask{x:T & w128{T, 32}} = emit{u8, '_mm_movemask_ps', v2f{x}}
|
||||
def getmask{x:T & w128{T, 64}} = emit{u8, '_mm_movemask_pd', v2d{x}}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user