core: support SIMD intrinsics in user code

This commit is contained in:
Alexander Alekhin
2019-07-18 07:25:59 +00:00
parent 054c796213
commit 8bac8b513c
3 changed files with 144 additions and 0 deletions
+7
View File
@@ -57,6 +57,13 @@ foreach(sample_filename ${cpp_samples})
if(HAVE_OPENGL AND sample_filename MATCHES "detect_mser")
target_compile_definitions(${tgt} PRIVATE HAVE_OPENGL)
endif()
if(sample_filename MATCHES "simd_")
# disabled intentionally - demonstation purposes only
#target_include_directories(${tgt} PRIVATE "${CMAKE_CURRENT_LIST_DIR}")
#target_compile_definitions(${tgt} PRIVATE OPENCV_SIMD_CONFIG_HEADER=opencv_simd_config_custom.hpp)
#target_compile_definitions(${tgt} PRIVATE OPENCV_SIMD_CONFIG_INCLUDE_DIR=1)
#target_compile_options(${tgt} PRIVATE -mavx2)
endif()
endforeach()
include("tutorial_code/calib3d/real_time_pose_estimation/CMakeLists.txt" OPTIONAL)
+49
View File
@@ -0,0 +1,49 @@
#include "opencv2/core.hpp"
#include "opencv2/core/simd_intrinsics.hpp"
using namespace cv;
int main(int /*argc*/, char** /*argv*/)
{
printf("================== macro dump ===================\n");
#ifdef CV_SIMD
printf("CV_SIMD is defined: " CVAUX_STR(CV_SIMD) "\n");
#ifdef CV_SIMD_WIDTH
printf("CV_SIMD_WIDTH is defined: " CVAUX_STR(CV_SIMD_WIDTH) "\n");
#endif
#ifdef CV_SIMD128
printf("CV_SIMD128 is defined: " CVAUX_STR(CV_SIMD128) "\n");
#endif
#ifdef CV_SIMD256
printf("CV_SIMD256 is defined: " CVAUX_STR(CV_SIMD256) "\n");
#endif
#ifdef CV_SIMD512
printf("CV_SIMD512 is defined: " CVAUX_STR(CV_SIMD512) "\n");
#endif
#ifdef CV_SIMD_64F
printf("CV_SIMD_64F is defined: " CVAUX_STR(CV_SIMD_64F) "\n");
#endif
#ifdef CV_SIMD_FP16
printf("CV_SIMD_FP16 is defined: " CVAUX_STR(CV_SIMD_FP16) "\n");
#endif
#else
printf("CV_SIMD is NOT defined\n");
#endif
#ifdef CV_SIMD
printf("================= sizeof checks =================\n");
printf("sizeof(v_uint8) = %d\n", (int)sizeof(v_uint8));
printf("sizeof(v_int32) = %d\n", (int)sizeof(v_int32));
printf("sizeof(v_float32) = %d\n", (int)sizeof(v_float32));
printf("================== arithm check =================\n");
v_uint8 a = vx_setall_u8(10);
v_uint8 c = a + vx_setall_u8(45);
printf("(vx_setall_u8(10) + vx_setall_u8(45)).get0() => %d\n", (int)c.get0());
#else
printf("\nSIMD intrinsics are not available. Check compilation target and passed build options.\n");
#endif
printf("===================== done ======================\n");
return 0;
}