Skip to content

Commit

Permalink
Fixed compilation with Intel compiler (openvinotoolkit#6788)
Browse files Browse the repository at this point in the history
* Fixed compilation with Intel compiler

* Fixed template containers for VPU

* Fixe one-dnn

* Updated submodule
  • Loading branch information
ilya-lavrenov authored and andrei-cv committed Aug 30, 2021
1 parent 30c7409 commit 3e2388d
Show file tree
Hide file tree
Showing 48 changed files with 164 additions and 164 deletions.
36 changes: 26 additions & 10 deletions cmake/developer_package/compile_flags/os_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ function(ie_sse42_optimization_flags flags)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# No such option for MSVC 2019
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set(${flags} /arch:SSE4.2 /QxSSE4.2 PARENT_SCOPE)
set(${flags} /QxSSE4.2 PARENT_SCOPE)
else()
message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}")
endif()
else()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set(${flags} -msse4.2 -xSSE4.2 PARENT_SCOPE)
set(${flags} -xSSE4.2 PARENT_SCOPE)
else()
set(${flags} -msse4.2 PARENT_SCOPE)
endif()
Expand All @@ -95,7 +95,7 @@ function(ie_avx2_optimization_flags flags)
endif()
else()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set(${flags} -march=core-avx2 -xCORE-AVX2 -mtune=core-avx2 PARENT_SCOPE)
set(${flags} -xCORE-AVX2 PARENT_SCOPE)
else()
set(${flags} -mavx2 -mfma PARENT_SCOPE)
endif()
Expand Down Expand Up @@ -152,6 +152,24 @@ function(ie_arm_neon_optimization_flags flags)
endif()
endfunction()

