mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
This commit is contained in:
+9
-104
@@ -40,6 +40,11 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#ifndef HAVE_OPENCL
|
||||
#include "ocl_disabled.impl.hpp"
|
||||
#else // HAVE_OPENCL
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <deque>
|
||||
@@ -106,23 +111,7 @@
|
||||
#include "opencv2/core/opencl/runtime/opencl_clamdblas.hpp"
|
||||
#include "opencv2/core/opencl/runtime/opencl_clamdfft.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
#include "opencv2/core/opencl/runtime/opencl_core.hpp"
|
||||
#else
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4100)
|
||||
#pragma warning(disable : 4702)
|
||||
#elif defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#endif
|
||||
// TODO FIXIT: This file can't be build without OPENCL
|
||||
#include "ocl_deprecated.hpp"
|
||||
#endif // HAVE_OPENCL
|
||||
|
||||
#ifdef HAVE_OPENCL_SVM
|
||||
#include "opencv2/core/opencl/runtime/opencl_svm_20.hpp"
|
||||
@@ -147,31 +136,6 @@ cv::utils::AllocatorStatisticsInterface& getOpenCLAllocatorStatistics()
|
||||
return opencl_allocator_stats;
|
||||
}
|
||||
|
||||
#ifndef HAVE_OPENCL
|
||||
#define CV_OPENCL_NO_SUPPORT() CV_Error(cv::Error::OpenCLApiCallError, "OpenCV build without OpenCL support")
|
||||
namespace {
|
||||
struct DummyImpl
|
||||
{
|
||||
DummyImpl() { CV_OPENCL_NO_SUPPORT(); }
|
||||
~DummyImpl() { /* do not throw in desctructors */ }
|
||||
IMPLEMENT_REFCOUNTABLE();
|
||||
};
|
||||
} // namespace
|
||||
|
||||
// TODO Replace to empty body (without HAVE_OPENCL)
|
||||
#define CV_OCL_TRACE_CHECK_RESULT(status, message) /* nothing */
|
||||
#define CV_OCL_API_ERROR_MSG(check_result, msg) cv::String()
|
||||
#define CV_OCL_CHECK_RESULT(check_result, msg) (void)check_result
|
||||
#define CV_OCL_CHECK_(expr, check_result) expr; (void)check_result
|
||||
#define CV_OCL_CHECK(expr) do { cl_int __cl_result = (expr); CV_OCL_CHECK_RESULT(__cl_result, #expr); } while (0)
|
||||
#define CV_OCL_DBG_CHECK_RESULT(check_result, msg) (void)check_result
|
||||
#define CV_OCL_DBG_CHECK_(expr, check_result) expr; (void)check_result
|
||||
#define CV_OCL_DBG_CHECK(expr) do { cl_int __cl_result = (expr); CV_OCL_CHECK_RESULT(__cl_result, #expr); } while (0)
|
||||
|
||||
static const bool CV_OPENCL_DISABLE_BUFFER_RECT_OPERATIONS = false;
|
||||
|
||||
#else // HAVE_OPENCL
|
||||
|
||||
#ifndef _DEBUG
|
||||
static bool isRaiseError()
|
||||
{
|
||||
@@ -270,7 +234,6 @@ static const String getBuildExtraOptions()
|
||||
static const bool CV_OPENCL_ENABLE_MEM_USE_HOST_PTR = utils::getConfigurationParameterBool("OPENCV_OPENCL_ENABLE_MEM_USE_HOST_PTR", true);
|
||||
static const size_t CV_OPENCL_ALIGNMENT_MEM_USE_HOST_PTR = utils::getConfigurationParameterSizeT("OPENCV_OPENCL_ALIGNMENT_MEM_USE_HOST_PTR", 4);
|
||||
|
||||
#endif // HAVE_OPENCL
|
||||
|
||||
struct UMat2D
|
||||
{
|
||||
@@ -331,7 +294,7 @@ static uint64 crc64( const uchar* data, size_t size, uint64 crc0=0 )
|
||||
return ~crc;
|
||||
}
|
||||
|
||||
#if defined HAVE_OPENCL && OPENCV_HAVE_FILESYSTEM_SUPPORT
|
||||
#if OPENCV_HAVE_FILESYSTEM_SUPPORT
|
||||
struct OpenCLBinaryCacheConfigurator
|
||||
{
|
||||
cv::String cache_path_;
|
||||
@@ -872,7 +835,6 @@ static bool g_isOpenCVActivated = false;
|
||||
bool haveOpenCL()
|
||||
{
|
||||
CV_TRACE_FUNCTION();
|
||||
#ifdef HAVE_OPENCL
|
||||
static bool g_isOpenCLInitialized = false;
|
||||
static bool g_isOpenCLAvailable = false;
|
||||
|
||||
@@ -902,9 +864,6 @@ bool haveOpenCL()
|
||||
g_isOpenCLInitialized = true;
|
||||
}
|
||||
return g_isOpenCLAvailable;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool useOpenCL()
|
||||
@@ -924,14 +883,12 @@ bool useOpenCL()
|
||||
return data.useOpenCL > 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
bool isOpenCLActivated()
|
||||
{
|
||||
if (!g_isOpenCVActivated)
|
||||
return false; // prevent unnecessary OpenCL activation via useOpenCL()->haveOpenCL() calls
|
||||
return useOpenCL();
|
||||
}
|
||||
#endif
|
||||
|
||||
void setUseOpenCL(bool flag)
|
||||
{
|
||||
@@ -1953,7 +1910,6 @@ static unsigned int getSVMCapabilitiesMask()
|
||||
} // namespace
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
static size_t getProgramCountLimit()
|
||||
{
|
||||
static bool initialized = false;
|
||||
@@ -1965,7 +1921,6 @@ static size_t getProgramCountLimit()
|
||||
}
|
||||
return count;
|
||||
}
|
||||
#endif
|
||||
|
||||
struct Context::Impl
|
||||
{
|
||||
@@ -3548,8 +3503,6 @@ internal::ProgramEntry::operator ProgramSource&() const
|
||||
|
||||
/////////////////////////////////////////// Program /////////////////////////////////////////////
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
static
|
||||
cv::String joinBuildOptions(const cv::String& a, const cv::String& b)
|
||||
{
|
||||
@@ -3963,10 +3916,6 @@ struct Program::Impl
|
||||
String sourceName_;
|
||||
};
|
||||
|
||||
#else // HAVE_OPENCL
|
||||
struct Program::Impl : public DummyImpl {};
|
||||
#endif // HAVE_OPENCL
|
||||
|
||||
|
||||
Program::Program() { p = 0; }
|
||||
|
||||
@@ -4009,7 +3958,6 @@ bool Program::create(const ProgramSource& src,
|
||||
p->release();
|
||||
p = NULL;
|
||||
}
|
||||
#ifdef HAVE_OPENCL
|
||||
p = new Impl(src, buildflags, errmsg);
|
||||
if(!p->handle)
|
||||
{
|
||||
@@ -4017,18 +3965,11 @@ bool Program::create(const ProgramSource& src,
|
||||
p = 0;
|
||||
}
|
||||
return p != 0;
|
||||
#else
|
||||
CV_OPENCL_NO_SUPPORT();
|
||||
#endif
|
||||
}
|
||||
|
||||
void* Program::ptr() const
|
||||
{
|
||||
#ifdef HAVE_OPENCL
|
||||
return p ? p->handle : 0;
|
||||
#else
|
||||
CV_OPENCL_NO_SUPPORT();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef OPENCV_REMOVE_DEPRECATED_API
|
||||
@@ -4051,44 +3992,30 @@ bool Program::write(String& bin) const
|
||||
|
||||
String Program::getPrefix() const
|
||||
{
|
||||
#ifdef HAVE_OPENCL
|
||||
if(!p)
|
||||
return String();
|
||||
Context::Impl* ctx_ = Context::getDefault().getImpl();
|
||||
CV_Assert(ctx_);
|
||||
return cv::format("opencl=%s\nbuildflags=%s", ctx_->getPrefixString().c_str(), p->buildflags.c_str());
|
||||
#else
|
||||
CV_OPENCL_NO_SUPPORT();
|
||||
#endif
|
||||
}
|
||||
|
||||
String Program::getPrefix(const String& buildflags)
|
||||
{
|
||||
#ifdef HAVE_OPENCL
|
||||
Context::Impl* ctx_ = Context::getDefault().getImpl();
|
||||
CV_Assert(ctx_);
|
||||
return cv::format("opencl=%s\nbuildflags=%s", ctx_->getPrefixString().c_str(), buildflags.c_str());
|
||||
#else
|
||||
CV_OPENCL_NO_SUPPORT();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif // OPENCV_REMOVE_DEPRECATED_API
|
||||
|
||||
void Program::getBinary(std::vector<char>& binary) const
|
||||
{
|
||||
#ifdef HAVE_OPENCL
|
||||
CV_Assert(p && "Empty program");
|
||||
p->getProgramBinary(binary);
|
||||
#else
|
||||
binary.clear();
|
||||
CV_OPENCL_NO_SUPPORT();
|
||||
#endif
|
||||
}
|
||||
|
||||
Program Context::Impl::getProg(const ProgramSource& src,
|
||||
const String& buildflags, String& errmsg)
|
||||
{
|
||||
#ifdef HAVE_OPENCL
|
||||
size_t limit = getProgramCountLimit();
|
||||
const ProgramSource::Impl* src_ = src.getImpl();
|
||||
CV_Assert(src_);
|
||||
@@ -4140,9 +4067,6 @@ Program Context::Impl::getProg(const ProgramSource& src,
|
||||
cacheList.push_front(key);
|
||||
}
|
||||
return prog;
|
||||
#else
|
||||
CV_OPENCL_NO_SUPPORT();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -4703,9 +4627,6 @@ public:
|
||||
|
||||
bool allocate(UMatData* u, AccessFlag accessFlags, UMatUsageFlags usageFlags) const CV_OVERRIDE
|
||||
{
|
||||
#ifndef HAVE_OPENCL
|
||||
return false;
|
||||
#else
|
||||
if(!u)
|
||||
return false;
|
||||
|
||||
@@ -4825,7 +4746,6 @@ public:
|
||||
u->markHostCopyObsolete(true);
|
||||
opencl_allocator_stats.onAllocate(u->size);
|
||||
return true;
|
||||
#endif // HAVE_OPENCL
|
||||
}
|
||||
|
||||
/*void sync(UMatData* u) const
|
||||
@@ -6705,27 +6625,19 @@ struct Timer::Impl
|
||||
|
||||
void start()
|
||||
{
|
||||
#ifdef HAVE_OPENCL
|
||||
CV_OCL_DBG_CHECK(clFinish((cl_command_queue)queue.ptr()));
|
||||
timer.start();
|
||||
#endif
|
||||
}
|
||||
|
||||
void stop()
|
||||
{
|
||||
#ifdef HAVE_OPENCL
|
||||
CV_OCL_DBG_CHECK(clFinish((cl_command_queue)queue.ptr()));
|
||||
timer.stop();
|
||||
#endif
|
||||
}
|
||||
|
||||
uint64 durationNS() const
|
||||
{
|
||||
#ifdef HAVE_OPENCL
|
||||
return (uint64)(timer.getTimeSec() * 1e9);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
TickMeter timer;
|
||||
@@ -6752,13 +6664,6 @@ uint64 Timer::durationNS() const
|
||||
return p->durationNS();
|
||||
}
|
||||
|
||||
#ifndef HAVE_OPENCL
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#elif defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#endif
|
||||
}} // namespace
|
||||
|
||||
#endif // HAVE_OPENCL
|
||||
|
||||
Reference in New Issue
Block a user