Merge pull request #46 from harshavardhana/pr_out_make_sure_to_use_simd_alignment_with_32

master
Harshavardhana 10 years ago
commit d6b65f1f04
  1. 23
      pkgs/erasure/encode.go

@ -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) {

Loading…
Cancel
Save