commit
0cf479dd5c
28 changed files with 2282 additions and 72 deletions
@ -0,0 +1,88 @@ |
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
|
||||
#ifndef OPENCV_CORE_SIMD_INTRINSICS_HPP |
||||
#define OPENCV_CORE_SIMD_INTRINSICS_HPP |
||||
|
||||
/**
|
||||
Helper header to support SIMD intrinsics (universal intrinsics) in user code. |
||||
Intrinsics documentation: https://docs.opencv.org/3.4/df/d91/group__core__hal__intrin.html
|
||||
|
||||
|
||||
Checks of target CPU instruction set based on compiler definitions don't work well enough. |
||||
More reliable solutions require utilization of configuration systems (like CMake). |
||||
|
||||
So, probably you need to specify your own configuration. |
||||
|
||||
You can do that via CMake in this way: |
||||
add_definitions(/DOPENCV_SIMD_CONFIG_HEADER=opencv_simd_config_custom.hpp) |
||||
or |
||||
add_definitions(/DOPENCV_SIMD_CONFIG_INCLUDE_DIR=1) |
||||
|
||||
Additionally you may need to add include directory to your files: |
||||
include_directories("${CMAKE_CURRENT_LIST_DIR}/opencv_config_${MYTARGET}") |
||||
|
||||
These files can be pre-generated for target configurations of your application |
||||
or generated by CMake on the fly (use CMAKE_BINARY_DIR for that). |
||||
|
||||
Notes: |
||||
- H/W capability checks are still responsibility of your applcation |
||||
- runtime dispatching is not covered by this helper header |
||||
*/ |
||||
|
||||
#ifdef __OPENCV_BUILD |
||||
#error "Use core/hal/intrin.hpp during OpenCV build" |
||||
#endif |
||||
|
||||
#ifdef OPENCV_HAL_INTRIN_HPP |
||||
#error "core/simd_intrinsics.hpp must be included before core/hal/intrin.hpp" |
||||
#endif |
||||
|
||||
#include "opencv2/core/cvdef.h" |
||||
#include "opencv2/core/version.hpp" |
||||
|
||||
#ifdef OPENCV_SIMD_CONFIG_HEADER |
||||
#include CVAUX_STR(OPENCV_SIMD_CONFIG_HEADER) |
||||
#elif defined(OPENCV_SIMD_CONFIG_INCLUDE_DIR) |
||||
#include "opencv_simd_config.hpp" // corresponding directory should be added via -I compiler parameter |
||||
#else // custom config headers
|
||||
|
||||
#if (!defined(CV_AVX_512F) || !CV_AVX_512F) && (defined(__AVX512__) || defined(__AVX512F__)) |
||||
# include <immintrin.h> |
||||
# undef CV_AVX_512F |
||||
# define CV_AVX_512F 1 |
||||
# ifndef OPENCV_SIMD_DONT_ASSUME_SKX // Skylake-X with AVX-512F/CD/BW/DQ/VL
|
||||
# undef CV_AVX512_SKX |
||||
# define CV_AVX512_SKX 1 |
||||
# undef CV_AVX_512CD |
||||
# define CV_AVX_512CD 1 |
||||
# undef CV_AVX_512BW |
||||
# define CV_AVX_512BW 1 |
||||
# undef CV_AVX_512DQ |
||||
# define CV_AVX_512DQ 1 |
||||
# undef CV_AVX_512VL |
||||
# define CV_AVX_512VL 1 |
||||
# endif |
||||
#endif // AVX512
|
||||
|
||||
// GCC/Clang: -mavx2
|
||||
// MSVC: /arch:AVX2
|
||||
#if defined __AVX2__ |
||||
# include <immintrin.h> |
||||
# undef CV_AVX2 |
||||
# define CV_AVX2 1 |
||||
# if defined __F16C__ |
||||
# undef CV_FP16 |
||||
# define CV_FP16 1 |
||||
# endif |
||||
#endif |
||||
|
||||
#endif |
||||
|
||||
// SSE / NEON / VSX is handled by cv_cpu_dispatch.h compatibility block
|
||||
#include "cv_cpu_dispatch.h" |
||||
|
||||
#include "hal/intrin.hpp" |
||||
|
||||
#endif // OPENCV_CORE_SIMD_INTRINSICS_HPP
|
@ -0,0 +1,12 @@ |
||||
if(WINCE) |
||||
# CommCtrl.lib does not exist in headless WINCE Adding this will make CMake |
||||
# Try_Compile succeed and therefore also C/C++ ABI Detetection work |
||||
# https://gitlab.kitware.com/cmake/cmake/blob/master/Modules/Platform/Windows- |
||||
# MSVC.cmake |
||||
set(CMAKE_C_STANDARD_LIBRARIES_INIT "coredll.lib") |
||||
set(CMAKE_CXX_STANDARD_LIBRARIES_INIT ${CMAKE_C_STANDARD_LIBRARIES_INIT}) |
||||
foreach(ID EXE SHARED MODULE) |
||||
string(APPEND CMAKE_${ID}_LINKER_FLAGS_INIT |
||||
" /NODEFAULTLIB:libc.lib /NODEFAULTLIB:oldnames.lib") |
||||
endforeach() |
||||
endif() |
@ -0,0 +1,35 @@ |
||||
set(CMAKE_SYSTEM_NAME WindowsCE) |
||||
|
||||
if(NOT CMAKE_SYSTEM_VERSION) |
||||
set(CMAKE_SYSTEM_VERSION 8.0) |
||||
endif() |
||||
|
||||
if(NOT CMAKE_SYSTEM_PROCESSOR) |
||||
set(CMAKE_SYSTEM_PROCESSOR armv7-a) |
||||
endif() |
||||
|
||||
if(NOT CMAKE_GENERATOR_TOOLSET) |
||||
set(CMAKE_GENERATOR_TOOLSET CE800) |
||||
endif() |
||||
|
||||
# Needed to make try_compile to succeed |
||||
if(BUILD_HEADLESS) |
||||
set(CMAKE_USER_MAKE_RULES_OVERRIDE |
||||
${CMAKE_CURRENT_LIST_DIR}/arm-wince-headless-overrides.cmake) |
||||
endif() |
||||
|
||||
if(NOT CMAKE_FIND_ROOT_PATH_MODE_PROGRAM) |
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) |
||||
endif() |
||||
|
||||
if(NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY) |
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) |
||||
endif() |
||||
|
||||
if(NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE) |
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) |
||||
endif() |
||||
|
||||
if(NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE) |
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) |
||||
endif() |
@ -0,0 +1,62 @@ |
||||
# Building OpenCV from Source for Windows Embedded Compact (WINCE/WEC) |
||||
|
||||
## Requirements |
||||
CMake 3.1.0 or higher |
||||
Windows Embedded Compact SDK |
||||
|
||||
## Configuring |
||||
To configure CMake for Windows Embedded, specify Visual Studio 2013 as generator and the name of your installed SDK: |
||||
|
||||
`cmake -G "Visual Studio 12 2013" -A "MySDK WEC2013" -DCMAKE_TOOLCHAIN_FILE:FILEPATH=../platforms/wince/arm-wince.toolchain.cmake` |
||||
|
||||
If you are building for a headless WINCE, specify `-DBUILD_HEADLESS=ON` when configuring. This will remove the `commctrl.lib` dependency. |
||||
|
||||
If you are building for anything else than WINCE800, you need to specify that in the configuration step. Example: |
||||
|
||||
``` |
||||
-DCMAKE_SYSTEM_VERSION=7.0 -DCMAKE_GENERATOR_TOOLSET=CE700 -DCMAKE_SYSTEM_PROCESSOR=arm-v4 |
||||
``` |
||||
|
||||
For headless WEC2013, this configuration may not be limited to but is known to work: |
||||
|
||||
``` |
||||
-DBUILD_EXAMPLES=OFF ` |
||||
-DBUILD_opencv_apps=OFF ` |
||||
-DBUILD_opencv_calib3d=OFF ` |
||||
-DBUILD_opencv_highgui=OFF ` |
||||
-DBUILD_opencv_features2d=OFF ` |
||||
-DBUILD_opencv_flann=OFF ` |
||||
-DBUILD_opencv_ml=OFF ` |
||||
-DBUILD_opencv_objdetect=OFF ` |
||||
-DBUILD_opencv_photo=OFF ` |
||||
-DBUILD_opencv_shape=OFF ` |
||||
-DBUILD_opencv_stitching=OFF ` |
||||
-DBUILD_opencv_superres=OFF ` |
||||
-DBUILD_opencv_ts=OFF ` |
||||
-DBUILD_opencv_video=OFF ` |
||||
-DBUILD_opencv_videoio=OFF ` |
||||
-DBUILD_opencv_videostab=OFF ` |
||||
-DBUILD_opencv_dnn=OFF ` |
||||
-DBUILD_opencv_java=OFF ` |
||||
-DBUILD_opencv_python2=OFF ` |
||||
-DBUILD_opencv_python3=OFF ` |
||||
-DBUILD_opencv_java_bindings_generator=OFF ` |
||||
-DBUILD_opencv_python_bindings_generator=OFF ` |
||||
-DBUILD_TIFF=OFF ` |
||||
-DCV_TRACE=OFF ` |
||||
-DWITH_OPENCL=OFF ` |
||||
-DHAVE_OPENCL=OFF ` |
||||
-DWITH_QT=OFF ` |
||||
-DWITH_GTK=OFF ` |
||||
-DWITH_QUIRC=OFF ` |
||||
-DWITH_JASPER=OFF ` |
||||
-DWITH_WEBP=OFF ` |
||||
-DWITH_PROTOBUF=OFF ` |
||||
-DBUILD_SHARED_LIBS=OFF ` |
||||
-DWITH_OPENEXR=OFF ` |
||||
-DWITH_TIFF=OFF ` |
||||
``` |
||||
|
||||
## Building |
||||
You are required to build using Unicode: |
||||
`cmake --build . -- /p:CharacterSet=Unicode` |
@ -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; |
||||
} |
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue