Commit 77912645 authored by Alexander Karsakov's avatar Alexander Karsakov

Added multi-block scheme

parent 2b9e5560
...@@ -65,10 +65,10 @@ enum OCL_FFT_TYPE ...@@ -65,10 +65,10 @@ enum OCL_FFT_TYPE
typedef tuple<OCL_FFT_TYPE, Size, int> DftParams; typedef tuple<OCL_FFT_TYPE, Size, int> DftParams;
typedef TestBaseWithParam<DftParams> DftFixture; typedef TestBaseWithParam<DftParams> DftFixture;
OCL_PERF_TEST_P(DftFixture, Dft, ::testing::Combine(Values(C2C, R2R, C2R, R2C), OCL_PERF_TEST_P(DftFixture, Dft, ::testing::Combine(Values(C2C/*, R2R, C2R, R2C*/),
Values(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3, Size(1024, 1024), Size(512, 512), Size(2048, 2048)), Values(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3, Size(1024, 1024), Size(512, 512), Size(2048, 2048)),
Values((int)DFT_ROWS, (int) 0, (int)DFT_SCALE/*, (int)DFT_INVERSE, Values((int) 0, (int)DFT_ROWS, (int)DFT_SCALE, (int)DFT_INVERSE,
(int)DFT_INVERSE | DFT_SCALE, (int)DFT_ROWS | DFT_INVERSE*/))) /*(int)DFT_INVERSE | DFT_SCALE,*/ (int)DFT_ROWS | DFT_INVERSE)))
{ {
const DftParams params = GetParam(); const DftParams params = GetParam();
const int dft_type = get<0>(params); const int dft_type = get<0>(params);
......
...@@ -2041,23 +2041,33 @@ static std::vector<int> ocl_getRadixes(int cols, std::vector<int>& radixes, std: ...@@ -2041,23 +2041,33 @@ static std::vector<int> ocl_getRadixes(int cols, std::vector<int>& radixes, std:
int n = 1; int n = 1;
int factor_index = 0; int factor_index = 0;
min_radix = INT_MAX;
// 2^n transforms // 2^n transforms
if ( (factors[factor_index] & 1) == 0 ) if ( (factors[factor_index] & 1) == 0 )
{ {
for( ; n < factors[factor_index]; ) for( ; n < factors[factor_index]; )
{ {
int radix = 2; int radix = 2, block = 1;
if (8*n <= factors[0]) if (8*n <= factors[0])
radix = 8; radix = 8;
else if (4*n <= factors[0]) else if (4*n <= factors[0])
{
radix = 4; radix = 4;
if (cols % 8 == 0)
block = 2;
}
else
{
if (cols % 8 == 0)
block = 4;
else if (cols % 4 == 0)
block = 2;
}
radixes.push_back(radix); radixes.push_back(radix);
if (radix == 2 && cols % 4 == 0) blocks.push_back(block);
min_radix = min(min_radix, 2*radix); min_radix = min(min_radix, block*radix);
else
min_radix = min(min_radix, radix);
n *= radix; n *= radix;
} }
factor_index++; factor_index++;
...@@ -2066,11 +2076,22 @@ static std::vector<int> ocl_getRadixes(int cols, std::vector<int>& radixes, std: ...@@ -2066,11 +2076,22 @@ static std::vector<int> ocl_getRadixes(int cols, std::vector<int>& radixes, std:
// all the other transforms // all the other transforms
for( ; factor_index < nf; factor_index++ ) for( ; factor_index < nf; factor_index++ )
{ {
radixes.push_back(factors[factor_index]); int radix = factors[factor_index], block = 1;
if (factors[factor_index] == 3 && cols % 6 == 0) if (radix == 3)
min_radix = min(min_radix, 2*factors[factor_index]); {
else if (cols % 12 == 0)
min_radix = min(min_radix, factors[factor_index]); block = 4;
else if (cols % 6 == 0)
block = 2;
}
else if (radix == 5)
{
if (cols % 10 == 0)
block = 2;
}
radixes.push_back(radix);
blocks.push_back(block);
min_radix = min(min_radix, block*radix);
} }
return radixes; return radixes;
} }
...@@ -2086,7 +2107,7 @@ struct OCL_FftPlan ...@@ -2086,7 +2107,7 @@ struct OCL_FftPlan
bool status; bool status;
OCL_FftPlan(int _size, int _flags): dft_size(_size), flags(_flags), status(true) OCL_FftPlan(int _size, int _flags): dft_size(_size), flags(_flags), status(true)
{ {
int min_radix = INT_MAX; int min_radix;
std::vector<int> radixes, blocks; std::vector<int> radixes, blocks;
ocl_getRadixes(dft_size, radixes, blocks, min_radix); ocl_getRadixes(dft_size, radixes, blocks, min_radix);
thread_count = (dft_size + min_radix-1) / min_radix; thread_count = (dft_size + min_radix-1) / min_radix;
...@@ -2102,9 +2123,9 @@ struct OCL_FftPlan ...@@ -2102,9 +2123,9 @@ struct OCL_FftPlan
int n = 1, twiddle_size = 0; int n = 1, twiddle_size = 0;
for (size_t i=0; i<radixes.size(); i++) for (size_t i=0; i<radixes.size(); i++)
{ {
int radix = radixes[i]; int radix = radixes[i], block = blocks[i];
if ((radix == 2 && dft_size % 4 == 0) || (radix == 3 && dft_size % 6 == 0)) if (block > 1)
radix_processing += format("fft_radix%d_B2(smem,twiddles+%d,ind,%d,%d);", radix, twiddle_size, n, dft_size/radix); radix_processing += format("fft_radix%d_B%d(smem,twiddles+%d,ind,%d,%d);", radix, block, twiddle_size, n, dft_size/radix);
else else
radix_processing += format("fft_radix%d(smem,twiddles+%d,ind,%d,%d);", radix, twiddle_size, n, dft_size/radix); radix_processing += format("fft_radix%d(smem,twiddles+%d,ind,%d,%d);", radix, twiddle_size, n, dft_size/radix);
twiddle_size += (radix-1)*n; twiddle_size += (radix-1)*n;
......
This diff is collapsed.
...@@ -62,7 +62,7 @@ namespace ocl { ...@@ -62,7 +62,7 @@ namespace ocl {
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// Dft // Dft
PARAM_TEST_CASE(Dft, cv::Size, OCL_FFT_TYPE, bool, bool, bool, bool) PARAM_TEST_CASE(Dft, cv::Size, OCL_FFT_TYPE, bool, bool, bool)
{ {
cv::Size dft_size; cv::Size dft_size;
int dft_flags, depth, cn, dft_type; int dft_flags, depth, cn, dft_type;
...@@ -91,9 +91,9 @@ PARAM_TEST_CASE(Dft, cv::Size, OCL_FFT_TYPE, bool, bool, bool, bool) ...@@ -91,9 +91,9 @@ PARAM_TEST_CASE(Dft, cv::Size, OCL_FFT_TYPE, bool, bool, bool, bool)
dft_flags |= cv::DFT_ROWS; dft_flags |= cv::DFT_ROWS;
if (GET_PARAM(3)) if (GET_PARAM(3))
dft_flags |= cv::DFT_SCALE; dft_flags |= cv::DFT_SCALE;
if (GET_PARAM(4)) /*if (GET_PARAM(4))
dft_flags |= cv::DFT_INVERSE; dft_flags |= cv::DFT_INVERSE;*/
inplace = GET_PARAM(5); inplace = GET_PARAM(4);
is1d = (dft_flags & DFT_ROWS) != 0 || dft_size.height == 1; is1d = (dft_flags & DFT_ROWS) != 0 || dft_size.height == 1;
...@@ -188,12 +188,12 @@ OCL_TEST_P(MulSpectrums, Mat) ...@@ -188,12 +188,12 @@ OCL_TEST_P(MulSpectrums, Mat)
OCL_INSTANTIATE_TEST_CASE_P(OCL_ImgProc, MulSpectrums, testing::Combine(Bool(), Bool())); OCL_INSTANTIATE_TEST_CASE_P(OCL_ImgProc, MulSpectrums, testing::Combine(Bool(), Bool()));
OCL_INSTANTIATE_TEST_CASE_P(Core, Dft, Combine(Values(cv::Size(6, 4), cv::Size(5, 8), cv::Size(6, 6), OCL_INSTANTIATE_TEST_CASE_P(Core, Dft, Combine(Values(cv::Size(16, 4), cv::Size(5, 8), cv::Size(6, 6),
cv::Size(512, 1), cv::Size(1280, 768)), cv::Size(512, 1), cv::Size(1280, 768)),
Values(/*(OCL_FFT_TYPE) R2C, */(OCL_FFT_TYPE) C2C/*, (OCL_FFT_TYPE) R2R, (OCL_FFT_TYPE) C2R*/), Values((OCL_FFT_TYPE) R2C, (OCL_FFT_TYPE) C2C, (OCL_FFT_TYPE) R2R, (OCL_FFT_TYPE) C2R),
Bool(), // DFT_ROWS Bool(), // DFT_ROWS
Bool(), // DFT_SCALE Bool(), // DFT_SCALE
Bool(), // DFT_INVERSE //Bool(), // DFT_INVERSE
Bool() // inplace Bool() // inplace
) )
); );
......
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