From 9e9faf7b53664dc08ebc0080d41f0976db72b6ec Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 30 Aug 2017 09:45:36 -0700 Subject: [PATCH] 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 --- vendor/github.com/minio/sha256-simd/README.md | 46 +++++++++++++++---- .../{cpuid_ppc64.go => cpuid_other.go} | 2 + .../minio/sha256-simd/sha256block_arm64.s | 2 +- ...{cpuid_ppc64le.go => sha256block_other.go} | 21 +++------ .../minio/sha256-simd/sha256block_ppc64.go | 22 --------- .../minio/sha256-simd/sha256block_ppc64le.go | 22 --------- vendor/vendor.json | 6 +-- 7 files changed, 49 insertions(+), 72 deletions(-) rename vendor/github.com/minio/sha256-simd/{cpuid_ppc64.go => cpuid_other.go} (93%) rename vendor/github.com/minio/sha256-simd/{cpuid_ppc64le.go => sha256block_other.go} (70%) delete mode 100644 vendor/github.com/minio/sha256-simd/sha256block_ppc64.go delete mode 100644 vendor/github.com/minio/sha256-simd/sha256block_ppc64le.go diff --git a/vendor/github.com/minio/sha256-simd/README.md b/vendor/github.com/minio/sha256-simd/README.md index 273eef9ba..39ee20074 100644 --- a/vendor/github.com/minio/sha256-simd/README.md +++ b/vendor/github.com/minio/sha256-simd/README.md @@ -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. diff --git a/vendor/github.com/minio/sha256-simd/cpuid_ppc64.go b/vendor/github.com/minio/sha256-simd/cpuid_other.go similarity index 93% rename from vendor/github.com/minio/sha256-simd/cpuid_ppc64.go rename to vendor/github.com/minio/sha256-simd/cpuid_other.go index 351dff4b6..e26952a82 100644 --- a/vendor/github.com/minio/sha256-simd/cpuid_ppc64.go +++ b/vendor/github.com/minio/sha256-simd/cpuid_other.go @@ -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) { diff --git a/vendor/github.com/minio/sha256-simd/sha256block_arm64.s b/vendor/github.com/minio/sha256-simd/sha256block_arm64.s index e1e30c939..104ce1113 100644 --- a/vendor/github.com/minio/sha256-simd/sha256block_arm64.s +++ b/vendor/github.com/minio/sha256-simd/sha256block_arm64.s @@ -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 diff --git a/vendor/github.com/minio/sha256-simd/cpuid_ppc64le.go b/vendor/github.com/minio/sha256-simd/sha256block_other.go similarity index 70% rename from vendor/github.com/minio/sha256-simd/cpuid_ppc64le.go rename to vendor/github.com/minio/sha256-simd/sha256block_other.go index 351dff4b6..38e740373 100644 --- a/vendor/github.com/minio/sha256-simd/cpuid_ppc64le.go +++ b/vendor/github.com/minio/sha256-simd/sha256block_other.go @@ -13,20 +13,11 @@ // limitations under the License. // -package sha256 - -func cpuid(op uint32) (eax, ebx, ecx, edx uint32) { - return 0, 0, 0, 0 -} +// +build ppc64 ppc64le mips mipsle mips64 mips64le s390x -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 -} +package sha256 -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) {} diff --git a/vendor/github.com/minio/sha256-simd/sha256block_ppc64.go b/vendor/github.com/minio/sha256-simd/sha256block_ppc64.go deleted file mode 100644 index b81017e8d..000000000 --- a/vendor/github.com/minio/sha256-simd/sha256block_ppc64.go +++ /dev/null @@ -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) {} diff --git a/vendor/github.com/minio/sha256-simd/sha256block_ppc64le.go b/vendor/github.com/minio/sha256-simd/sha256block_ppc64le.go deleted file mode 100644 index b81017e8d..000000000 --- a/vendor/github.com/minio/sha256-simd/sha256block_ppc64le.go +++ /dev/null @@ -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) {} diff --git a/vendor/vendor.json b/vendor/vendor.json index e1cae6f1c..18367f428 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -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=",