cpu.go 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. // CacheLinePad is used to pad structs to avoid false sharing.
  8. type CacheLinePad struct{ _ [cacheLineSize]byte }
  9. // X86 contains the supported CPU features of the
  10. // current X86/AMD64 platform. If the current platform
  11. // is not X86/AMD64 then all feature flags are false.
  12. //
  13. // X86 is padded to avoid false sharing. Further the HasAVX
  14. // and HasAVX2 are only set if the OS supports XMM and YMM
  15. // registers in addition to the CPUID feature bit being set.
  16. var X86 struct {
  17. _ CacheLinePad
  18. HasAES bool // AES hardware implementation (AES NI)
  19. HasADX bool // Multi-precision add-carry instruction extensions
  20. HasAVX bool // Advanced vector extension
  21. HasAVX2 bool // Advanced vector extension 2
  22. HasBMI1 bool // Bit manipulation instruction set 1
  23. HasBMI2 bool // Bit manipulation instruction set 2
  24. HasERMS bool // Enhanced REP for MOVSB and STOSB
  25. HasFMA bool // Fused-multiply-add instructions
  26. HasOSXSAVE bool // OS supports XSAVE/XRESTOR for saving/restoring XMM registers.
  27. HasPCLMULQDQ bool // PCLMULQDQ instruction - most often used for AES-GCM
  28. HasPOPCNT bool // Hamming weight instruction POPCNT.
  29. HasSSE2 bool // Streaming SIMD extension 2 (always available on amd64)
  30. HasSSE3 bool // Streaming SIMD extension 3
  31. HasSSSE3 bool // Supplemental streaming SIMD extension 3
  32. HasSSE41 bool // Streaming SIMD extension 4 and 4.1
  33. HasSSE42 bool // Streaming SIMD extension 4 and 4.2
  34. _ CacheLinePad
  35. }
  36. // ARM64 contains the supported CPU features of the
  37. // current ARMv8(aarch64) platform. If the current platform
  38. // is not arm64 then all feature flags are false.
  39. var ARM64 struct {
  40. _ CacheLinePad
  41. HasFP bool // Floating-point instruction set (always available)
  42. HasASIMD bool // Advanced SIMD (always available)
  43. HasEVTSTRM bool // Event stream support
  44. HasAES bool // AES hardware implementation
  45. HasPMULL bool // Polynomial multiplication instruction set
  46. HasSHA1 bool // SHA1 hardware implementation
  47. HasSHA2 bool // SHA2 hardware implementation
  48. HasCRC32 bool // CRC32 hardware implementation
  49. HasATOMICS bool // Atomic memory operation instruction set
  50. HasFPHP bool // Half precision floating-point instruction set
  51. HasASIMDHP bool // Advanced SIMD half precision instruction set
  52. HasCPUID bool // CPUID identification scheme registers
  53. HasASIMDRDM bool // Rounding double multiply add/subtract instruction set
  54. HasJSCVT bool // Javascript conversion from floating-point to integer
  55. HasFCMA bool // Floating-point multiplication and addition of complex numbers
  56. HasLRCPC bool // Release Consistent processor consistent support
  57. HasDCPOP bool // Persistent memory support
  58. HasSHA3 bool // SHA3 hardware implementation
  59. HasSM3 bool // SM3 hardware implementation
  60. HasSM4 bool // SM4 hardware implementation
  61. HasASIMDDP bool // Advanced SIMD double precision instruction set
  62. HasSHA512 bool // SHA512 hardware implementation
  63. HasSVE bool // Scalable Vector Extensions
  64. HasASIMDFHM bool // Advanced SIMD multiplication FP16 to FP32
  65. _ CacheLinePad
  66. }