mirror of
https://github.com/minio/minio.git
synced 2025-04-18 17:55:28 -04:00
Thanks for Frank Wessels <fwessels@xs4all.nl> for all the heavy lifting work. Comparative benchmarks are as below. ``` benchmark old ns/op new ns/op delta BenchmarkHash64-4 742 411 -44.61% BenchmarkHash128-4 681 346 -49.19% BenchmarkWrite1K-4 4239 1497 -64.69% BenchmarkWrite8K-4 33633 11514 -65.77% BenchmarkWrite32K-4 134091 45947 -65.73% BenchmarkWrite128K-4 537976 183643 -65.86% benchmark old MB/s new MB/s speedup BenchmarkHash64-4 86.18 155.51 1.80x BenchmarkHash128-4 187.96 369.10 1.96x BenchmarkWrite1K-4 241.55 683.87 2.83x BenchmarkWrite8K-4 3897.06 11383.41 2.92x BenchmarkWrite32K-4 977.48 2852.63 2.92x BenchmarkWrite128K-4 243.64 713.73 2.93x ``` Fixes #2030
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
// +build 386,!gccgo amd64,!gccgo
|
|
|
|
// Copyright 2016 Frank Wessels <fwessels@xs4all.nl>
|
|
//
|
|
// 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 blake2b
|
|
|
|
func cpuid(op uint32) (eax, ebx, ecx, edx uint32)
|
|
func xgetbv(index uint32) (eax, edx uint32)
|
|
|
|
// True when SIMD instructions are available.
|
|
var avx = haveAVX()
|
|
|
|
// haveSSE returns true if we have streaming SIMD instructions.
|
|
func haveAVX() bool {
|
|
_, _, c, _ := cpuid(1)
|
|
|
|
// Check XGETBV, OXSAVE and AVX bits
|
|
if c&(1<<26) != 0 && c&(1<<27) != 0 && c&(1<<28) != 0 {
|
|
// Check for OS support
|
|
eax, _ := xgetbv(0)
|
|
return (eax & 0x6) == 0x6
|
|
}
|
|
return false
|
|
}
|