Commit 01dafce1 authored by Alexey Spizhevoy's avatar Alexey Spizhevoy

fixed some bugs in GPU matrix reductions, removed <functional> into precomp.hpp

parent 0da71a01
......@@ -328,7 +328,7 @@ namespace cv { namespace gpu { namespace mathfunc
__shared__ best_type smaxval[nthreads];
uint tid = threadIdx.y * blockDim.x + threadIdx.x;
uint idx = min(tid, gridDim.x * gridDim.y - 1);
uint idx = min(tid, size - 1);
sminval[tid] = minval[idx];
smaxval[tid] = maxval[idx];
......@@ -671,7 +671,7 @@ namespace cv { namespace gpu { namespace mathfunc
__shared__ uint smaxloc[nthreads];
uint tid = threadIdx.y * blockDim.x + threadIdx.x;
uint idx = min(tid, gridDim.x * gridDim.y - 1);
uint idx = min(tid, size - 1);
sminval[tid] = minval[idx];
smaxval[tid] = maxval[idx];
......@@ -1150,7 +1150,7 @@ namespace cv { namespace gpu { namespace mathfunc
const int tid = threadIdx.y * blockDim.x + threadIdx.x;
DstType res = tid < gridDim.x * gridDim.y ? result[tid] : VecTraits<DstType>::all(0);
DstType res = tid < size ? result[tid] : VecTraits<DstType>::all(0);
smem[tid] = res.x;
smem[tid + nthreads] = res.y;
__syncthreads();
......@@ -1262,7 +1262,7 @@ namespace cv { namespace gpu { namespace mathfunc
const int tid = threadIdx.y * blockDim.x + threadIdx.x;
DstType res = tid < gridDim.x * gridDim.y ? result[tid] : VecTraits<DstType>::all(0);
DstType res = tid < size ? result[tid] : VecTraits<DstType>::all(0);
smem[tid] = res.x;
smem[tid + nthreads] = res.y;
smem[tid + 2 * nthreads] = res.z;
......@@ -1384,7 +1384,7 @@ namespace cv { namespace gpu { namespace mathfunc
const int tid = threadIdx.y * blockDim.x + threadIdx.x;
DstType res = tid < gridDim.x * gridDim.y ? result[tid] : VecTraits<DstType>::all(0);
DstType res = tid < size ? result[tid] : VecTraits<DstType>::all(0);
smem[tid] = res.x;
smem[tid + nthreads] = res.y;
smem[tid + 2 * nthreads] = res.z;
......
......@@ -41,7 +41,6 @@
//M*/
#include "precomp.hpp"
#include <functional>
using namespace cv;
using namespace cv::gpu;
......
......@@ -276,11 +276,11 @@ void cv::gpu::minMax(const GpuMat& src, double* minVal, double* maxVal, const Gp
minMaxMaskCaller<double> };
CV_Assert(src.channels() == 1);
CV_Assert(mask.empty() || (mask.type() == CV_8U && src.size() == mask.size()));
bool double_ok = hasGreaterOrEqualVersion(1, 3) &&
hasNativeDoubleSupport(getDevice());
CV_Assert(src.type() != CV_64F || double_ok);
CV_Assert(src.type() != CV_64F || (hasGreaterOrEqualVersion(1, 3) &&
hasNativeDoubleSupport(getDevice())));
double minVal_; if (!minVal) minVal = &minVal_;
double maxVal_; if (!maxVal) maxVal = &maxVal_;
......@@ -375,11 +375,11 @@ void cv::gpu::minMaxLoc(const GpuMat& src, double* minVal, double* maxVal, Point
minMaxLocMaskCaller<double> };
CV_Assert(src.channels() == 1);
CV_Assert(mask.empty() || (mask.type() == CV_8U && src.size() == mask.size()));
bool double_ok = hasGreaterOrEqualVersion(1, 3) &&
hasNativeDoubleSupport(getDevice());
CV_Assert(src.type() != CV_64F || double_ok);
CV_Assert(src.type() != CV_64F || (hasGreaterOrEqualVersion(1, 3) &&
hasNativeDoubleSupport(getDevice())));
double minVal_; if (!minVal) minVal = &minVal_;
double maxVal_; if (!maxVal) maxVal = &maxVal_;
......@@ -459,9 +459,8 @@ int cv::gpu::countNonZero(const GpuMat& src, GpuMat& buf)
CV_Assert(src.channels() == 1);
bool double_ok = hasGreaterOrEqualVersion(1, 3) &&
hasNativeDoubleSupport(getDevice());
CV_Assert(src.type() != CV_64F || double_ok);
CV_Assert(src.type() != CV_64F || (hasGreaterOrEqualVersion(1, 3) &&
hasNativeDoubleSupport(getDevice())));
Size buf_size;
getBufSizeRequired(src.cols, src.rows, buf_size.width, buf_size.height);
......
......@@ -57,6 +57,7 @@
#include <sstream>
#include <exception>
#include <iterator>
#include <functional>
#include "opencv2/gpu/gpu.hpp"
#include "opencv2/imgproc/imgproc.hpp"
......
......@@ -49,7 +49,7 @@ using namespace std;
using namespace gpu;
#define CHECK(pred, err) if (!(pred)) { \
ts->printf(CvTS::LOG, "Fail: \"%s\" at line: %d\n", #pred, __LINE__); \
ts->printf(CvTS::CONSOLE, "Fail: \"%s\" at line: %d\n", #pred, __LINE__); \
ts->set_failed_test_info(err); \
return; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment