Fixed headers compilation with strict flags (#8403)

* Fixed headers compilation with strict flags

* Fixed Windows

* Fix

* Fix2
This commit is contained in:
Ilya Lavrenov 2021-11-08 18:48:19 +03:00 committed by GitHub
parent 8cb7824c21
commit 031e998a15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 65 additions and 34 deletions

View File

@ -11,12 +11,16 @@
*/
#pragma once
#ifndef NOMINMAX
# define NOMINMAX
#endif
#include <d3d11.h>
#include <memory>
#include <string>
#include "openvin/runtime/gpu/ocl.hpp"
#include "openvino/runtime/gpu/ocl.hpp"
namespace ov {
namespace runtime {
@ -62,10 +66,10 @@ public:
* @param remote_tensor remote tensor to check
*/
static void type_check(const RemoteTensor& remote_tensor) {
remote_type_check(remote_context.get_params(),
{{GPU_PARAM_KEY(DEV_OBJECT_HANDLE), {}},
{GPU_PARAM_KEY(VA_PLANE), {}},
{GPU_PARAM_KEY(SHARED_MEM_TYPE), {GPU_PARAM_VALUE(VA_SURFACE)}}});
RemoteTensor::type_check(remote_tensor,
{{GPU_PARAM_KEY(DEV_OBJECT_HANDLE), {}},
{GPU_PARAM_KEY(VA_PLANE), {}},
{GPU_PARAM_KEY(SHARED_MEM_TYPE), {GPU_PARAM_VALUE(VA_SURFACE)}}});
}
/**
@ -94,7 +98,6 @@ public:
*/
class D3DContext : public ClContext {
using RemoteContext::create_tensor;
static constexpr const char* device_name = "GPU";
public:
/**
@ -102,8 +105,8 @@ public:
* @param remote_context remote context to check
*/
static void type_check(const RemoteContext& remote_context) {
remote_type_check(
remote_context.get_params(),
RemoteContext::type_check(
remote_context,
{{GPU_PARAM_KEY(VA_DEVICE), {}}, {GPU_PARAM_KEY(CONTEXT_TYPE), {GPU_PARAM_VALUE(VA_SHARED)}}});
}
@ -120,7 +123,7 @@ public:
* @param core OpenVINO Runtime Core object instance
* @param device A pointer to ID3D11Device to be used to create a remote context
*/
D3DContext(Core& core, ID3D11Device* device) {
D3DContext(Core& core, ID3D11Device* device) : ClContext(core, (cl_context) nullptr) {
// clang-format off
ParamMap context_params = {
{GPU_PARAM_KEY(CONTEXT_TYPE), GPU_PARAM_VALUE(VA_SHARED)},
@ -137,7 +140,7 @@ public:
* @param nv12_surf A ID3D11Texture2D instance to create NV12 tensor from
* @return A pair of remote tensors for each plane
*/
std::pair<D3DSurface2DTensor, D3DSurface2DTensor> create_tensor_nv12(const size_t height, const size_t width, const ID3D11Texture2D* nv12_surf) {
std::pair<D3DSurface2DTensor, D3DSurface2DTensor> create_tensor_nv12(const size_t height, const size_t width, ID3D11Texture2D* nv12_surf) {
ParamMap tensor_params = {{GPU_PARAM_KEY(SHARED_MEM_TYPE), GPU_PARAM_VALUE(VA_SURFACE)},
{GPU_PARAM_KEY(DEV_OBJECT_HANDLE), static_cast<gpu_handle_param>(nv12_surf)},
{GPU_PARAM_KEY(VA_PLANE), uint32_t(0)}};
@ -155,7 +158,7 @@ public:
* @param buffer A pointer to ID3D11Buffer instance to create remote tensor based on
* @return A remote tensor instance
*/
D3DBufferTensor create_tensor(const element::Type type, const Shape& shape, const ID3D11Buffer* buffer) {
D3DBufferTensor create_tensor(const element::Type type, const Shape& shape, ID3D11Buffer* buffer) {
ParamMap params = {{GPU_PARAM_KEY(SHARED_MEM_TYPE), GPU_PARAM_VALUE(DX_BUFFER)},
{GPU_PARAM_KEY(DEV_OBJECT_HANDLE), static_cast<gpu_handle_param>(buffer)}};
create_tensor(type, shape, params);

View File

@ -123,7 +123,12 @@ public:
* ExecutableNetwork::get_context() or Core::create_context() calls.
*/
class ClContext : public RemoteContext {
protected:
using RemoteContext::create_tensor;
/**
* @brief GPU device name
*/
static constexpr const char* device_name = "GPU";
public:

View File

@ -68,7 +68,6 @@ public:
*/
class VAContext : public ClContext {
using RemoteContext::create_tensor;
static constexpr const char* device_name = "GPU";
public:
/**
@ -76,8 +75,8 @@ public:
* @param remote_context remote context to check
*/
static void type_check(const RemoteContext& remote_context) {
remote_type_check(
remote_context.get_params(),
RemoteContext::type_check(
remote_context,
{{GPU_PARAM_KEY(VA_DEVICE), {}}, {GPU_PARAM_KEY(CONTEXT_TYPE), {GPU_PARAM_VALUE(VA_SHARED)}}});
}
@ -94,7 +93,7 @@ public:
* @param core OpenVINO Runtime Core object
* @param device A `VADisplay` to create remote context from
*/
VAContext(Core& core, VADisplay device) {
VAContext(Core& core, VADisplay device) : ClContext(core, (cl_context) nullptr) {
ParamMap context_params = {{GPU_PARAM_KEY(CONTEXT_TYPE), GPU_PARAM_VALUE(VA_SHARED)},
{GPU_PARAM_KEY(VA_DEVICE), static_cast<gpu_handle_param>(device)}};
*this = core.create_context(device_name, context_params);

View File

@ -331,7 +331,6 @@ using CreatePluginEngineFunc = void(std::shared_ptr<IInferencePlugin>&);
* @private
*/
using CreateExtensionFunc = void(std::shared_ptr<IExtension>&);
;
/**
* @def IE_CREATE_PLUGIN

View File

@ -28,7 +28,7 @@ static MemBandwidthPressure MemBandwidthPressureTolerance(
const float memThresholdAssumeLimited = MemBandwidthPressure::LIMITED) {
int total_convs = 0, mem_limited_convs = 0, compute_convs = 0, total_gemms = 0, mem_limited_gemms = 0,
total_deconvs = 0, compute_deconvs = 0, mem_limited_deconvs = 0;
auto memLimitedFactor = [&](int size_data_moved, int datatype_size = 4) -> float {
auto memLimitedFactor = [&](int size_data_moved, int datatype_size) -> float {
return (L2_cache_size * 1.0f /*util factor, tbd */
/ (size_data_moved * datatype_size));
};

View File

@ -123,32 +123,44 @@ function(ie_headers_compilation_with_custom_flags)
cmake_parse_arguments(IE_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(IE_TEST_PLUGIN_API)
set(IE_TEST_INCLUDE_DIRECTORY
$<TARGET_PROPERTY:inference_engine_plugin_api,INTERFACE_INCLUDE_DIRECTORIES>)
set(include_dirs
"${OpenVINO_SOURCE_DIR}/inference-engine/src/plugin_api/")
else()
set(IE_TEST_INCLUDE_DIRECTORY
$<TARGET_PROPERTY:inference_engine,INTERFACE_INCLUDE_DIRECTORIES>)
set(include_dirs
"${OpenVINO_SOURCE_DIR}/ngraph/core/include"
"${OpenVINO_SOURCE_DIR}/inference-engine/src/inference_engine/include/ie"
"${OpenVINO_SOURCE_DIR}/inference-engine/src/inference_engine/include/")
endif()
file(GLOB_RECURSE header_files RELATIVE "${IE_TEST_INCLUDE_DIRECTORY}"
"${IE_TEST_INCLUDE_DIRECTORY}/*")
foreach(include_dir IN LISTS include_dirs)
file(GLOB_RECURSE header_files_local RELATIVE "${include_dir}" "${include_dir}/*.hpp")
list(APPEND header_files ${header_files_local})
endforeach()
if(NOT IE_TEST_CXX_STANDARD)
set(IE_TEST_CXX_STANDARD ${CMAKE_CXX_STANDARD})
endif()
if(NOT IE_TEST_PLUGIN_API)
list(APPEND IE_TEST_HEADERS_TO_SKIP "_tbl.hpp")
if(NOT OPENCL_HEADERS_DIR)
list(APPEND IE_TEST_HEADERS_TO_SKIP "gpu/gpu_ocl_wrapper.hpp"
"gpu/gpu_context_api_ocl.hpp"
"gpu/gpu_context_api_va.hpp"
"gpu/gpu_context_api_dx.hpp")
"gpu/gpu_context_api_dx.hpp"
"gpu/gpu_ocl_wrapper.hpp"
"openvino/runtime/gpu/ocl_wrapper.hpp"
"openvino/runtime/gpu/ocl.hpp"
"openvino/runtime/gpu/va.hpp"
"openvino/runtime/gpu/dx.hpp")
endif()
if(NOT WIN32)
list(APPEND IE_TEST_HEADERS_TO_SKIP "gpu/gpu_context_api_dx.hpp")
list(APPEND IE_TEST_HEADERS_TO_SKIP "gpu/gpu_context_api_dx.hpp"
"openvino/runtime/gpu/dx.hpp")
endif()
if(NOT LIBVA_FOUND)
list(APPEND IE_TEST_HEADERS_TO_SKIP "gpu/gpu_context_api_va.hpp")
list(APPEND IE_TEST_HEADERS_TO_SKIP "gpu/gpu_context_api_va.hpp"
"openvino/runtime/gpu/va.hpp")
endif()
endif()
@ -157,7 +169,7 @@ function(ie_headers_compilation_with_custom_flags)
# skip user-passed headers
set(skip_current_file OFF)
foreach(skip_file IN LISTS IE_TEST_HEADERS_TO_SKIP)
if(header_file STREQUAL skip_file)
if("${header_file}" MATCHES "${skip_file}")
set(skip_current_file ON)
endif()
endforeach()
@ -187,8 +199,7 @@ function(ie_headers_compilation_with_custom_flags)
$<TARGET_PROPERTY:pugixml::static,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:openvino::itt,INTERFACE_INCLUDE_DIRECTORIES>)
target_include_directories(${target_name} PRIVATE
$<TARGET_PROPERTY:ngraph,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:inference_engine_preproc,INTERFACE_INCLUDE_DIRECTORIES>)
$<TARGET_PROPERTY:inference_engine_plugin_api,INTERFACE_INCLUDE_DIRECTORIES>)
else()
# OpenCL headers if any
if(OPENCL_HEADERS_DIR)
@ -233,12 +244,19 @@ endfunction()
ie_headers_compilation_with_custom_flags(TEST_SUFFIX Cxx17
CXX_STANDARD 17)
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
ie_headers_compilation_with_custom_flags(TEST_SUFFIX Cxx20
CXX_STANDARD 20)
endif()
if(UNIX)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
ie_headers_compilation_with_custom_flags(TEST_SUFFIX WarningsAreErrors
FLAGS -Wremarks -Wcheck -Werror-all -Werror -Wall)
else()
ie_headers_compilation_with_custom_flags(TEST_SUFFIX Pedantic FLAGS -Wpedantic)
elseif(BUILD_SHARED_LIBS)
# fix warnings wit RTTI
# ie_headers_compilation_with_custom_flags(TEST_SUFFIX Pedantic
# FLAGS -Wpedantic)
endif()
else()
ie_headers_compilation_with_custom_flags(TEST_SUFFIX WindowsAreErrors
@ -260,14 +278,21 @@ endif()
ie_headers_compilation_with_custom_flags(TEST_SUFFIX PluginApiCxx17
CXX_STANDARD 17 PLUGIN_API)
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
ie_headers_compilation_with_custom_flags(TEST_SUFFIX PluginApiCxx20
CXX_STANDARD 20 PLUGIN_API)
endif()
if(UNIX)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
ie_headers_compilation_with_custom_flags(TEST_SUFFIX PluginApiWarningsAreErrors
FLAGS -Werror-all -Werror -Wall
PLUGIN_API)
else()
ie_headers_compilation_with_custom_flags(TEST_SUFFIX PluginApiPedantic FLAGS -Wpedantic
PLUGIN_API)
elseif(BUILD_SHARED_LIBS)
# fix warnings wit RTTI
# ie_headers_compilation_with_custom_flags(TEST_SUFFIX PluginApiPedantic
# FLAGS -Wpedantic
# PLUGIN_API)
endif()
else()
ie_headers_compilation_with_custom_flags(TEST_SUFFIX PluginApiWindowsAreErrors