Generalized OpenCL handling (#15253)

* Squashed commit of the following:

commit 62c992f6a0bc3a2f559faac6912be9c5632a359f
Author: Ilya Lavrenov <ilya.lavrenov@intel.com>
Date:   Sun Jan 22 11:38:18 2023 +0400

    Generalized OpenCL handling

* Updates

* Fixes

* Update thirdparty/CMakeLists.txt

test

* Fixed build with CL/cl2.hpp

* Fixes

* Fixes

* Fixed compilation flags

* Fixed build with target OpenCL 120

* Don't use cache
This commit is contained in:
Ilya Lavrenov 2023-02-03 19:36:47 +04:00 committed by GitHub
parent f5fb22e205
commit de1631d67d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 474 additions and 237 deletions

View File

@ -120,7 +120,6 @@ jobs:
-DSELECTIVE_BUILD=COLLECT ^
-DCMAKE_C_COMPILER:PATH="$(MSVC_COMPILER_PATH)" ^
-DCMAKE_CXX_COMPILER:PATH="$(MSVC_COMPILER_PATH)" ^
-DENABLE_CLDNN=OFF ^
-DENABLE_INTEL_GPU=OFF ^
-DENABLE_MULTI=OFF ^
-DENABLE_AUTO=OFF ^
@ -166,7 +165,6 @@ jobs:
-DSELECTIVE_BUILD_STAT=$(BUILD_DIR)\*.csv ^
-DCMAKE_C_COMPILER:PATH="$(MSVC_COMPILER_PATH)" ^
-DCMAKE_CXX_COMPILER:PATH="$(MSVC_COMPILER_PATH)" ^
-DENABLE_CLDNN=OFF ^
-DENABLE_INTEL_GPU=OFF ^
-DENABLE_MULTI=OFF ^
-DENABLE_AUTO=OFF ^

View File

@ -14,11 +14,9 @@ ie_option (ENABLE_COMPILE_TOOL "Enables compile_tool" ON)
ie_option (ENABLE_STRICT_DEPENDENCIES "Skip configuring \"convinient\" dependencies for efficient parallel builds" ON)
ie_dependent_option (ENABLE_CLDNN "clDnn based plugin for OpenVINO Runtime" ON "X86_64;NOT APPLE;NOT MINGW;NOT WINDOWS_STORE;NOT WINDOWS_PHONE" OFF)
ie_dependent_option (ENABLE_INTEL_GPU "GPU plugin for OpenVINO Runtime on Intel GPU" ON "ENABLE_CLDNN" OFF)
ie_dependent_option (ENABLE_INTEL_GPU "GPU OpenCL-based plugin for OpenVINO Runtime" ON "X86_64;NOT APPLE;NOT MINGW;NOT WINDOWS_STORE;NOT WINDOWS_PHONE" OFF)
if (NOT ENABLE_CLDNN OR ANDROID OR
(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0))
if (ANDROID OR (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0))
# oneDNN doesn't support old compilers and android builds for now, so we'll
# build GPU plugin without oneDNN
set(ENABLE_ONEDNN_FOR_GPU_DEFAULT OFF)
@ -26,7 +24,7 @@ else()
set(ENABLE_ONEDNN_FOR_GPU_DEFAULT ON)
endif()
ie_option (ENABLE_ONEDNN_FOR_GPU "Enable oneDNN with GPU support" ${ENABLE_ONEDNN_FOR_GPU_DEFAULT})
ie_dependent_option (ENABLE_ONEDNN_FOR_GPU "Enable oneDNN with GPU support" ${ENABLE_ONEDNN_FOR_GPU_DEFAULT} "ENABLE_INTEL_GPU" OFF)
ie_option (ENABLE_PROFILING_ITT "Build with ITT tracing. Optionally configure pre-built ittnotify library though INTEL_VTUNE_DIR variable." OFF)
@ -112,7 +110,7 @@ ie_dependent_option(ENABLE_TBB_RELEASE_ONLY "Only Release TBB libraries are link
if(CMAKE_HOST_LINUX AND LINUX)
# Debian packages are enabled on Ubuntu systems
# so, system TBB / pugixml can be tried for usage
# so, system TBB / pugixml / OpenCL can be tried for usage
set(ENABLE_SYSTEM_LIBS_DEFAULT ON)
else()
set(ENABLE_SYSTEM_LIBS_DEFAULT OFF)
@ -125,6 +123,7 @@ else()
set(ENABLE_SYSTEM_TBB_DEFAULT ${ENABLE_SYSTEM_LIBS_DEFAULT})
endif()
# users wants to use his own TBB version, specific either via env vars or cmake options
if(DEFINED ENV{TBBROOT} OR DEFINED ENV{TBB_DIR} OR DEFINED TBB_DIR OR DEFINED TBBROOT)
set(ENABLE_SYSTEM_TBB_DEFAULT OFF)
endif()
@ -134,6 +133,8 @@ ie_dependent_option (ENABLE_SYSTEM_PUGIXML "use the system copy of pugixml" ${EN
ie_dependent_option (ENABLE_SYSTEM_TBB "use the system version of TBB" ${ENABLE_SYSTEM_TBB_DEFAULT} "THREADING MATCHES TBB" OFF)
ie_dependent_option (ENABLE_SYSTEM_OPENCL "Use the system version of OpenCL" ${ENABLE_SYSTEM_LIBS_DEFAULT} "BUILD_SHARED_LIBS;ENABLE_INTEL_GPU" OFF)
ie_option (ENABLE_DEBUG_CAPS "enable OpenVINO debug capabilities at runtime" OFF)
ie_dependent_option (ENABLE_GPU_DEBUG_CAPS "enable GPU debug capabilities at runtime" ON "ENABLE_DEBUG_CAPS" OFF)

View File

@ -90,8 +90,9 @@ macro(ov_cpack_settings)
# 2022 release series
# - 2022.1.0 is the last public release with debian packages from Intel install team
# - 2022.1.1, 2022.2 do not have debian packages enabled, distributed only as archives
# - 2022.3 is the first release where Debian updated packages are introduced
2022.3.0)
# - 2022.3 is the first release where Debian updated packages are introduced, others 2022.3.X are LTS
2022.3.0 2022.3.1 2022.3.2 2022.3.3 2022.3.4 2022.3.5
)
#
# core: base dependency for each component
@ -334,6 +335,7 @@ macro(ov_cpack_settings)
set(samples_build_deps "cmake, g++, gcc, libc6-dev, make, pkg-config")
set(samples_build_deps_suggest "libopencv-core-dev, libopencv-imgproc-dev, libopencv-imgcodecs-dev")
set(samples_opencl_suggest "ocl-icd-opencl-dev, opencl-headers")
if(OV_GLIBC_VERSION VERSION_LESS_EQUAL 2.27)
# Ubuntu 18.04, Debian 9 cases
set(json_library "nlohmann-json-dev")
@ -345,7 +347,7 @@ macro(ov_cpack_settings)
set(CPACK_COMPONENT_SAMPLES_DESCRIPTION "Intel(R) Distribution of OpenVINO(TM) Toolkit C / C++ Samples")
set(CPACK_COMPONENT_SAMPLES_DEPENDS "${OV_CPACK_COMP_CORE_DEV}")
set(CPACK_DEBIAN_SAMPLES_PACKAGE_NAME "openvino-samples-${cpack_name_ver}")
set(CPACK_DEBIAN_SAMPLES_PACKAGE_SUGGESTS "${samples_build_deps_suggest}, ${all_plugins_suggest}")
set(CPACK_DEBIAN_SAMPLES_PACKAGE_SUGGESTS "${samples_build_deps_suggest}, ${samples_opencl_suggest}, ${all_plugins_suggest}")
set(CPACK_DEBIAN_SAMPLES_PACKAGE_DEPENDS "libgflags-dev, zlib1g-dev, ${json_library}")
# can be skipped with --no-install-recommends
set(CPACK_DEBIAN_SAMPLES_PACKAGE_RECOMMENDS "${samples_build_deps}")

View File

@ -76,8 +76,8 @@ macro(ov_cpack_settings)
# 2022 release series
# - 2022.1.0 is the last public release with rpm packages from Intel install team
# - 2022.1.1, 2022.2 do not have rpm packages enabled, distributed only as archives
# - 2022.3 is the first release where RPM updated packages are introduced
2022.3.0
# - 2022.3 is the first release where RPM updated packages are introduced, others 2022.3.X are LTS
2022.3.0 2022.3.1 2022.3.2 2022.3.3 2022.3.4 2022.3.5
)
find_host_program(rpmlint_PROGRAM NAMES rpmlint DOC "Path to rpmlint")
@ -286,6 +286,7 @@ macro(ov_cpack_settings)
set(samples_build_deps "cmake3, gcc-c++, gcc, glibc-devel, make, pkgconf-pkg-config")
set(samples_build_deps_suggest "opencv-devel >= 3.0")
set(samples_opencl_deps_suggest "ocl-icd-devel, opencl-headers")
# c_samples / cpp_samples
set(CPACK_COMPONENT_SAMPLES_DESCRIPTION "Intel(R) Distribution of OpenVINO(TM) Toolkit C / C++ Samples")
@ -293,7 +294,7 @@ macro(ov_cpack_settings)
set(samples_package "${CPACK_RPM_SAMPLES_PACKAGE_NAME} = ${cpack_full_ver}")
# SUGGESTS may be unsupported, it's part of RPM 4.12.0 (Sep 16th 2014) only
# see https://rpm.org/timeline.html
set(CPACK_RPM_SAMPLES_PACKAGE_SUGGESTS "${samples_build_deps_suggest}, ${plugin_packages}")
set(CPACK_RPM_SAMPLES_PACKAGE_SUGGESTS "${samples_build_deps_suggest}, ${samples_opencl_deps_suggest}, ${plugin_packages}")
set(CPACK_RPM_SAMPLES_PACKAGE_REQUIRES "${core_dev_package}, ${samples_build_deps}, gflags-devel, json-devel, zlib-devel")
set(CPACK_RPM_SAMPLES_PACKAGE_ARCHITECTURE "noarch")

View File

@ -20,36 +20,8 @@ file(GLOB SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/*.c"
"${CMAKE_CURRENT_SOURCE_DIR}/gpu/*.cpp")
find_package(OpenCL)
find_path(OpenCL_HPP_INCLUDE_DIR
NAMES
CL/opencl.hpp OpenCL/opencl.hpp
HINTS
${opencl_root_hints}
ENV "PROGRAMFILES(X86)"
ENV AMDAPPSDKROOT
ENV INTELOCLSDKROOT
ENV NVSDKCOMPUTE_ROOT
ENV CUDA_PATH
ENV ATISTREAMSDKROOT
ENV OCL_ROOT
PATH_SUFFIXES
include
OpenCL/common/inc
"AMD APP/include")
if(TARGET OpenCL)
# Use OpenCL CPP headers from sources if present
set(OpenCL_HEADERS ${OPENCL_HEADERS_DIR})
set(OpenCL_LIB "OpenCL")
elseif(OpenCL_HPP_INCLUDE_DIR)
# Append OpenCL CPP headers to C headers and use both
set(OpenCL_HEADERS ${OpenCL_INCLUDE_DIR} ${OpenCL_HPP_INCLUDE_DIR})
set(OpenCL_LIB "OpenCL::OpenCL")
endif()
# remove GPU remote snippets if OCL hasn't been found
if (NOT (OpenCL_FOUND AND OpenCL_HEADERS))
# remove GPU remote snippets if OpenCL hasn't been found
if (NOT TARGET OpenCL::OpenCL)
list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/gpu/context_sharing_va.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/gpu/context_sharing.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/gpu/preprocessing.cpp"
@ -98,9 +70,8 @@ target_include_directories(${TARGET_NAME} PRIVATE "${OpenVINO_SOURCE_DIR}/src/in
"${OpenVINO_SOURCE_DIR}/src/frontends/common/include"
"${OpenVINO_SOURCE_DIR}/src/core/template_extension/new/")
if(OpenCL_FOUND AND OpenCL_HEADERS)
target_link_libraries(${TARGET_NAME} PRIVATE ${OpenCL_LIB})
target_include_directories(${TARGET_NAME} PRIVATE ${OpenCL_HEADERS})
if(TARGET OpenCL::OpenCL)
target_link_libraries(${TARGET_NAME} PRIVATE OpenCL::OpenCL)
if(libva_FOUND)
target_compile_definitions(${TARGET_NAME} PRIVATE ENABLE_LIBVA)

View File

@ -1,5 +1,4 @@
#include <openvino/runtime/core.hpp>
#define OV_GPU_USE_OPENCL_HPP
#include <openvino/runtime/intel_gpu/ocl/ocl.hpp>
cl::Context get_ocl_context(); // a function which returns cl context created on the app side

View File

@ -1,6 +1,5 @@
#ifdef ENABLE_LIBVA
#include <openvino/runtime/core.hpp>
#define OV_GPU_USE_OPENCL_HPP
#include <openvino/runtime/intel_gpu/ocl/va.hpp>
#include <openvino/runtime/intel_gpu/properties.hpp>
#include <openvino/core/preprocess/pre_post_process.hpp>

View File

@ -1,5 +1,4 @@
#include <openvino/runtime/core.hpp>
#define OV_GPU_USE_OPENCL_HPP
#include <openvino/runtime/intel_gpu/ocl/ocl.hpp>
#include <openvino/runtime/intel_gpu/properties.hpp>
#include <openvino/core/preprocess/pre_post_process.hpp>

View File

@ -1,5 +1,4 @@
#include <openvino/runtime/core.hpp>
#define OV_GPU_USE_OPENCL_HPP
#include <openvino/runtime/intel_gpu/ocl/ocl.hpp>

View File

@ -1,7 +1,5 @@
#include <openvino/runtime/core.hpp>
#include <openvino/runtime/intel_gpu/properties.hpp>
#define OV_GPU_USE_OPENCL_HPP
#include <openvino/runtime/intel_gpu/ocl/ocl.hpp>
#ifdef WIN32

View File

@ -48,6 +48,9 @@ if [ -f /etc/lsb-release ] || [ -f /etc/debian_version ] ; then
`# openvino main dependencies` \
libtbb-dev \
libpugixml-dev \
`# OpenCL for GPU` \
ocl-icd-opencl-dev \
opencl-headers \
`# GPU plugin extensions` \
libva-dev \
`# python API` \
@ -83,7 +86,8 @@ if [ -f /etc/lsb-release ] || [ -f /etc/debian_version ] ; then
elif [ -f /etc/redhat-release ] || grep -q "rhel" /etc/os-release ; then
# RHEL 8 / CentOS 7
yum update
yum install -y centos-release-scl epel-release
yum install -y centos-release-scl
yum install -y epel-release
yum install -y \
file \
`# build tools` \
@ -108,6 +112,9 @@ elif [ -f /etc/redhat-release ] || grep -q "rhel" /etc/os-release ; then
pugixml-devel \
`# GPU plugin dependency` \
libva-devel \
`# OpenCL for GPU` \
ocl-icd-devel \
opencl-headers \
`# python API` \
python3-pip \
python3-devel \
@ -148,11 +155,25 @@ else
fi
# cmake 3.20.0 or higher is required to build OpenVINO
current_cmake_ver=$(cmake --version | sed -ne 's/[^0-9]*\(\([0-9]\.\)\{0,4\}[0-9][^.]\).*/\1/p')
if command -v cmake &> /dev/null; then
cmake_command=cmake
elif command -v cmake3 &> /dev/null; then
cmake_command=cmake3
fi
current_cmake_ver=$($cmake_command --version | sed -ne 's/[^0-9]*\(\([0-9]\.\)\{0,4\}[0-9][^.]\).*/\1/p')
required_cmake_ver=3.20.0
if [ ! "$(printf '%s\n' "$required_cmake_ver" "$current_cmake_ver" | sort -V | head -n1)" = "$required_cmake_ver" ]; then
installed_cmake_ver=3.23.2
arch=$(uname -m)
if command -v apt-get &> /dev/null; then
apt-get install -y --no-install-recommends wget
else
yum install -y wget
fi
cmake_install_bin="cmake-${installed_cmake_ver}-linux-${arch}.sh"
github_cmake_release="https://github.com/Kitware/CMake/releases/download/v${installed_cmake_ver}/${cmake_install_bin}"
wget "${github_cmake_release}" -O "${cmake_install_bin}"

View File

@ -90,69 +90,62 @@ endif()
if(SAMPLES_ENABLE_OPENCL)
find_package(OpenCL QUIET)
if(NOT OpenCL_FOUND)
MESSAGE(WARNING "OpenCL is disabled or not found, ${TARGET_NAME} will be built without OpenCL support. Install OpenCL.")
message(WARNING "OpenCL is disabled or not found, ${TARGET_NAME} will be built without OpenCL support. Install OpenCL.")
endif()
set(opencl_header_search_params
HINTS
${opencl_root_hints}
PATHS
ENV "PROGRAMFILES(X86)"
ENV AMDAPPSDKROOT
ENV INTELOCLSDKROOT
ENV NVSDKCOMPUTE_ROOT
ENV CUDA_PATH
ENV ATISTREAMSDKROOT
ENV OCL_ROOT
PATH_SUFFIXES
"include"
"OpenCL/common/inc"
"AMD APP/include")
find_path(OpenCL_HPP_INCLUDE_DIR
NAMES
CL/opencl.hpp OpenCL/opencl.hpp
HINTS
${opencl_root_hints}
ENV "PROGRAMFILES(X86)"
ENV AMDAPPSDKROOT
ENV INTELOCLSDKROOT
ENV NVSDKCOMPUTE_ROOT
ENV CUDA_PATH
ENV ATISTREAMSDKROOT
ENV OCL_ROOT
PATH_SUFFIXES
include
OpenCL/common/inc
"AMD APP/include")
CL/opencl.hpp OpenCL/opencl.hpp
${opencl_header_search_params})
find_path(CL2_HPP_INCLUDE_DIR
NAMES
CL/cl2.hpp OpenCL/cl2.hpp
HINTS
${opencl_root_hints}
ENV "PROGRAMFILES(X86)"
ENV AMDAPPSDKROOT
ENV INTELOCLSDKROOT
ENV NVSDKCOMPUTE_ROOT
ENV CUDA_PATH
ENV ATISTREAMSDKROOT
ENV OCL_ROOT
PATH_SUFFIXES
include
OpenCL/common/inc
"AMD APP/include")
CL/cl2.hpp OpenCL/cl2.hpp
${opencl_header_search_params})
if(OpenCL_FOUND AND (OpenCL_HPP_INCLUDE_DIR OR CL2_HPP_INCLUDE_DIR))
set(OpenCL_DEFINITIONS HAVE_GPU_DEVICE_MEM_SUPPORT)
if(TARGET OpenCL)
# Use OpenCL CPP headers from sources if present
set(OpenCL_HEADERS ${OPENCL_HEADERS_DIR})
set(OpenCL_LIB "OpenCL")
elseif(OpenCL_HPP_INCLUDE_DIR OR CL2_HPP_INCLUDE_DIR)
# Append OpenCL CPP headers to C headers and use both
set(OpenCL_HEADERS ${OpenCL_INCLUDE_DIR})
if (OpenCL_HPP_INCLUDE_DIR)
list(APPEND ${OpenCL_HEADERS} ${OpenCL_HPP_INCLUDE_DIR})
endif()
if (CL2_HPP_INCLUDE_DIR)
list(APPEND ${OpenCL_HEADERS} ${CL2_HPP_INCLUDE_DIR})
endif()
set(OpenCL_LIB "OpenCL::OpenCL")
else()
MESSAGE(WARNING "OpenCL CPP header is not found, ${TARGET_NAME} will be built without OpenCL support. Download it from: https://github.com/KhronosGroup/OpenCL-CLHPP and set -Dopencl_root_hints=[PATH]/OpenCL-CLHPP/include to cmake.")
endif()
if(OpenCL_FOUND AND OpenCL_HEADERS)
target_link_libraries(${TARGET_NAME} PRIVATE ${OpenCL_LIB})
target_include_directories(${TARGET_NAME} PRIVATE ${OpenCL_HEADERS})
target_compile_definitions(${TARGET_NAME} PRIVATE HAVE_GPU_DEVICE_MEM_SUPPORT)
if (OpenCL_HPP_INCLUDE_DIR OR OPENCL_HEADERS_DIR)
if(OpenCL_HPP_INCLUDE_DIR)
list(APPEND OpenCL_HEADERS ${OpenCL_HPP_INCLUDE_DIR})
# the macro below is defined when opencl.hpp is found to suppress deprecation message from cl2.hpp
target_compile_definitions(${TARGET_NAME} PRIVATE OV_GPU_USE_OPENCL_HPP)
list(APPEND OpenCL_DEFINITIONS OV_GPU_USE_OPENCL_HPP)
endif()
if(CL2_HPP_INCLUDE_DIR)
list(APPEND OpenCL_HEADERS ${CL2_HPP_INCLUDE_DIR})
endif()
# cmake cannot set properties for imported targets
get_target_property(opencl_target OpenCL::OpenCL ALIASED_TARGET)
if(NOT TARGET ${opencl_target})
set(opencl_target OpenCL::OpenCL)
endif()
set_property(TARGET ${opencl_target} APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${OpenCL_HEADERS})
set_property(TARGET ${opencl_target} APPEND PROPERTY
INTERFACE_COMPILE_DEFINITIONS ${OpenCL_DEFINITIONS})
target_link_libraries(${TARGET_NAME} PRIVATE OpenCL::OpenCL)
else()
message(WARNING "OpenCL CPP header is not found, ${TARGET_NAME} will be built without OpenCL support. Download it from: https://github.com/KhronosGroup/OpenCL-CLHPP and set -Dopencl_root_hints=[PATH]/OpenCL-CLHPP/include to cmake.")
endif()
endif()

