Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
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
ngraph
Commits
a7ac003f
Commit
a7ac003f
authored
Jun 28, 2019
by
pruthvi
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into pruthvi/memory_allocator
parents
5dc3b1be
b02b0812
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
7 deletions
+18
-7
cpu_backend.cpp
src/ngraph/runtime/cpu/cpu_backend.cpp
+14
-7
cpu_backend.hpp
src/ngraph/runtime/cpu/cpu_backend.hpp
+4
-0
No files found.
src/ngraph/runtime/cpu/cpu_backend.cpp
View file @
a7ac003f
...
@@ -109,18 +109,24 @@ shared_ptr<runtime::Executable>
...
@@ -109,18 +109,24 @@ shared_ptr<runtime::Executable>
#endif
#endif
shared_ptr
<
runtime
::
Executable
>
rc
;
shared_ptr
<
runtime
::
Executable
>
rc
;
auto
it
=
m_exec_map
.
find
(
func
);
// we will protect the access to map (m_exec_map) across multiple threads by creating a lock_gaurd
if
(
it
!=
m_exec_map
.
end
())
// m_exec_map_mutex will be released once the object `guard` goes out of scope
{
{
rc
=
it
->
second
;
std
::
lock_guard
<
std
::
mutex
>
guard
(
m_exec_map_mutex
);
auto
it
=
m_exec_map
.
find
(
func
);
if
(
it
!=
m_exec_map
.
end
())
{
rc
=
it
->
second
;
return
rc
;
}
}
}
else
rc
=
make_shared
<
CPU_Executable
>
(
func
,
pass_config
,
get_host_memory_allocator
(),
performance_counters_enabled
);
{
{
rc
=
make_shared
<
CPU_Executable
>
(
std
::
lock_guard
<
std
::
mutex
>
guard
(
m_exec_map_mutex
);
func
,
pass_config
,
get_host_memory_allocator
(),
performance_counters_enabled
);
m_exec_map
.
insert
({
func
,
rc
});
m_exec_map
.
insert
({
func
,
rc
});
return
rc
;
}
}
return
rc
;
}
}
runtime
::
cpu
::
CPU_Executable
::
CPU_Executable
(
shared_ptr
<
Function
>
func
,
runtime
::
cpu
::
CPU_Executable
::
CPU_Executable
(
shared_ptr
<
Function
>
func
,
...
@@ -164,6 +170,7 @@ bool runtime::cpu::CPU_Executable::call(const vector<shared_ptr<runtime::Tensor>
...
@@ -164,6 +170,7 @@ bool runtime::cpu::CPU_Executable::call(const vector<shared_ptr<runtime::Tensor>
void
runtime
::
cpu
::
CPU_Backend
::
remove_compiled_function
(
shared_ptr
<
Executable
>
exec
)
void
runtime
::
cpu
::
CPU_Backend
::
remove_compiled_function
(
shared_ptr
<
Executable
>
exec
)
{
{
std
::
lock_guard
<
std
::
mutex
>
guard
(
m_exec_map_mutex
);
for
(
auto
it
=
m_exec_map
.
begin
();
it
!=
m_exec_map
.
end
();
++
it
)
for
(
auto
it
=
m_exec_map
.
begin
();
it
!=
m_exec_map
.
end
();
++
it
)
{
{
if
(
it
->
second
==
exec
)
if
(
it
->
second
==
exec
)
...
...
src/ngraph/runtime/cpu/cpu_backend.hpp
View file @
a7ac003f
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#include <map>
#include <map>
#include <memory>
#include <memory>
#include <mutex>
#include "cpu_backend_visibility.h"
#include "cpu_backend_visibility.h"
#include "ngraph/pass/pass_config.hpp"
#include "ngraph/pass/pass_config.hpp"
...
@@ -70,6 +71,9 @@ namespace ngraph
...
@@ -70,6 +71,9 @@ namespace ngraph
bool
is_supported_property
(
const
Property
prop
)
const
override
;
bool
is_supported_property
(
const
Property
prop
)
const
override
;
private
:
private
:
// this mutex will be used to protect the addition and deletion
// of function to m_exec_map across multiple threads
std
::
mutex
m_exec_map_mutex
;
std
::
unordered_map
<
std
::
shared_ptr
<
Function
>
,
std
::
shared_ptr
<
Executable
>>
std
::
unordered_map
<
std
::
shared_ptr
<
Function
>
,
std
::
shared_ptr
<
Executable
>>
m_exec_map
;
m_exec_map
;
std
::
unique_ptr
<
Allocator
>
m_allocator
;
std
::
unique_ptr
<
Allocator
>
m_allocator
;
...
...
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