2
0

cpuid.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Copyright 2012 The LibYuv Project Authors. All rights reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <string.h>
  13. #define INCLUDE_LIBYUV_COMPARE_H_
  14. #include "libyuv.h"
  15. #include "./psnr.h"
  16. #include "./ssim.h"
  17. int main(int argc, const char* argv[]) {
  18. int cpu_flags = TestCpuFlag(-1);
  19. int has_arm = TestCpuFlag(kCpuHasARM);
  20. int has_mips = TestCpuFlag(kCpuHasMIPS);
  21. int has_x86 = TestCpuFlag(kCpuHasX86);
  22. (void)argc;
  23. (void)argv;
  24. #if defined(__i386__) || defined(__x86_64__) || \
  25. defined(_M_IX86) || defined(_M_X64)
  26. if (has_x86) {
  27. int family, model, cpu_info[4];
  28. // Vendor ID:
  29. // AuthenticAMD AMD processor
  30. // CentaurHauls Centaur processor
  31. // CyrixInstead Cyrix processor
  32. // GenuineIntel Intel processor
  33. // GenuineTMx86 Transmeta processor
  34. // Geode by NSC National Semiconductor processor
  35. // NexGenDriven NexGen processor
  36. // RiseRiseRise Rise Technology processor
  37. // SiS SiS SiS SiS processor
  38. // UMC UMC UMC UMC processor
  39. CpuId(0, 0, &cpu_info[0]);
  40. cpu_info[0] = cpu_info[1]; // Reorder output
  41. cpu_info[1] = cpu_info[3];
  42. cpu_info[3] = 0;
  43. printf("Cpu Vendor: %s\n", (char*)(&cpu_info[0]));
  44. // CPU Family and Model
  45. // 3:0 - Stepping
  46. // 7:4 - Model
  47. // 11:8 - Family
  48. // 13:12 - Processor Type
  49. // 19:16 - Extended Model
  50. // 27:20 - Extended Family
  51. CpuId(1, 0, &cpu_info[0]);
  52. family = ((cpu_info[0] >> 8) & 0x0f) | ((cpu_info[0] >> 16) & 0xff0);
  53. model = ((cpu_info[0] >> 4) & 0x0f) | ((cpu_info[0] >> 12) & 0xf0);
  54. printf("Cpu Family %d (0x%x), Model %d (0x%x)\n", family, family,
  55. model, model);
  56. }
  57. #endif
  58. printf("Cpu Flags %x\n", cpu_flags);
  59. printf("Has ARM %x\n", has_arm);
  60. printf("Has MIPS %x\n", has_mips);
  61. printf("Has X86 %x\n", has_x86);
  62. if (has_arm) {
  63. int has_neon = TestCpuFlag(kCpuHasNEON);
  64. printf("Has NEON %x\n", has_neon);
  65. }
  66. if (has_mips) {
  67. int has_msa = TestCpuFlag(kCpuHasMSA);
  68. printf("Has MSA %x\n", has_msa);
  69. int has_mmi = TestCpuFlag(kCpuHasMMI);
  70. printf("Has MMI %x\n", has_mmi);
  71. }
  72. if (has_x86) {
  73. int has_sse2 = TestCpuFlag(kCpuHasSSE2);
  74. int has_ssse3 = TestCpuFlag(kCpuHasSSSE3);
  75. int has_sse41 = TestCpuFlag(kCpuHasSSE41);
  76. int has_sse42 = TestCpuFlag(kCpuHasSSE42);
  77. int has_avx = TestCpuFlag(kCpuHasAVX);
  78. int has_avx2 = TestCpuFlag(kCpuHasAVX2);
  79. int has_erms = TestCpuFlag(kCpuHasERMS);
  80. int has_fma3 = TestCpuFlag(kCpuHasFMA3);
  81. int has_f16c = TestCpuFlag(kCpuHasF16C);
  82. int has_gfni = TestCpuFlag(kCpuHasGFNI);
  83. int has_avx512bw = TestCpuFlag(kCpuHasAVX512BW);
  84. int has_avx512vl = TestCpuFlag(kCpuHasAVX512VL);
  85. int has_avx512vbmi = TestCpuFlag(kCpuHasAVX512VBMI);
  86. int has_avx512vbmi2 = TestCpuFlag(kCpuHasAVX512VBMI2);
  87. int has_avx512vbitalg = TestCpuFlag(kCpuHasAVX512VBITALG);
  88. int has_avx512vpopcntdq = TestCpuFlag(kCpuHasAVX512VPOPCNTDQ);
  89. printf("Has SSE2 %x\n", has_sse2);
  90. printf("Has SSSE3 %x\n", has_ssse3);
  91. printf("Has SSE4.1 %x\n", has_sse41);
  92. printf("Has SSE4.2 %x\n", has_sse42);
  93. printf("Has AVX %x\n", has_avx);
  94. printf("Has AVX2 %x\n", has_avx2);
  95. printf("Has ERMS %x\n", has_erms);
  96. printf("Has FMA3 %x\n", has_fma3);
  97. printf("Has F16C %x\n", has_f16c);
  98. printf("Has GFNI %x\n", has_gfni);
  99. printf("Has AVX512BW %x\n", has_avx512bw);
  100. printf("Has AVX512VL %x\n", has_avx512vl);
  101. printf("Has AVX512VBMI %x\n", has_avx512vbmi);
  102. printf("Has AVX512VBMI2 %x\n", has_avx512vbmi2);
  103. printf("Has AVX512VBITALG %x\n", has_avx512vbitalg);
  104. printf("Has AVX512VPOPCNTDQ %x\n", has_avx512vpopcntdq);
  105. }
  106. return 0;
  107. }