Skip to content

Commit c121e89

Browse files
Intel compiler support (openvinotoolkit#24217)
### Details: - Initial version of Intel compiler support - Only Linux is covered - Current PR is a prerequisite for openvinotoolkit#23534
1 parent 3b0d201 commit c121e89

File tree

62 files changed

+170
-113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+170
-113
lines changed

.github/workflows/code_snippets.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ jobs:
3636
packages: ocl-icd-opencl-dev opencl-headers
3737
version: 3.0
3838

39+
- name: Install scons
40+
if: runner.os == 'macOS'
41+
run: brew install scons
42+
3943
- name: CMake configure
4044
run: cmake -DCMAKE_BUILD_TYPE=Release -DTHREADING=SEQ -B build
4145

cmake/dependencies.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ function(ov_download_tbb)
158158
update_deps_cache(TBB_DIR "${TBBROOT}/lib/cmake/TBB" "Path to TBB cmake folder")
159159
elseif(EXISTS "${TBBROOT}/lib/cmake/tbb/TBBConfig.cmake")
160160
# oneTBB release package version less than 2021.6.0
161+
# or TBB from oneAPI package
161162
update_deps_cache(TBB_DIR "${TBBROOT}/lib/cmake/tbb" "Path to TBB cmake folder")
162163
elseif(EXISTS "${TBBROOT}/lib64/cmake/TBB/TBBConfig.cmake")
163164
# 64-bits oneTBB case

cmake/developer_package/compile_flags/os_flags.cmake

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ macro(ov_disable_deprecated_warnings)
2020
else()
2121
set(ov_c_cxx_deprecated "-diag-disable=1478,1786")
2222
endif()
23-
elseif(OV_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX)
23+
elseif(OV_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_INTEL_LLVM)
2424
set(ov_c_cxx_deprecated "-Wno-deprecated-declarations")
2525
else()
2626
message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}")
@@ -48,7 +48,7 @@ macro(ov_deprecated_no_errors)
4848
else()
4949
set(ov_c_cxx_deprecated_no_errors "-diag-warning=1478,1786")
5050
endif()
51-
elseif(OV_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX)
51+
elseif(OV_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_INTEL_LLVM)
5252
set(ov_c_cxx_deprecated_no_errors "-Wno-error=deprecated-declarations")
5353
# Suppress #warning messages
5454
set(ov_c_cxx_deprecated_no_errors "${ov_c_cxx_deprecated_no_errors} -Wno-cpp")
@@ -68,7 +68,7 @@ endmacro()
6868
# Exports flags for 3rdparty modules, but without errors
6969
#
7070
macro(ov_dev_package_no_errors)
71-
if(OV_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX)
71+
if(OV_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_INTEL_LLVM)
7272
set(ov_c_cxx_dev_no_errors "-Wno-all")
7373
if(SUGGEST_OVERRIDE_SUPPORTED)
7474
set(ov_cxx_dev_no_errors "-Wno-error=suggest-override")
@@ -100,7 +100,7 @@ endmacro()
100100
macro(ov_sse42_optimization_flags flags)
101101
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
102102
# No such option for MSVC 2019
103-
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
103+
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel" OR OV_COMPILER_IS_INTEL_LLVM)
104104
if(WIN32)
105105
set(${flags} /QxSSE4.2)
106106
else()
@@ -130,7 +130,7 @@ macro(ov_avx2_optimization_flags flags)
130130
else()
131131
set(${flags} -xCORE-AVX2)
132132
endif()
133-
elseif(OV_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX)
133+
elseif(OV_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_INTEL_LLVM)
134134
set(${flags} -mavx2 -mfma -mf16c)
135135
else()
136136
message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}")
@@ -152,7 +152,7 @@ macro(ov_avx512_optimization_flags flags)
152152
else()
153153
set(${flags} -xCOMMON-AVX512)
154154
endif()
155-
elseif(OV_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX)
155+
elseif(OV_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_INTEL_LLVM)
156156
set(${flags} -mavx512f -mavx512bw -mavx512vl -mfma -mf16c)
157157
else()
158158
message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}")
@@ -200,7 +200,7 @@ function(ov_disable_all_warnings)
200200

