Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -3,13 +3,14 @@ ocv_add_module(core ${ZLIB_LIBRARIES})
|
||||
ocv_module_include_directories(${ZLIB_INCLUDE_DIR})
|
||||
|
||||
if(HAVE_CUDA)
|
||||
file(GLOB lib_cuda "src/cuda/*.cu")
|
||||
source_group("Cuda" FILES "${lib_cuda}")
|
||||
|
||||
ocv_source_group("Src\\Cuda" GLOB "src/cuda/*.cu")
|
||||
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/src" "${OpenCV_SOURCE_DIR}/modules/gpu/src/cuda" ${CUDA_INCLUDE_DIRS})
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef)
|
||||
|
||||
file(GLOB lib_cuda "src/cuda/*.cu")
|
||||
ocv_cuda_compile(cuda_objs ${lib_cuda})
|
||||
|
||||
|
||||
set(cuda_link_libs ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
|
||||
else()
|
||||
set(lib_cuda "")
|
||||
|
@@ -440,7 +440,7 @@ template<typename _Tp, int m, int n> class CV_EXPORTS Matx
|
||||
{
|
||||
public:
|
||||
typedef _Tp value_type;
|
||||
typedef Matx<_Tp, MIN(m, n), 1> diag_type;
|
||||
typedef Matx<_Tp, (m < n ? m : n), 1> diag_type;
|
||||
typedef Matx<_Tp, m, n> mat_type;
|
||||
enum { depth = DataDepth<_Tp>::value, rows = m, cols = n, channels = rows*cols,
|
||||
type = CV_MAKETYPE(depth, channels) };
|
||||
@@ -4620,6 +4620,34 @@ public:
|
||||
|
||||
CV_EXPORTS void parallel_for_(const Range& range, const ParallelLoopBody& body);
|
||||
|
||||
/////////////////////////// Synchronization Primitives ///////////////////////////////
|
||||
|
||||
class CV_EXPORTS Mutex
|
||||
{
|
||||
public:
|
||||
Mutex();
|
||||
~Mutex();
|
||||
Mutex(const Mutex& m);
|
||||
Mutex& operator = (const Mutex& m);
|
||||
|
||||
void lock();
|
||||
bool trylock();
|
||||
void unlock();
|
||||
|
||||
struct Impl;
|
||||
protected:
|
||||
Impl* impl;
|
||||
};
|
||||
|
||||
class CV_EXPORTS AutoLock
|
||||
{
|
||||
public:
|
||||
AutoLock(Mutex& m) : mutex(&m) { mutex->lock(); }
|
||||
~AutoLock() { mutex->unlock(); }
|
||||
protected:
|
||||
Mutex* mutex;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
@@ -72,9 +72,11 @@ namespace cv { namespace gpu
|
||||
FEATURE_SET_COMPUTE_13 = 13,
|
||||
FEATURE_SET_COMPUTE_20 = 20,
|
||||
FEATURE_SET_COMPUTE_21 = 21,
|
||||
FEATURE_SET_COMPUTE_30 = 30,
|
||||
GLOBAL_ATOMICS = FEATURE_SET_COMPUTE_11,
|
||||
SHARED_ATOMICS = FEATURE_SET_COMPUTE_12,
|
||||
NATIVE_DOUBLE = FEATURE_SET_COMPUTE_13
|
||||
NATIVE_DOUBLE = FEATURE_SET_COMPUTE_13,
|
||||
WARP_SHUFFLE_FUNCTIONS = FEATURE_SET_COMPUTE_30
|
||||
};
|
||||
|
||||
// Gives information about what GPU archs this OpenCV GPU module was
|
||||
|
@@ -44,7 +44,7 @@
|
||||
#include "opencv2/gpu/device/transform.hpp"
|
||||
#include "opencv2/gpu/device/functional.hpp"
|
||||
|
||||
namespace cv { namespace gpu { namespace device
|
||||
namespace cv { namespace gpu { namespace device
|
||||
{
|
||||
template <typename T> struct shift_and_sizeof;
|
||||
template <> struct shift_and_sizeof<signed char> { enum { shift = 0 }; };
|
||||
@@ -272,7 +272,7 @@ namespace cv { namespace gpu { namespace device
|
||||
template <typename T, typename D> struct TransformFunctorTraits< Convertor<T, D> > : detail::ConvertTraits< Convertor<T, D> >
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
template<typename T, typename D>
|
||||
void cvt_(DevMem2Db src, DevMem2Db dst, double alpha, double beta, cudaStream_t stream)
|
||||
{
|
||||
@@ -282,6 +282,11 @@ namespace cv { namespace gpu { namespace device
|
||||
cv::gpu::device::transform((DevMem2D_<T>)src, (DevMem2D_<D>)dst, op, WithOutMask(), stream);
|
||||
}
|
||||
|
||||
#if defined __clang__
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wmissing-declarations"
|
||||
#endif
|
||||
|
||||
void convert_gpu(DevMem2Db src, int sdepth, DevMem2Db dst, int ddepth, double alpha, double beta, cudaStream_t stream)
|
||||
{
|
||||
typedef void (*caller_t)(DevMem2Db src, DevMem2Db dst, double alpha, double beta, cudaStream_t stream);
|
||||
@@ -318,4 +323,8 @@ namespace cv { namespace gpu { namespace device
|
||||
|
||||
func(src, dst, alpha, beta, stream);
|
||||
}
|
||||
|
||||
#if defined __clang__
|
||||
# pragma clang diagnostic pop
|
||||
#endif
|
||||
}}} // namespace cv { namespace gpu { namespace device
|
||||
|
@@ -1199,10 +1199,6 @@ namespace
|
||||
|
||||
void setTo(GpuMat& m, Scalar s, const GpuMat& mask) const
|
||||
{
|
||||
NppiSize sz;
|
||||
sz.width = m.cols;
|
||||
sz.height = m.rows;
|
||||
|
||||
if (mask.empty())
|
||||
{
|
||||
if (s[0] == 0.0 && s[1] == 0.0 && s[2] == 0.0 && s[3] == 0.0)
|
||||
|
@@ -42,6 +42,16 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#if !defined HAVE_TBB && !defined HAVE_OPENMP && !defined HAVE_GCD && !defined HAVE_CONCURRENCY
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define HAVE_GCD
|
||||
#elif defined _MSC_VER && _MSC_VER >= 1600
|
||||
#define HAVE_CONCURRENCY
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONCURRENCY
|
||||
# include <ppl.h>
|
||||
#elif defined HAVE_OPENMP
|
||||
@@ -106,7 +116,22 @@ namespace cv
|
||||
|
||||
#elif defined HAVE_CONCURRENCY
|
||||
|
||||
Concurrency::parallel_for(range.start, range.end, body);
|
||||
class ConcurrencyProxyLoopBody
|
||||
{
|
||||
public:
|
||||
ConcurrencyProxyLoopBody(const ParallelLoopBody& body) : _body(body) {}
|
||||
|
||||
void operator ()(int i) const
|
||||
{
|
||||
_body(Range(i, i + 1));
|
||||
}
|
||||
|
||||
private:
|
||||
const ParallelLoopBody& _body;
|
||||
ConcurrencyProxyLoopBody& operator=(const ConcurrencyProxyLoopBody&) {return *this;}
|
||||
} proxy(body);
|
||||
|
||||
Concurrency::parallel_for(range.start, range.end, proxy);
|
||||
|
||||
#elif defined HAVE_OPENMP
|
||||
|
||||
|
@@ -930,4 +930,104 @@ BOOL WINAPI DllMain( HINSTANCE, DWORD fdwReason, LPVOID )
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
#if defined WIN32 || defined _WIN32 || defined WINCE
|
||||
|
||||
struct Mutex::Impl
|
||||
{
|
||||
Impl() { InitializeCriticalSection(&cs); refcount = 1; }
|
||||
~Impl() { DeleteCriticalSection(&cs); }
|
||||
|
||||
void lock() { EnterCriticalSection(&cs); }
|
||||
bool trylock() { return TryEnterCriticalSection(&cs) != 0; }
|
||||
void unlock() { LeaveCriticalSection(&cs); }
|
||||
|
||||
CRITICAL_SECTION cs;
|
||||
int refcount;
|
||||
};
|
||||
|
||||
#elif defined __APPLE__
|
||||
|
||||
#include <libkern/OSAtomic.h>
|
||||
|
||||
struct Mutex::Impl
|
||||
{
|
||||
Impl() { sl = OS_SPINLOCK_INIT; refcount = 1; }
|
||||
~Impl() {}
|
||||
|
||||
void lock() { OSSpinLockLock(&sl); }
|
||||
bool trylock() { return OSSpinLockTry(&sl); }
|
||||
void unlock() { OSSpinLockUnlock(&sl); }
|
||||
|
||||
OSSpinLock sl;
|
||||
int refcount;
|
||||
};
|
||||
|
||||
#elif defined __linux__ && !defined ANDROID
|
||||
|
||||
struct Mutex::Impl
|
||||
{
|
||||
Impl() { pthread_spin_init(&sl, 0); refcount = 1; }
|
||||
~Impl() { pthread_spin_destroy(&sl); }
|
||||
|
||||
void lock() { pthread_spin_lock(&sl); }
|
||||
bool trylock() { return pthread_spin_trylock(&sl) == 0; }
|
||||
void unlock() { pthread_spin_unlock(&sl); }
|
||||
|
||||
pthread_spinlock_t sl;
|
||||
int refcount;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
struct Mutex::Impl
|
||||
{
|
||||
Impl() { pthread_mutex_init(&sl, 0); refcount = 1; }
|
||||
~Impl() { pthread_mutex_destroy(&sl); }
|
||||
|
||||
void lock() { pthread_mutex_lock(&sl); }
|
||||
bool trylock() { return pthread_mutex_trylock(&sl) == 0; }
|
||||
void unlock() { pthread_mutex_unlock(&sl); }
|
||||
|
||||
pthread_mutex_t sl;
|
||||
int refcount;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Mutex::Mutex()
|
||||
{
|
||||
impl = new Mutex::Impl;
|
||||
}
|
||||
|
||||
Mutex::~Mutex()
|
||||
{
|
||||
if( CV_XADD(&impl->refcount, -1) == 1 )
|
||||
delete impl;
|
||||
impl = 0;
|
||||
}
|
||||
|
||||
Mutex::Mutex(const Mutex& m)
|
||||
{
|
||||
impl = m.impl;
|
||||
CV_XADD(&impl->refcount, 1);
|
||||
}
|
||||
|
||||
Mutex& Mutex::operator = (const Mutex& m)
|
||||
{
|
||||
CV_XADD(&m.impl->refcount, 1);
|
||||
if( CV_XADD(&impl->refcount, -1) == 1 )
|
||||
delete impl;
|
||||
impl = m.impl;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Mutex::lock() { impl->lock(); }
|
||||
void Mutex::unlock() { impl->unlock(); }
|
||||
bool Mutex::trylock() { return impl->trylock(); }
|
||||
|
||||
}
|
||||
|
||||
/* End of file. */
|
Reference in New Issue
Block a user