1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Updated optimal block size estimation for the convolve() function

This commit is contained in:
Alexey Spizhevoy
2011-10-03 14:05:52 +00:00
parent bee68e519a
commit 8a799aa89a
5 changed files with 37 additions and 16 deletions
+7 -5
View File
@@ -735,16 +735,18 @@ PERF_TEST_P(DevInfo_Size, dft, testing::Combine(testing::ValuesIn(devices()),
SANITY_CHECK(dst_host);
}
PERF_TEST_P(DevInfo_Size, convolve, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES)))
PERF_TEST_P(DevInfo_Int_Int, convolve, testing::Combine(testing::ValuesIn(devices()),
testing::Values(512, 1024, 1536, 2048, 2560, 3072, 3584),
testing::Values(27, 32, 64)))
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int image_size = std::tr1::get<1>(GetParam());
int templ_size = std::tr1::get<2>(GetParam());
setDevice(devInfo.deviceID());
Mat image_host(size, CV_32FC1);
Mat templ_host(size, CV_32FC1);
Mat image_host(image_size, image_size, CV_32FC1);
Mat templ_host(templ_size, templ_size, CV_32FC1);
declare.in(image_host, templ_host, WARMUP_RNG);
+1
View File
@@ -32,6 +32,7 @@ struct CvtColorInfo
typedef TestBaseWithParam<DeviceInfo> DevInfo;
typedef TestBaseWithParam< std::tr1::tuple<DeviceInfo, Size> > DevInfo_Size;
typedef TestBaseWithParam< std::tr1::tuple<DeviceInfo, int, int> > DevInfo_Int_Int;
typedef TestBaseWithParam< std::tr1::tuple<DeviceInfo, MatType> > DevInfo_MatType;
typedef TestBaseWithParam< std::tr1::tuple<DeviceInfo, Size, MatType> > DevInfo_Size_MatType;
typedef TestBaseWithParam< std::tr1::tuple<DeviceInfo, Size, MatType, MatType> > DevInfo_Size_MatType_MatType;
+8 -3
View File
@@ -1546,18 +1546,23 @@ void cv::gpu::ConvolveBuf::create(Size image_size, Size templ_size)
Size cv::gpu::ConvolveBuf::estimateBlockSize(Size result_size, Size templ_size)
{
int scale = 40;
Size bsize_min(1024, 1024);
Size bsize_min(512, 512);
// Check whether we use Fermi generation or newer GPU
if (DeviceInfo().majorVersion() >= 2)
{
bsize_min.width = 2048;
bsize_min.height = 2048;
bsize_min.width = 1024;
bsize_min.height = 1024;
}
Size bsize(std::max(templ_size.width * scale, bsize_min.width),
std::max(templ_size.height * scale, bsize_min.height));
int blocks_per_row = (result_size.width + bsize.width - 1) / bsize.width;
int blocks_per_col = (result_size.height + bsize.height - 1) / bsize.height;
bsize.width = (result_size.width + blocks_per_row - 1) / blocks_per_row;
bsize.height = (result_size.height + blocks_per_col - 1) / blocks_per_col;
bsize.width = std::min(bsize.width, result_size.width);
bsize.height = std::min(bsize.height, result_size.height);
return bsize;