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
89f23a35
Commit
89f23a35
authored
Jul 24, 2019
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15091 from anton-potapov:fluid_internal_parallellism_custom_pfor
parents
79310a00
8936d556
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
7 deletions
+30
-7
gfluidkernel.hpp
modules/gapi/include/opencv2/gapi/fluid/gfluidkernel.hpp
+11
-0
gfluidbackend.cpp
modules/gapi/src/backends/fluid/gfluidbackend.cpp
+16
-6
gfluidbackend.hpp
modules/gapi/src/backends/fluid/gfluidbackend.hpp
+3
-1
gapi_fluid_parallel_rois_test.cpp
modules/gapi/test/gapi_fluid_parallel_rois_test.cpp
+0
-0
No files found.
modules/gapi/include/opencv2/gapi/fluid/gfluidkernel.hpp
View file @
89f23a35
...
...
@@ -104,12 +104,23 @@ struct GFluidParallelOutputRois
std
::
vector
<
GFluidOutputRois
>
parallel_rois
;
};
struct
GFluidParallelFor
{
std
::
function
<
void
(
std
::
size_t
,
std
::
function
<
void
(
std
::
size_t
)
>
)
>
parallel_for
;
};
namespace
detail
{
template
<>
struct
CompileArgTag
<
GFluidOutputRois
>
{
static
const
char
*
tag
()
{
return
"gapi.fluid.outputRois"
;
}
};
template
<>
struct
CompileArgTag
<
GFluidParallelFor
>
{
static
const
char
*
tag
()
{
return
"gapi.fluid.parallelFor"
;
}
};
template
<>
struct
CompileArgTag
<
GFluidParallelOutputRois
>
{
static
const
char
*
tag
()
{
return
"gapi.fluid.parallelOutputRois"
;
}
...
...
modules/gapi/src/backends/fluid/gfluidbackend.cpp
View file @
89f23a35
...
...
@@ -94,8 +94,16 @@ namespace
auto
graph_data
=
fluidExtractInputDataFromGraph
(
graph
,
nodes
);
const
auto
parallel_out_rois
=
cv
::
gimpl
::
getCompileArg
<
cv
::
GFluidParallelOutputRois
>
(
args
);
const
auto
gpfor
=
cv
::
gimpl
::
getCompileArg
<
cv
::
GFluidParallelFor
>
(
args
);
auto
serial_for
=
[](
std
::
size_t
count
,
std
::
function
<
void
(
std
::
size_t
)
>
f
){
for
(
std
::
size_t
i
=
0
;
i
<
count
;
++
i
){
f
(
i
);
}
};
auto
pfor
=
gpfor
.
has_value
()
?
gpfor
.
value
().
parallel_for
:
serial_for
;
return
parallel_out_rois
.
has_value
()
?
EPtr
{
new
cv
::
gimpl
::
GParallelFluidExecutable
(
graph
,
graph_data
,
std
::
move
(
parallel_out_rois
.
value
().
parallel_rois
))}
EPtr
{
new
cv
::
gimpl
::
GParallelFluidExecutable
(
graph
,
graph_data
,
std
::
move
(
parallel_out_rois
.
value
().
parallel_rois
)
,
pfor
)}
:
EPtr
{
new
cv
::
gimpl
::
GFluidExecutable
(
graph
,
graph_data
,
std
::
move
(
rois
.
rois
))}
;
}
...
...
@@ -1325,7 +1333,9 @@ void cv::gimpl::GFluidExecutable::run(std::vector<InObj> &input_objs,
cv
::
gimpl
::
GParallelFluidExecutable
::
GParallelFluidExecutable
(
const
ade
::
Graph
&
g
,
const
FluidGraphInputData
&
graph_data
,
const
std
::
vector
<
GFluidOutputRois
>
&
parallelOutputRois
)
const
std
::
vector
<
GFluidOutputRois
>
&
parallelOutputRois
,
const
decltype
(
parallel_for
)
&
pfor
)
:
parallel_for
(
pfor
)
{
for
(
auto
&&
rois
:
parallelOutputRois
){
tiles
.
emplace_back
(
new
GFluidExecutable
(
g
,
graph_data
,
rois
.
rois
));
...
...
@@ -1342,10 +1352,10 @@ void cv::gimpl::GParallelFluidExecutable::reshape(ade::Graph&, const GCompileArg
void
cv
::
gimpl
::
GParallelFluidExecutable
::
run
(
std
::
vector
<
InObj
>
&&
input_objs
,
std
::
vector
<
OutObj
>
&&
output_objs
)
{
for
(
auto
&
tile
:
tiles
){
GAPI_Assert
((
bool
)
tile
);
tile
->
run
(
input_objs
,
output_objs
);
}
parallel_for
(
tiles
.
size
(),
[
&
,
this
](
std
::
size_t
index
){
GAPI_Assert
((
bool
)
tile
s
[
index
]
);
tile
s
[
index
]
->
run
(
input_objs
,
output_objs
);
}
);
}
...
...
modules/gapi/src/backends/fluid/gfluidbackend.hpp
View file @
89f23a35
...
...
@@ -166,10 +166,12 @@ class GParallelFluidExecutable final: public GIslandExecutable {
GParallelFluidExecutable
(
const
GParallelFluidExecutable
&
)
=
delete
;
// due std::unique_ptr in members list
std
::
vector
<
std
::
unique_ptr
<
GFluidExecutable
>>
tiles
;
decltype
(
GFluidParallelFor
::
parallel_for
)
parallel_for
;
public
:
GParallelFluidExecutable
(
const
ade
::
Graph
&
g
,
const
FluidGraphInputData
&
graph_data
,
const
std
::
vector
<
GFluidOutputRois
>
&
parallelOutputRois
);
const
std
::
vector
<
GFluidOutputRois
>
&
parallelOutputRois
,
const
decltype
(
parallel_for
)
&
pfor
);
virtual
inline
bool
canReshape
()
const
override
{
return
false
;
}
...
...
modules/gapi/test/gapi_fluid_parallel_rois_test.cpp
View file @
89f23a35
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