View File

@ -141,7 +141,7 @@ if(LINUX)
endif()
if(CMAKE_VERSION VERSION_LESS 3.15)
message(${message_mode} "Cmake version 3.15 and higher is required. Provided version ${CMAKE_VERSION}")
message(${message_mode} "Cmake version 3.15 and higher is required to build 'openvino' wheel. Provided version ${CMAKE_VERSION}")
set(ENABLE_WHEEL_DEFAULT OFF)
endif()

View File

@ -44,8 +44,6 @@ add_subdirectory(src/graph)
file(GLOB_RECURSE PLUGIN_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/plugin/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/include/intel_gpu/plugin/*.hpp)
addVersionDefines(src/plugin/plugin.cpp CI_BUILD_NUMBER)
ie_add_plugin(NAME ${TARGET_NAME}
DEVICE_NAME "GPU"
SOURCES ${PLUGIN_SOURCES}
@ -62,7 +60,7 @@ target_include_directories(${TARGET_NAME} PRIVATE
set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO})
# Workaround to avoid warnings during LTO build
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(${TARGET_NAME} PROPERTIES LINK_FLAGS_RELEASE "-Wno-error=maybe-uninitialized -Wno-maybe-uninitialized"
LINK_FLAGS_RELWITHDEBINFO "-Wno-error=maybe-uninitialized -Wno-maybe-uninitialized")
endif()

View File

@ -12,10 +12,6 @@
# define NOMINMAX
#endif
#ifndef OV_GPU_USE_OPENCL_HPP
#define OV_GPU_USE_OPENCL_HPP
#endif
#ifdef _WIN32
# include <gpu/gpu_context_api_dx.hpp>
#else

View File

@ -18,10 +18,6 @@
# define NOMINMAX
#endif
#ifndef OV_GPU_USE_OPENCL_HPP
#define OV_GPU_USE_OPENCL_HPP
#endif
#ifdef _WIN32
# include <gpu/gpu_context_api_dx.hpp>
#else

View File

@ -4,3 +4,4 @@
typedef cl_uint VASurfaceID;
typedef void* VADisplay;
typedef void* VAImageFormat;

View File

@ -33,7 +33,7 @@ target_include_directories(${TARGET_NAME} PUBLIC
target_compile_options(${TARGET_NAME} PRIVATE
$<$<CONFIG:Release>:$<IF:$<CXX_COMPILER_ID:MSVC>,/Os,-Os>>)
target_link_libraries(${TARGET_NAME} PUBLIC OpenCL)
target_link_libraries(${TARGET_NAME} PUBLIC OpenCL::OpenCL)
target_link_libraries(${TARGET_NAME} PRIVATE openvino_intel_gpu_kernels
openvino_intel_gpu_runtime
ov_shape_inference

View File

@ -70,7 +70,7 @@ if(COMMAND add_cpplint_target)
add_cpplint_target(${TARGET_NAME}_cpplint FOR_TARGETS ${TARGET_NAME})
endif()
target_link_libraries(${TARGET_NAME} PUBLIC OpenCL rapidjson inference_engine_plugin_api)
target_link_libraries(${TARGET_NAME} PUBLIC OpenCL::OpenCL rapidjson inference_engine_plugin_api)
set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO})

View File

@ -30,18 +30,24 @@ endif()
target_include_directories(${TARGET_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${INCLUDE_DIR}>)
target_compile_options(${TARGET_NAME} PRIVATE
$<$<CONFIG:Release>:$<IF:$<CXX_COMPILER_ID:MSVC>,/Os,-Os>>)
if(COMMAND add_cpplint_target)
add_cpplint_target(${TARGET_NAME}_cpplint FOR_TARGETS ${TARGET_NAME})
endif()
target_compile_options(${TARGET_NAME} PRIVATE
$<$<CONFIG:Release>:
$<IF:$<CXX_COMPILER_ID:MSVC>,/Os,-Os
>
>
$<$<CXX_COMPILER_ID:GNU>:
$<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,6.0>:
-Wno-ignored-attributes
>
>)
add_cpplint_target(${TARGET_NAME}_cpplint FOR_TARGETS ${TARGET_NAME})
set_ie_threading_interface_for(${TARGET_NAME})
target_link_libraries(${TARGET_NAME} PRIVATE
OpenCL
OpenCL::OpenCL
openvino::itt
inference_engine_plugin_api
)

View File

@ -248,7 +248,7 @@ void kernels_cache::build_batch(const engine& build_engine, const batch_program&
cl::Program program(cl_build_engine.get_cl_context(), batch.source);
{
OV_ITT_SCOPED_TASK(ov::intel_gpu::itt::domains::intel_gpu_plugin, "KernelsCache::BuildProgram::RunCompilation");
if (program.build(cl_build_engine.get_cl_device(), batch.options.c_str()) != CL_SUCCESS)
if (program.build({cl_build_engine.get_cl_device()}, batch.options.c_str()) != CL_SUCCESS)
throw std::runtime_error("Failed in building program.");
}
@ -272,7 +272,7 @@ void kernels_cache::build_batch(const engine& build_engine, const batch_program&
}
} else {
cl::Program program(cl_build_engine.get_cl_context(), {cl_build_engine.get_cl_device()}, precompiled_kernels);
if (program.build(cl_build_engine.get_cl_device(), batch.options.c_str()) != CL_SUCCESS)
if (program.build({cl_build_engine.get_cl_device()}, batch.options.c_str()) != CL_SUCCESS)
throw std::runtime_error("Failed in building program with a precompiled kernel.");
program.createKernels(&kernels);
@ -522,7 +522,7 @@ void kernels_cache::save(BinaryOutputBuffer& ob) const {
try {
cl::vector<cl::Kernel> kernels;
cl::Program programs(build_engine->get_cl_context(), {build_engine->get_cl_device()}, binary_kernels);
programs.build(build_engine->get_cl_device());
programs.build({build_engine->get_cl_device()});
programs.createKernels(&kernels);
for (auto& k : kernels) {
@ -561,7 +561,7 @@ void kernels_cache::load(BinaryInputBuffer& ib) {
for (auto& binary_kernels : precompiled_kernels) {
cl::vector<cl::Kernel> kernels;
cl::Program program(build_engine->get_cl_context(), {build_engine->get_cl_device()}, {binary_kernels});
program.build(build_engine->get_cl_device());
program.build({build_engine->get_cl_device()});
program.createKernels(&kernels);
for (auto& k : kernels) {

View File

@ -7,37 +7,244 @@
///
#pragma once
#include <array>
#ifdef OV_GPU_USE_OPENCL_HPP
#include <CL/opencl.hpp>
#else
#include <CL/cl2.hpp>
#endif
#include <CL/cl_ext.h>
#define NOMINMAX
#ifdef _WIN32
#include <CL/cl_d3d11.h>
# define NOMINMAX
# include <CL/cl_d3d11.h>
typedef cl_d3d11_device_source_khr cl_device_source_intel;
typedef cl_d3d11_device_set_khr cl_device_set_intel;
#else
#include <CL/cl_va_api_media_sharing_intel.h>
# include <CL/cl_va_api_media_sharing_intel.h>
typedef cl_va_api_device_source_intel cl_device_source_intel;
typedef cl_va_api_device_set_intel cl_device_set_intel;
#endif
/********************************************
* cl_intel_required_subgroup_size extension *
*********************************************/
#if !defined(cl_intel_required_subgroup_size)
#define cl_intel_required_subgroup_size 1
// cl_intel_required_subgroup_size
#define CL_DEVICE_SUB_GROUP_SIZES_INTEL 0x4108
// cl_intel_device_attribute_query
#define CL_DEVICE_IP_VERSION_INTEL 0x4250
#define CL_DEVICE_ID_INTEL 0x4251
#define CL_DEVICE_NUM_SLICES_INTEL 0x4252
#define CL_DEVICE_NUM_SUB_SLICES_PER_SLICE_INTEL 0x4253
#define CL_DEVICE_NUM_EUS_PER_SUB_SLICE_INTEL 0x4254
#define CL_DEVICE_NUM_THREADS_PER_EU_INTEL 0x4255
#define CL_DEVICE_FEATURE_CAPABILITIES_INTEL 0x4256
#endif // cl_intel_required_subgroup_size
namespace cl {
namespace detail {
CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SUB_GROUP_SIZES_INTEL, vector<size_type>)
} // namespace detail
} // namespace cl
/***************************************************************
* cl_intel_command_queue_families
***************************************************************/
#if !defined(cl_intel_command_queue_families)
#define cl_intel_command_queue_families 1
typedef cl_bitfield cl_command_queue_capabilities_intel;
#define CL_QUEUE_FAMILY_MAX_NAME_SIZE_INTEL 64
typedef struct _cl_queue_family_properties_intel {
cl_command_queue_properties properties;
cl_command_queue_capabilities_intel capabilities;
cl_uint count;
char name[CL_QUEUE_FAMILY_MAX_NAME_SIZE_INTEL];
} cl_queue_family_properties_intel;
/* cl_device_info */
#define CL_DEVICE_QUEUE_FAMILY_PROPERTIES_INTEL 0x418B
/* cl_queue_properties */
#define CL_QUEUE_FAMILY_INTEL 0x418C
#define CL_QUEUE_INDEX_INTEL 0x418D
/* cl_command_queue_capabilities_intel */
#define CL_QUEUE_DEFAULT_CAPABILITIES_INTEL 0
#endif // cl_intel_command_queue_families
/*******************************************
* cl_intel_unified_shared_memory extension *
********************************************/
#if !defined(cl_intel_unified_shared_memory)
#define cl_intel_unified_shared_memory 1
/* cl_mem_alloc_info_intel */
#define CL_MEM_ALLOC_TYPE_INTEL 0x419A
#define CL_MEM_ALLOC_SIZE_INTEL 0x419C
/* cl_unified_shared_memory_type_intel */
#define CL_MEM_TYPE_UNKNOWN_INTEL 0x4196
#define CL_MEM_TYPE_HOST_INTEL 0x4197
#define CL_MEM_TYPE_DEVICE_INTEL 0x4198
#define CL_MEM_TYPE_SHARED_INTEL 0x4199
/* cl_device_info */
#define CL_DEVICE_HOST_MEM_CAPABILITIES_INTEL 0x4190
#define CL_DEVICE_DEVICE_MEM_CAPABILITIES_INTEL 0x4191
#define CL_DEVICE_SINGLE_DEVICE_SHARED_MEM_CAPABILITIES_INTEL 0x4192
/* cl_device_unified_shared_memory_capabilities_intel - bitfield */
#define CL_UNIFIED_SHARED_MEMORY_ACCESS_INTEL (1 << 0)
typedef cl_ulong cl_properties;
typedef cl_properties cl_mem_properties_intel;
typedef cl_uint cl_mem_info_intel;
typedef cl_uint cl_unified_shared_memory_type_intel;
typedef cl_bitfield cl_device_unified_shared_memory_capabilities_intel;
typedef cl_int (CL_API_CALL *
clMemFreeINTEL_fn)(
cl_context context,
void* ptr);
typedef cl_int (CL_API_CALL *
clSetKernelArgMemPointerINTEL_fn)(
cl_kernel kernel,
cl_uint arg_index,
const void* arg_value);
typedef cl_int (CL_API_CALL *
clEnqueueMemcpyINTEL_fn)(
cl_command_queue command_queue,
cl_bool blocking,
void* dst_ptr,
const void* src_ptr,
size_t size,
cl_uint num_events_in_wait_list,
const cl_event* event_wait_list,
cl_event* event);
typedef void* (CL_API_CALL *
clHostMemAllocINTEL_fn)(
cl_context context,
const cl_mem_properties_intel* properties,
size_t size,
cl_uint alignment,
cl_int* errcode_ret);
typedef void* (CL_API_CALL *
clSharedMemAllocINTEL_fn)(
cl_context context,
cl_device_id device,
const cl_mem_properties_intel* properties,
size_t size,
cl_uint alignment,
cl_int* errcode_ret);
typedef void* (CL_API_CALL *
clDeviceMemAllocINTEL_fn)(
cl_context context,
cl_device_id device,
const cl_mem_properties_intel* properties,
size_t size,
cl_uint alignment,
cl_int* errcode_ret);
typedef cl_int (CL_API_CALL *
clGetMemAllocInfoINTEL_fn)(
cl_context context,
const void* ptr,
cl_mem_info_intel param_name,
size_t param_value_size,
void* param_value,
size_t* param_value_size_ret);
typedef cl_int (CL_API_CALL *
clEnqueueMemsetINTEL_fn)( /* Deprecated */
cl_command_queue command_queue,
void* dst_ptr,
cl_int value,
size_t size,
cl_uint num_events_in_wait_list,
const cl_event* event_wait_list,
cl_event* event);
typedef cl_int (CL_API_CALL *
clEnqueueMemFillINTEL_fn)(
cl_command_queue command_queue,
void* dst_ptr,
const void* pattern,
size_t pattern_size,
size_t size,
cl_uint num_events_in_wait_list,
const cl_event* event_wait_list,
cl_event* event);
#endif // cl_intel_unified_shared_memory
/********************************
* cl_intel_planar_yuv extension *
*********************************/
#if !defined(CL_NV12_INTEL)
#define CL_NV12_INTEL 0x410E
#endif // CL_NV12_INTEL
#if !defined(CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)
#define CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL (1 << 25)
#endif // CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL
/*********************************
* cl_khr_device_uuid extension
*********************************/
#if !defined(cl_khr_device_uuid)
#define cl_khr_device_uuid 1
#define CL_UUID_SIZE_KHR 16
#define CL_DEVICE_UUID_KHR 0x106A
// for C++ wrappers
using uuid_array = std::array<cl_uchar, CL_UUID_SIZE_KHR>;
namespace cl {
namespace detail {
CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_UUID_KHR, uuid_array)
} // namespace detail
} // namespace cl
#endif // cl_khr_device_uuid
/***************************************************************
* cl_intel_device_attribute_query
***************************************************************/
#if !defined(cl_intel_device_attribute_query)
#define cl_intel_device_attribute_query 1
typedef cl_bitfield cl_device_feature_capabilities_intel;
/* For GPU devices, version 1.0.0: */
/* cl_device_feature_capabilities_intel */
#define CL_DEVICE_FEATURE_FLAG_DP4A_INTEL (1 << 0)
#define CL_DEVICE_FEATURE_FLAG_DPAS_INTEL (1 << 1)
#define CL_DEVICE_FEATURE_FLAG_DP4A_INTEL (1 << 0)
#define CL_DEVICE_FEATURE_FLAG_DPAS_INTEL (1 << 1)
/* cl_device_info */
#define CL_DEVICE_IP_VERSION_INTEL 0x4250
#define CL_DEVICE_ID_INTEL 0x4251
#define CL_DEVICE_NUM_SLICES_INTEL 0x4252
#define CL_DEVICE_NUM_SUB_SLICES_PER_SLICE_INTEL 0x4253
#define CL_DEVICE_NUM_EUS_PER_SUB_SLICE_INTEL 0x4254
#define CL_DEVICE_NUM_THREADS_PER_EU_INTEL 0x4255
#define CL_DEVICE_FEATURE_CAPABILITIES_INTEL 0x4256
#endif // cl_intel_device_attribute_query
#define CL_HPP_PARAM_NAME_CL_INTEL_COMMAND_QUEUE_FAMILIES_(F) \
F(cl_device_info, CL_DEVICE_QUEUE_FAMILY_PROPERTIES_INTEL, cl::vector<cl_queue_family_properties_intel>) \
@ -47,7 +254,6 @@ typedef cl_bitfield cl_device_feature_capabilities_intel;
namespace cl {
namespace detail {
CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SUB_GROUP_SIZES_INTEL, vector<size_type>)
CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_IP_VERSION_INTEL, cl_uint)
CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_ID_INTEL, cl_uint)
CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_NUM_SLICES_INTEL, cl_uint)

