some comments
This commit is contained in:
parent
c94d51dcaf
commit
b4e53abbe4
@ -36,6 +36,7 @@ def hash_val{x:u32 & hasarch{'SSE4.2'}} = {
|
|||||||
# Allocate and initialize resizing hash table
|
# Allocate and initialize resizing hash table
|
||||||
# Initial size sz+ext and maximum size msz+ext
|
# Initial size sz+ext and maximum size msz+ext
|
||||||
# One region for each type in Ts initialized with value from v0s
|
# One region for each type in Ts initialized with value from v0s
|
||||||
|
# Allocates the maximum at the start, resizes downwards within the existing allocation
|
||||||
def hash_alloc{logsz, msz, ext, Ts, v0s, has_radix, ordered} = {
|
def hash_alloc{logsz, msz, ext, Ts, v0s, has_radix, ordered} = {
|
||||||
def ws = each{width,Ts}
|
def ws = each{width,Ts}
|
||||||
def wt = tupsel{0,ws}
|
def wt = tupsel{0,ws}
|
||||||
@ -56,15 +57,18 @@ def hash_alloc{logsz, msz, ext, Ts, v0s, has_radix, ordered} = {
|
|||||||
each{memset{., ., sze}, ptrs, v0s}
|
each{memset{., ., sze}, ptrs, v0s}
|
||||||
|
|
||||||
def hash_resize{cc, m} = {
|
def hash_resize{cc, m} = {
|
||||||
dif := sz*((1<<m)-1)
|
dif := sz*((1<<m)-1) # Number of elements of space to add
|
||||||
sh -= m; sz <<= m
|
sh -= m; sz <<= m
|
||||||
set_thresh{}
|
set_thresh{}
|
||||||
cc = 0
|
cc = 0 # Collision counter
|
||||||
k:tupsel{0,Ts} = 0; --k
|
k:tupsel{0,Ts} = 0; --k # Index where to move an element to
|
||||||
each{{p,v} => { p -= dif; memset{p, v, dif} }, ptrs, v0s}
|
each{{p,v} => { p -= dif; memset{p, v, dif} }, ptrs, v0s}
|
||||||
def {hash, ...vals} = ptrs; def {h0, ...v0r} = v0s
|
def {hash, ...vals} = ptrs; def {h0, ...v0r} = v0s
|
||||||
s := sz+ext
|
s := sz+ext
|
||||||
i := dif
|
i := dif
|
||||||
|
|
||||||
|
# Iterate over existing elements in blocks of e<=32
|
||||||
|
# Branchlessly skips over h0
|
||||||
while (i < s) {
|
while (i < s) {
|
||||||
e := min{s-i, usz~~32}
|
e := min{s-i, usz~~32}
|
||||||
b:u32 = 0
|
b:u32 = 0
|
||||||
|
|||||||
@ -338,6 +338,7 @@ oper &- ({v:T,m} => v & -promote{T,m}) infix left 35
|
|||||||
def rty{name} = if (to_prim{name}=='∊') i8 else i32
|
def rty{name} = if (to_prim{name}=='∊') i8 else i32
|
||||||
def ity{name} = (to_prim{name}=='⊒')**(*u32)
|
def ity{name} = (to_prim{name}=='⊒')**(*u32)
|
||||||
fn hashtab{T, name}(rp:*rty{name}, iv:*void, mi:usz, fv:*void, ni:usz, links:ity{name}) = {
|
fn hashtab{T, name}(rp:*rty{name}, iv:*void, mi:usz, fv:*void, ni:usz, links:ity{name}) = {
|
||||||
|
# iv,mi/ip,m - searched-in; fv,ni/fp,n - searched-for; may get swapped around & back
|
||||||
def prim = to_prim{name}
|
def prim = to_prim{name}
|
||||||
def U = if (prim=='∊') usz else u32
|
def U = if (prim=='∊') usz else u32
|
||||||
m := cast_i{U,mi}; n := cast_i{U,ni}
|
m := cast_i{U,mi}; n := cast_i{U,ni}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user