simd_basic.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "opencv2/core.hpp"
  2. #include "opencv2/core/simd_intrinsics.hpp"
  3. using namespace cv;
  4. int main(int /*argc*/, char** /*argv*/)
  5. {
  6. printf("================== macro dump ===================\n");
  7. #ifdef CV_SIMD
  8. printf("CV_SIMD is defined: " CVAUX_STR(CV_SIMD) "\n");
  9. #ifdef CV_SIMD_WIDTH
  10. printf("CV_SIMD_WIDTH is defined: " CVAUX_STR(CV_SIMD_WIDTH) "\n");
  11. #endif
  12. #ifdef CV_SIMD128
  13. printf("CV_SIMD128 is defined: " CVAUX_STR(CV_SIMD128) "\n");
  14. #endif
  15. #ifdef CV_SIMD256
  16. printf("CV_SIMD256 is defined: " CVAUX_STR(CV_SIMD256) "\n");
  17. #endif
  18. #ifdef CV_SIMD512
  19. printf("CV_SIMD512 is defined: " CVAUX_STR(CV_SIMD512) "\n");
  20. #endif
  21. #ifdef CV_SIMD_64F
  22. printf("CV_SIMD_64F is defined: " CVAUX_STR(CV_SIMD_64F) "\n");
  23. #endif
  24. #ifdef CV_SIMD_FP16
  25. printf("CV_SIMD_FP16 is defined: " CVAUX_STR(CV_SIMD_FP16) "\n");
  26. #endif
  27. #else
  28. printf("CV_SIMD is NOT defined\n");
  29. #endif
  30. #ifdef CV_SIMD
  31. printf("================= sizeof checks =================\n");
  32. printf("sizeof(v_uint8) = %d\n", (int)sizeof(v_uint8));
  33. printf("sizeof(v_int32) = %d\n", (int)sizeof(v_int32));
  34. printf("sizeof(v_float32) = %d\n", (int)sizeof(v_float32));
  35. printf("================== arithm check =================\n");
  36. v_uint8 a = vx_setall_u8(10);
  37. v_uint8 c = a + vx_setall_u8(45);
  38. printf("(vx_setall_u8(10) + vx_setall_u8(45)).get0() => %d\n", (int)c.get0());
  39. #else
  40. printf("\nSIMD intrinsics are not available. Check compilation target and passed build options.\n");
  41. #endif
  42. printf("===================== done ======================\n");
  43. return 0;
  44. }