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
24a21089
Commit
24a21089
authored
Nov 20, 2017
by
Robert Kimball
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
3f215a06
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
22 deletions
+27
-22
compiler.cpp
src/ngraph/codegen/compiler.cpp
+17
-19
compiler.hpp
src/ngraph/codegen/compiler.hpp
+7
-3
external_function.cpp
src/ngraph/runtime/cpu/external_function.cpp
+3
-0
No files found.
src/ngraph/codegen/compiler.cpp
View file @
24a21089
...
...
@@ -89,14 +89,10 @@ static std::string GetExecutablePath(const char* Argv0)
}
StaticCompiler
::
StaticCompiler
()
:
m_precompiled_header
s_enable
d
(
false
)
:
m_precompiled_header
_vali
d
(
false
)
,
m_debuginfo_enabled
(
false
)
,
m_source_name
(
"code.cpp"
)
{
#if NGCPU_PCH
m_precompiled_headers_enabled
=
true
;
#endif
#if NGCPU_DEBUGINFO
m_debuginfo_enabled
=
true
;
#endif
...
...
@@ -215,17 +211,6 @@ StaticCompiler::StaticCompiler()
CGO
.
setDebugInfo
(
codegenoptions
::
FullDebugInfo
);
}
// if (!m_precompiled_header_valid)
// {
// }
if
(
m_precompiled_header_valid
)
{
// Preprocessor options
auto
&
PPO
=
m_compiler
->
getInvocation
().
getPreprocessorOpts
();
PPO
.
ImplicitPCHInclude
=
"ngcpu.pch"
;
PPO
.
DisablePCHValidation
=
1
;
}
// Enable various target features
// Most of these are for Eigen
auto
&
TO
=
m_compiler
->
getInvocation
().
getTargetOpts
();
...
...
@@ -317,7 +302,19 @@ void StaticCompiler::use_cached_files()
std
::
unique_ptr
<
llvm
::
Module
>
StaticCompiler
::
compile
(
const
string
&
source
)
{
generate_pch
(
source
);
if
(
!
m_precompiled_header_valid
&&
m_precomiled_header_source
.
empty
()
==
false
)
{
NGRAPH_INFO
<<
m_precomiled_header_source
;
generate_pch
(
m_precomiled_header_source
);
}
if
(
m_precompiled_header_valid
)
{
NGRAPH_INFO
;
// Preprocessor options
auto
&
PPO
=
m_compiler
->
getInvocation
().
getPreprocessorOpts
();
PPO
.
ImplicitPCHInclude
=
m_pch_path
;
PPO
.
DisablePCHValidation
=
1
;
}
// Map code filename to a memoryBuffer
StringRef
source_ref
(
source
);
...
...
@@ -342,8 +339,8 @@ std::unique_ptr<llvm::Module> StaticCompiler::compile(const string& source)
void
StaticCompiler
::
generate_pch
(
const
string
&
source
)
{
NGRAPH_INFO
;
string
pch_path
=
file_util
::
path_join
(
file_util
::
get_temp_directory
(),
"ngraph.pch"
);
m_compiler
->
getFrontendOpts
().
OutputFile
=
pch_path
;
m_
pch_path
=
file_util
::
path_join
(
file_util
::
get_temp_directory
(),
"ngraph.pch"
);
m_compiler
->
getFrontendOpts
().
OutputFile
=
m_
pch_path
;
// Map code filename to a memoryBuffer
StringRef
source_ref
(
source
);
...
...
@@ -355,6 +352,7 @@ void StaticCompiler::generate_pch(const string& source)
if
(
m_compiler
->
ExecuteAction
(
*
compilerAction
)
==
true
)
{
NGRAPH_INFO
;
m_precompiled_header_valid
=
true
;
}
buffer
.
release
();
...
...
src/ngraph/codegen/compiler.hpp
View file @
24a21089
...
...
@@ -62,20 +62,24 @@ public:
StaticCompiler
();
~
StaticCompiler
();
void
set_precompiled_headers_enabled
(
bool
state
)
{
m_precompiled_headers_enabled
=
state
;
}
bool
is_precompiled_headers_enabled
()
{
return
m_precompiled_headers_enabled
;
}
void
set_debuginfo_enabled
(
bool
state
)
{
m_debuginfo_enabled
=
state
;
}
bool
is_debuginfo_enabled
()
{
return
m_debuginfo_enabled
;
}
void
set_precomiled_header_source
(
const
std
::
string
&
source
)
{
m_precomiled_header_source
=
source
;
}
void
add_header_search_path
(
const
std
::
string
&
path
);
std
::
unique_ptr
<
llvm
::
Module
>
compile
(
const
std
::
string
&
source
);
void
generate_pch
(
const
std
::
string
&
source
);
private
:
std
::
unique_ptr
<
clang
::
CompilerInstance
>
m_compiler
;
bool
m_precompiled_header
s_enable
d
;
bool
m_precompiled_header
_vali
d
;
bool
m_debuginfo_enabled
;
std
::
string
m_source_name
;
std
::
vector
<
std
::
string
>
m_extra_search_path_list
;
std
::
string
m_pch_path
;
std
::
string
m_precomiled_header_source
;
bool
is_version_number
(
const
std
::
string
&
path
);
void
use_cached_files
();
...
...
src/ngraph/runtime/cpu/external_function.cpp
View file @
24a21089
...
...
@@ -197,6 +197,7 @@ void ExternalFunction::compile()
using namespace ngraph::runtime::cpu::eigen;
)"
;
string
pch_header_source
=
TU
.
get_code
();
TU
<<
"// Declare all functions
\n
"
;
for
(
shared_ptr
<
Function
>
f
:
pass_manager
.
get_state
().
get_functions
())
...
...
@@ -318,6 +319,8 @@ using namespace ngraph::runtime::cpu::eigen;
codegen
::
Compiler
compiler
;
codegen
::
ExecutionEngine
execution_engine
;
compiler
.
set_precomiled_header_source
(
pch_header_source
);
auto
llvm_module
=
compiler
.
compile
(
code
);
if
(
llvm_module
==
nullptr
)
{
...
...
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