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
634da9f3
Commit
634da9f3
authored
Jun 09, 2014
by
Ilya Lavrenov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added norm_inf support to minmaxloc kernel
parent
7f2662b3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
67 deletions
+26
-67
ocl_defs.hpp
modules/core/include/opencv2/core/opencl/ocl_defs.hpp
+1
-1
minmaxloc.cl
modules/core/src/opencl/minmaxloc.cl
+18
-4
reduce.cl
modules/core/src/opencl/reduce.cl
+1
-24
stat.cpp
modules/core/src/stat.cpp
+6
-38
No files found.
modules/core/include/opencv2/core/opencl/ocl_defs.hpp
View file @
634da9f3
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved.
// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
// Third party copyrights are property of their respective owners.
#define CV_OPENCL_RUN_ASSERT
//
#define CV_OPENCL_RUN_ASSERT
#ifdef HAVE_OPENCL
#ifdef HAVE_OPENCL
...
...
modules/core/src/opencl/minmaxloc.cl
View file @
634da9f3
...
@@ -41,10 +41,15 @@
...
@@ -41,10 +41,15 @@
#
if
kercn
!=
3
#
if
kercn
!=
3
#
define
loadpix
(
addr
)
*
(
__global
const
srcT
*
)(
addr
)
#
define
loadpix
(
addr
)
*
(
__global
const
srcT
*
)(
addr
)
#
define
srcTSIZE
(
int
)
sizeof
(
srcT
1
)
#
define
srcTSIZE
(
int
)
sizeof
(
srcT
)
#
else
#
else
#
define
loadpix
(
addr
)
vload3
(
0
,
(
__global
const
srcT1
*
)(
addr
))
#
define
loadpix
(
addr
)
vload3
(
0
,
(
__global
const
srcT1
*
)(
addr
))
#
define
srcTSIZE
((
int
)
sizeof
(
srcT1
))
#
define
srcTSIZE
((
int
)
sizeof
(
srcT1
)
*
3
)
#
endif
#
ifndef
HAVE_MASK
#
undef
srcTSIZE
#
define
srcTSIZE
(
int
)
sizeof
(
srcT1
)
#
endif
#
endif
#
ifdef
NEED_MINLOC
#
ifdef
NEED_MINLOC
...
@@ -106,7 +111,12 @@ __kernel void minmaxloc(__global const uchar * srcptr, int src_step, int src_off
...
@@ -106,7 +111,12 @@ __kernel void minmaxloc(__global const uchar * srcptr, int src_step, int src_off
{
{
int
lid
=
get_local_id
(
0
)
;
int
lid
=
get_local_id
(
0
)
;
int
gid
=
get_group_id
(
0
)
;
int
gid
=
get_group_id
(
0
)
;
int
id
=
get_global_id
(
0
)
*
kercn
;
int
id
=
get_global_id
(
0
)
#
ifndef
HAVE_MASK
*
kercn
;
#
else
;
#
endif
srcptr
+=
src_offset
;
srcptr
+=
src_offset
;
#
ifdef
HAVE_MASK
#
ifdef
HAVE_MASK
...
@@ -150,7 +160,11 @@ __kernel void minmaxloc(__global const uchar * srcptr, int src_step, int src_off
...
@@ -150,7 +160,11 @@ __kernel void minmaxloc(__global const uchar * srcptr, int src_step, int src_off
dstT
temp2
;
dstT
temp2
;
#
endif
#
endif
for
(
int
grain
=
groupnum
*
WGS
*
kercn
; id < total; id += grain)
for
(
int
grain
=
groupnum
*
WGS
#
ifndef
HAVE_MASK
*
kercn
#
endif
; id < total; id += grain)
{
{
#
ifdef
HAVE_MASK
#
ifdef
HAVE_MASK
#
ifdef
HAVE_MASK_CONT
#
ifdef
HAVE_MASK_CONT
...
...
modules/core/src/opencl/reduce.cl
View file @
634da9f3
...
@@ -543,32 +543,9 @@
...
@@ -543,32 +543,9 @@
#
define
CALC_RESULT
\
#
define
CALC_RESULT
\
storepix
(
localmem[0],
dstptr
+
dstTSIZE
*
gid
)
storepix
(
localmem[0],
dstptr
+
dstTSIZE
*
gid
)
//
norm
(
NORM_INF
)
with
cn
>
1
and
mask
#
elif
defined
OP_NORM_INF_MASK
#
define
DECLARE_LOCAL_MEM
\
__local
srcT
localmem_max[WGS2_ALIGNED]
#
define
DEFINE_ACCUMULATOR
\
srcT
maxval
=
MIN_VAL,
temp
#
define
REDUCE_GLOBAL
\
MASK_INDEX
; \
if
(
mask[mask_index]
)
\
{
\
temp
=
loadpix
(
srcptr
+
src_index
)
; \
maxval
=
max
(
maxval,
(
srcT
)(
temp
>=
(
srcT
)(
0
)
?
temp
:
-temp
))
; \
}
#
define
SET_LOCAL_1
\
localmem_max[lid]
=
maxval
#
define
REDUCE_LOCAL_1
\
localmem_max[lid
-
WGS2_ALIGNED]
=
max
(
maxval,
localmem_max[lid
-
WGS2_ALIGNED]
)
#
define
REDUCE_LOCAL_2
\
localmem_max[lid]
=
max
(
localmem_max[lid],
localmem_max[lid2]
)
#
define
CALC_RESULT
\
storepix
(
localmem_max[0],
dstptr
+
dstTSIZE
*
gid
)
#
else
#
else
#
error
"No operation"
#
error
"No operation"
#
endif
//
end
of
norm
(
NORM_INF
)
with
cn
>
1
and
mask
#
endif
#
ifdef
OP_DOT
#
ifdef
OP_DOT
#
undef
EXTRA_PARAMS
#
undef
EXTRA_PARAMS
...
...
modules/core/src/stat.cpp
View file @
634da9f3
...
@@ -1437,7 +1437,7 @@ static bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int*
...
@@ -1437,7 +1437,7 @@ static bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int*
kercn
=
haveMask
?
cn
:
std
::
min
(
4
,
ocl
::
predictOptimalVectorWidth
(
_src
));
kercn
=
haveMask
?
cn
:
std
::
min
(
4
,
ocl
::
predictOptimalVectorWidth
(
_src
));
CV_Assert
(
(
cn
==
1
&&
(
!
haveMask
||
_mask
.
type
()
==
CV_8U
))
||
CV_Assert
(
(
cn
==
1
&&
(
!
haveMask
||
_mask
.
type
()
==
CV_8U
))
||
(
cn
>=
1
&&
(
!
haveMask
||
haveSrc2
)
&&
!
minLoc
&&
!
maxLoc
)
);
(
cn
>=
1
&&
!
minLoc
&&
!
maxLoc
)
);
if
(
ddepth
<
0
)
if
(
ddepth
<
0
)
ddepth
=
depth
;
ddepth
=
depth
;
...
@@ -1465,7 +1465,7 @@ static bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int*
...
@@ -1465,7 +1465,7 @@ static bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int*
if
(
needMinVal
)
if
(
needMinVal
)
needMinLoc
=
true
;
needMinLoc
=
true
;
else
else
needMax
Val
=
true
;
needMax
Loc
=
true
;
}
}
char
cvt
[
40
];
char
cvt
[
40
];
...
@@ -1484,8 +1484,6 @@ static bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int*
...
@@ -1484,8 +1484,6 @@ static bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int*
haveSrc2
?
" -D HAVE_SRC2"
:
""
,
maxVal2
?
" -D OP_CALC2"
:
""
,
haveSrc2
?
" -D HAVE_SRC2"
:
""
,
maxVal2
?
" -D OP_CALC2"
:
""
,
haveSrc2
&&
_src2
.
isContinuous
()
?
" -D HAVE_SRC2_CONT"
:
""
);
haveSrc2
&&
_src2
.
isContinuous
()
?
" -D HAVE_SRC2_CONT"
:
""
);
printf
(
"%s
\n
"
,
opts
.
c_str
());
ocl
::
Kernel
k
(
"minmaxloc"
,
ocl
::
core
::
minmaxloc_oclsrc
,
opts
);
ocl
::
Kernel
k
(
"minmaxloc"
,
ocl
::
core
::
minmaxloc_oclsrc
,
opts
);
if
(
k
.
empty
())
if
(
k
.
empty
())
return
false
;
return
false
;
...
@@ -1496,7 +1494,7 @@ static bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int*
...
@@ -1496,7 +1494,7 @@ static bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int*
(
maxVal2
?
esz
:
0
));
(
maxVal2
?
esz
:
0
));
UMat
src
=
_src
.
getUMat
(),
src2
=
_src2
.
getUMat
(),
db
(
1
,
dbsize
,
CV_8UC1
),
mask
=
_mask
.
getUMat
();
UMat
src
=
_src
.
getUMat
(),
src2
=
_src2
.
getUMat
(),
db
(
1
,
dbsize
,
CV_8UC1
),
mask
=
_mask
.
getUMat
();
if
(
cn
>
1
)
if
(
cn
>
1
&&
!
haveMask
)
{
{
src
=
src
.
reshape
(
1
);
src
=
src
.
reshape
(
1
);
src2
=
src2
.
reshape
(
1
);
src2
=
src2
.
reshape
(
1
);
...
@@ -2181,39 +2179,9 @@ static bool ocl_norm( InputArray _src, int normType, InputArray _mask, double &
...
@@ -2181,39 +2179,9 @@ static bool ocl_norm( InputArray _src, int normType, InputArray _mask, double &
if
(
normType
==
NORM_INF
)
if
(
normType
==
NORM_INF
)
{
{
if
(
cn
==
1
||
!
haveMask
)
if
(
!
ocl_minMaxIdx
(
_src
,
NULL
,
&
result
,
NULL
,
NULL
,
_mask
,
ocl_minMaxIdx
(
_src
,
NULL
,
&
result
,
NULL
,
NULL
,
_mask
,
std
::
max
(
depth
,
CV_32S
),
depth
!=
CV_8U
&&
depth
!=
CV_16U
))
std
::
max
(
depth
,
CV_32S
),
depth
!=
CV_8U
&&
depth
!=
CV_16U
);
return
false
;
else
{
int
dbsize
=
d
.
maxComputeUnits
();
size_t
wgs
=
d
.
maxWorkGroupSize
();
int
wgs2_aligned
=
1
;
while
(
wgs2_aligned
<
(
int
)
wgs
)
wgs2_aligned
<<=
1
;
wgs2_aligned
>>=
1
;
ocl
::
Kernel
k
(
"reduce"
,
ocl
::
core
::
reduce_oclsrc
,
format
(
"-D OP_NORM_INF_MASK -D HAVE_MASK -D DEPTH_%d"
" -D srcT=%s -D srcT1=%s -D WGS=%d -D cn=%d -D WGS2_ALIGNED=%d%s%s%s"
,
depth
,
ocl
::
typeToStr
(
type
),
ocl
::
typeToStr
(
depth
),
wgs
,
cn
,
wgs2_aligned
,
doubleSupport
?
" -D DOUBLE_SUPPORT"
:
""
,
src
.
isContinuous
()
?
" -D HAVE_CONT_SRC"
:
""
,
_mask
.
isContinuous
()
?
" -D HAVE_MASK_CONT"
:
""
));
if
(
k
.
empty
())
return
false
;
UMat
db
(
1
,
dbsize
,
type
),
mask
=
_mask
.
getUMat
();
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
src
),
src
.
cols
,
(
int
)
src
.
total
(),
dbsize
,
ocl
::
KernelArg
::
PtrWriteOnly
(
db
),
ocl
::
KernelArg
::
ReadOnlyNoSize
(
mask
));
size_t
globalsize
=
dbsize
*
wgs
;
if
(
!
k
.
run
(
1
,
&
globalsize
,
&
wgs
,
true
))
return
false
;
minMaxIdx
(
db
.
getMat
(
ACCESS_READ
),
NULL
,
&
result
,
NULL
,
NULL
,
noArray
());
}
}
}
else
if
(
normType
==
NORM_L1
||
normType
==
NORM_L2
||
normType
==
NORM_L2SQR
)
else
if
(
normType
==
NORM_L1
||
normType
==
NORM_L2
||
normType
==
NORM_L2SQR
)
{
{
...
...
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