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
f940c293
Commit
f940c293
authored
Nov 16, 2017
by
Robert Kimball
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compile faster
parent
6961353d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
7 deletions
+35
-7
compiler.cpp
src/ngraph/codegen/compiler.cpp
+23
-6
compiler.hpp
src/ngraph/codegen/compiler.hpp
+12
-1
No files found.
src/ngraph/codegen/compiler.cpp
View file @
f940c293
...
...
@@ -62,6 +62,22 @@ using namespace std;
using
namespace
ngraph
::
codegen
;
static
HeaderCache
s_header_cache
;
static
StaticCompiler
s_static_compiler
;
static
std
::
mutex
m_mutex
;
Compiler
::
Compiler
()
{
}
Compiler
::~
Compiler
()
{
}
std
::
unique_ptr
<
llvm
::
Module
>
Compiler
::
compile
(
const
std
::
string
&
source
)
{
lock_guard
<
mutex
>
lock
(
m_mutex
);
return
s_static_compiler
.
compile
(
source
);
}
static
std
::
string
GetExecutablePath
(
const
char
*
Argv0
)
{
...
...
@@ -71,11 +87,12 @@ static std::string GetExecutablePath(const char* Argv0)
return
llvm
::
sys
::
fs
::
getMainExecutable
(
Argv0
,
MainAddr
);
}
Compiler
::
Compiler
()
StaticCompiler
::
Static
Compiler
()
:
m_precompiled_headers_enabled
(
false
)
,
m_debuginfo_enabled
(
false
)
,
m_source_name
(
"code.cpp"
)
{
NGRAPH_INFO
<<
"Hello from the static compiler constructor"
;
llvm
::
InitializeAllTargets
();
llvm
::
InitializeAllTargetMCs
();
llvm
::
InitializeAllAsmPrinters
();
...
...
@@ -215,11 +232,11 @@ Compiler::Compiler()
TO
.
FeaturesAsWritten
.
emplace_back
(
"+fma"
);
}
Compiler
::~
Compiler
()
StaticCompiler
::~
Static
Compiler
()
{
}
bool
Compiler
::
is_version_number
(
const
string
&
path
)
bool
Static
Compiler
::
is_version_number
(
const
string
&
path
)
{
bool
rc
=
true
;
vector
<
string
>
tokens
=
ngraph
::
split
(
path
,
'.'
);
...
...
@@ -236,7 +253,7 @@ bool Compiler::is_version_number(const string& path)
return
rc
;
}
void
Compiler
::
add_header_search_path
(
HeaderSearchOptions
&
hso
,
const
string
&
path
)
void
Static
Compiler
::
add_header_search_path
(
HeaderSearchOptions
&
hso
,
const
string
&
path
)
{
#ifdef USE_CACHE
static
vector
<
string
>
valid_ext
=
{
".h"
,
".hpp"
,
".tcc"
,
""
};
...
...
@@ -269,7 +286,7 @@ void Compiler::add_header_search_path(HeaderSearchOptions& hso, const string& pa
#endif
}
void
Compiler
::
use_cached_files
(
std
::
unique_ptr
<
CompilerInstance
>&
ci
)
void
Static
Compiler
::
use_cached_files
(
std
::
unique_ptr
<
CompilerInstance
>&
ci
)
{
HeaderSearchOptions
&
hso
=
ci
->
getInvocation
().
getHeaderSearchOpts
();
for
(
const
string
&
path
:
s_header_cache
.
get_include_paths
())
...
...
@@ -282,7 +299,7 @@ void Compiler::use_cached_files(std::unique_ptr<CompilerInstance>& ci)
}
}
std
::
unique_ptr
<
llvm
::
Module
>
Compiler
::
compile
(
const
string
&
source
)
std
::
unique_ptr
<
llvm
::
Module
>
Static
Compiler
::
compile
(
const
string
&
source
)
{
// Map code filename to a memoryBuffer
StringRef
source_ref
(
source
);
...
...
src/ngraph/codegen/compiler.hpp
View file @
f940c293
...
...
@@ -28,6 +28,7 @@ namespace ngraph
{
class
module
;
class
Compiler
;
class
StaticCompiler
;
class
HeaderCache
;
}
}
...
...
@@ -45,11 +46,21 @@ private:
std
::
unique_ptr
<
llvm
::
Module
>
m_module
;
};
class
ngraph
::
codegen
::
Compiler
:
public
llvm
::
SectionMemoryManager
class
ngraph
::
codegen
::
Compiler
{
public
:
Compiler
();
~
Compiler
();
std
::
unique_ptr
<
llvm
::
Module
>
compile
(
const
std
::
string
&
source
);
private
:
};
class
ngraph
::
codegen
::
StaticCompiler
:
public
llvm
::
SectionMemoryManager
{
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
;
}
...
...
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