Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
52f76a32
Commit
52f76a32
authored
Jul 22, 2014
by
Alexander Karsakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added rest Elena's changes
parent
77912645
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
109 additions
and
60 deletions
+109
-60
perf_dxt.cpp
modules/core/perf/opencl/perf_dxt.cpp
+3
-3
dxt.cpp
modules/core/src/dxt.cpp
+90
-41
fft.cl
modules/core/src/opencl/fft.cl
+0
-0
test_dft.cpp
modules/core/test/ocl/test_dft.cpp
+16
-16
No files found.
modules/core/perf/opencl/perf_dxt.cpp
View file @
52f76a32
...
...
@@ -65,10 +65,10 @@ enum OCL_FFT_TYPE
typedef
tuple
<
OCL_FFT_TYPE
,
Size
,
int
>
DftParams
;
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
((
int
)
0
,
(
int
)
DFT_ROWS
,
(
int
)
DFT_SCALE
,
(
int
)
DFT_INVERSE
,
/*(int)DFT_INVERSE | DFT_SCALE,*/
(
int
)
DFT_ROWS
|
DFT_INVERSE
)))
Values
((
int
)
0
,
(
int
)
DFT_ROWS
,
(
int
)
DFT_SCALE
/*
, (int)DFT_INVERSE,
(int)DFT_INVERSE | DFT_SCALE, (int)DFT_ROWS | DFT_INVERSE*/
)))
{
const
DftParams
params
=
GetParam
();
const
int
dft_type
=
get
<
0
>
(
params
);
...
...
modules/core/src/dxt.cpp
View file @
52f76a32
...
...
@@ -1791,14 +1791,6 @@ namespace cv {
CV_Assert(s == CLFFT_SUCCESS); \
}
enum
FftType
{
R2R
=
0
,
// real to real
C2R
=
1
,
// opencl HERMITIAN_INTERLEAVED to real
R2C
=
2
,
// real to opencl HERMITIAN_INTERLEAVED
C2C
=
3
// complex to complex
};
class
PlanCache
{
struct
FftPlan
...
...
@@ -2034,6 +2026,14 @@ namespace cv
#ifdef HAVE_OPENCL
enum
FftType
{
R2R
=
0
,
C2R
=
1
,
R2C
=
2
,
C2C
=
3
};
static
std
::
vector
<
int
>
ocl_getRadixes
(
int
cols
,
std
::
vector
<
int
>&
radixes
,
std
::
vector
<
int
>&
blocks
,
int
&
min_radix
)
{
int
factors
[
34
];
...
...
@@ -2054,13 +2054,19 @@ static std::vector<int> ocl_getRadixes(int cols, std::vector<int>& radixes, std:
else
if
(
4
*
n
<=
factors
[
0
])
{
radix
=
4
;
if
(
cols
%
8
==
0
)
if
(
cols
%
12
==
0
)
block
=
3
;
else
if
(
cols
%
8
==
0
)
block
=
2
;
}
else
{
if
(
cols
%
8
==
0
)
if
(
cols
%
10
==
0
)
block
=
5
;
else
if
(
cols
%
8
==
0
)
block
=
4
;
else
if
(
cols
%
6
==
0
)
block
=
3
;
else
if
(
cols
%
4
==
0
)
block
=
2
;
}
...
...
@@ -2081,6 +2087,8 @@ static std::vector<int> ocl_getRadixes(int cols, std::vector<int>& radixes, std:
{
if
(
cols
%
12
==
0
)
block
=
4
;
else
if
(
cols
%
9
==
0
)
block
=
3
;
else
if
(
cols
%
6
==
0
)
block
=
2
;
}
...
...
@@ -2142,7 +2150,6 @@ struct OCL_FftPlan
{
int
radix
=
radixes
[
i
];
n
*=
radix
;
for
(
int
j
=
1
;
j
<
radix
;
j
++
)
{
...
...
@@ -2160,7 +2167,7 @@ struct OCL_FftPlan
dft_size
,
dft_size
/
thread_count
,
radix_processing
.
c_str
());
}
bool
enqueueTransform
(
InputArray
_src
,
OutputArray
_dst
,
int
dft_size
,
int
flags
,
bool
rows
=
true
)
const
bool
enqueueTransform
(
InputArray
_src
,
OutputArray
_dst
,
int
dft_size
,
int
flags
,
int
fftType
,
bool
rows
=
true
)
const
{
if
(
!
status
)
return
false
;
...
...
@@ -2195,12 +2202,25 @@ struct OCL_FftPlan
if
(
src
.
channels
()
==
1
)
options
+=
" -D REAL_INPUT"
;
else
options
+=
" -D COMPLEX_INPUT"
;
if
(
dst
.
channels
()
==
1
)
options
+=
" -D CCS_OUTPUT"
;
if
((
is1d
&&
src
.
channels
()
==
1
)
||
(
rows
&&
(
flags
&
DFT_REAL_OUTPUT
)))
options
+=
" -D NO_CONJUGATE"
;
options
+=
" -D REAL_OUTPUT"
;
if
(
is1d
)
options
+=
" -D IS_1D"
;
if
(
!
inv
)
{
if
((
is1d
&&
src
.
channels
()
==
1
)
||
(
rows
&&
(
fftType
==
R2R
)))
options
+=
" -D NO_CONJUGATE"
;
}
else
{
if
(
is1d
&&
fftType
==
C2R
||
(
rows
&&
fftType
==
R2R
))
options
+=
" -D NO_CONJUGATE"
;
if
(
dst
.
cols
%
2
==
0
)
options
+=
" -D EVEN"
;
}
ocl
::
Kernel
k
(
kernel_name
.
c_str
(),
ocl
::
core
::
fft_oclsrc
,
options
);
if
(
k
.
empty
())
...
...
@@ -2253,16 +2273,16 @@ protected:
std
::
vector
<
OCL_FftPlan
*>
planStorage
;
};
static
bool
ocl_dft_C2C_rows
(
InputArray
_src
,
OutputArray
_dst
,
int
nonzero_rows
,
int
flags
)
static
bool
ocl_dft_C2C_rows
(
InputArray
_src
,
OutputArray
_dst
,
int
nonzero_rows
,
int
flags
,
int
fftType
)
{
const
OCL_FftPlan
*
plan
=
OCL_FftPlanCache
::
getInstance
().
getFftPlan
(
_src
.
cols
(),
flags
);
return
plan
->
enqueueTransform
(
_src
,
_dst
,
nonzero_rows
,
flags
,
true
);
return
plan
->
enqueueTransform
(
_src
,
_dst
,
nonzero_rows
,
flags
,
fftType
,
true
);
}
static
bool
ocl_dft_C2C_cols
(
InputArray
_src
,
OutputArray
_dst
,
int
nonzero_cols
,
int
flags
)
static
bool
ocl_dft_C2C_cols
(
InputArray
_src
,
OutputArray
_dst
,
int
nonzero_cols
,
int
flags
,
int
fftType
)
{
const
OCL_FftPlan
*
plan
=
OCL_FftPlanCache
::
getInstance
().
getFftPlan
(
_src
.
rows
(),
flags
);
return
plan
->
enqueueTransform
(
_src
,
_dst
,
nonzero_cols
,
flags
,
false
);
return
plan
->
enqueueTransform
(
_src
,
_dst
,
nonzero_cols
,
flags
,
f
ftType
,
f
alse
);
}
static
bool
ocl_dft
(
InputArray
_src
,
OutputArray
_dst
,
int
flags
,
int
nonzero_rows
)
...
...
@@ -2298,29 +2318,26 @@ static bool ocl_dft(InputArray _src, OutputArray _dst, int flags, int nonzero_ro
complex_output
=
1
;
}
FftType
fftType
=
(
FftType
)(
complex_input
<<
0
|
complex_output
<<
1
);
// Forward Complex to CCS not supported
if
(
complex_input
&&
real_output
&&
!
inv
)
{
flags
^=
DFT_REAL_OUTPUT
;
flags
|=
DFT_COMPLEX_OUTPUT
;
real_output
=
0
;
complex_output
=
1
;
}
if
(
fftType
==
C2R
&&
!
inv
)
fftType
=
C2C
;
// Inverse CCS to Complex not supported
if
(
real_input
&&
complex_output
&&
inv
)
{
complex_output
=
0
;
real_output
=
1
;
}
if
(
fftType
==
R2C
&&
inv
)
fftType
=
R2R
;
UMat
output
;
if
(
complex_output
)
if
(
fftType
==
C2C
||
fftType
==
R2C
)
{
// complex output
_dst
.
create
(
src
.
size
(),
CV_32FC2
);
output
=
_dst
.
getUMat
();
}
}
else
{
// real output
if
(
is1d
)
{
_dst
.
create
(
src
.
size
(),
CV_32FC1
);
...
...
@@ -2333,17 +2350,49 @@ static bool ocl_dft(InputArray _src, OutputArray _dst, int flags, int nonzero_ro
}
}
if
(
!
ocl_dft_C2C_rows
(
src
,
output
,
nonzero_rows
,
flags
))
return
false
;
if
(
!
is1d
)
if
(
!
inv
)
{
int
nonzero_cols
=
real_input
&&
real_output
?
output
.
cols
/
2
+
1
:
output
.
cols
;
if
(
!
ocl_dft_C2C_cols
(
output
,
_dst
,
nonzero_cols
,
flags
))
if
(
!
ocl_dft_C2C_rows
(
src
,
output
,
nonzero_rows
,
flags
,
fftType
))
return
false
;
}
else
if
(
!
is1d
)
{
int
nonzero_cols
=
fftType
==
R2R
?
output
.
cols
/
2
+
1
:
output
.
cols
;
if
(
!
ocl_dft_C2C_cols
(
output
,
_dst
,
nonzero_cols
,
flags
,
fftType
))
return
false
;
}
}
else
{
_dst
.
assign
(
output
);
if
(
fftType
==
C2C
)
{
// complex output
if
(
!
ocl_dft_C2C_rows
(
src
,
output
,
nonzero_rows
,
flags
,
fftType
))
return
false
;
if
(
!
is1d
)
{
if
(
!
ocl_dft_C2C_cols
(
output
,
output
,
output
.
cols
,
flags
,
fftType
))
return
false
;
}
}
else
{
if
(
is1d
)
{
if
(
!
ocl_dft_C2C_rows
(
src
,
output
,
nonzero_rows
,
flags
,
fftType
))
return
false
;
}
else
{
int
nonzero_cols
=
src
.
cols
/
2
+
1
;
// : src.cols;
if
(
!
ocl_dft_C2C_cols
(
src
,
output
,
nonzero_cols
,
flags
,
fftType
))
return
false
;
if
(
!
ocl_dft_C2C_rows
(
output
,
_dst
,
nonzero_rows
,
flags
,
fftType
))
return
false
;
}
}
}
return
true
;
}
...
...
modules/core/src/opencl/fft.cl
View file @
52f76a32
This diff is collapsed.
Click to expand it.
modules/core/test/ocl/test_dft.cpp
View file @
52f76a32
...
...
@@ -50,10 +50,10 @@
enum
OCL_FFT_TYPE
{
R2R
=
0
,
// real to real (CCS)
C2R
=
1
,
// complex to real (CCS)
R2C
=
2
,
// real (CCS) to complex
C2C
=
3
// complex to complex
R2R
=
0
,
C2R
=
1
,
R2C
=
2
,
C2C
=
3
};
namespace
cvtest
{
...
...
@@ -62,7 +62,7 @@ namespace ocl {
////////////////////////////////////////////////////////////////////////////
// Dft
PARAM_TEST_CASE
(
Dft
,
cv
::
Size
,
OCL_FFT_TYPE
,
bool
,
bool
,
bool
)
PARAM_TEST_CASE
(
Dft
,
cv
::
Size
,
OCL_FFT_TYPE
,
bool
,
bool
,
bool
,
bool
)
{
cv
::
Size
dft_size
;
int
dft_flags
,
depth
,
cn
,
dft_type
;
...
...
@@ -88,12 +88,12 @@ PARAM_TEST_CASE(Dft, cv::Size, OCL_FFT_TYPE, bool, bool, bool)
}
if
(
GET_PARAM
(
2
))
dft_flags
|=
cv
::
DFT_
ROWS
;
dft_flags
|=
cv
::
DFT_
INVERSE
;
if
(
GET_PARAM
(
3
))
dft_flags
|=
cv
::
DFT_ROWS
;
if
(
GET_PARAM
(
4
))
dft_flags
|=
cv
::
DFT_SCALE
;
/*if (GET_PARAM(4))
dft_flags |= cv::DFT_INVERSE;*/
inplace
=
GET_PARAM
(
4
);
inplace
=
GET_PARAM
(
5
);
is1d
=
(
dft_flags
&
DFT_ROWS
)
!=
0
||
dft_size
.
height
==
1
;
...
...
@@ -116,16 +116,16 @@ OCL_TEST_P(Dft, Mat)
OCL_OFF
(
cv
::
dft
(
src
,
dst
,
dft_flags
));
OCL_ON
(
cv
::
dft
(
usrc
,
udst
,
dft_flags
));
if
(
dft_type
==
R2C
&&
is1d
)
if
(
dft_type
==
R2C
&&
is1d
&&
(
dft_flags
&
cv
::
DFT_INVERSE
)
==
0
)
{
dst
=
dst
(
cv
::
Range
(
0
,
dst
.
rows
),
cv
::
Range
(
0
,
dst
.
cols
/
2
+
1
));
udst
=
udst
(
cv
::
Range
(
0
,
udst
.
rows
),
cv
::
Range
(
0
,
udst
.
cols
/
2
+
1
));
}
//
Mat gpu = udst.getMat(ACCESS_READ);
//
std::cout << src << std::endl;
//
std::cout << dst << std::endl;
//
std::cout << gpu << std::endl;
Mat
gpu
=
udst
.
getMat
(
ACCESS_READ
);
std
::
cout
<<
src
<<
std
::
endl
;
std
::
cout
<<
dst
<<
std
::
endl
;
std
::
cout
<<
gpu
<<
std
::
endl
;
//int cn = udst.channels();
//
...
...
@@ -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
(
Core
,
Dft
,
Combine
(
Values
(
cv
::
Size
(
16
,
4
),
cv
::
Size
(
5
,
8
),
cv
::
Size
(
6
,
6
),
OCL_INSTANTIATE_TEST_CASE_P
(
Core
,
Dft
,
Combine
(
Values
(
cv
::
Size
(
4
,
1
),
cv
::
Size
(
5
,
8
),
cv
::
Size
(
6
,
6
),
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
),
Bool
(),
// DFT_INVERSE
Bool
(),
// DFT_ROWS
Bool
(),
// DFT_SCALE
//Bool(), // DFT_INVERSE
Bool
()
// inplace
)
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment