Go as an internal package internal/cpu that exposes all the necessary functions to detect flavors of SIMD. See an example of use in the bytes package .
I'm trying to get capability flags variables from internal/cpu
package but when i'm trying to execute go build, i'm getting following error: cannot find package "internal/cpu
import (
"fmt"
"internal/cpu"
)
func main() {
if cpu.X86.HasAVX2 {
fmt.Println("AVX2 SIMD instructions available")
}
}
What i did wrong?
You will not be able to import internal/cpu
due to this rule:
Code in or below a directory named "internal" is importable only by code in the directory tree rooted at the parent of "internal".
https://golang.org/cmd/go/#hdr-Internal_Directories
You can copy out the parts of the code you need, just make sure to follow the LICENSE, which is fairly open:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.