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
3e976292
Commit
3e976292
authored
Jul 31, 2019
by
pruthvi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Address PR comments
- mutex to make setting the shared library search directory thread safe
parent
5c268aa8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
4 deletions
+9
-4
backend.cpp
src/ngraph/runtime/backend.cpp
+6
-4
backend.hpp
src/ngraph/runtime/backend.hpp
+3
-0
No files found.
src/ngraph/runtime/backend.cpp
View file @
3e976292
...
...
@@ -31,10 +31,11 @@
using
namespace
std
;
using
namespace
ngraph
;
std
::
mutex
runtime
::
Backend
::
m_mtx
;
std
::
string
runtime
::
Backend
::
s_backend_shared_library_search_directory
;
// This finds the full path of the containing shared library
static
string
find_my_
fil
e
()
static
string
find_my_
pathnam
e
()
{
#ifdef _WIN32
HMODULE
hModule
=
GetModuleHandleW
(
L"ngraph.dll"
);
...
...
@@ -48,7 +49,7 @@ static string find_my_file()
return
path
;
#else
Dl_info
dl_info
;
dladdr
(
reinterpret_cast
<
void
*>
(
find_my_
fil
e
),
&
dl_info
);
dladdr
(
reinterpret_cast
<
void
*>
(
find_my_
pathnam
e
),
&
dl_info
);
return
dl_info
.
dli_fname
;
#endif
}
...
...
@@ -116,7 +117,7 @@ void runtime::Backend::remove_compiled_function(std::shared_ptr<Executable> exec
std
::
shared_ptr
<
runtime
::
Executable
>
runtime
::
Backend
::
load
(
istream
&
input_stream
)
{
throw
runtime_error
(
"load opertion unimplemented."
);
throw
runtime_error
(
"load oper
a
tion unimplemented."
);
}
bool
runtime
::
Backend
::
is_device_memory
(
void
*
ptr
)
...
...
@@ -128,6 +129,7 @@ bool runtime::Backend::is_device_memory(void* ptr)
void
runtime
::
Backend
::
set_backend_shared_library_search_directory
(
const
string
&
path
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
runtime
::
Backend
::
m_mtx
);
s_backend_shared_library_search_directory
=
path
;
}
...
...
@@ -135,7 +137,7 @@ const string& runtime::Backend::get_backend_shared_library_search_directory()
{
if
(
s_backend_shared_library_search_directory
.
empty
())
{
s_backend_shared_library_search_directory
=
find_my_
fil
e
();
s_backend_shared_library_search_directory
=
find_my_
pathnam
e
();
}
return
s_backend_shared_library_search_directory
;
}
...
...
src/ngraph/runtime/backend.hpp
View file @
3e976292
...
...
@@ -17,6 +17,7 @@
#pragma once
#include <memory>
#include <mutex>
#include "ngraph/function.hpp"
#include "ngraph/pass/pass_config.hpp"
...
...
@@ -172,5 +173,7 @@ public:
virtual
bool
is_device_memory
(
void
*
ptr
);
private
:
// mutex to modify s_backend_shared_library_search_directory thread safe
static
std
::
mutex
m_mtx
;
static
std
::
string
s_backend_shared_library_search_directory
;
};
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