CPUDetect.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright 2008 Dolphin Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. // Detect the CPU, so we'll know which optimizations to use
  4. #pragma once
  5. #include <string>
  6. enum class CPUVendor
  7. {
  8. Intel,
  9. AMD,
  10. ARM,
  11. Other,
  12. };
  13. struct CPUInfo
  14. {
  15. CPUVendor vendor = CPUVendor::Other;
  16. std::string cpu_id;
  17. std::string model_name;
  18. bool HTT = false;
  19. int num_cores = 0;
  20. bool bSSE3 = false;
  21. bool bSSSE3 = false;
  22. bool bSSE4_1 = false;
  23. bool bSSE4_2 = false;
  24. bool bLZCNT = false;
  25. bool bAVX = false;
  26. bool bBMI1 = false;
  27. bool bBMI2 = false;
  28. // PDEP and PEXT are ridiculously slow on AMD Zen1, Zen1+ and Zen2 (Family 17h)
  29. bool bBMI2FastParallelBitOps = false;
  30. bool bFMA = false;
  31. bool bFMA4 = false;
  32. bool bAES = false;
  33. bool bMOVBE = false;
  34. // This flag indicates that the hardware supports some mode
  35. // in which denormal inputs _and_ outputs are automatically set to (signed) zero.
  36. bool bFlushToZero = false;
  37. bool bAtom = false;
  38. bool bCRC32 = false;
  39. bool bSHA1 = false;
  40. bool bSHA2 = false;
  41. // ARMv8 specific
  42. bool bAFP = false; // Alternate floating-point behavior
  43. // Call Detect()
  44. explicit CPUInfo();
  45. // The returned string consists of "<model_name>,<cpu_id>,<flag...>"
  46. // Where:
  47. // model_name and cpud_id may be zero-length
  48. // model_name is human-readable marketing name
  49. // cpu_id is ':'-delimited string of id info
  50. // flags are optionally included if the related feature is supported and reporting its enablement
  51. // seems useful to report
  52. std::string Summarize();
  53. private:
  54. void Detect();
  55. };
  56. extern CPUInfo cpu_info;