The Simd Library is a free open source image processing library and machine learning, designed for C and C++ programmers. It provides many useful high performance algorithms for image processing and machine learning such as: pixel format conversion, image scaling and filtration, extraction of statistic information from images, motion detection, object detection and classification, neural network.
The algorithms are optimized with using of different SIMD CPU extensions. In particular the library supports following CPU extensions: SSE, AVX, AVX-512 and AMX for x86/x64, NEON for ARM.
The Simd Library has C API and also contains useful C++ classes and functions to facilitate access to C API. The library supports dynamic and static linking, 32-bit and 64-bit Windows and Linux, MSVS, G++ and Clang compilers, MSVS project and CMake build systems.
The Simd Library has next folder's structure:
simd/src/Simd/- contains source codes of the library.
simd/src/Test/- contains test framework of the library.
simd/src/Use/- contains the use examples of the library.
simd/py/SimdPy/- contains Python wrapper of the library.
simd/prj/vs2015/- contains project files of Microsoft Visual Studio 2015.
simd/prj/vs2017/- contains project files of Microsoft Visual Studio 2017.
simd/prj/vs2019/- contains project files of Microsoft Visual Studio 2019.
simd/prj/vs2022/- contains project files of Microsoft Visual Studio 2022.
simd/prj/cmd/- contains additional scripts needed for building of the library in Windows.
simd/prj/cmake/- contains files of CMake build systems.
simd/prj/sh/- contains additional scripts needed for building of the library in Linux.
simd/prj/txt/- contains text files needed for building of the library.
simd/data/cascade/- contains OpenCV cascades (HAAR and LBP).
simd/data/image/- contains image samples.
simd/data/network/- contains examples of trained networks.
simd/docs/- contains documentation of the library.
To build the library and test application for Windows 32/64 you can use Microsoft Visual Studio 2022 (or 2015/2017/2019). These project files are in the directory:
By default the library is built as a DLL (Dynamic Linked Library). You also may build it as a static library. To do this you must change appropriate property (Configuration Type) of Simd project and also define macro
SIMD_STATIC in file:
Also in order to build the library you can use CMake and MinGW:
To build the library and test application for Linux 32/64 you need to use CMake build systems. Files of CMake build systems are placed in the directory:
simd/prj/cmake/. The library can be built for x86/x64, and ARM(32/64) platforms with using of G++ or Clang compilers. With using of native compiler (g++) for current platform it is simple:
To build the library for ARM(32/64) platform you can also use toolchain for cross compilation. There is an example of using for ARM (32 bit):
And for ARM (64 bit):
As result the library and the test application will be built in the current directory.
There are addition build parameters:
SIMD_AVX512- Enable of AVX-512 (AVX-512F, AVX-512CD, AVX-512VL, AVX-512DQ, AVX-512BW) CPU extensions. It is switched on by default.
SIMD_AVX512VNNI- Enable of AVX-512-VNNI CPU extensions. It is switched on by default.
SIMD_AMXBF16- Enable of AMX-BF16, AMX-INT8 and AVX-512-BF16 CPU extensions. It is switched off by default.
SIMD_TEST- Build test framework. It is switched on by default.
SIMD_INFO- Print build information. It is switched on by default.
SIMD_PERF- Enable of internal performance statistic. It is switched off by default.
SIMD_SHARED- Build as SHARED library. It is switched off by default.
SIMD_GET_VERSION- Call scipt to get Simd Library version. It is switched on by default.
SIMD_SYNET- Enable optimizations for Synet framework. It is switched on by default.
SIMD_INT8_DEBUG- Enable debug INT8 capabilities for Synet framework. It is switched off by default.
SIMD_HIDE- Hide internal functions of Simd Library. It is switched off by default.
SIMD_RUNTIME- Enable of runtime faster algorithm choise. It is switched on by default.
SIMD_TEST_FLAGS- Addition compiler flags to build test framework.
SIMD_OPENCV- Use OpenCV in test framework. It is switched off by default.
SIMD_INSTALL- Enabling of install target. It is switched on by default.
SIMD_UNINSTALL- Enabling of uninstall target. It is switched on by default.
SIMD_PYTHON- Enabling of Simd Python wrapper. It is switched on by default.
If you use the library from C code you must include:
And to use the library from C++ code you must include:
In order to use Simd::Detection you must include:
In order to use Simd::Neural framework you must include:
In order to use Simd::Motion framework you must include:
If you need use mutual conversion between Simd and OpenCV types you just have to define macro
SIMD_OPENCV_ENABLE before including of Simd headers:
And you can convert next types:
The test suite is needed for testing of correctness of work of the library and also for its performance testing. There is a set of tests for every function from API of the library. There is an example of test application using:
Where next parameters were used:
-m=a- a auto checking mode which includes performance testing (only for library built in Release mode). In this case different implementations of each functions will be compared between themselves (for example a scalar implementation and implementations with using of different SIMD instructions such as SSE2, AVX2, and other). Also it can be
-m=s(running of special tests).
-tt=1- a number of test threads. Use -1 to set maximum parallelization.
-fi=Sobel- an include filter. In current case will be tested only functions which contain word
Sobelin their names. If you miss this parameter then full testing will be performed. You can use several filters - function name has to satisfy at least one of them.
-ot=log.txt- a file name with test report (in TEXT file format). The test's report also will be output to console.
Also you can use parameters:
-?in order to print help message.
-r=../..to set project root directory.
-pa=1to print alignment statistics.
-pi=1to print internal statistics (Cmake parameter SIMD_PERF must be ON).
-c=512a number of channels in test image for performance testing.
-h=1080a height of test image for performance testing.
-w=1920a width of test image for performance testing.
-oh=log.htmla file name with test report (in HTML file format).
-s=sample.avia video source (Simd::Motion test).
-o=output.avian annotated video output (Simd::Motion test).
-wt=1a thread number used to parallelize algorithms. Use -1 to set maximum parallelization.
-fe=Absan exlude filter to exclude some tests.
-mt=100a minimal test execution time (in milliseconds).
-lc=1to litter CPU cache between test runs.
-ri=city.jpga name of real image used in some tests. The image have to be placed in
-tr=2a number of test execution repeats.
-ts=1to print statistics of time of tests execution.
-cc=1to check c++ API.