Skip to content

Instantly share code, notes, and snippets.

@dgryski
Created March 18, 2015 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgryski/b54eacc26b199c6652dd to your computer and use it in GitHub Desktop.
Save dgryski/b54eacc26b199c6652dd to your computer and use it in GitHub Desktop.
// +build ignore
package main
import "fmt"
func main() {
// 9 + 9 + 9 + 9 + 9 + 9 + 10
srcmask := uint64(0x007f800000000000)
dstmask := srcmask >> 8
shift := 8
var what string
// what = ` s.tables[t] = append(s.tables[t], entry{hash: p, docid: docid}); t++`
what = ` ids = append(ids, findInTable(s.tables[t], p, mask3)...); t++`
fmt.Println(`
t := 0
var p uint64
for i := 0; i < 6; i++ {
p = sig
` + what)
for i := 0; i < 5; i++ {
fmt.Printf(" p = (sig & 0x%016x) | (sig & 0x%016x >> %d) | (sig & 0x%016x << %d)\n", ^(srcmask | dstmask), srcmask, shift, dstmask, shift)
fmt.Println(what)
dstmask >>= 8
shift += 8
}
srcmask = 0x007f000000000000
dstmask = 0x07f
for i := 0; i < 1; i++ {
fmt.Printf(" p = (sig & 0x%016x) | (sig & 0x%016x >> %d) | (sig & 0x%016x << %d)\n", ^(srcmask | dstmask), srcmask, shift, dstmask, shift)
fmt.Println(what)
fmt.Println(` sig = (sig << 9) | (sig >> (64 - 9))`)
}
fmt.Println(`}`)
// 8 + 8 + 8 + 8 + 8 + 7 + 7 has lower MSE than 8 + 8 + 8 + 8 + 8 + 8 + 6
srcmask = 0x003fc00000000000
dstmask = srcmask >> 8
shift = 8
fmt.Println(what)
for i := 0; i < 4; i++ {
fmt.Printf(" p = (sig & 0x%016x) | (sig & 0x%016x >> %d) | (sig & 0x%016x << %d)\n", ^(srcmask | dstmask), srcmask, shift, dstmask, shift)
fmt.Println(what)
dstmask >>= 8
shift += 8
}
srcmask = 0x003f800000000000
dstmask = 0x07f << 7
shift = (64 - 10 - 7)
for i := 0; i < 2; i++ {
fmt.Printf(" p = (sig & 0x%016x) | (sig & 0x%016x >> %d) | (sig & 0x%016x << %d)\n", ^(srcmask | dstmask), srcmask, shift, dstmask, shift)
fmt.Println(what)
dstmask >>= 7
shift += 7
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment