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
95bd32b5
Commit
95bd32b5
authored
Oct 28, 2013
by
Andrey Pavlenko
Committed by
OpenCV Buildbot
Oct 28, 2013
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1705 from ilya-lavrenov:ocl_flip
parents
bb15c006
cf5df1a7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
66 deletions
+30
-66
arithm.cpp
modules/ocl/src/arithm.cpp
+30
-66
arithm_flip.cl
modules/ocl/src/opencl/arithm_flip.cl
+0
-0
arithm_flip_rc.cl
modules/ocl/src/opencl/arithm_flip_rc.cl
+0
-0
No files found.
modules/ocl/src/arithm.cpp
View file @
95bd32b5
...
...
@@ -693,83 +693,47 @@ double cv::ocl::norm(const oclMat &src1, const oclMat &src2, int normType)
////////////////////////////////// flip //////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
static
void
arithmetic_flip_rows_run
(
const
oclMat
&
src
,
oclMat
&
dst
,
string
kernelName
)
{
int
channels
=
dst
.
oclchannels
();
int
depth
=
dst
.
depth
();
int
vector_lengths
[
4
][
7
]
=
{{
4
,
4
,
4
,
4
,
1
,
1
,
1
},
{
4
,
4
,
4
,
4
,
1
,
1
,
1
},
{
4
,
4
,
4
,
4
,
1
,
1
,
1
},
{
4
,
4
,
4
,
4
,
1
,
1
,
1
}
};
size_t
vector_length
=
vector_lengths
[
channels
-
1
][
depth
];
int
offset_cols
=
((
dst
.
offset
%
dst
.
step
)
/
dst
.
elemSize1
())
&
(
vector_length
-
1
);
int
cols
=
divUp
(
dst
.
cols
*
channels
+
offset_cols
,
vector_length
);
int
rows
=
divUp
(
dst
.
rows
,
2
);
size_t
localThreads
[
3
]
=
{
64
,
4
,
1
};
size_t
globalThreads
[
3
]
=
{
cols
,
rows
,
1
};
int
dst_step1
=
dst
.
cols
*
dst
.
elemSize
();
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
src
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
src
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
src
.
offset
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
dst
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
dst
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
dst
.
offset
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
dst
.
rows
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
cols
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
rows
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
dst_step1
));
enum
{
FLIP_COLS
=
1
<<
0
,
FLIP_ROWS
=
1
<<
1
,
FLIP_BOTH
=
FLIP_ROWS
|
FLIP_COLS
};
openCLExecuteKernel
(
src
.
clCxt
,
&
arithm_flip
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
depth
);
}
static
void
arithmetic_flip_cols_run
(
const
oclMat
&
src
,
oclMat
&
dst
,
string
kernelName
,
bool
isVertical
)
static
void
arithmetic_flip_run
(
const
oclMat
&
src
,
oclMat
&
dst
,
string
kernelName
,
int
flipType
)
{
int
channels
=
dst
.
oclchannels
();
int
depth
=
dst
.
depth
();
int
cols
=
dst
.
cols
,
rows
=
dst
.
rows
;
if
((
cols
==
1
&&
flipType
==
FLIP_COLS
)
||
(
rows
==
1
&&
flipType
==
FLIP_ROWS
)
||
(
rows
==
1
&&
cols
==
1
&&
flipType
==
FLIP_BOTH
))
{
src
.
copyTo
(
dst
);
return
;
}
int
vector_lengths
[
4
][
7
]
=
{{
1
,
1
,
1
,
1
,
1
,
1
,
1
},
{
1
,
1
,
1
,
1
,
1
,
1
,
1
},
{
1
,
1
,
1
,
1
,
1
,
1
,
1
},
{
1
,
1
,
1
,
1
,
1
,
1
,
1
}
};
cols
=
flipType
==
FLIP_COLS
?
divUp
(
cols
,
2
)
:
cols
;
rows
=
flipType
&
FLIP_ROWS
?
divUp
(
rows
,
2
)
:
rows
;
size_t
vector_length
=
vector_lengths
[
channels
-
1
][
depth
];
int
offset_cols
=
((
dst
.
offset
%
dst
.
step
)
/
dst
.
elemSize
())
&
(
vector_length
-
1
);
int
cols
=
divUp
(
dst
.
cols
+
offset_cols
,
vector_length
);
cols
=
isVertical
?
cols
:
divUp
(
cols
,
2
);
int
rows
=
isVertical
?
divUp
(
dst
.
rows
,
2
)
:
dst
.
rows
;
const
char
*
const
channelMap
[]
=
{
""
,
""
,
"2"
,
"4"
,
"4"
};
const
char
*
const
typeMap
[]
=
{
"uchar"
,
"char"
,
"ushort"
,
"short"
,
"int"
,
"float"
,
"double"
};
std
::
string
buildOptions
=
format
(
"-D T=%s%s"
,
typeMap
[
dst
.
depth
()],
channelMap
[
dst
.
oclchannels
()]);
size_t
localThreads
[
3
]
=
{
64
,
4
,
1
};
size_t
globalThreads
[
3
]
=
{
cols
,
rows
,
1
};
int
dst_step1
=
dst
.
cols
*
dst
.
elemSize
();
int
elemSize
=
src
.
elemSize
();
int
src_step
=
src
.
step
/
elemSize
,
src_offset
=
src
.
offset
/
elemSize
;
int
dst_step
=
dst
.
step
/
elemSize
,
dst_offset
=
dst
.
offset
/
elemSize
;
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
src
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
src
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
src
.
offset
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
src
_
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
src
_
offset
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
dst
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
dst
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
dst
.
offset
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
dst
_
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
dst
_
offset
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
dst
.
rows
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
dst
.
cols
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
rows
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
cols
));
if
(
isVertical
)
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
rows
));
else
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
cols
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
dst_step1
));
const
cv
::
ocl
::
ProgramEntry
*
source
=
isVertical
?
&
arithm_flip_rc
:
&
arithm_flip
;
openCLExecuteKernel
(
src
.
clCxt
,
source
,
kernelName
,
globalThreads
,
localThreads
,
args
,
src
.
oclchannels
(),
depth
);
openCLExecuteKernel
(
src
.
clCxt
,
&
arithm_flip
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
,
buildOptions
.
c_str
());
}
void
cv
::
ocl
::
flip
(
const
oclMat
&
src
,
oclMat
&
dst
,
int
flipCode
)
...
...
@@ -783,11 +747,11 @@ void cv::ocl::flip(const oclMat &src, oclMat &dst, int flipCode)
dst
.
create
(
src
.
size
(),
src
.
type
());
if
(
flipCode
==
0
)
arithmetic_flip_r
ows_run
(
src
,
dst
,
"arithm_flip_rows"
);
arithmetic_flip_r
un
(
src
,
dst
,
"arithm_flip_rows"
,
FLIP_ROWS
);
else
if
(
flipCode
>
0
)
arithmetic_flip_
cols_run
(
src
,
dst
,
"arithm_flip_cols"
,
false
);
arithmetic_flip_
run
(
src
,
dst
,
"arithm_flip_cols"
,
FLIP_COLS
);
else
arithmetic_flip_
cols_run
(
src
,
dst
,
"arithm_flip_rc"
,
true
);
arithmetic_flip_
run
(
src
,
dst
,
"arithm_flip_rows_cols"
,
FLIP_BOTH
);
}
//////////////////////////////////////////////////////////////////////////////
...
...
modules/ocl/src/opencl/arithm_flip.cl
View file @
95bd32b5
This diff is collapsed.
Click to expand it.
modules/ocl/src/opencl/arithm_flip_rc.cl
deleted
100644 → 0
View file @
bb15c006
This diff is collapsed.
Click to expand it.
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