Skip to content

Commit

Permalink
no two passes, 1 pass is enough
Browse files Browse the repository at this point in the history
  • Loading branch information
neurlang authored and Your Name committed May 13, 2024
1 parent 5c1ac4d commit 71fdfe0
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions learning/learn.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ func (h *HyperParameters) reduce2(alphabet *[2][]uint32) (off [2]uint32) {
mutex.Lock()
out[0] = ^uint32(0)
out[1] = ^uint32(0)
where++
mutex.Unlock()
if h.DisableProgressBar {
println("Deadline 2")
Expand Down Expand Up @@ -348,6 +349,7 @@ func (h *HyperParameters) reduce1(alphabet *[2][]uint32) (off [2]uint32) {
mutex.Lock()
out[0] = ^uint32(0)
out[1] = ^uint32(0)
where++
mutex.Unlock()
if h.DisableProgressBar {
println("Deadline 1")
Expand Down Expand Up @@ -395,12 +397,7 @@ func (h *HyperParameters) reduce(max uint32, maxl modulo_t, alphabet *[2][]uint3
} else {
mutex.RUnlock()
}

// two linear passes amortize the complexity of finding error in the cubic stage
for q := uint32(1); q <= 2; q++{
if maxl <= 4 {
break
}
if maxl > 4{
var set = make([]byte, (max+3)/4, (max+3)/4)
//max_recip := real_modulo_recip(max)
maxl_recip := real_modulo_recip(maxl)
Expand All @@ -410,7 +407,7 @@ func (h *HyperParameters) reduce(max uint32, maxl modulo_t, alphabet *[2][]uint3

//println("at", v, i)
i = hash.Hash(v, s, max)
v = alphabet[j&1][uint32((uint64(((i+q) * maxl_recip)) * uint64(maxl)) >> 32)]
v = alphabet[j&1][uint32((uint64(((i+1) * maxl_recip)) * uint64(maxl)) >> 32)]
//fmt.Println(letter)

// imodmax = i % max, but i is at worst 2*max-1
Expand Down Expand Up @@ -456,7 +453,13 @@ func (h *HyperParameters) reduce(max uint32, maxl modulo_t, alphabet *[2][]uint3
//if max < 64 && int0 != int1 {
// continue outer
//}

mutex.RLock()
if my_where != where || out[0] != 0 || out[1] != 0 {
mutex.RUnlock()
return
} else {
mutex.RUnlock()
}
mutex.Lock()
if h.DisableProgressBar {
println("Size: ", maxl, "Modulo:", max)
Expand Down Expand Up @@ -485,6 +488,7 @@ func (h *HyperParameters) reduce(max uint32, maxl modulo_t, alphabet *[2][]uint3
mutex.Lock()
out[0] = ^uint32(0)
out[1] = ^uint32(0)
where++
mutex.Unlock()
if h.DisableProgressBar {
println("Deadline")
Expand Down

0 comments on commit 71fdfe0

Please sign in to comment.