Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pycodegen
pystencils
Commits
8d22fddf
Commit
8d22fddf
authored
5 years ago
by
Stephan Seitz
Browse files
Options
Downloads
Patches
Plain Diff
llvm: Add llc to pystencils' config
parent
a57a164a
No related branches found
No related tags found
1 merge request
!53
Compile CUDA using the LLVM backend
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pystencils/cpu/cpujit.py
+13
-0
13 additions, 0 deletions
pystencils/cpu/cpujit.py
pystencils/llvm/llvmjit.py
+7
-2
7 additions, 2 deletions
pystencils/llvm/llvmjit.py
with
20 additions
and
2 deletions
pystencils/cpu/cpujit.py
+
13
−
0
View file @
8d22fddf
...
...
@@ -134,11 +134,22 @@ def create_folder(path, is_file):
pass
def
get_llc_command
():
"""
Try to get executable for llvm
'
s IR compiler llc
We try if one of the following is in PATH: llc, llc-10, llc-9, llc-8, llc-7, llc-6
"""
candidates
=
[
'
llc
'
,
'
llc-10
'
,
'
llc-9
'
,
'
llc-8
'
,
'
llc-7
'
,
'
llc-6
'
]
found_executables
=
(
e
for
e
in
candidates
if
shutil
.
which
(
e
))
return
next
(
found_executables
,
None
)
def
read_config
():
if
platform
.
system
().
lower
()
==
'
linux
'
:
default_compiler_config
=
OrderedDict
([
(
'
os
'
,
'
linux
'
),
(
'
command
'
,
'
g++
'
),
(
'
llc_command
'
,
get_llc_command
()
or
'
llc
'
),
(
'
flags
'
,
'
-Ofast -DNDEBUG -fPIC -march=native -fopenmp -std=c++11
'
),
(
'
restrict_qualifier
'
,
'
__restrict__
'
)
])
...
...
@@ -146,6 +157,7 @@ def read_config():
default_compiler_config
=
OrderedDict
([
(
'
os
'
,
'
windows
'
),
(
'
msvc_version
'
,
'
latest
'
),
(
'
llc_command
'
,
get_llc_command
()
or
'
llc
'
),
(
'
arch
'
,
'
x64
'
),
(
'
flags
'
,
'
/Ox /fp:fast /openmp /arch:avx
'
),
(
'
restrict_qualifier
'
,
'
__restrict
'
)
...
...
@@ -154,6 +166,7 @@ def read_config():
default_compiler_config
=
OrderedDict
([
(
'
os
'
,
'
darwin
'
),
(
'
command
'
,
'
clang++
'
),
(
'
llc_command
'
,
get_llc_command
()
or
'
llc
'
),
(
'
flags
'
,
'
-Ofast -DNDEBUG -fPIC -march=native -Xclang -fopenmp -std=c++11
'
),
(
'
restrict_qualifier
'
,
'
__restrict__
'
)
])
...
...
This diff is collapsed.
Click to expand it.
pystencils/llvm/llvmjit.py
+
7
−
2
View file @
8d22fddf
...
...
@@ -284,7 +284,7 @@ class CudaJit(Jit):
self
.
_llvmmod
=
llvm
.
parse_assembly
(
str
(
llvmmod
))
def
compile
(
self
):
from
pystencils.cpu.cpujit
import
get_cache_config
from
pystencils.cpu.cpujit
import
get_cache_config
,
get_compiler_config
,
get_llc_command
import
hashlib
compiler_cache
=
get_cache_config
()[
'
object_cache
'
]
ir_file
=
join
(
compiler_cache
,
hashlib
.
md5
(
str
(
self
.
_llvmmod
).
encode
()).
hexdigest
()
+
'
.ll
'
)
...
...
@@ -297,7 +297,12 @@ class CudaJit(Jit):
if
not
exists
(
ptx_file
):
self
.
write_ll
(
ir_file
)
subprocess
.
check_call
([
'
llc-10
'
,
'
-mcpu=
'
+
arch
,
ir_file
,
'
-o
'
,
ptx_file
])
if
'
llc
'
in
get_compiler_config
():
llc_command
=
get_compiler_config
()[
'
llc
'
]
else
:
llc_command
=
get_llc_command
()
or
'
llc
'
subprocess
.
check_call
([
llc_command
,
'
-mcpu=
'
+
arch
,
ir_file
,
'
-o
'
,
ptx_file
])
# cubin_file = ir_file.replace('.ll', '.cubin')
# if not exists(cubin_file):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment