mirror of
https://github.com/fumiama/blake2b-simd.git
synced 2026-06-08 20:10:33 +08:00
Detect SSE automatically and enable corresponding optimized code path.
With this change, following happens.
```
if sse {
compressSSE()
return
}
compressGeneric()
```
compressGeneric is used as a fallback when SSE is not detected.
This commit is contained in:
committed by
Harshavardhana
parent
83ff4cf5f4
commit
3a46db1cb4
29
cpuid.go
Normal file
29
cpuid.go
Normal file
@@ -0,0 +1,29 @@
|
||||
// +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)
|
||||
|
||||
// True when SIMD instructions are available.
|
||||
var sse = haveSSE()
|
||||
|
||||
// haveSSE returns true if we have streaming SIMD instructions.
|
||||
func haveSSE() bool {
|
||||
_, _, _, d := cpuid(1)
|
||||
return (d & (1 << 25)) != 0
|
||||
}
|
||||
Reference in New Issue
Block a user