first_hom, try_first_hom, popc_hom
This commit is contained in:
parent
c64cdb2c61
commit
8c7c0227a5
@ -197,6 +197,20 @@ def hom_to_int{...vs if length{vs}>1} = {
|
||||
(hi << (h*k)) | lo
|
||||
}
|
||||
def hom_to_int{x if ktup{x}} = hom_to_int{...x}
|
||||
def first_hom{x:[_]_} = ctz_ext{hom_to_int_ext{x}}
|
||||
def popc_hom{x:[_]_} = {
|
||||
def {n,v} = hom_to_int_ext{x}
|
||||
popc{v} / n
|
||||
}
|
||||
def try_first_hom{x:[_]_} = {
|
||||
def ex = hom_to_int_ext{x}
|
||||
val:ux = 0
|
||||
ok:u1 = 0
|
||||
if (select{ex,1} != 0) {
|
||||
ok = 1
|
||||
val = ctz_ext{ex}
|
||||
}
|
||||
}
|
||||
|
||||
def load{V=[k]E, ptr:*E } = load{*V~~ptr, 0}
|
||||
def load{V=[k]E, ptr:*E, k} = load{*V~~ptr, 0}
|
||||
|
||||
@ -3,7 +3,7 @@ include './mask'
|
||||
include './vecfold'
|
||||
include './hashtab'
|
||||
|
||||
def findFirst{C, M, F, ...v1} = {
|
||||
def find_first{C, M, F, ...v1} = {
|
||||
def exit = makelabel{}
|
||||
def args = undef{M{...each{select{., 0}, v1}}}
|
||||
def am = length{select{v1,0}}
|
||||
@ -23,12 +23,12 @@ def search{E, x, n:(u64), OP} = {
|
||||
def VT = [bulk]E
|
||||
def end = make_branch{
|
||||
tup{u64, ty_u{VT}},
|
||||
{i,c} => return{i*bulk + promote{u64, ctz_ext{hom_to_int_ext{c}}}}
|
||||
{i,c} => return{i*bulk + promote{u64, first_hom{c}}}
|
||||
}
|
||||
@for_mu{bulk, tern{arch_defvw>=256, 1, 2}}(x in tup{VT,*E~~x}, M in 'm' over is to n) {
|
||||
eq:= each{OP, x}
|
||||
if (any_hom{M{tree_fold{|, eq}}}) {
|
||||
findFirst{
|
||||
find_first{
|
||||
{i,c} => any_hom{c},
|
||||
{i,c} => tup{i,c},
|
||||
end,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user