Documentation
¶
Index ¶
- Variables
- func And(dst, a []byte)
- func AndXor(dst, a, b []byte)
- func BitExtract(b []byte, i int) byte
- func ConcurrentBitOp(f func([]byte, []byte), dst, a []byte)
- func ConcurrentDoubleBitOp(f func([]byte, []byte, []byte), dst, a, b []byte)
- func ConcurrentTransposeTall(matrix [][]byte) [][]byte
- func ConcurrentTransposeWide(matrix [][]byte) [][]byte
- func Count(r io.Reader) (int64, error)
- func DoubleXor(dst, a, b []byte)
- func Exhaust(n int64, r io.Reader) <-chan []byte
- func IsBitSet(b []byte, i int) bool
- func Pad(n, multiple int) int
- func PadBitMap(n, multiple int) int
- func SafeReadLine(r *bufio.Reader) (line []byte, err error)
- func SampleRandomBitMatrix(row, col int) ([][]uint8, error)
- func Sel(ctx context.Context, f func() error) error
- func Sels(fs ...func() error) chan error
- func Xor(dst, a []byte)
- type BitVect
Constants ¶
This section is empty.
Variables ¶
var ErrByteLengthMissMatch = fmt.Errorf("provided bytes do not have the same length for bit operations")
Functions ¶
func And ¶
func And(dst, a []byte)
And casts the first part of the byte slices (length divisible by 8) into uint64 and then performs AND on the slices of uint64. The excess elements that could not be cast are ANDed conventionally. The whole operation is performed in place. Panic if a and dst do not have the same length. Only tested on x86-64.
func AndXor ¶
func AndXor(dst, a, b []byte)
AndXor casts the first part of the byte slices (length divisible by 8) into uint64 and then performs AND on the slices of uint64 (with a) and then performs XOR (with b). The excess elements that could not be cast are operated on conventionally. The whole operation is performed in place. Panic if a, b and dst do not have the same length. Only tested on x86-64.
func ConcurrentBitOp ¶
ConcurrentBitOp performs an in-place bitwise operation, f, on each byte from a with dst if they are both the same length.
func ConcurrentDoubleBitOp ¶
ConcurrentDoubleBitOp performs an in-place double bitwise operation, f, on each byte from a with dst if they are both the same length
func ConcurrentTransposeTall ¶
ConcurrentTransposeTall tranposes a tall (64 column) matrix. If the input matrix does not have a multiple of 512 rows (tall), panic. First it determines how many 512x512 bit blocks are necessary to contain the matrix. The blocks are divided among the number of workers. If there are fewer blocks than workers, this function operates as though it were single-threaded. For those small sets, performance could be improved by limiting the number of workers to the number of blocks but this incurs a performance penalty and it is much more likely that there will be more blocks than workers/cpu cores. Each goroutine, iterates over the blocks for which it is responsible. For each block it generates a BitVect from the matrix at the appropriate index, performs a cache-oblivious, in-place, contiguous transpose on the BitVect, and finally writes the result to a shared final output matrix. The last worker is responsible for any excess blocks which were not evenly divisible into the number of workers.
func ConcurrentTransposeWide ¶
ConcurrentTransposeWide tranposes a wide (512 row) matrix. If the input matrix does not have a multiple of 64 columns (wide), panic. First it determines how many 512x512 bit blocks are necessary to contain the matrix. The blocks are divided among the number of workers. If there are fewer blocks than workers, this function operates as though it were single-threaded. For those small sets, performance could be improved by limiting the number of workers to the number of blocks but this incurs a performance penalty and it is much more likely that there will be more blocks than workers/cpu cores. Each goroutine iterates over the blocks for which it is responsible. For each block it generates a BitVect from the matrix at the appropriate index, performs a cache-oblivious, in-place, contiguous transpose on the BitVect, and finally writes the result to a shared final output matrix. The last worker is responsible for any excess blocks which were not evenly divisible into the number of workers.
func DoubleXor ¶
func DoubleXor(dst, a, b []byte)
DoubleXor casts the first part of the byte slices (length divisible by 8) into uint64 and then performs XOR on the slices of uint64 (first with a and then with b). The excess elements that could not be cast are XORed conventionally. The whole operation is performed in place. Panic if a, b and dst do not have the same length. Only tested on x86-64.
func Exhaust ¶
Exhaust consumes all the identifiers in r, It expects that each indentifier is line separated with \n at the end of each line.
func IsBitSet ¶
IsBitSet returns true if bit i is set in a byte slice. It extracts bits from the least significant bit (i = 0) to the most significant bit (i = 7).
func PadBitMap ¶
PadBitMap returns the total padded length such that n is padded to a multiple of multiple bytes to fit in a bitmap.
func SafeReadLine ¶
SafeReadLine blocks until a whole line can be read or r returns an error. warning: expects lines to be \n separated
func SampleRandomBitMatrix ¶
SampleRandomBitMatrix allocates a 2D byte matrix of dimension row x col, and adds extra rows of 0s to have the number of rows be a multiple of 512, fills each entry in the byte matrix with pseudorandom byte values from a rand reader.
func Xor ¶
func Xor(dst, a []byte)
Xor casts the first part of the byte slices (length divisible by 8) into uint64 and then performs XOR on the slices of uint64. The excess elements that could not be cast are XORed conventionally. The whole operation is performed in place. Panic if a and dst do not have the same length. Only tested on x86-64.