View File

@ -4,7 +4,7 @@
# TODO: fix in tests
if(SUGGEST_OVERRIDE_SUPPORTED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-suggest-override")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-suggest-override")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
@ -57,7 +57,7 @@ set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_REL
target_link_libraries(${TARGET_NAME} PRIVATE openvino_intel_gpu_graph
inference_engine
OpenCL
OpenCL::OpenCL
gtest
gtest_main
gflags

View File

@ -85,7 +85,7 @@ TEST(mem_perf_test_to_device, DISABLED_buffer_no_lock) {
std::cout << "Time of kernel execution" << std::endl;
cl::Program program(ctx, kernel_code);
checkStatus(program.build(device, ""), "build");
checkStatus(program.build({device}, ""), "build");
cl::Buffer input_buffer(ctx, CL_MEM_READ_WRITE, sizeof(uint8_t) * img_size * img_size);
cl::Buffer output_buffer(ctx, CL_MEM_READ_WRITE, sizeof(float) * img_size * img_size);
cl::Kernel kernel(program, "simple_reorder");
@ -109,7 +109,7 @@ TEST(mem_perf_test_to_device, DISABLED_buffer_lock_rw) {
std::cout << "Time of copying data from mapped to host cl::Buffer (ReadWrite access modifier) to device memory" << std::endl;
cl::Program program(ctx, kernel_code);
checkStatus(program.build(device, ""), "build");
checkStatus(program.build({device}, ""), "build");
cl::Buffer input_buffer(ctx, CL_MEM_READ_WRITE, sizeof(uint8_t) * img_size * img_size);
cl::Buffer output_buffer(ctx, CL_MEM_READ_WRITE, sizeof(float) * img_size * img_size);
cl::Kernel kernel(program, "simple_reorder");
@ -142,7 +142,7 @@ TEST(mem_perf_test_to_device, DISABLED_buffer_lock_w) {
std::cout << "Time of copying data from mapped to host cl::Buffer (Write access modifier) to device memory" << std::endl;
cl::Program program(ctx, kernel_code);
checkStatus(program.build(device, ""), "build");
checkStatus(program.build({device}, ""), "build");
cl::Buffer input_buffer(ctx, CL_MEM_READ_WRITE, sizeof(uint8_t) * img_size * img_size);
cl::Buffer output_buffer(ctx, CL_MEM_READ_WRITE, sizeof(float) * img_size * img_size);
cl::Kernel kernel(program, "simple_reorder");
@ -175,7 +175,7 @@ TEST(mem_perf_test_to_device, DISABLED_buffer_copy) {
std::cout << "Time of copying data from host buffer (std::vector) to cl::Buffer located in device memory" << std::endl;
cl::Program program(ctx, kernel_code);
checkStatus(program.build(device, ""), "build");
checkStatus(program.build({device}, ""), "build");
cl::Buffer input_buffer(ctx, CL_MEM_READ_WRITE, sizeof(uint8_t) * img_size * img_size);
cl::Buffer output_buffer(ctx, CL_MEM_READ_WRITE, sizeof(float) * img_size * img_size);
cl::Kernel kernel(program, "simple_reorder");
@ -212,7 +212,7 @@ TEST(mem_perf_test_to_device, DISABLED_buffer_copy_usm_host) {
std::cout << "Time of copying data from host buffer cl::UsmMemory (UsmHost type) to cl::Buffer located in device memory" << std::endl;
cl::Program program(ctx, kernel_code);
checkStatus(program.build(device, ""), "build");
checkStatus(program.build({device}, ""), "build");
cl::Buffer input_buffer(ctx, CL_MEM_READ_WRITE, sizeof(uint8_t) * img_size * img_size);
cl::Buffer output_buffer(ctx, CL_MEM_READ_WRITE, sizeof(float) * img_size * img_size);
cl::Kernel kernel(program, "simple_reorder");
@ -252,7 +252,7 @@ TEST(mem_perf_test_to_device, DISABLED_usm_host) {
std::cout << "Time of transfering data from host buffer cl::UsmMemory (UsmHost type) to device" << std::endl;
cl::Program program(ctx, kernel_code);
checkStatus(program.build(device, ""), "build");
checkStatus(program.build({device}, ""), "build");
cl::UsmMemory input_buffer(usm_helper);
input_buffer.allocateHost(sizeof(uint8_t) * img_size * img_size);
cl::UsmMemory output_buffer(usm_helper);
@ -296,7 +296,7 @@ TEST(mem_perf_test_to_device, DISABLED_usm_device) {
std::cout << "Time of copying data from device buffer cl::UsmMemory (UsmDevice type) to cl::UsmMemory (UsmDevice type)" << std::endl;
cl::Program program(ctx, kernel_code);
checkStatus(program.build(device, ""), "build");
checkStatus(program.build({device}, ""), "build");
cl::UsmMemory input_buffer_host(usm_helper);
input_buffer_host.allocateHost(sizeof(uint8_t) * img_size * img_size);
cl::UsmMemory input_buffer_device(usm_helper);
@ -361,7 +361,7 @@ TEST(mem_perf_test_to_device, DISABLED_usm_device_copy) {
std::cout << "Time of copying data from host buffer cl::UsmMemory (UsmHost type) to cl::UsmMemory (UsmDevice type)" << std::endl;
cl::Program program(ctx, kernel_code);
checkStatus(program.build(device, ""), "build");
checkStatus(program.build({device}, ""), "build");
cl::UsmMemory input_buffer_host(usm_helper);
input_buffer_host.allocateHost(sizeof(uint8_t) * img_size * img_size);
cl::UsmMemory input_buffer_device(usm_helper);
@ -416,7 +416,7 @@ TEST(mem_perf_test_to_device, DISABLED_cl_buffer_to_usm_device) {
std::cout << "Time of kernel execution w/o copying the data (input buffer is cl::Buffer located in device memory)" << std::endl;
cl::Program program(ctx, kernel_code);
checkStatus(program.build(device, ""), "build");
checkStatus(program.build({device}, ""), "build");
cl::Buffer input_buffer(ctx, CL_MEM_READ_WRITE, sizeof(uint8_t) * img_size * img_size);
cl::UsmMemory input_buffer_host(usm_helper);
input_buffer_host.allocateHost(sizeof(uint8_t) * img_size * img_size);
@ -462,7 +462,7 @@ TEST(mem_perf_test_to_host, DISABLED_buffer_lock_rw) {
std::cout << "Time of copying data from device buffer (cl::Buffer) to host via buffer mapping (ReadWrite access modifier)" << std::endl;
cl::Program program(ctx, kernel_code);
checkStatus(program.build(device, ""), "build");
checkStatus(program.build({device}, ""), "build");
cl::Buffer input_buffer(ctx, CL_MEM_READ_WRITE, sizeof(uint8_t) * img_size * img_size);
cl::Buffer output_buffer(ctx, CL_MEM_READ_WRITE, sizeof(float) * img_size * img_size);
cl::Kernel kernel(program, "simple_reorder");
@ -506,7 +506,7 @@ TEST(mem_perf_test_to_host, DISABLED_buffer_lock_r) {
std::cout << "Time of copying data from device buffer (cl::Buffer) to host via buffer mapping (Read access modifier)" << std::endl;
cl::Program program(ctx, kernel_code);
checkStatus(program.build(device, ""), "build");
checkStatus(program.build({device}, ""), "build");
cl::Buffer input_buffer(ctx, CL_MEM_READ_WRITE, sizeof(uint8_t) * img_size * img_size);
cl::Buffer output_buffer(ctx, CL_MEM_READ_WRITE, sizeof(float) * img_size * img_size);
cl::Kernel kernel(program, "simple_reorder");
@ -560,7 +560,7 @@ TEST(mem_perf_test_to_host, DISABLED_buffer_copy_usm_host_ptr_blocking_r) {
std::cout << "Time of copying data from device buffer (cl::Buffer) to host buffer cl::UsmMemory (UsmHost type) - Bloking call" << std::endl;
cl::Program program(ctx, kernel_code);
checkStatus(program.build(device, ""), "build");
checkStatus(program.build({device}, ""), "build");
cl::Buffer input_buffer(ctx, CL_MEM_READ_WRITE, sizeof(uint8_t) * img_size * img_size);
cl::Buffer output_buffer(ctx, CL_MEM_READ_WRITE, sizeof(float) * img_size * img_size);
cl::Kernel kernel(program, "simple_reorder");
@ -601,7 +601,7 @@ TEST(mem_perf_test_to_host, DISABLED_buffer_copy_usm_host_ptr_events_r) {
std::cout << "Time of copying data from device buffer (cl::Buffer) to host buffer cl::UsmMemory (UsmHost type) - Non-blocling call (events)" << std::endl;
cl::Program program(ctx, kernel_code);
checkStatus(program.build(device, ""), "build");
checkStatus(program.build({device}, ""), "build");
cl::Buffer input_buffer(ctx, CL_MEM_READ_WRITE, sizeof(uint8_t) * img_size * img_size);
cl::Buffer output_buffer(ctx, CL_MEM_READ_WRITE, sizeof(float) * img_size * img_size);
cl::Kernel kernel(program, "simple_reorder");
@ -644,7 +644,7 @@ TEST(mem_perf_test_to_host, DISABLED_buffer_copy_host_ptr_events_r) {
std::cout << "Time of copying data from device buffer (cl::Buffer) to host buffer (std::vector) - Non-blocling call (events)" << std::endl;
cl::Program program(ctx, kernel_code);
checkStatus(program.build(device, ""), "build");
checkStatus(program.build({device}, ""), "build");
cl::Buffer input_buffer(ctx, CL_MEM_READ_WRITE, sizeof(uint8_t) * img_size * img_size);
cl::Buffer output_buffer(ctx, CL_MEM_READ_WRITE, sizeof(float) * img_size * img_size);
cl::Kernel kernel(program, "simple_reorder");
@ -687,7 +687,7 @@ TEST(mem_perf_test_to_host_and_back_to_device, DISABLED_buffer_copy_usm_host_ptr
<< "and back to device (cl::Buffer) - Non-blocling calls (events)" << std::endl;
cl::Program program(ctx, kernel_code);
checkStatus(program.build(device, ""), "build");
checkStatus(program.build({device}, ""), "build");
cl::Buffer input_buffer(ctx, CL_MEM_READ_WRITE, sizeof(uint8_t) * img_size * img_size);
cl::Buffer output_buffer(ctx, CL_MEM_READ_WRITE, sizeof(float) * img_size * img_size);
cl::Kernel kernel(program, "simple_reorder");
@ -732,7 +732,7 @@ TEST(mem_perf_test_to_host_and_back_to_device, DISABLED_buffer_copy_host_ptr_eve
std::cout << "Time of copying data from device buffer (cl::Buffer) to host buffer (std::vector) and back to device (cl::Buffer) - Non-blocling calls (events)" << std::endl;
cl::Program program(ctx, kernel_code);
checkStatus(program.build(device, ""), "build");
checkStatus(program.build({device}, ""), "build");
cl::Buffer input_buffer(ctx, CL_MEM_READ_WRITE, sizeof(uint8_t) * img_size * img_size);
cl::Buffer output_buffer(ctx, CL_MEM_READ_WRITE, sizeof(float) * img_size * img_size);
cl::Kernel kernel(program, "simple_reorder");

View File

@ -79,7 +79,6 @@ if(ENABLE_ONEDNN_FOR_GPU)
"-DDNNL_LIBRARY_TYPE=STATIC"
"-DOpenCL_LIBRARY=${OpenCL_LIBRARY}"
"-DOpenCL_INCLUDE_DIR=${OpenCL_INCLUDE_DIR}"
"-DOPENCL_VERSION_2_2=${OPENCL_VERSION_2_2}"
)
add_library(onednn_gpu_tgt INTERFACE)
set_target_properties(onednn_gpu_tgt PROPERTIES

View File

@ -15,7 +15,8 @@ addIeTargetTest(
openvino_intel_gpu_plugin
LINK_LIBRARIES
funcSharedTests
OpenCL
OpenCL::NewHeaders # should come before OpenCL::OpenCL
OpenCL::OpenCL
ADD_CPPLINT
LABELS
GPU

View File

@ -29,10 +29,6 @@
#define NOMINMAX_DEFINED_CTX_UT
#endif
#ifndef OV_GPU_USE_OPENCL_HPP
# define OV_GPU_USE_OPENCL_HPP
#endif
#include <gpu/gpu_context_api_dx.hpp>
#include <openvino/runtime/intel_gpu/ocl/dx.hpp>
#include <atlbase.h>

View File

@ -7,8 +7,6 @@
#include <vector>
#include <memory>
#define OV_GPU_USE_OPENCL_HPP
#include "openvino/runtime/intel_gpu/ocl/ocl.hpp"
#include "openvino/runtime/core.hpp"
#include "openvino/runtime/intel_gpu/properties.hpp"

View File

@ -11,10 +11,6 @@
# define NOMINMAX
#endif
#ifndef OV_GPU_USE_OPENCL_HPP
# define OV_GPU_USE_OPENCL_HPP
#endif
#ifdef _WIN32
# include <gpu/gpu_context_api_dx.hpp>
#elif defined ENABLE_LIBVA

View File

@ -4,8 +4,6 @@
#include "behavior/executable_network/get_metric.hpp"
#define OV_GPU_USE_OPENCL_HPP
#ifdef _WIN32
# include "gpu/gpu_context_api_dx.hpp"
#elif defined ENABLE_LIBVA

View File

@ -7,8 +7,6 @@
#include "behavior/ov_plugin/core_integration.hpp"
#include "openvino/runtime/intel_gpu/properties.hpp"
#define OV_GPU_USE_OPENCL_HPP
#ifdef _WIN32
# include "gpu/gpu_context_api_dx.hpp"
#elif defined ENABLE_LIBVA

View File

@ -4,8 +4,6 @@
#include "behavior/plugin/core_integration.hpp"
#define OV_GPU_USE_OPENCL_HPP
#ifdef _WIN32
# include "gpu/gpu_context_api_dx.hpp"
#elif defined ENABLE_LIBVA

View File

@ -4,9 +4,6 @@
#include <string>
#include <vector>
#ifndef OV_GPU_USE_OPENCL_HPP
# define OV_GPU_USE_OPENCL_HPP
#endif
#include "openvino/runtime/intel_gpu/ocl/ocl.hpp"
#include "openvino/runtime/core.hpp"
#include "openvino/runtime/properties.hpp"

View File

@ -2,6 +2,13 @@
# SPDX-License-Identifier: Apache-2.0
#
# Android toolchain does not provide pkg-config file. So, cmake mistakenly uses
# build system pkg-config executable, which finds packages on build system. Such
# libraries cannot be linked into Android binaries.
if(NOT ANDROID)
find_package(PkgConfig QUIET)
endif()
if(SUGGEST_OVERRIDE_SUPPORTED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-suggest-override")
endif()
@ -19,29 +26,104 @@ if(ENABLE_SAMPLES OR ENABLE_TESTS)
add_subdirectory(cnpy EXCLUDE_FROM_ALL)
endif()
if(ENABLE_INTEL_GPU)
add_subdirectory(ocl)
endif()
add_subdirectory(xbyak EXCLUDE_FROM_ALL)
openvino_developer_export_targets(COMPONENT openvino_common TARGETS xbyak)
ov_install_static_lib(xbyak ${OV_CPACK_COMP_CORE})
#
# OpenCL
#
if(ENABLE_INTEL_GPU)
if(ENABLE_SYSTEM_OPENCL)
# try to find system OpenCL (installed via 'brew install opencl-icd-loader')
find_package(OpenCLICDLoader QUIET)
if(OpenCLICDLoader_FOUND)
# 'brew install opencl-headers'
find_package(OpenCLHeaders QUIET)
if(NOT OpenCLHeaders_FOUND)
message(FATAL_ERROR "OpenCLHeaders not found, but OpenCLICDLoader is installed. Please, install OpenCL headers")
else()
set_target_properties(OpenCL::Headers PROPERTIES IMPORTED_GLOBAL ON)
endif()
else()
# try to find system OpenCL:
# - 'sudo -E apt-get install opencl-headers ocl-icd-opencl-dev'
# - 'sudo -E yum install ocl-icd-devel opencl-headers'
# - 'conda install khronos-opencl-icd-loader -c conda-forge'
find_package(OpenCL QUIET)
endif()
endif()
if(TARGET OpenCL::OpenCL)
set_target_properties(OpenCL::OpenCL PROPERTIES IMPORTED_GLOBAL ON)
# try to find CL/opencl.hpp
find_file(OpenCL_HPP
NAMES CL/opencl.hpp OpenCL/opencl.hpp
HINTS ${OpenCL_INCLUDE_DIRS}
DOC "Path to CL/opencl.hpp")
# add definition to select proper header and suppress warnings
if(OpenCL_HPP)
set_target_properties(OpenCL::OpenCL PROPERTIES
INTERFACE_COMPILE_DEFINITIONS OV_GPU_USE_OPENCL_HPP)
endif()
# set variables for onednn_gpu
if(OpenCLHeaders_FOUND)
set(OpenCL_INCLUDE_DIR "$<TARGET_PROPERTY:OpenCL::Headers,INTERFACE_INCLUDE_DIRECTORIES>" PARENT_SCOPE)
set(OpenCL_LIBRARY "$<TARGET_PROPERTY:OpenCL::OpenCL,IMPORTED_LOCATION_RELEASE>" PARENT_SCOPE)
elseif(OpenCL_FOUND)
# find_package(OpenCL) already defines OpenCL_INCLUDE_DIR and OpenCL_LIBRARY
# see https://cmake.org/cmake/help/latest/module/FindOpenCL.html
message(STATUS "Found OpenCL (ver. ${OpenCL_VERSION_STRING}, include dirs ${OpenCL_INCLUDE_DIRS})")
else()
message(FATAL_ERROR "Internal error: cannot find OpenCL headers")
endif()
else()
add_subdirectory(ocl)
set(OpenCL_INCLUDE_DIR "${OpenCL_INCLUDE_DIR}" PARENT_SCOPE)
set(OpenCL_LIBRARY "${OpenCL_LIBRARY}" PARENT_SCOPE)
endif()
# cmake cannot set properties for imported targets
get_target_property(opencl_target OpenCL::OpenCL ALIASED_TARGET)
if(NOT TARGET ${opencl_target})
set(opencl_target OpenCL::OpenCL)
endif()
if(SUGGEST_OVERRIDE_SUPPORTED)
set_target_properties(${opencl_target} PROPERTIES INTERFACE_COMPILE_OPTIONS "-Wno-suggest-override")
endif()
# used in tests
add_library(opencl_new_headers INTERFACE)
add_library(OpenCL::NewHeaders ALIAS opencl_new_headers)
foreach(opencl_dir "${CMAKE_CURRENT_SOURCE_DIR}/ocl/clhpp_headers/include" "${CMAKE_CURRENT_SOURCE_DIR}/ocl/cl_headers")
if(EXISTS "${opencl_dir}")
set_property(TARGET opencl_new_headers APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES
$<BUILD_INTERFACE:${opencl_dir}>)
set_target_properties(opencl_new_headers PROPERTIES
INTERFACE_COMPILE_DEFINITIONS OV_GPU_USE_OPENCL_HPP)
endif()
endforeach()
endif()
#
# zlib
#
if(ENABLE_SAMPLES OR ENABLE_TESTS)
if(NOT ANDROID)
find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_search_module(zlib QUIET
IMPORTED_TARGET GLOBAL
zlib)
if(zlib_FOUND)
add_library(zlib::zlib ALIAS PkgConfig::zlib)
message(STATUS "${PKG_CONFIG_EXECUTABLE}: zlib (${zlib_VERSION}) is found at ${zlib_PREFIX}")
endif()
if(PkgConfig_FOUND)
pkg_search_module(zlib QUIET
IMPORTED_TARGET GLOBAL
zlib)
if(zlib_FOUND)
add_library(zlib::zlib ALIAS PkgConfig::zlib)
message(STATUS "${PKG_CONFIG_EXECUTABLE}: zlib (${zlib_VERSION}) is found at ${zlib_PREFIX}")
endif()
endif()
@ -55,7 +137,6 @@ endif()
#
if(ENABLE_SYSTEM_PUGIXML)
find_package(PkgConfig QUIET)
# try system pugixml first
find_package(PugiXML QUIET)
if(PugiXML_FOUND)
@ -79,7 +160,7 @@ if(ENABLE_SYSTEM_PUGIXML)
endif()
# to property generate OpenVINO Developer packages files
set(PugiXML_FOUND ${PugiXML_FOUND} CACHE BOOL "" FORCE)
elseif(PkgConfig_FOUND AND NOT ANDROID)
elseif(PkgConfig_FOUND)
# U18 case when cmake interface is not available
pkg_search_module(pugixml QUIET
IMPORTED_TARGET GLOBAL

View File

@ -19,57 +19,48 @@ function(get_lib_name TARGET_NAME LIBRARY_NAME)
endfunction()
function(get_lib_path OUTPUT_DIR FINAL_OUTPUT_DIR)
if(WIN32)
set(LIB_DIR "")
else()
set(LIB_DIR "lib")
endif()
if (NOT CMAKE_GENERATOR MATCHES "Ninja" AND NOT UNIX)
if(OV_GENERATOR_MULTI_CONFIG)
set(OUTPUT_DIR "${OUTPUT_DIR}/${CMAKE_BUILD_TYPE}")
endif()
set("${FINAL_OUTPUT_DIR}" "${OUTPUT_DIR}/${LIB_DIR}" PARENT_SCOPE)
set("${FINAL_OUTPUT_DIR}" "${OUTPUT_DIR}" PARENT_SCOPE)
endfunction()
if(WIN32)
set(CMAKE_DEBUG_POSTFIX "")
endif()
set(OPENCL_ICD_LOADER_HEADERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cl_headers/" CACHE PATH "Path to OCL includes" FORCE)
# for icd_loader project we need to override path to OpenCL C headers
set(OPENCL_ICD_LOADER_HEADERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cl_headers/"
CACHE PATH "Path to OCL includes" FORCE)
set(OPENCL_HEADERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cl_headers/" "${CMAKE_CURRENT_SOURCE_DIR}/clhpp_headers/include/" CACHE PATH "Path to OCL (CL and CLHPP) includes" FORCE)
# Reset compilation options for ICD loader as default OpenVINO cmake options lead to removing a lot of symbols from the library
unset(CMAKE_C_VISIBILITY_PRESET)
unset(CMAKE_DEBUG_POSTFIX)
# Reset compilation options for ICD loader as default IE options lead to removing a lot of symbols from the library
set(CMAKE_C_VISIBILITY_PRESET default)
set(CMAKE_SHARED_LINKER_FLAGS "")
set(CMAKE_C_FLAGS "")
set(CMAKE_CXX_FLAGS "")
set(CMAKE_C_FLAGS_RELEASE "")
set(CMAKE_CXX_FLAGS_RELEASE "")
# OpenCL has absolute paths to include directories
set(CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION OFF)
if(NOT DEFINED USE_DYNAMIC_VCXX_RUNTIME)
set(USE_DYNAMIC_VCXX_RUNTIME ON)
endif()
#
# Build OpenCL ICD loader
#
add_subdirectory(icd_loader EXCLUDE_FROM_ALL)
add_library(OpenCL::OpenCL ALIAS OpenCL)
# override INTERFACE_INCLUDE_DIRECTORIES
set_property(TARGET OpenCL PROPERTY INTERFACE_INCLUDE_DIRECTORIES
$<BUILD_INTERFACE:${OPENCL_ICD_LOADER_HEADERS_DIR}>)
foreach(dir IN LISTS OPENCL_HEADERS_DIR)
target_include_directories(OpenCL SYSTEM PUBLIC $<BUILD_INTERFACE:${dir}>)
endforeach()
# use CL/opencl.hpp
target_compile_definitions(OpenCL INTERFACE OV_GPU_USE_OPENCL_HPP)
target_include_directories(OpenCL INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cl_headers>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/clhpp_headers/include>)
# The following varables are needed to make find_package(OpenCL) work
set(OPENCL_VERSION_2_2 ON CACHE BOOL "" FORCE)
set(OpenCL_VERSION_STRING "2.2" CACHE STRING "" FORCE)
set(OpenCL_INCLUDE_DIR "${OPENCL_HEADERS_DIR}" CACHE PATH "" FORCE)
set(OPENCLROOT "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}" CACHE PATH "" FORCE)
# The following variables are needed to make find_package(OpenCL) work
get_lib_path("${OUTPUT_ROOT}/${BIN_FOLDER}" OPENCL_LIB_DIR)
get_lib_name("OpenCL" OPENCL_LIB_NAME)
set(OpenCL_LIBRARY "${OPENCL_LIB_DIR}/${OPENCL_LIB_NAME}" CACHE PATH "" FORCE)
set(OpenCL_INCLUDE_DIR "${OPENCL_ICD_LOADER_HEADERS_DIR}" PARENT_SCOPE)
set(OpenCL_LIBRARY "${OPENCL_LIB_DIR}/${OPENCL_LIB_NAME}" PARENT_SCOPE)
# installation
ov_install_static_lib(OpenCL gpu)

@ -1 +1 @@
Subproject commit 1d3dc4e7562ac56ee8ab00607af7bd55fb091f22
Subproject commit a51354a85f41d203e755124ad51ae3425933df45

@ -1 +1 @@
Subproject commit 89d843beba559f65e4a77833fcf8604e874a3371
Subproject commit 4a1157466afe72a87e8abc59537ef577534ccadf

@ -1 +1 @@
Subproject commit 9b5e3849b49a1448996c8b96ba086cd774d987db
Subproject commit 4aa683775c4ee55594196c79def7a75103d75e4c