2
0

cpuid.c 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. #if defined(__i386__) || defined(__x86_64__) || \
  23. defined(_M_IX86) || defined(_M_X64)
  24. if (has_x86) {
  25. uint32 family, model, cpu_info[4];
  26. // Vendor ID:
  27. // AuthenticAMD AMD processor
  28. // CentaurHauls Centaur processor
  29. // CyrixInstead Cyrix processor
  30. // GenuineIntel Intel processor
  31. // GenuineTMx86 Transmeta processor
  32. // Geode by NSC National Semiconductor processor
  33. // NexGenDriven NexGen processor
  34. // RiseRiseRise Rise Technology processor
  35. // SiS SiS SiS SiS processor
  36. // UMC UMC UMC UMC processor
  37. CpuId(0, 0, &cpu_info[0]);
  38. cpu_info[0] = cpu_info[1]; // Reorder output
  39. cpu_info[1] = cpu_info[3];
  40. cpu_info[3] = 0;
  41. printf("Cpu Vendor: %s\n", (char*)(&cpu_info[0]));
  42. // CPU Family and Model
  43. // 3:0 - Stepping
  44. // 7:4 - Model
  45. // 11:8 - Family
  46. // 13:12 - Processor Type
  47. // 19:16 - Extended Model
  48. // 27:20 - Extended Family
  49. CpuId(1, 0, &cpu_info[0]);
  50. family = ((cpu_info[0] >> 8) & 0x0f) | ((cpu_info[0] >> 16) & 0xff0);
  51. model = ((cpu_info[0] >> 4) & 0x0f) | ((cpu_info[0] >> 12) & 0xf0);
  52. printf("Cpu Family %d (0x%x), Model %d (0x%x)\n", family, family,
  53. model, model);
  54. }
  55. #endif
  56. printf("Cpu Flags %x\n", cpu_flags);
  57. printf("Has ARM %x\n", has_arm);
  58. printf("Has MIPS %x\n", has_mips);
  59. printf("Has X86 %x\n", has_x86);
  60. if (has_arm) {
  61. int has_neon = TestCpuFlag(kCpuHasNEON);
  62. printf("Has NEON %x\n", has_neon);
  63. }
  64. if (has_mips) {
  65. int has_dspr2 = TestCpuFlag(kCpuHasDSPR2);
  66. printf("Has DSPR2 %x\n", has_dspr2);
  67. }
  68. if (has_x86) {
  69. int has_sse2 = TestCpuFlag(kCpuHasSSE2);
  70. int has_ssse3 = TestCpuFlag(kCpuHasSSSE3);
  71. int has_sse41 = TestCpuFlag(kCpuHasSSE41);
  72. int has_sse42 = TestCpuFlag(kCpuHasSSE42);
  73. int has_avx = TestCpuFlag(kCpuHasAVX);
  74. int has_avx2 = TestCpuFlag(kCpuHasAVX2);
  75. int has_avx3 = TestCpuFlag(kCpuHasAVX3);
  76. int has_erms = TestCpuFlag(kCpuHasERMS);
  77. int has_fma3 = TestCpuFlag(kCpuHasFMA3);
  78. printf("Has SSE2 %x\n", has_sse2);
  79. printf("Has SSSE3 %x\n", has_ssse3);
  80. printf("Has SSE4.1 %x\n", has_sse41);
  81. printf("Has SSE4.2 %x\n", has_sse42);
  82. printf("Has AVX %x\n", has_avx);
  83. printf("Has AVX2 %x\n", has_avx2);
  84. printf("Has AVX3 %x\n", has_avx3);
  85. printf("Has ERMS %x\n", has_erms);
  86. printf("Has FMA3 %x\n", has_fma3);
  87. }
  88. return 0;
  89. }