Make sure to use SIMD Alignment with 32

This commit is contained in:
Harshavardhana 2014-11-27 02:15:41 -08:00
parent fd52a211f4
commit f1fcd3be06

View File

@ -38,8 +38,9 @@ const (
) )
const ( const (
DEFAULT_K = 10 K = 10
DEFAULT_M = 3 M = 3
ALIGN = 32
) )
type EncoderParams struct { type EncoderParams struct {
@ -148,16 +149,16 @@ func NewEncoder(ep *EncoderParams) *Encoder {
} }
func (e *Encoder) CalcChunkSize(block_len int) int { func (e *Encoder) CalcChunkSize(block_len int) int {
var alignment int = e.p.k * e.p.w var alignment int = ALIGN
var padding = block_len % alignment var remainder = block_len % alignment
var padded_len int var chunk_size int
if padding > 0 { chunk_size = block_len
padded_len = block_len + (alignment - padding) if remainder > 0 {
} else { chunk_size = block_len + (alignment - remainder)
padded_len = block_len
} }
return padded_len / e.p.k
return chunk_size / e.p.k
} }
func (e *Encoder) Encode(block []byte) ([][]byte, int) { func (e *Encoder) Encode(block []byte) ([][]byte, int) {