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 <CL/sycl.hpp>, 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 <yasunori.shimura@intel.com>
This commit is contained in:
Yasunori Shimura 2021-02-13 14:44:25 +09:00 committed by GitHub
parent eeb7835128
commit 15d6a0ff48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 12 deletions

View File

@ -577,13 +577,14 @@ public:
/** /**
*@brief Virtual destructor. *@brief Virtual destructor.
*/ */
#ifdef __clang__
#if defined(__clang__) && !defined(__SYCL_COMPILER_VERSION)
virtual ~TBlob(); virtual ~TBlob();
#else #else
virtual ~TBlob() { virtual ~TBlob() {
free(); free();
} }
#endif // __clang__ #endif // __clang__ && !__SYCL_COMPILER_VERSION
/** /**
* @brief Gets the size of the given type. * @brief Gets the size of the given type.
@ -806,7 +807,7 @@ protected:
} }
}; };
#ifdef __clang__ #if defined(__clang__) && !defined(__SYCL_COMPILER_VERSION)
extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob<float>); extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob<float>);
extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob<double>); extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob<double>);
extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob<int8_t>); extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob<int8_t>);
@ -819,7 +820,7 @@ extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob<long>);
extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob<long long>); extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob<long long>);
extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob<unsigned long>); extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob<unsigned long>);
extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob<unsigned long long>); extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob<unsigned long long>);
#endif // __clang__ #endif // __clang__ && !__SYCL_COMPILER_VERSION
/** /**
* @brief Creates a blob with the given tensor descriptor. * @brief Creates a blob with the given tensor descriptor.

View File

@ -265,11 +265,11 @@ private:
struct HasOperatorEqual : CheckOperatorEqual<T, EqualTo>::type {}; struct HasOperatorEqual : CheckOperatorEqual<T, EqualTo>::type {};
struct Any { struct Any {
#ifdef __clang__ #if defined(__clang__) && !defined(__SYCL_COMPILER_VERSION)
virtual ~Any(); virtual ~Any();
#else #else
virtual ~Any() = default; virtual ~Any() = default;
#endif #endif // __clang__ && !__SYCL_COMPILER_VERSION
virtual bool is(const std::type_info&) const = 0; virtual bool is(const std::type_info&) const = 0;
virtual Any* copy() const = 0; virtual Any* copy() const = 0;
virtual bool operator==(const Any& rhs) const = 0; virtual bool operator==(const Any& rhs) const = 0;
@ -326,7 +326,7 @@ private:
Any* ptr = nullptr; Any* ptr = nullptr;
}; };
#ifdef __clang__ #if defined(__clang__) && !defined(__SYCL_COMPILER_VERSION)
extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<InferenceEngine::Blob::Ptr>); extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<InferenceEngine::Blob::Ptr>);
extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<int>); extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<int>);
extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<bool>); extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<bool>);
@ -341,6 +341,6 @@ extern template struct INFERENCE_ENGINE_API_CLASS(
InferenceEngine::Parameter::RealData<std::tuple<unsigned int, unsigned int>>); InferenceEngine::Parameter::RealData<std::tuple<unsigned int, unsigned int>>);
extern template struct INFERENCE_ENGINE_API_CLASS( extern template struct INFERENCE_ENGINE_API_CLASS(
InferenceEngine::Parameter::RealData<std::tuple<unsigned int, unsigned int, unsigned int>>); InferenceEngine::Parameter::RealData<std::tuple<unsigned int, unsigned int, unsigned int>>);
#endif // __clang__ #endif // __clang__ && !__SYCL_COMPILER_VERSION
} // namespace InferenceEngine } // namespace InferenceEngine

View File

@ -81,7 +81,7 @@ Parameter::~Parameter() {
clear(); clear();
} }
#ifdef __clang__ #if defined(__clang__) && !defined(__SYCL_COMPILER_VERSION)
Parameter::Any::~Any() {} Parameter::Any::~Any() {}
template struct InferenceEngine::Parameter::RealData<int>; template struct InferenceEngine::Parameter::RealData<int>;
@ -97,12 +97,12 @@ template struct InferenceEngine::Parameter::RealData<std::vector<unsigned long>>
template struct InferenceEngine::Parameter::RealData<std::tuple<unsigned int, unsigned int>>; template struct InferenceEngine::Parameter::RealData<std::tuple<unsigned int, unsigned int>>;
template struct InferenceEngine::Parameter::RealData<std::tuple<unsigned int, unsigned int, unsigned int>>; template struct InferenceEngine::Parameter::RealData<std::tuple<unsigned int, unsigned int, unsigned int>>;
template struct InferenceEngine::Parameter::RealData<InferenceEngine::Blob::Ptr>; template struct InferenceEngine::Parameter::RealData<InferenceEngine::Blob::Ptr>;
#endif // __clang__ #endif // __clang__ && !__SYCL_COMPILER_VERSION
// //
// ie_blob.h // ie_blob.h
// //
#ifdef __clang__ #if defined(__clang__) && !defined(__SYCL_COMPILER_VERSION)
template <typename T, typename U> template <typename T, typename U>
TBlob<T, U>::~TBlob() { TBlob<T, U>::~TBlob() {
free(); free();
@ -120,4 +120,4 @@ template class InferenceEngine::TBlob<long>;
template class InferenceEngine::TBlob<long long>; template class InferenceEngine::TBlob<long long>;
template class InferenceEngine::TBlob<unsigned long>; template class InferenceEngine::TBlob<unsigned long>;
template class InferenceEngine::TBlob<unsigned long long>; template class InferenceEngine::TBlob<unsigned long long>;
#endif // __clang__ #endif // __clang__ && !__SYCL_COMPILER_VERSION