201201
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
202202
target_compile_options(${target} PRIVATE /WX-)
203-
elseif(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG)
203+
elseif(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG OR OV_COMPILER_IS_INTEL_LLVM)
204204
target_compile_options(${target} PRIVATE -w)
205205
# required for LTO
206206
set(link_interface INTERFACE_LINK_OPTIONS)
@@ -239,7 +239,7 @@ endmacro()
239239
function(ov_force_include target scope header_file)
240240
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
241241
target_compile_options(${target} ${scope} /FI"${header_file}")
242-
elseif(OV_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX)
242+
elseif(OV_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_INTEL_LLVM)
243243
target_compile_options(${target} ${scope} -include "${header_file}")
244244
else()
245245
message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}")
@@ -314,7 +314,7 @@ set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
314314
if(CMAKE_CL_64)
315315
# Default char Type Is unsigned
316316
# ov_add_compiler_flags(/J)
317-
elseif(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG)
317+
elseif(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG OR OV_COMPILER_IS_INTEL_LLVM)
318318
ov_add_compiler_flags(-fsigned-char)
319319
endif()
320320

@@ -449,21 +449,11 @@ else()
449449
# To guarantee OpenVINO can be used with gcc versions 7 through 12
450450
# - https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html
451451
# - https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html
452-
if(CMAKE_COMPILER_IS_GNUCXX)
453-
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "8")
454-
# Enable __FILE__ trim only for release mode
455-
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ffile-prefix-map=${OV_NATIVE_PROJECT_ROOT_DIR}/= -ffile-prefix-map=${OV_RELATIVE_BIN_PATH}/=")
456-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffile-prefix-map=${OV_NATIVE_PROJECT_ROOT_DIR}/= -ffile-prefix-map=${OV_RELATIVE_BIN_PATH}/=")
457-
endif()
458-
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wabi=11")
459-
endif()
460-
461-
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
462-
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "10")
463-
# Enable __FILE__ trim only for release mode
464-
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ffile-prefix-map=${OV_NATIVE_PROJECT_ROOT_DIR}/= -ffile-prefix-map=${OV_RELATIVE_BIN_PATH}/=")
465-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffile-prefix-map=${OV_NATIVE_PROJECT_ROOT_DIR}/= -ffile-prefix-map=${OV_RELATIVE_BIN_PATH}/=")
466-
endif()
452+
if((CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8) OR
453+
(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10) OR OV_COMPILER_IS_INTEL_LLVM)
454+
# Enable __FILE__ trim only for release mode
455+
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ffile-prefix-map=${OV_NATIVE_PROJECT_ROOT_DIR}/= -ffile-prefix-map=${OV_RELATIVE_BIN_PATH}/=")
456+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffile-prefix-map=${OV_NATIVE_PROJECT_ROOT_DIR}/= -ffile-prefix-map=${OV_RELATIVE_BIN_PATH}/=")
467457
endif()
468458

469459
#
@@ -483,6 +473,10 @@ else()
483473
ov_add_compiler_flags(-diag-disable=remark,177,2196)
484474
endif()
485475

476+
if(OV_COMPILER_IS_INTEL_LLVM)
477+
ov_add_compiler_flags(-Wno-tautological-constant-compare)
478+
endif()
479+
486480
#
487481
# Linker flags
488482
#
@@ -507,6 +501,11 @@ else()
507501
endif()
508502
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
509503
endif()
504+
505+
if(OV_COMPILER_IS_INTEL_LLVM)
506+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-intel")
507+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-intel")
508+
endif()
510509
endif()
511510

512511
add_compile_definitions(

cmake/developer_package/compile_flags/sdl.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33
#
44

5-
if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG OR
5+
if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG OR OV_COMPILER_IS_INTEL_LLVM OR
66
(UNIX AND CMAKE_CXX_COMPILER_ID STREQUAL "Intel"))
77
set(OV_C_CXX_FLAGS "${OV_C_CXX_FLAGS} -Wformat -Wformat-security")
88

@@ -32,7 +32,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG OR
3232
if(NOT MINGW)
3333
set(OV_LINKER_FLAGS "${OV_LINKER_FLAGS} -z noexecstack -z relro -z now")
3434
endif()
35-
elseif(OV_COMPILER_IS_CLANG)
35+
elseif(OV_COMPILER_IS_CLANG OR OV_COMPILER_IS_INTEL_LLVM)
3636
if(EMSCRIPTEN)
3737
# emcc does not support fortification
3838
# https://stackoverflow.com/questions/58854858/undefined-symbol-stack-chk-guard-in-libopenh264-so-when-building-ffmpeg-wit