#
# Disables all warnings for 3rd party targets
#
function(ov_disable_all_warnings)
foreach(target IN LISTS ARGN)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(${target} PRIVATE /WX-)
elseif(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG)
target_compile_options(${target} PRIVATE -w)
elseif(UNIX AND CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
# 193: zero used for undefined preprocessing identifier "XXX"
# 1011: missing return statement at end of non-void function "XXX"
# 2415: variable "xxx" of static storage duration was declared but never referenced
target_compile_options(${target} PRIVATE -diag-disable=warn,193,1011,2415)
endif()
endforeach()
endfunction()

#
# Enables Link Time Optimization compilation
#
Expand Down Expand Up @@ -286,15 +304,12 @@ else()
ie_add_compiler_flags(-Wreturn-type)
ie_add_compiler_flags(-Wunused-variable)

# Disable noisy warnings

if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
ie_add_compiler_flags(-Wswitch)
elseif(UNIX)
ie_add_compiler_flags(-Wuninitialized -Winit-self)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
ie_add_compiler_flags(-Wno-error=switch
-Winconsistent-missing-override)
ie_add_compiler_flags(-Winconsistent-missing-override)
else()
ie_add_compiler_flags(-Wmaybe-uninitialized)
check_cxx_compiler_flag("-Wsuggest-override" SUGGEST_OVERRIDE_SUPPORTED)
Expand All @@ -304,10 +319,11 @@ else()
endif()
endif()

# Disable noisy warnings

if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
ie_add_compiler_flags(-diag-disable=remark)
# noisy warnings from Intel Compiler 19.1.1.217 20200306
ie_add_compiler_flags(-diag-disable=2196)
# 177: function "XXX" was declared but never referenced
ie_add_compiler_flags(-diag-disable=remark,177,2196)
endif()

# Linker flags
Expand Down
1 change: 1 addition & 0 deletions docs/template_extension/cpu_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ InferenceEngine::StatusCode OpImplementation::init(InferenceEngine::LayerConfig&
IE_THROW() << "Operation supports only FP32 precisions!";
}
} catch (InferenceEngine::Exception& ex) {
error = ex.what();
if (resp) {
strncpy(resp->msg, error.c_str(), sizeof(resp->msg) - 1);
resp->msg[sizeof(resp->msg) - 1] = 0;
Expand Down
1 change: 1 addition & 0 deletions docs/template_extension/fft_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ InferenceEngine::StatusCode FFTImpl::init(InferenceEngine::LayerConfig& config,
IE_THROW() << "Operation supports only FP32 precisions!";
}
} catch (InferenceEngine::Exception& ex) {
error = ex.what();
if (resp) {
strncpy(resp->msg, error.c_str(), sizeof(resp->msg) - 1);
resp->msg[sizeof(resp->msg) - 1] = 0;
Expand Down
3 changes: 3 additions & 0 deletions inference-engine/cmake/ie_parallel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function(set_ie_threading_interface_for TARGET_NAME)
set(TBB_IMPORTED_TARGETS ${TBB_IMPORTED_TARGETS} PARENT_SCOPE)
set(TBB_VERSION ${TBB_VERSION} PARENT_SCOPE)
if (NOT TBB_FOUND)
set(THREADING "SEQ" PARENT_SCOPE)
ext_message(WARNING "TBB was not found by the configured TBB_DIR/TBBROOT path.\
SEQ method will be used.")
endif ()
Expand Down Expand Up @@ -95,6 +96,7 @@ function(set_ie_threading_interface_for TARGET_NAME)
set(IE_THREAD_DEFINE "IE_THREAD_TBB")
ie_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} ${TBB_IMPORTED_TARGETS})
else ()
set(THREADING "SEQ" PARENT_SCOPE)
ext_message(WARNING "TBB was not found by the configured TBB_DIR path.\
SEQ method will be used for ${TARGET_NAME}")
endif ()
Expand Down Expand Up @@ -133,6 +135,7 @@ function(set_ie_threading_interface_for TARGET_NAME)

if (NOT OMP_LIBRARIES_RELEASE)
ext_message(WARNING "Intel OpenMP not found. Intel OpenMP support will be disabled. ${IE_THREAD_DEFINE} is defined")
set(THREADING "SEQ" PARENT_SCOPE)
else ()
set(IE_THREAD_DEFINE "IE_THREAD_OMP")

Expand Down
7 changes: 7 additions & 0 deletions inference-engine/ie_bridges/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ else()
endif()
endif()

function(ov_python_disable_intel_warnings target)
if(UNIX AND CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
# 1292: unknown attribute "fallthrough"
target_compile_options(${target} PRIVATE -diag-disable=1292)
endif()
endfunction()

set (PYTHON_BRIDGE_SRC_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory (src/openvino/inference_engine)
add_subdirectory (src/openvino/offline_transformations)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ set_source_files_properties(${PYX_SOURCES} PROPERTIES CYTHON_IS_CXX ON)
# create target

cython_add_module(${TARGET_NAME} ${SOURCES})
set(INSTALLED_TARGETS ${TARGET_NAME})
ov_python_disable_intel_warnings(${TARGET_NAME})

set(INSTALLED_TARGETS ${TARGET_NAME})
list(REMOVE_ITEM PYX_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/ie_api.pyx")

foreach(PYX_FILE IN LISTS PYX_SOURCES)
get_filename_component(PYX_NAME "${PYX_FILE}" NAME_WE)
cython_add_module(${PYX_NAME} ${PYX_FILE})
ov_python_disable_intel_warnings(${PYX_NAME})
add_dependencies(${TARGET_NAME} ${PYX_NAME})
target_include_directories(${PYX_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
target_link_libraries(${PYX_NAME} PRIVATE ${InferenceEngine_LIBRARIES})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/offline_transformations_
# create target

cython_add_module(${TARGET_NAME} ${SOURCES})

add_dependencies(${TARGET_NAME} ie_api)
ov_python_disable_intel_warnings(${TARGET_NAME})

if(COMMAND ie_add_vs_version_file)
ie_add_vs_version_file(NAME ${TARGET_NAME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/test_utils_api.pyx
# create target

cython_add_module(${TARGET_NAME} ${SOURCES})

add_dependencies(${TARGET_NAME} ie_api)
ov_python_disable_intel_warnings(${TARGET_NAME})

if(COMMAND ie_add_vs_version_file)
ie_add_vs_version_file(NAME ${TARGET_NAME}
Expand Down
8 changes: 4 additions & 4 deletions inference-engine/samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ else()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") #treating warnings as errors
endif()

if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -diag-disable:177")
endif()

set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
if (APPLE)
Expand Down Expand Up @@ -135,10 +139,6 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/cnpy")
add_subdirectory(thirdparty/cnpy EXCLUDE_FROM_ALL)
endif()

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif()

if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/common/utils")
add_subdirectory(common/utils)
endif()
Expand Down
4 changes: 2 additions & 2 deletions inference-engine/src/gna_plugin/backend/dnn_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ OvGnaType OvGnaTypeIntFromBytes(T bytesPerElement) {
return r->second;
}

static std::string OvGnaTypeToString(OvGnaType type) {
inline std::string OvGnaTypeToString(OvGnaType type) {
static const std::map<OvGnaType, std::string> typeToString = {
{OvGnaTypeInt8, "OvGnaTypeInt8"},
{OvGnaTypeInt16, "OvGnaTypeInt16"},
Expand All @@ -241,7 +241,7 @@ static std::string OvGnaTypeToString(OvGnaType type) {
return r->second;
}

static std::string OvGnaModeToString(OvGnaMode mode) {
inline std::string OvGnaModeToString(OvGnaMode mode) {
static const std::map<OvGnaMode, std::string> modeToString = {
{OvGnaModeDefault, "OvGnaModeDefault"},
{OvGnaModeDisabled, "OvGnaModeDisabled"},
Expand Down
2 changes: 2 additions & 0 deletions inference-engine/src/gna_plugin/backend/gna_limitations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class Validator {

static void ThrowIfNotEmpty(const std::string prefix, const std::string error);
public:
Validator() = default;

void ValidateCnn2D(std::string name, const uint32_t inHeight, const uint32_t inWidth,
const uint32_t inChannels, const uint32_t kH, const uint32_t kW, const uint32_t kN,
const uint32_t strideH, const uint32_t strideW, OvGnaType inPrecision) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void HeteroInferRequest::SetBlob(const std::string& name, const InferenceEngine:
if (findInputAndOutputBlobByName(name, foundInput, foundOutput)) {
r->SetBlob(name, data, foundInput->getPreProcess());
}
} catch (const InferenceEngine::NotFound& ex) {}
} catch (const InferenceEngine::NotFound&) {}
}
}

Expand Down
11 changes: 8 additions & 3 deletions inference-engine/src/inference_engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,14 @@ list(APPEND core_components ngraph)
list(APPEND PATH_VARS "IE_INCLUDE_DIR" "IE_NGRAPH_DIR"
"IE_PARALLEL_CMAKE")

if((THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO") AND TBBROOT MATCHES ${TEMP})
# define variables for InferenceEngineConfig.cmake
if(THREADING MATCHES "^(TBB|TBB_AUTO)$")
set(IE_TBB_DIR "${TBB_DIR}")
list(APPEND PATH_VARS "IE_TBB_DIR")
endif()

# install only downloaded TBB, system one is not installed
if(THREADING MATCHES "^(TBB|TBB_AUTO)$" AND TBBROOT MATCHES ${TEMP})
ie_cpack_add_component(tbb REQUIRED)
list(APPEND core_components tbb)

Expand All @@ -249,8 +256,6 @@ if((THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO") AND TBBROOT MATCH
COMPONENT tbb)

set(IE_TBB_DIR_INSTALL "external/tbb/cmake")
set(IE_TBB_DIR "${TBB_DIR}")
list(APPEND PATH_VARS "IE_TBB_DIR")

install(FILES "${TBB}/cmake/TBBConfig.cmake"
"${TBB}/cmake/TBBConfigVersion.cmake"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void InferRequest::SetCompletionCallbackImpl(std::function<void(InferRequest, St
statusCode = [&] {
try {
std::rethrow_exception(exceptionPtr);
} CATCH_IE_EXCEPTIONS_RETURN catch (const std::exception& ex) {
} CATCH_IE_EXCEPTIONS_RETURN catch (const std::exception&) {
return GENERAL_ERROR;
} catch (...) {
return UNEXPECTED;
Expand All @@ -148,7 +148,7 @@ void InferRequest::SetCompletionCallbackImpl(IInferRequest::CompletionCallback c
statusCode = [&] {
try {
std::rethrow_exception(exceptionPtr);
} CATCH_IE_EXCEPTIONS_RETURN catch (const std::exception& ex) {
} CATCH_IE_EXCEPTIONS_RETURN catch (const std::exception&) {
return GENERAL_ERROR;
} catch (...) {
return UNEXPECTED;
Expand Down
2 changes: 1 addition & 1 deletion inference-engine/src/inference_engine/ie_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ class Core::Impl : public ICore, public std::enable_shared_from_this<ICore> {
plugin.ImportNetwork(networkStream, config);
networkIsImported = true;
});
} catch (const HeaderException& ex) {
} catch (const HeaderException&) {
// For these exceptions just remove old cache and set that import didn't work
cacheManager->removeCacheEntry(blobId);
networkIsImported = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ void VariantWrapper<IntervalsAlignmentAttributePtr>::merge(

resultSharedValue->preferablePrecisions.insert(sharedValue->preferablePrecisions.begin(), sharedValue->preferablePrecisions.end());

const auto resultSize = abs(resultSharedValue->minInterval.high - resultSharedValue->minInterval.low);
const auto size = abs(sharedValue->minInterval.high - sharedValue->minInterval.low);
const auto resultSize = std::abs(resultSharedValue->minInterval.high - resultSharedValue->minInterval.low);
const auto size = std::abs(sharedValue->minInterval.high - sharedValue->minInterval.low);
if (resultSize > size) {
resultSharedValue->minInterval = sharedValue->minInterval;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ template <typename typelist, typename default_t, typename pred_t, typename type_
namespace {
struct cv_type_id {
template <typename type>
const int operator()(type_to_type<type>) { return cv_type_to_depth<type>::depth; }
int operator()(type_to_type<type>) { return cv_type_to_depth<type>::depth; }
};

} // namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ bool pass::Serialize::run_on_function(std::shared_ptr<ngraph::Function> f) {

try {
serializeFunc(xml_file, bin_file);
} catch (const ngraph::CheckFailure& e) {
} catch (const ngraph::CheckFailure&) {
// optimization decission was made to create .bin file upfront and
// write to it directly instead of buffering its content in memory,
// hence we need to delete it here in case of failure
Expand Down
2 changes: 1 addition & 1 deletion inference-engine/src/vpu/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function(add_common_target TARGET_NAME STATIC_IE)
UNITY
)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_COMPILER_IS_GNUCXX)
# TODO: enable some day and fix all warnings
# target_compile_options(${TARGET_NAME} PRIVATE "-Wall")
target_compile_options(${TARGET_NAME} PRIVATE "-Werror=unused-function")
Expand Down
21 changes: 15 additions & 6 deletions inference-engine/src/vpu/common/include/vpu/utils/containers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,33 @@

namespace vpu {

template<class Key, class Value, template<class...> class Map>
inline std::vector<Key> getKeys(const Map<Key, Value>& map) {
template <template <typename, typename...> class Map,
typename Key,
typename Value,
typename... AddParams>
inline std::vector<Key> getKeys(const Map<Key, Value, AddParams...>& map) {
auto keys = std::vector<Key>{};
keys.reserve(map.size());
std::transform(map.cbegin(), map.cend(), std::back_inserter(keys), [](const std::pair<Key, Value>& entry) { return entry.first; });
return keys;
}

template<class Key, class Value, template<class...> class Map>
inline std::vector<Value> getValues(const Map<Key, Value>& map) {
template <template <typename, typename...> class Map,
typename Key,
typename Value,
typename... AddParams>
inline std::vector<Value> getValues(const Map<Key, Value, AddParams...>& map) {
auto values = std::vector<Value>{};
values.reserve(map.size());
std::transform(map.cbegin(), map.cend(), std::back_inserter(values), [](const std::pair<Key, Value>& entry) { return entry.second; });
return values;
}

template<class Key, class Value, template<class...> class Map>
inline Map<Value, Key> inverse(const Map<Key, Value>& map) {
template <template <typename, typename...> class Map,
typename Key,
typename Value,
typename... AddParams>
inline Map<Value, Key> inverse(const Map<Key, Value, AddParams...>& map) {
auto inverted = Map<Value, Key>{};
for (const auto& entry : map) {
const auto& insertion = inverted.emplace(entry.second, entry.first);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void TilingCMXLimitKBOption::validate(const std::string& value) {
int intValue;
try {
intValue = std::stoi(value);
} catch (const std::exception& e) {
} catch (const std::exception&) {
VPU_THROW_FORMAT(R"(unexpected {} option value "{}", must be a number)", key(), value);
}

Expand Down Expand Up @@ -54,7 +54,7 @@ TilingCMXLimitKBOption::value_type TilingCMXLimitKBOption::parse(const std::stri
int intValue;
try {
intValue = std::stoi(value);
} catch (const std::exception& e) {
} catch (const std::exception&) {
VPU_THROW_FORMAT(R"(unexpected {} option value "{}", must be a number)", key(), value);
}

Expand Down
2 changes: 1 addition & 1 deletion inference-engine/src/vpu/graph_transformer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function(add_graph_transformer_target TARGET_NAME STATIC_IE)
set(TBB_IMPORTED_TARGETS ${TBB_IMPORTED_TARGETS} PARENT_SCOPE)
set(TBB_VERSION ${TBB_VERSION} PARENT_SCOPE)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_COMPILER_IS_GNUCXX)
# TODO: enable some day and fix all warnings
# target_compile_options(${TARGET_NAME} PRIVATE "-Wall")
target_compile_options(${TARGET_NAME} PRIVATE "-Werror=unused-function")
Expand Down
2 changes: 1 addition & 1 deletion inference-engine/src/vpu/myriad_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ target_include_directories(${TARGET_NAME}
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}")

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_COMPILER_IS_GNUCXX)
target_compile_options(${TARGET_NAME}
PRIVATE
-Wall)
Expand Down
Loading

0 comments on commit 3e2388d

Please sign in to comment.