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
8ae669b6
Commit
8ae669b6
authored
Oct 24, 2017
by
Jaikrishnan Menon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CPU: Allow the use of precompiled headers when compiling generated code
This reduces compilation time by ~10x
parent
2bd9e144
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
1 deletion
+24
-1
compiler.cpp
src/ngraph/codegen/compiler.cpp
+10
-0
compiler.hpp
src/ngraph/codegen/compiler.hpp
+4
-0
external_function.cpp
src/ngraph/runtime/cpu/external_function.cpp
+10
-1
No files found.
src/ngraph/codegen/compiler.cpp
View file @
8ae669b6
...
...
@@ -67,6 +67,7 @@ static std::string GetExecutablePath(const char* Argv0)
execution_state
::
execution_state
()
:
m_execution_engine
{
nullptr
}
,
pch_enabled
(
false
)
{
}
...
...
@@ -151,8 +152,17 @@ std::unique_ptr<llvm::Module> execution_state::compile(const string& source, con
// CodeGen options
auto
&
CGO
=
Clang
->
getInvocation
().
getCodeGenOpts
();
// TODO: Debuginfo inclusion should be predicated
CGO
.
setDebugInfo
(
codegenoptions
::
FullDebugInfo
);
if
(
pch_enabled
)
{
// Preprocessor options
auto
&
PPO
=
Clang
->
getInvocation
().
getPreprocessorOpts
();
PPO
.
ImplicitPCHInclude
=
"ngcpu.pch"
;
PPO
.
DisablePCHValidation
=
1
;
}
// Map code filename to a memoryBuffer
StringRef
source_ref
(
source
);
unique_ptr
<
MemoryBuffer
>
buffer
=
MemoryBuffer
::
getMemBufferCopy
(
source_ref
);
...
...
src/ngraph/codegen/compiler.hpp
View file @
8ae669b6
...
...
@@ -44,6 +44,9 @@ public:
execution_state
();
~
execution_state
();
void
enable_pch
()
{
pch_enabled
=
true
;
}
void
disable_pch
()
{
pch_enabled
=
false
;
}
std
::
unique_ptr
<
llvm
::
Module
>
compile
(
const
std
::
string
&
source
,
const
std
::
string
&
name
=
""
);
bool
add_module
(
std
::
unique_ptr
<
llvm
::
Module
>&
);
...
...
@@ -61,6 +64,7 @@ public:
private
:
llvm
::
ExecutionEngine
*
m_execution_engine
;
std
::
string
jit_error
;
bool
pch_enabled
;
template
<
typename
signature
>
std
::
function
<
signature
>
f_cast
(
void
*
f
)
...
...
src/ngraph/runtime/cpu/external_function.cpp
View file @
8ae669b6
...
...
@@ -59,6 +59,10 @@
#include "ngraph/runtime/cpu/external_function.hpp"
#include "ngraph/runtime/utils.hpp"
// TODO: Decide if we want to ship this or
// just enable it for developer build-test cycles
#define NGCPU_PCH
using
namespace
std
;
using
namespace
ngraph
::
runtime
::
cpu
;
...
...
@@ -176,7 +180,7 @@ using namespace ngraph::element;
using namespace ngraph::runtime;
using namespace ngraph::runtime::cpu::eigen;
extern "C" void __entrypoint(ngraph::runtime::cpu::CallFrame* call_frame,
extern "C" void __entrypoint(ngraph::runtime::cpu::CallFrame* call_frame,
ngraph::runtime::TensorViewPtrs& tensor_views)
{
)"
;
...
...
@@ -215,6 +219,11 @@ extern "C" void __entrypoint(ngraph::runtime::cpu::CallFrame* call_frame,
out
.
close
();
ngraph
::
codegen
::
execution_state
estate
;
#if defined(NGCPU_PCH)
estate
.
enable_pch
();
#endif
auto
llvm_module
=
estate
.
compile
(
TU
,
"__ngcpu_codegen.cpp"
);
assert
(
llvm_module
);
estate
.
add_module
(
llvm_module
);
...
...
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