From 15d6a0ff485161f0e4cb60e1de5169bee73f92d8 Mon Sep 17 00:00:00 2001 From: Yasunori Shimura <63567854+yas-sim@users.noreply.github.com> Date: Sat, 13 Feb 2021 14:44:25 +0900 Subject: [PATCH] DPC++ link error workaround. (#4192) * DPC++ link error workaround. OpenVINO C++ program failed to link when DPC++ compiler is used. 'make_shared_blob' causes 'unresolved external symbol' error on linking. Commented out some __clang__ specific directives to workaround the issue in "ie_blob.h". * DPC++ compatibility issue fix #2 1. Removed type-by-type template class definition for __clang__. 2. Modified TBlob() destructor. The 'unresolved reference' error occur again if I left 'virtual ~TBlob();' only. It seems it needs to be 'virtual ~TBlob() {};'. * DPC++ compatibility fix #3 - Add DPC++ conditional code Uses '__SYCL_COMPILER_VERSION' predefined macro to check if the compiler is a DPC++ or not. Added conditional directive to switch code based of the detected compiler. NOTE: User program must include , or the '__SYCL_COMPILER_VERSION' macro won't be defined and this fix won't take effect. * DPC++ compatibility issue fix #4 Changed from #ifdef to #if + logical formulas. * DPC++ compatibility issue fix #5 Added compiler check logic in src/ie_rtti.cpp * DPC++ Compatibility issue #6 - ie_parameter.cpp Added compiler check macro for DPC++ to ie_parameter.cpp as well. Co-authored-by: Yasunori Shimura --- inference-engine/include/ie_blob.h | 9 +++++---- inference-engine/include/ie_parameter.hpp | 8 ++++---- inference-engine/src/inference_engine/ie_rtti.cpp | 8 ++++---- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/inference-engine/include/ie_blob.h b/inference-engine/include/ie_blob.h index 234a13528ebdd1..30b9b6b978ad58 100644 --- a/inference-engine/include/ie_blob.h +++ b/inference-engine/include/ie_blob.h @@ -577,13 +577,14 @@ class TBlob : public MemoryBlob { /** *@brief Virtual destructor. */ -#ifdef __clang__ + +#if defined(__clang__) && !defined(__SYCL_COMPILER_VERSION) virtual ~TBlob(); #else virtual ~TBlob() { free(); } -#endif // __clang__ +#endif // __clang__ && !__SYCL_COMPILER_VERSION /** * @brief Gets the size of the given type. @@ -806,7 +807,7 @@ class TBlob : public MemoryBlob { } }; -#ifdef __clang__ +#if defined(__clang__) && !defined(__SYCL_COMPILER_VERSION) extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob); extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob); extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob); @@ -819,7 +820,7 @@ extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob); extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob); extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob); extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob); -#endif // __clang__ +#endif // __clang__ && !__SYCL_COMPILER_VERSION /** * @brief Creates a blob with the given tensor descriptor. diff --git a/inference-engine/include/ie_parameter.hpp b/inference-engine/include/ie_parameter.hpp index d274edd083a203..e53cef2fb2cade 100644 --- a/inference-engine/include/ie_parameter.hpp +++ b/inference-engine/include/ie_parameter.hpp @@ -265,11 +265,11 @@ class INFERENCE_ENGINE_API_CLASS(Parameter) { struct HasOperatorEqual : CheckOperatorEqual::type {}; struct Any { -#ifdef __clang__ +#if defined(__clang__) && !defined(__SYCL_COMPILER_VERSION) virtual ~Any(); #else virtual ~Any() = default; -#endif +#endif // __clang__ && !__SYCL_COMPILER_VERSION virtual bool is(const std::type_info&) const = 0; virtual Any* copy() const = 0; virtual bool operator==(const Any& rhs) const = 0; @@ -326,7 +326,7 @@ class INFERENCE_ENGINE_API_CLASS(Parameter) { Any* ptr = nullptr; }; -#ifdef __clang__ +#if defined(__clang__) && !defined(__SYCL_COMPILER_VERSION) extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData); extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData); extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData); @@ -341,6 +341,6 @@ extern template struct INFERENCE_ENGINE_API_CLASS( InferenceEngine::Parameter::RealData>); extern template struct INFERENCE_ENGINE_API_CLASS( InferenceEngine::Parameter::RealData>); -#endif // __clang__ +#endif // __clang__ && !__SYCL_COMPILER_VERSION } // namespace InferenceEngine diff --git a/inference-engine/src/inference_engine/ie_rtti.cpp b/inference-engine/src/inference_engine/ie_rtti.cpp index a2e45d59fab47e..e32e69ff1881f5 100644 --- a/inference-engine/src/inference_engine/ie_rtti.cpp +++ b/inference-engine/src/inference_engine/ie_rtti.cpp @@ -81,7 +81,7 @@ Parameter::~Parameter() { clear(); } -#ifdef __clang__ +#if defined(__clang__) && !defined(__SYCL_COMPILER_VERSION) Parameter::Any::~Any() {} template struct InferenceEngine::Parameter::RealData; @@ -97,12 +97,12 @@ template struct InferenceEngine::Parameter::RealData> template struct InferenceEngine::Parameter::RealData>; template struct InferenceEngine::Parameter::RealData>; template struct InferenceEngine::Parameter::RealData; -#endif // __clang__ +#endif // __clang__ && !__SYCL_COMPILER_VERSION // // ie_blob.h // -#ifdef __clang__ +#if defined(__clang__) && !defined(__SYCL_COMPILER_VERSION) template TBlob::~TBlob() { free(); @@ -120,4 +120,4 @@ template class InferenceEngine::TBlob; template class InferenceEngine::TBlob; template class InferenceEngine::TBlob; template class InferenceEngine::TBlob; -#endif // __clang__ +#endif // __clang__ && !__SYCL_COMPILER_VERSION