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
66ac4621
Commit
66ac4621
authored
Jul 23, 2014
by
Alexander Karsakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Final refactoring, fixes
parent
1d2cf0e2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
90 deletions
+33
-90
perf_arithm.cpp
modules/core/perf/opencl/perf_arithm.cpp
+1
-1
perf_dxt.cpp
modules/core/perf/opencl/perf_dxt.cpp
+9
-28
dxt.cpp
modules/core/src/dxt.cpp
+0
-0
ocl.cpp
modules/core/src/ocl.cpp
+3
-5
fft.cl
modules/core/src/opencl/fft.cl
+0
-0
test_dft.cpp
modules/core/test/ocl/test_dft.cpp
+20
-56
No files found.
modules/core/perf/opencl/perf_arithm.cpp
View file @
66ac4621
...
...
@@ -292,7 +292,7 @@ OCL_PERF_TEST_P(MagnitudeFixture, Magnitude, ::testing::Combine(
typedef
Size_MatType
TransposeFixture
;
OCL_PERF_TEST_P
(
TransposeFixture
,
Transpose
,
::
testing
::
Combine
(
OCL_TEST_SIZES
,
Values
(
CV_8UC1
,
CV_32FC1
,
CV_8UC2
,
CV_32FC2
,
CV_8UC4
,
CV_32FC4
)
))
OCL_TEST_SIZES
,
OCL_TEST_TYPES_134
))
{
const
Size_MatType_t
params
=
GetParam
();
const
Size
srcSize
=
get
<
0
>
(
params
);
...
...
modules/core/perf/opencl/perf_dxt.cpp
View file @
66ac4621
...
...
@@ -54,40 +54,21 @@ namespace ocl {
///////////// dft ////////////////////////
enum
OCL_FFT_TYPE
{
R2R
=
0
,
// real to real (CCS)
C2R
=
1
,
// complex to real
R2C
=
2
,
// real to complex
C2C
=
3
// complex to complex
};
typedef
tuple
<
OCL_FFT_TYPE
,
Size
,
int
>
DftParams
;
typedef
tuple
<
Size
,
int
>
DftParams
;
typedef
TestBaseWithParam
<
DftParams
>
DftFixture
;
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*/
)))
OCL_PERF_TEST_P
(
DftFixture
,
Dft
,
::
testing
::
Combine
(
Values
(
OCL_SIZE_1
,
OCL_SIZE_2
,
OCL_SIZE_3
),
Values
((
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
);
const
Size
srcSize
=
get
<
1
>
(
params
);
int
flags
=
get
<
2
>
(
params
);
int
in_cn
,
out_cn
;
switch
(
dft_type
)
{
case
R2R
:
flags
|=
cv
::
DFT_REAL_OUTPUT
;
in_cn
=
1
;
out_cn
=
1
;
break
;
case
C2R
:
flags
|=
cv
::
DFT_REAL_OUTPUT
;
in_cn
=
2
;
out_cn
=
2
;
break
;
case
R2C
:
flags
|=
cv
::
DFT_COMPLEX_OUTPUT
;
in_cn
=
1
;
out_cn
=
2
;
break
;
case
C2C
:
flags
|=
cv
::
DFT_COMPLEX_OUTPUT
;
in_cn
=
2
;
out_cn
=
2
;
break
;
}
UMat
src
(
srcSize
,
CV_MAKE_TYPE
(
CV_32F
,
in_cn
)),
dst
(
srcSize
,
CV_MAKE_TYPE
(
CV_32F
,
out_cn
));
const
Size
srcSize
=
get
<
0
>
(
params
);
const
int
flags
=
get
<
1
>
(
params
);
UMat
src
(
srcSize
,
CV_32FC2
),
dst
(
srcSize
,
CV_32FC2
);
declare
.
in
(
src
,
WARMUP_RNG
).
out
(
dst
);
OCL_TEST_CYCLE
()
cv
::
dft
(
src
,
dst
,
flags
);
OCL_TEST_CYCLE
()
cv
::
dft
(
src
,
dst
,
flags
|
DFT_COMPLEX_OUTPUT
);
SANITY_CHECK
(
dst
,
1e-3
);
}
...
...
modules/core/src/dxt.cpp
View file @
66ac4621
This diff is collapsed.
Click to expand it.
modules/core/src/ocl.cpp
View file @
66ac4621
...
...
@@ -3002,8 +3002,7 @@ bool Kernel::run(int dims, size_t _globalsize[], size_t _localsize[],
sync
?
0
:
&
p
->
e
);
if
(
sync
||
retval
!=
CL_SUCCESS
)
{
int
a
=
clFinish
(
qq
);
CV_OclDbgAssert
(
a
==
CL_SUCCESS
);
CV_OclDbgAssert
(
clFinish
(
qq
)
==
CL_SUCCESS
);
p
->
cleanupUMats
();
}
else
...
...
@@ -3899,9 +3898,8 @@ public:
if
(
(
accessFlags
&
ACCESS_READ
)
!=
0
&&
u
->
hostCopyObsolete
()
)
{
AlignedDataPtr
<
false
,
true
>
alignedPtr
(
u
->
data
,
u
->
size
,
CV_OPENCL_DATA_PTR_ALIGNMENT
);
int
a
=
clEnqueueReadBuffer
(
q
,
(
cl_mem
)
u
->
handle
,
CL_TRUE
,
0
,
u
->
size
,
alignedPtr
.
getAlignedPtr
(),
0
,
0
,
0
);
CV_Assert
(
a
==
CL_SUCCESS
);
CV_Assert
(
clEnqueueReadBuffer
(
q
,
(
cl_mem
)
u
->
handle
,
CL_TRUE
,
0
,
u
->
size
,
alignedPtr
.
getAlignedPtr
(),
0
,
0
,
0
)
==
CL_SUCCESS
);
u
->
markHostCopyObsolete
(
false
);
}
}
...
...
modules/core/src/opencl/fft.cl
View file @
66ac4621
This diff is collapsed.
Click to expand it.
modules/core/test/ocl/test_dft.cpp
View file @
66ac4621
...
...
@@ -48,26 +48,17 @@
#ifdef HAVE_OPENCL
enum
OCL_FFT_TYPE
{
R2R
=
0
,
C2R
=
1
,
R2C
=
2
,
C2C
=
3
};
namespace
cvtest
{
namespace
ocl
{
////////////////////////////////////////////////////////////////////////////
// Dft
PARAM_TEST_CASE
(
Dft
,
cv
::
Size
,
OCL_FFT_TYPE
,
bool
,
bool
,
bool
,
bool
)
PARAM_TEST_CASE
(
Dft
,
cv
::
Size
,
MatDepth
,
bool
,
bool
,
bool
,
bool
)
{
cv
::
Size
dft_size
;
int
dft_flags
,
depth
,
cn
,
dft_type
;
bool
hint
;
bool
is1d
;
int
dft_flags
,
depth
;
bool
inplace
;
TEST_DECLARE_INPUT_PARAMETER
(
src
);
TEST_DECLARE_OUTPUT_PARAMETER
(
dst
);
...
...
@@ -75,60 +66,34 @@ PARAM_TEST_CASE(Dft, cv::Size, OCL_FFT_TYPE, bool, bool, bool, bool)
virtual
void
SetUp
()
{
dft_size
=
GET_PARAM
(
0
);
d
ft_type
=
GET_PARAM
(
1
);
depth
=
CV_32F
;
d
epth
=
GET_PARAM
(
1
);
inplace
=
GET_PARAM
(
2
)
;
dft_flags
=
0
;
switch
(
dft_type
)
{
case
R2R
:
dft_flags
|=
cv
::
DFT_REAL_OUTPUT
;
cn
=
1
;
break
;
case
C2R
:
dft_flags
|=
cv
::
DFT_REAL_OUTPUT
;
cn
=
2
;
break
;
case
R2C
:
dft_flags
|=
cv
::
DFT_COMPLEX_OUTPUT
;
cn
=
1
;
break
;
case
C2C
:
dft_flags
|=
cv
::
DFT_COMPLEX_OUTPUT
;
cn
=
2
;
break
;
}
if
(
GET_PARAM
(
2
))
dft_flags
|=
cv
::
DFT_INVERSE
;
if
(
GET_PARAM
(
3
))
dft_flags
|=
cv
::
DFT_ROWS
;
if
(
GET_PARAM
(
4
))
dft_flags
|=
cv
::
DFT_SCALE
;
hint
=
GET_PARAM
(
5
);
is1d
=
(
dft_flags
&
DFT_ROWS
)
!=
0
||
dft_size
.
height
==
1
;
if
(
GET_PARAM
(
5
))
dft_flags
|=
cv
::
DFT_INVERSE
;
}
void
generateTestData
()
void
generateTestData
(
int
cn
=
2
)
{
src
=
randomMat
(
dft_size
,
CV_MAKE_TYPE
(
depth
,
cn
),
0.0
,
100.0
);
usrc
=
src
.
getUMat
(
ACCESS_READ
);
if
(
inplace
)
dst
=
src
,
udst
=
usrc
;
}
};
OCL_TEST_P
(
Dft
,
Mat
)
OCL_TEST_P
(
Dft
,
C2C
)
{
generateTestData
();
int
nonzero_rows
=
hint
?
src
.
cols
-
randomInt
(
1
,
src
.
rows
-
1
)
:
0
;
OCL_OFF
(
cv
::
dft
(
src
,
dst
,
dft_flags
,
nonzero_rows
));
OCL_ON
(
cv
::
dft
(
usrc
,
udst
,
dft_flags
,
nonzero_rows
));
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 << dst << std::endl;
//std::cout << gpu << std::endl;
//int cn = udst.channels();
//
//Mat dst1ch = dst.reshape(1);
//Mat gpu1ch = gpu.reshape(1);
//Mat df;
//absdiff(dst1ch, gpu1ch, df);
//std::cout << Mat_<int>(df) << std::endl;
OCL_OFF
(
cv
::
dft
(
src
,
dst
,
dft_flags
|
cv
::
DFT_COMPLEX_OUTPUT
));
OCL_ON
(
cv
::
dft
(
usrc
,
udst
,
dft_flags
|
cv
::
DFT_COMPLEX_OUTPUT
));
double
eps
=
src
.
size
().
area
()
*
1e-4
;
EXPECT_MAT_NEAR
(
dst
,
udst
,
eps
);
...
...
@@ -185,15 +150,15 @@ 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
(
10
,
10
),
cv
::
Size
(
36
,
36
),
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
OCL_INSTANTIATE_TEST_CASE_P
(
Core
,
Dft
,
Combine
(
Values
(
cv
::
Size
(
2
,
3
),
cv
::
Size
(
5
,
4
),
cv
::
Size
(
25
,
20
),
cv
::
Size
(
512
,
1
),
cv
::
Size
(
1024
,
768
)),
Values
(
CV_32F
,
CV_64F
),
Bool
(),
// inplace
Bool
(),
// DFT_ROWS
Bool
(),
// DFT_SCALE
Bool
()
// hint
)
Bool
())
// DFT_INVERSE
);
}
}
// namespace cvtest::ocl
#endif // HAVE_OPENCL
\ No newline at end of file
#endif // HAVE_OPENCL
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