unroll int×u1

This commit is contained in:
dzaima 2023-01-23 21:43:39 +02:00
parent 721dd8889b
commit 92c855920b
3 changed files with 19 additions and 5 deletions

View File

@ -76,3 +76,17 @@ def spreadBits{T, a & vcount{T} <= elwidth{T} & quality{eltype{T}}=='u'} = {
def loadBatchBit{T, x:*u64, n:(Size)} = { # vector with type T with each element being either all 0s or 1s
spreadBits{T, b_getBatchLo{vcount{T}, x, n}}
}
def truncBits{n, v & n<=8} = cast_i{u8, v}
def truncBits{n, v & n==16} = cast_i{u16, v}
def truncBits{n, v & n==32} = cast_i{u32, v}
def truncBits{n, v & n==64} = cast_i{u64, v}
def loadBatchBit{T, x:*u64, is & ktup{is}} = {
# def len = tuplen{is}
# def count = vcount{T}
# assert{count*len <= 64}
# bits:= b_getBatchLo{count*len, x, tupsel{0,is}}
# @collect(i to len) spreadBits{T, truncBits{count, bits>>(i*count)}}
each{{i} => loadBatchBit{T, x, i}, is}
}

View File

@ -152,10 +152,10 @@ def arithAAimpl{vw, mode, F, W, X, R, w, x, r, len} = {
def TU = ty_u{R}
def TV = [bulk]TU
maskedLoop{bulk, len, {i, M} => {
cw:= loadBatch{*TU~~w, i, TV}
cx:= loadBatchBit{TV, *u64~~x, i}
storeBatch{*TU~~r, i, cw&cx, M}
muLoop{bulk, 2, len, {is, M} => {
def cw = loadBatch{*TU~~w, is, TV}
def cx = loadBatchBit{TV, *u64~~x, is}
storeBatch{*TU~~r, is, each{&, cw, cx}, M}
}}
} else {
def bulk = vw / max{max{width{W}, width{X}}, width{R}}

View File

@ -48,7 +48,7 @@ def broadcast{T, v & w128f{T, 32}} = emit{T, '_mm_set1_ps', v}
local def makeGen{T,s,x} = emit{T, s, ...each{{c}=>promote{eltype{T},c}, x}}
def make{T, ...xs & w128f{T,64} & tuplen{xs}== 2} = makeGen{T, '_mm_setr_pd', xs}
def make{T, ...xs & w128f{T,32} & tuplen{xs}== 4} = makeGen{T, '_mm_setr_ps', xs}
def make{T, ...xs & w128i{T,64} & tuplen{xs}== 2} = makeGen{T, '_mm_setr_epi64x', xs}
def make{T, ...xs & w128i{T,64} & tuplen{xs}== 2} = makeGen{T, '_mm_set_epi64x', tup{tupsel{1,xs}, tupsel{0,xs}}}
def make{T, ...xs & w128i{T,32} & tuplen{xs}== 4} = makeGen{T, '_mm_setr_epi32', xs}
def make{T, ...xs & w128i{T,16} & tuplen{xs}== 8} = makeGen{T, '_mm_setr_epi16', xs}
def make{T, ...xs & w128i{T, 8} & tuplen{xs}==16} = makeGen{T, '_mm_setr_epi8', xs}