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
c83455d8
Commit
c83455d8
authored
May 23, 2014
by
Ilya Lavrenov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimized cv::repeat
parent
7249622c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
10 deletions
+69
-10
copy.cpp
modules/core/src/copy.cpp
+20
-8
ocl.cpp
modules/core/src/ocl.cpp
+2
-2
repeat.cl
modules/core/src/opencl/repeat.cl
+47
-0
No files found.
modules/core/src/copy.cpp
View file @
c83455d8
...
@@ -758,16 +758,28 @@ void flip( InputArray _src, OutputArray _dst, int flip_mode )
...
@@ -758,16 +758,28 @@ void flip( InputArray _src, OutputArray _dst, int flip_mode )
static
bool
ocl_repeat
(
InputArray
_src
,
int
ny
,
int
nx
,
OutputArray
_dst
)
static
bool
ocl_repeat
(
InputArray
_src
,
int
ny
,
int
nx
,
OutputArray
_dst
)
{
{
if
(
ny
==
1
&&
nx
==
1
)
{
_src
.
copyTo
(
_dst
);
return
true
;
}
int
type
=
_src
.
type
(),
depth
=
CV_MAT_DEPTH
(
type
),
cn
=
CV_MAT_CN
(
type
),
rowsPerWI
=
ocl
::
Device
::
getDefault
().
isIntel
()
?
4
:
1
,
kercn
=
std
::
min
(
ocl
::
predictOptimalVectorWidth
(
_src
,
_dst
),
4
);
ocl
::
Kernel
k
(
"repeat"
,
ocl
::
core
::
repeat_oclsrc
,
format
(
"-D T=%s -D nx=%d -D ny=%d -D rowsPerWI=%d -D cn=%d"
,
ocl
::
memopTypeToStr
(
CV_MAKE_TYPE
(
depth
,
kercn
)),
nx
,
ny
,
rowsPerWI
,
kercn
));
if
(
k
.
empty
())
return
false
;
UMat
src
=
_src
.
getUMat
(),
dst
=
_dst
.
getUMat
();
UMat
src
=
_src
.
getUMat
(),
dst
=
_dst
.
getUMat
();
k
.
args
(
ocl
::
KernelArg
::
ReadOnly
(
src
,
cn
,
kercn
),
ocl
::
KernelArg
::
WriteOnlyNoSize
(
dst
));
for
(
int
y
=
0
;
y
<
ny
;
++
y
)
size_t
globalsize
[]
=
{
src
.
cols
*
cn
/
kercn
,
(
src
.
rows
+
rowsPerWI
-
1
)
/
rowsPerWI
};
for
(
int
x
=
0
;
x
<
nx
;
++
x
)
return
k
.
run
(
2
,
globalsize
,
NULL
,
false
);
{
Rect
roi
(
x
*
src
.
cols
,
y
*
src
.
rows
,
src
.
cols
,
src
.
rows
);
UMat
hdr
(
dst
,
roi
);
src
.
copyTo
(
hdr
);
}
return
true
;
}
}
#endif
#endif
...
...
modules/core/src/ocl.cpp
View file @
c83455d8
...
@@ -4406,8 +4406,8 @@ String kernelToStr(InputArray _kernel, int ddepth, const char * name)
...
@@ -4406,8 +4406,8 @@ String kernelToStr(InputArray _kernel, int ddepth, const char * name)
CV_Assert(src.isMat() || src.isUMat()); \
CV_Assert(src.isMat() || src.isUMat()); \
int ctype = src.type(), ccn = CV_MAT_CN(ctype); \
int ctype = src.type(), ccn = CV_MAT_CN(ctype); \
Size csize = src.size(); \
Size csize = src.size(); \
cols.push_back(ccn *
src.size()
.width); \
cols.push_back(ccn *
csize
.width); \
if (ctype != type
|| csize != ssize
) \
if (ctype != type) \
return 1; \
return 1; \
offsets.push_back(src.offset()); \
offsets.push_back(src.offset()); \
steps.push_back(src.step()); \
steps.push_back(src.step()); \
...
...
modules/core/src/opencl/repeat.cl
0 → 100644
View file @
c83455d8
//
This
file
is
part
of
OpenCV
project.
//
It
is
subject
to
the
license
terms
in
the
LICENSE
file
found
in
the
top-level
directory
//
of
this
distribution
and
at
http://opencv.org/license.html.
//
Copyright
(
C
)
2014
,
Itseez,
Inc.,
all
rights
reserved.
//
Third
party
copyrights
are
property
of
their
respective
owners.
#
if
cn
!=
3
#
define
loadpix
(
addr
)
*
(
__global
const
T
*
)(
addr
)
#
define
storepix
(
val,
addr
)
*
(
__global
T
*
)(
addr
)
=
val
#
define
TSIZE
(
int
)
sizeof
(
T
)
#
else
#
define
loadpix
(
addr
)
vload3
(
0
,
(
__global
const
T1
*
)(
addr
))
#
define
storepix
(
val,
addr
)
vstore3
(
val,
0
,
(
__global
T1
*
)(
addr
))
#
define
TSIZE
((
int
)
sizeof
(
T1
)
*3
)
#
endif
__kernel
void
repeat
(
__global
const
uchar
*
srcptr,
int
src_step,
int
src_offset,
int
src_rows,
int
src_cols,
__global
uchar
*
dstptr,
int
dst_step,
int
dst_offset
)
{
int
x
=
get_global_id
(
0
)
;
int
y0
=
get_global_id
(
1
)
*
rowsPerWI
;
if
(
x
<
src_cols
)
{
int
src_index
=
mad24
(
y0,
src_step,
mad24
(
x,
(
int
)
sizeof
(
T
)
,
src_offset
))
;
int
dst_index0
=
mad24
(
y0,
dst_step,
mad24
(
x,
(
int
)
sizeof
(
T
)
,
dst_offset
))
;
for
(
int
y
=
y0,
y1
=
min
(
src_rows,
y0
+
rowsPerWI
)
; y < y1; ++y, src_index += src_step, dst_index0 += dst_step)
{
T
srcelem
=
loadpix
(
srcptr
+
src_index
)
;
#
pragma
unroll
for
(
int
ey
=
0
; ey < ny; ++ey)
{
int
dst_index
=
mad24
(
ey
*
src_rows,
dst_step,
dst_index0
)
;
#
pragma
unroll
for
(
int
ex
=
0
; ex < nx; ++ex)
{
storepix
(
srcelem,
dstptr
+
dst_index
)
;
dst_index
=
mad24
(
src_cols,
(
int
)
sizeof
(
T
)
,
dst_index
)
;
}
}
}
}
}
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