mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
Updated version of klauspost/reedsolomon using proper AVX2 instructions as well a providing support for Cauchy matrices. (#5215)
This commit is contained in:
parent
c9e00ae0a5
commit
6e6aeb6a9e
11
vendor/github.com/klauspost/reedsolomon/README.md
generated
vendored
11
vendor/github.com/klauspost/reedsolomon/README.md
generated
vendored
@ -24,10 +24,15 @@ go get -u github.com/klauspost/reedsolomon
|
||||
|
||||
# Changes
|
||||
|
||||
## October 1, 2017
|
||||
|
||||
* [Cauchy Matrix](https://godoc.org/github.com/klauspost/reedsolomon#WithCauchyMatrix) is now an option. Thanks to [templexxx](https://github.com/templexxx) for the basis of this.
|
||||
* Default maximum number of [goroutines](https://godoc.org/github.com/klauspost/reedsolomon#WithMaxGoroutines) has been increased for better multi-core scaling.
|
||||
* After several requests the Reconstruct and ReconstructData now slices of zero length but sufficient capacity to be used instead of allocating new memory.
|
||||
|
||||
## August 26, 2017
|
||||
|
||||
* The[`Encoder()`](https://godoc.org/github.com/klauspost/reedsolomon#Encoder) now contains an `Update` function contributed by [chenzhongtao](https://github.com/chenzhongtao).
|
||||
|
||||
* The [`Encoder()`](https://godoc.org/github.com/klauspost/reedsolomon#Encoder) now contains an `Update` function contributed by [chenzhongtao](https://github.com/chenzhongtao).
|
||||
* [Frank Wessels](https://github.com/fwessels) kindly contributed ARM 64 bit assembly, which gives a huge performance boost on this platform.
|
||||
|
||||
## July 20, 2017
|
||||
@ -155,7 +160,7 @@ It might seem like a limitation that all data should be in memory, but an import
|
||||
splitA[i] = data[i][:25000]
|
||||
splitB[i] = data[i][25000:]
|
||||
|
||||
// Concencate it to itself
|
||||
// Concatenate it to itself
|
||||
merged[i] = append(make([]byte, 0, len(data[i])*2), data[i]...)
|
||||
merged[i] = append(merged[i], data[i]...)
|
||||
}
|
||||
|
3
vendor/github.com/klauspost/reedsolomon/galois.go
generated
vendored
3
vendor/github.com/klauspost/reedsolomon/galois.go
generated
vendored
@ -73,6 +73,9 @@ func galSub(a, b byte) byte {
|
||||
return a ^ b
|
||||
}
|
||||
|
||||
// Table from https://github.com/templexxx/reedsolomon
|
||||
var invTable = [256]byte{0x0, 0x1, 0x8e, 0xf4, 0x47, 0xa7, 0x7a, 0xba, 0xad, 0x9d, 0xdd, 0x98, 0x3d, 0xaa, 0x5d, 0x96, 0xd8, 0x72, 0xc0, 0x58, 0xe0, 0x3e, 0x4c, 0x66, 0x90, 0xde, 0x55, 0x80, 0xa0, 0x83, 0x4b, 0x2a, 0x6c, 0xed, 0x39, 0x51, 0x60, 0x56, 0x2c, 0x8a, 0x70, 0xd0, 0x1f, 0x4a, 0x26, 0x8b, 0x33, 0x6e, 0x48, 0x89, 0x6f, 0x2e, 0xa4, 0xc3, 0x40, 0x5e, 0x50, 0x22, 0xcf, 0xa9, 0xab, 0xc, 0x15, 0xe1, 0x36, 0x5f, 0xf8, 0xd5, 0x92, 0x4e, 0xa6, 0x4, 0x30, 0x88, 0x2b, 0x1e, 0x16, 0x67, 0x45, 0x93, 0x38, 0x23, 0x68, 0x8c, 0x81, 0x1a, 0x25, 0x61, 0x13, 0xc1, 0xcb, 0x63, 0x97, 0xe, 0x37, 0x41, 0x24, 0x57, 0xca, 0x5b, 0xb9, 0xc4, 0x17, 0x4d, 0x52, 0x8d, 0xef, 0xb3, 0x20, 0xec, 0x2f, 0x32, 0x28, 0xd1, 0x11, 0xd9, 0xe9, 0xfb, 0xda, 0x79, 0xdb, 0x77, 0x6, 0xbb, 0x84, 0xcd, 0xfe, 0xfc, 0x1b, 0x54, 0xa1, 0x1d, 0x7c, 0xcc, 0xe4, 0xb0, 0x49, 0x31, 0x27, 0x2d, 0x53, 0x69, 0x2, 0xf5, 0x18, 0xdf, 0x44, 0x4f, 0x9b, 0xbc, 0xf, 0x5c, 0xb, 0xdc, 0xbd, 0x94, 0xac, 0x9, 0xc7, 0xa2, 0x1c, 0x82, 0x9f, 0xc6, 0x34, 0xc2, 0x46, 0x5, 0xce, 0x3b, 0xd, 0x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5f, 0x59, 0x5b, 0x55, 0x57, 0x51, 0x53, 0x4d, 0x4f, 0x49, 0x4b, 0x45, 0x47, 0x41, 0x43, 0x7d, 0x7f, 0x79, 0x7b, 0x75, 0x77, 0x71, 0x73, 0x6d, 0x6f, 0x69, 0x6b, 0x65, 0x67, 0x61, 0x63, 0x9d, 0x9f, 0x99, 0x9b, 0x95, 0x97, 0x91, 0x93, 0x8d, 0x8f, 0x89, 0x8b, 0x85, 0x87, 0x81, 0x83, 0xbd, 0xbf, 0xb9, 0xbb, 0xb5, 0xb7, 0xb1, 0xb3, 0xad, 0xaf, 0xa9, 0xab, 0xa5, 0xa7, 0xa1, 0xa3, 0xdd, 0xdf, 0xd9, 0xdb, 0xd5, 0xd7, 0xd1, 0xd3, 0xcd, 0xcf, 0xc9, 0xcb, 0xc5, 0xc7, 0xc1, 0xc3, 0xfd, 0xff, 0xf9, 0xfb, 0xf5, 0xf7, 0xf1, 0xf3, 0xed, 0xef, 0xe9, 0xeb, 0xe5, 0xe7, 0xe1, 0xe3},
|
||||
|
66
vendor/github.com/klauspost/reedsolomon/galois_amd64.s
generated
vendored
66
vendor/github.com/klauspost/reedsolomon/galois_amd64.s
generated
vendored
@ -87,31 +87,31 @@ TEXT ·galMulAVX2Xor(SB), 7, $0
|
||||
MOVQ high+24(FP), DX // DX: &high
|
||||
MOVQ $15, BX // BX: low mask
|
||||
MOVQ BX, X5
|
||||
MOVOU (SI), X6 // X6 low
|
||||
MOVOU (SI), X6 // X6: low
|
||||
MOVOU (DX), X7 // X7: high
|
||||
MOVQ in_len+56(FP), R9 // R9: len(in)
|
||||
|
||||
LONG $0x384de3c4; WORD $0x01f6 // VINSERTI128 YMM6, YMM6, XMM6, 1 ; low
|
||||
LONG $0x3845e3c4; WORD $0x01ff // VINSERTI128 YMM7, YMM7, XMM7, 1 ; high
|
||||
LONG $0x787d62c4; BYTE $0xc5 // VPBROADCASTB YMM8, XMM5 ; X8: lomask (unpacked)
|
||||
VINSERTI128 $1, X6, Y6, Y6 // low
|
||||
VINSERTI128 $1, X7, Y7, Y7 // high
|
||||
VPBROADCASTB X5, Y8 // Y8: lomask (unpacked)
|
||||
|
||||
SHRQ $5, R9 // len(in) /32
|
||||
SHRQ $5, R9 // len(in) / 32
|
||||
MOVQ out+72(FP), DX // DX: &out
|
||||
MOVQ in+48(FP), SI // R11: &in
|
||||
MOVQ in+48(FP), SI // SI: &in
|
||||
TESTQ R9, R9
|
||||
JZ done_xor_avx2
|
||||
|
||||
loopback_xor_avx2:
|
||||
LONG $0x066ffec5 // VMOVDQU YMM0, [rsi]
|
||||
LONG $0x226ffec5 // VMOVDQU YMM4, [rdx]
|
||||
LONG $0xd073f5c5; BYTE $0x04 // VPSRLQ YMM1, YMM0, 4 ; X1: high input
|
||||
LONG $0xdb7dc1c4; BYTE $0xc0 // VPAND YMM0, YMM0, YMM8 ; X0: low input
|
||||
LONG $0xdb75c1c4; BYTE $0xc8 // VPAND YMM1, YMM1, YMM8 ; X1: high input
|
||||
LONG $0x004de2c4; BYTE $0xd0 // VPSHUFB YMM2, YMM6, YMM0 ; X2: mul low part
|
||||
LONG $0x0045e2c4; BYTE $0xd9 // VPSHUFB YMM3, YMM7, YMM1 ; X2: mul high part
|
||||
LONG $0xdbefedc5 // VPXOR YMM3, YMM2, YMM3 ; X3: Result
|
||||
LONG $0xe4efe5c5 // VPXOR YMM4, YMM3, YMM4 ; X4: Result
|
||||
LONG $0x227ffec5 // VMOVDQU [rdx], YMM4
|
||||
VMOVDQU (SI), Y0
|
||||
VMOVDQU (DX), Y4
|
||||
VPSRLQ $4, Y0, Y1 // Y1: high input
|
||||
VPAND Y8, Y0, Y0 // Y0: low input
|
||||
VPAND Y8, Y1, Y1 // Y1: high input
|
||||
VPSHUFB Y0, Y6, Y2 // Y2: mul low part
|
||||
VPSHUFB Y1, Y7, Y3 // Y3: mul high part
|
||||
VPXOR Y3, Y2, Y3 // Y3: Result
|
||||
VPXOR Y4, Y3, Y4 // Y4: Result
|
||||
VMOVDQU Y4, (DX)
|
||||
|
||||
ADDQ $32, SI // in+=32
|
||||
ADDQ $32, DX // out+=32
|
||||
@ -119,8 +119,7 @@ loopback_xor_avx2:
|
||||
JNZ loopback_xor_avx2
|
||||
|
||||
done_xor_avx2:
|
||||
// VZEROUPPER
|
||||
BYTE $0xc5; BYTE $0xf8; BYTE $0x77
|
||||
VZEROUPPER
|
||||
RET
|
||||
|
||||
// func galMulAVX2(low, high, in, out []byte)
|
||||
@ -129,29 +128,29 @@ TEXT ·galMulAVX2(SB), 7, $0
|
||||
MOVQ high+24(FP), DX // DX: &high
|
||||
MOVQ $15, BX // BX: low mask
|
||||
MOVQ BX, X5
|
||||
MOVOU (SI), X6 // X6 low
|
||||
MOVOU (SI), X6 // X6: low
|
||||
MOVOU (DX), X7 // X7: high
|
||||
MOVQ in_len+56(FP), R9 // R9: len(in)
|
||||
|
||||
LONG $0x384de3c4; WORD $0x01f6 // VINSERTI128 YMM6, YMM6, XMM6, 1 ; low
|
||||
LONG $0x3845e3c4; WORD $0x01ff // VINSERTI128 YMM7, YMM7, XMM7, 1 ; high
|
||||
LONG $0x787d62c4; BYTE $0xc5 // VPBROADCASTB YMM8, XMM5 ; X8: lomask (unpacked)
|
||||
VINSERTI128 $1, X6, Y6, Y6 // low
|
||||
VINSERTI128 $1, X7, Y7, Y7 // high
|
||||
VPBROADCASTB X5, Y8 // Y8: lomask (unpacked)
|
||||
|
||||
SHRQ $5, R9 // len(in) /32
|
||||
SHRQ $5, R9 // len(in) / 32
|
||||
MOVQ out+72(FP), DX // DX: &out
|
||||
MOVQ in+48(FP), SI // R11: &in
|
||||
MOVQ in+48(FP), SI // SI: &in
|
||||
TESTQ R9, R9
|
||||
JZ done_avx2
|
||||
|
||||
loopback_avx2:
|
||||
LONG $0x066ffec5 // VMOVDQU YMM0, [rsi]
|
||||
LONG $0xd073f5c5; BYTE $0x04 // VPSRLQ YMM1, YMM0, 4 ; X1: high input
|
||||
LONG $0xdb7dc1c4; BYTE $0xc0 // VPAND YMM0, YMM0, YMM8 ; X0: low input
|
||||
LONG $0xdb75c1c4; BYTE $0xc8 // VPAND YMM1, YMM1, YMM8 ; X1: high input
|
||||
LONG $0x004de2c4; BYTE $0xd0 // VPSHUFB YMM2, YMM6, YMM0 ; X2: mul low part
|
||||
LONG $0x0045e2c4; BYTE $0xd9 // VPSHUFB YMM3, YMM7, YMM1 ; X2: mul high part
|
||||
LONG $0xe3efedc5 // VPXOR YMM4, YMM2, YMM3 ; X4: Result
|
||||
LONG $0x227ffec5 // VMOVDQU [rdx], YMM4
|
||||
VMOVDQU (SI), Y0
|
||||
VPSRLQ $4, Y0, Y1 // Y1: high input
|
||||
VPAND Y8, Y0, Y0 // Y0: low input
|
||||
VPAND Y8, Y1, Y1 // Y1: high input
|
||||
VPSHUFB Y0, Y6, Y2 // Y2: mul low part
|
||||
VPSHUFB Y1, Y7, Y3 // Y3: mul high part
|
||||
VPXOR Y3, Y2, Y4 // Y4: Result
|
||||
VMOVDQU Y4, (DX)
|
||||
|
||||
ADDQ $32, SI // in+=32
|
||||
ADDQ $32, DX // out+=32
|
||||
@ -159,8 +158,7 @@ loopback_avx2:
|
||||
JNZ loopback_avx2
|
||||
|
||||
done_avx2:
|
||||
|
||||
BYTE $0xc5; BYTE $0xf8; BYTE $0x77 // VZEROUPPER
|
||||
VZEROUPPER
|
||||
RET
|
||||
|
||||
// func sSE2XorSlice(in, out []byte)
|
||||
|
15
vendor/github.com/klauspost/reedsolomon/options.go
generated
vendored
15
vendor/github.com/klauspost/reedsolomon/options.go
generated
vendored
@ -14,10 +14,11 @@ type options struct {
|
||||
minSplitSize int
|
||||
useAVX2, useSSSE3, useSSE2 bool
|
||||
usePAR1Matrix bool
|
||||
useCauchy bool
|
||||
}
|
||||
|
||||
var defaultOptions = options{
|
||||
maxGoroutines: 50,
|
||||
maxGoroutines: 384,
|
||||
minSplitSize: 512,
|
||||
}
|
||||
|
||||
@ -81,5 +82,17 @@ func withSSE2(enabled bool) Option {
|
||||
func WithPAR1Matrix() Option {
|
||||
return func(o *options) {
|
||||
o.usePAR1Matrix = true
|
||||
o.useCauchy = false
|
||||
}
|
||||
}
|
||||
|
||||
// WithCauchyMatrix will make the encoder build a Cauchy style matrix.
|
||||
// The output of this is not compatible with the standard output.
|
||||
// A Cauchy matrix is faster to generate. This does not affect data throughput,
|
||||
// but will result in slightly faster start-up time.
|
||||
func WithCauchyMatrix() Option {
|
||||
return func(o *options) {
|
||||
o.useCauchy = true
|
||||
o.usePAR1Matrix = false
|
||||
}
|
||||
}
|
||||
|
27
vendor/github.com/klauspost/reedsolomon/reedsolomon.go
generated
vendored
27
vendor/github.com/klauspost/reedsolomon/reedsolomon.go
generated
vendored
@ -183,6 +183,26 @@ func buildMatrixPAR1(dataShards, totalShards int) (matrix, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func buildMatrixCauchy(dataShards, totalShards int) (matrix, error) {
|
||||
result, err := newMatrix(totalShards, dataShards)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for r, row := range result {
|
||||
// The top portion of the matrix is the identity
|
||||
// matrix, and the bottom is a transposed Cauchy matrix.
|
||||
if r < dataShards {
|
||||
result[r][r] = 1
|
||||
} else {
|
||||
for c := range row {
|
||||
result[r][c] = invTable[(byte(r ^ c))]
|
||||
}
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// New creates a new encoder and initializes it to
|
||||
// the number of data shards and parity shards that
|
||||
// you want to use. You can reuse this encoder.
|
||||
@ -208,9 +228,12 @@ func New(dataShards, parityShards int, opts ...Option) (Encoder, error) {
|
||||
}
|
||||
|
||||
var err error
|
||||
if r.o.usePAR1Matrix {
|
||||
switch {
|
||||
case r.o.useCauchy:
|
||||
r.m, err = buildMatrixCauchy(dataShards, r.Shards)
|
||||
case r.o.usePAR1Matrix:
|
||||
r.m, err = buildMatrixPAR1(dataShards, r.Shards)
|
||||
} else {
|
||||
default:
|
||||
r.m, err = buildMatrix(dataShards, r.Shards)
|
||||
}
|
||||
if err != nil {
|
||||
|
6
vendor/vendor.json
vendored
6
vendor/vendor.json
vendored
@ -267,10 +267,10 @@
|
||||
"revisionTime": "2016-10-16T15:41:25Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "sGHmZAWf2bzBFBwL8HPg4u9aJAA=",
|
||||
"checksumSHA1": "Nlhq327ZGeEh1gkPEBNPJKFlwds=",
|
||||
"path": "github.com/klauspost/reedsolomon",
|
||||
"revision": "ddcafc661e43ab1786575c0fc4b5b935b121de05",
|
||||
"revisionTime": "2017-09-20T19:08:25Z"
|
||||
"revision": "e52c150f961e65ab9538bf1276b33bf469f919d8",
|
||||
"revisionTime": "2017-11-18T15:17:31Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "dNYxHiBLalTqluak2/Z8c3RsSEM=",
|
||||
|
Loading…
Reference in New Issue
Block a user