Support source compilation on s390 and ppc64le (#4859)

NOTE: This doesn't validate that minio will work fine
on these platforms and is tested. Since we do not validate
on these architectures this is to be treated as just a build fix.

Fixes #4858
This commit is contained in:
Harshavardhana 2017-08-30 09:45:36 -07:00 committed by Dee Koder
parent 2bca51ab2c
commit 9e9faf7b53
7 changed files with 49 additions and 72 deletions

View File

@ -8,20 +8,48 @@ This package is designed as a drop-in replacement for `crypto/sha256`. For Intel
This package uses Golang assembly and as such does not depend on cgo. The Intel versions are based on the implementations as described in "Fast SHA-256 Implementations on Intel Architecture Processors" by J. Guilford et al.
## Drop-In Replacement
Following code snippet shows you how you can directly replace wherever `crypto/sha256` is used can be replaced with `github.com/minio/sha256-simd`.
Before:
```go
import "crypto/sha256"
func main() {
...
shaWriter := sha256.New()
io.Copy(shaWriter, file)
...
}
```
After:
```go
import "github.com/minio/sha256-simd"
func main() {
...
shaWriter := sha256.New()
io.Copy(shaWriter, file)
...
}
```
## Performance
Below is the speed in MB/s for a single core (ranked fast to slow) as well as the factor of improvement over `crypto/sha256` (when applicable).
| Processor | Package | Speed | Improvement |
| --------------------------------- | ---------------------------- | -----------:| -----------:|
| 1.2 GHz ARM Cortex-A53 | minio/sha256-simd (ARM64) | 638.2 MB/s | 105x |
| 2.4 GHz Intel Xeon CPU E5-2620 v3 | minio/sha256-simd (AVX2) (*) | 355.0 MB/s | 1.88x |
| 2.4 GHz Intel Xeon CPU E5-2620 v3 | minio/sha256-simd (AVX) | 306.0 MB/s | 1.62x |
| 2.4 GHz Intel Xeon CPU E5-2620 v3 | minio/sha256-simd (SSE) | 298.7 MB/s | 1.58x |
| 2.4 GHz Intel Xeon CPU E5-2620 v3 | crypto/sha256 | 189.2 MB/s | |
| 1.2 GHz ARM Cortex-A53 | crypto/sha256 | 6.1 MB/s | |
| Processor | Package | Speed | Improvement |
| --------------------------------- | ------------------------- | -----------:| -----------:|
| 1.2 GHz ARM Cortex-A53 | minio/sha256-simd (ARM64) | 638.2 MB/s | 105x |
| 2.4 GHz Intel Xeon CPU E5-2620 v3 | minio/sha256-simd (AVX2) | 355.0 MB/s | 1.88x |
| 2.4 GHz Intel Xeon CPU E5-2620 v3 | minio/sha256-simd (AVX) | 306.0 MB/s | 1.62x |
| 2.4 GHz Intel Xeon CPU E5-2620 v3 | minio/sha256-simd (SSE) | 298.7 MB/s | 1.58x |
| 2.4 GHz Intel Xeon CPU E5-2620 v3 | crypto/sha256 | 189.2 MB/s | |
| 1.2 GHz ARM Cortex-A53 | crypto/sha256 | 6.1 MB/s | |
(*) Measured with the "unrolled"/"demacro-ed" AVX2 version. Due to some Golang assembly restrictions the AVX2 version that uses `defines` loses about 15% performance. The optimized version is contained in the git history so for maximum speed you want to do this after getting: `git cat-file blob 586b6e > sha256blockAvx2_amd64.s` (or vendor it for your project; see [here](https://github.com/minio/sha256-simd/blob/13b11bdf9b0580a756a111492d2ae382bab7ec79/sha256blockAvx2_amd64.s) to view it in its full glory).
Note that the AVX2 version is measured with the "unrolled"/"demacro-ed" version. Due to some Golang assembly restrictions the AVX2 version that uses `defines` loses about 15% performance (you can see the macrofied version, which is a little bit easier to read, [here](https://github.com/minio/sha256-simd/blob/e1b0a493b71bb31e3f1bf82d3b8cbd0d6960dfa6/sha256blockAvx2_amd64.s)).
See further down for detailed performance.

View File

@ -13,6 +13,8 @@
// limitations under the License.
//
// +build ppc64 ppc64le mips mipsle mips64 mips64le s390x
package sha256
func cpuid(op uint32) (eax, ebx, ecx, edx uint32) {

View File

@ -19,7 +19,7 @@
//
//
// Based on implementaion as found in https://github.com/jocover/sha256-armv8
// Based on implementation as found in https://github.com/jocover/sha256-armv8
//
// Use github.com/minio/asm2plan9s on this file to assemble ARM instructions to
// their Plan9 equivalents

View File

@ -13,20 +13,11 @@
// limitations under the License.
//
// +build ppc64 ppc64le mips mipsle mips64 mips64le s390x
package sha256
func cpuid(op uint32) (eax, ebx, ecx, edx uint32) {
return 0, 0, 0, 0
}
func cpuidex(op, op2 uint32) (eax, ebx, ecx, edx uint32) {
return 0, 0, 0, 0
}
func xgetbv(index uint32) (eax, edx uint32) {
return 0, 0
}
func haveArmSha() bool {
return false
}
func blockAvx2Go(dig *digest, p []byte) {}
func blockAvxGo(dig *digest, p []byte) {}
func blockSsseGo(dig *digest, p []byte) {}
func blockArmGo(dig *digest, p []byte) {}

View File

@ -1,22 +0,0 @@
/*
* Minio Cloud Storage, (C) 2016 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sha256
func blockAvx2Go(dig *digest, p []byte) {}
func blockAvxGo(dig *digest, p []byte) {}
func blockSsseGo(dig *digest, p []byte) {}
func blockArmGo(dig *digest, p []byte) {}

View File

@ -1,22 +0,0 @@
/*
* Minio Cloud Storage, (C) 2016 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sha256
func blockAvx2Go(dig *digest, p []byte) {}
func blockAvxGo(dig *digest, p []byte) {}
func blockSsseGo(dig *digest, p []byte) {}
func blockArmGo(dig *digest, p []byte) {}

6
vendor/vendor.json vendored
View File

@ -348,10 +348,10 @@
"revisionTime": "2017-06-19T22:00:32Z"
},
{
"checksumSHA1": "URVle4qtadmW9w9BulDRHY3kxnA=",
"checksumSHA1": "cYuXpiVBMypgkEr0Wqd79jPPyBg=",
"path": "github.com/minio/sha256-simd",
"revision": "e82e73b775766b9011503e80e6772fc32b9afc5b",
"revisionTime": "2016-12-19T23:17:30Z"
"revision": "43ed500fe4d485d97534014d9f98521216240002",
"revisionTime": "2017-08-28T17:39:33Z"
},
{
"checksumSHA1": "zvQr4zOz1/g/Fui6co0sctxrJ28=",