cpu.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2018 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // Package cpu implements processor feature detection for
  5. // various CPU architectures.
  6. package cpu
  7. // X86 contains the supported CPU features of the
  8. // current X86/AMD64 platform. If the current platform
  9. // is not X86/AMD64 then all feature flags are false.
  10. //
  11. // X86 is padded to avoid false sharing. Further the HasAVX
  12. // and HasAVX2 are only set if the OS supports XMM and YMM
  13. // registers in addition to the CPUID feature bit being set.
  14. var X86 struct {
  15. _ [cacheLineSize]byte
  16. HasAES bool // AES hardware implementation (AES NI)
  17. HasADX bool // Multi-precision add-carry instruction extensions
  18. HasAVX bool // Advanced vector extension
  19. HasAVX2 bool // Advanced vector extension 2
  20. HasBMI1 bool // Bit manipulation instruction set 1
  21. HasBMI2 bool // Bit manipulation instruction set 2
  22. HasERMS bool // Enhanced REP for MOVSB and STOSB
  23. HasFMA bool // Fused-multiply-add instructions
  24. HasOSXSAVE bool // OS supports XSAVE/XRESTOR for saving/restoring XMM registers.
  25. HasPCLMULQDQ bool // PCLMULQDQ instruction - most often used for AES-GCM
  26. HasPOPCNT bool // Hamming weight instruction POPCNT.
  27. HasSSE2 bool // Streaming SIMD extension 2 (always available on amd64)
  28. HasSSE3 bool // Streaming SIMD extension 3
  29. HasSSSE3 bool // Supplemental streaming SIMD extension 3
  30. HasSSE41 bool // Streaming SIMD extension 4 and 4.1
  31. HasSSE42 bool // Streaming SIMD extension 4 and 4.2
  32. _ [cacheLineSize]byte
  33. }