Intel® oneAPI DPC++/C++ Compiler is a latest and greatest SYCL/C++ compiler from Intel. Intel C/C++ Classic compiler will be deprecated in 2024 release.
The description on upgrade process and instructions for OpenCV with latest compiler can be found in this article.
Content expert:
Alina Shadrina
Prerequisites
- Install Intel® oneAPI Base Toolkit which contains Intel® oneAPI DPC++/C++ Compiler. Please, refer to Install Intel® oneAPI Toolkits and Components the Get Started Guide in case of any questions. To check for supported Linux distributions and hardware requirements, please refer Intel® oneAPI DPC++/C++ Compiler System Requirements.
- Please, refer to OpenCV* tutorials Installation in Linux to check the prerequisites and find detailed build commands for the corresponding operating system.
- CMake 3.20.5 and later
Building OpenCV with Intel® oneAPI DPC++/C++ Compiler on Linux
- Get the latest version of openCV:
$ git clone https://github.com/opencv/opencv.git
and make sure you are using branch 4.*:
$ git status On branch 4.x
- Navigate to OpenCV repository and prepare the build folder:
$ cd opencv $ mkdir build && cd build
- Set up Intel oneAPI environment variables
- For default installation:
$ source /opt/intel/oneapi/setvars.sh
-
- For non-default installation:
$ source $<PATH_TO_ONEAPI>/setvars.sh
- Run CMake * with Intel® oneAPI DPC++/C++ Compiler to configure the project:
$ cmake -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx ../
As a result, the build log looks as follows:
-- 'Release' build type is used by default. Use CMAKE_BUILD_TYPE to specify build type (Release or Debug) -- The CXX compiler identification is IntelLLVM 2023.2.0 -- The C compiler identification is IntelLLVM 2023.2.0 … -- C/C++: -- Built as dynamic libs?: YES -- C++ standard: 11 -- C++ Compiler: /opt/intel/oneapi/compiler/latest/linux/bin/icpx (ver 2023.2.0) -- C++ flags (Release): -fsigned-char -msse3 -O3 -DNDEBUG -- C++ flags (Debug): -fsigned-char -msse3 -g -- C Compiler: /opt/intel/oneapi/compiler/latest/linux/bin/icx -- C flags (Release): -fsigned-char -msse3 -O3 -DNDEBUG -- C flags (Debug): -fsigned-char -msse3 -g …
- After that, run CMake * to build executables:
$ cmake --build . [ 0%] Built target opencv_dnn_plugins [ 0%] Built target opencv_highgui_plugins …
- Make sure openCV* is compiled with Intel® oneAPI DPC++/C++ Compiler:
$ readelf -p .comment bin/opencv_annotation String dump of section '.comment': [ 0] GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 [ 2b] Intel(R) oneAPI DPC++/C++ Compiler 2023.2.0 (2023.2.0.20230721) [ 6b] Intel(R) oneAPI DPC++/C++ Compiler 2023.2.0 (2023.x.0.20230407)