cmake/developer_package/cross_compile/native_compile.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function(ov_native_compile_external_project)
6262
endif()
6363

6464
# compile flags
65-
if(CMAKE_COMPILER_IS_GNUCXX)
65+
if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG OR OV_COMPILER_IS_INTEL_LLVM)
6666
set(compile_flags "-Wno-undef -Wno-error -Wno-deprecated-declarations")
6767
endif()
6868

cmake/developer_package/frontends/frontends.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ macro(ov_add_frontend)
212212
endif()
213213

214214
# remove -Wmissing-declarations warning, because of frontends implementation specific
215-
if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG)
215+
if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG OR OV_COMPILER_IS_INTEL_LLVM)
216216
target_compile_options(${TARGET_NAME} PRIVATE -Wno-missing-declarations)
217217
endif()
218218

cmake/developer_package/target_flags.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$")
111111
endif()
112112
endif()
113113

114+
if(CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
115+
set(OV_COMPILER_IS_INTEL_LLVM ON)
116+
endif()
117+
114118
get_property(OV_GENERATOR_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
115119

116120
function(ov_get_compiler_definition definition var)

docs/snippets/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44

55
set(TARGET_NAME openvino_docs_snippets)
66

7-
if(CMAKE_COMPILER_IS_GNUCXX)
7+
if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG OR OV_COMPILER_IS_INTEL_LLVM)
88
ov_add_compiler_flags(-Wall)
9-
endif()
10-
11-
if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG)
129
ov_add_compiler_flags(-Wno-unused-variable)
1310
endif()
1411
if(UNUSED_BUT_SET_VARIABLE_SUPPORTED)

docs/snippets/template_pattern_transformation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "openvino/opsets/opset3.hpp"
1111
#include "openvino/pass/manager.hpp"
1212
#include "openvino/pass/pattern/op/wrap_type.hpp"
13+
#include "transformations/utils/utils.hpp"
1314
#include "template_model_transformation.hpp"
1415

1516
// ! [graph_rewrite:template_transformation_cpp]
@@ -61,7 +62,7 @@ ov::pass::ReluReluFusionMatcher::ReluReluFusionMatcher() {
6162
auto m_relu1 = ov::pass::pattern::wrap_type<ov::opset3::Relu>(pattern::consumers_count(1));
6263
auto m_relu2 = ov::pass::pattern::wrap_type<ov::opset3::Relu>({m_relu1});
6364

64-
ov::matcher_pass_callback callback = [=](pattern::Matcher& m) {
65+
ov::matcher_pass_callback callback = [OV_CAPTURE_CPY_AND_THIS](pattern::Matcher& m) {
6566
// Map that helps to connect labels with matched outputs
6667
auto& node_to_output = m.get_pattern_value_map();
6768

src/bindings/python/src/pyopenvino/CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PYTHON_BRIDGE_OUTPUT_DIRECTORY})
2121
set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${PYTHON_BRIDGE_OUTPUT_DIRECTORY})
2222
set(CMAKE_PDB_OUTPUT_DIRECTORY ${PYTHON_BRIDGE_OUTPUT_DIRECTORY})
2323

24-
# compile options
24+
# compile and linker options
2525

2626
if(OV_COMPILER_IS_APPLECLANG)
2727
add_link_options(-stdlib=libc++)
28-
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
28+
elseif(CMAKE_COMPILER_IS_GNUCXX)
2929
# WA for GCC 7.5 "PYBIND11_NOINLINE inline" warning
30-
add_compile_options(-Wno-error=attributes)
30+
ov_add_compiler_flags(-Wno-error=attributes)
3131
endif()
3232

33-
if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG)
34-
# for proper fix need to update pybind to version which does not use PyEval_InitThreads()
35-
add_compile_options(-Wno-deprecated-declarations -Wno-undef)
33+
if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG OR OV_COMPILER_IS_INTEL_LLVM)
34+
# TODO: remove this deprecated API usage
35+
ov_add_compiler_flags(-Wno-error=deprecated-declarations)
3636
endif()
3737

3838
if(ENABLE_TESTS)

0 commit comments

Comments
 (0)