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
20897779
Commit
20897779
authored
7 years ago
by
Jan Hönig
Committed by
Martin Bauer
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Removed unused llvm code
parent
8788b468
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
llvm/kernelcreation.py
+2
-53
2 additions, 53 deletions
llvm/kernelcreation.py
llvm/llvmjit.py
+0
-18
0 additions, 18 deletions
llvm/llvmjit.py
with
2 additions
and
71 deletions
llvm/kernelcreation.py
+
2
−
53
View file @
20897779
from
pystencils.astnodes
import
SympyAssignment
,
Block
,
LoopOverCoordinate
,
KernelFunction
from
pystencils.transformations
import
insert_casts
from
pystencils.transformations
import
resolve_field_accesses
,
\
type_all_equations
,
move_constants_before_loop
,
insert_casts
from
pystencils.data_types
import
TypedSymbol
,
BasicType
,
StructType
from
pystencils.field
import
FieldType
from
functools
import
partial
from
functools
import
partial
from
pystencils.llvm.llvmjit
import
make_python_function
from
pystencils.llvm.llvmjit
import
make_python_function
...
@@ -54,51 +50,4 @@ def create_indexed_kernel(assignments, index_fields, function_name="kernel", typ
...
@@ -54,51 +50,4 @@ def create_indexed_kernel(assignments, index_fields, function_name="kernel", typ
:param coordinate_names: name of the coordinate fields in the struct data type
:param coordinate_names: name of the coordinate fields in the struct data type
:return: abstract syntax tree
:return: abstract syntax tree
"""
"""
fields_read
,
fields_written
,
assignments
=
type_all_equations
(
assignments
,
type_info
)
raise
NotImplementedError
all_fields
=
fields_read
.
union
(
fields_written
)
for
indexField
in
index_fields
:
indexField
.
fieldType
=
FieldType
.
INDEXED
assert
FieldType
.
is_indexed
(
indexField
)
assert
indexField
.
spatial_dimensions
==
1
,
"
Index fields have to be 1D
"
non_index_fields
=
[
f
for
f
in
all_fields
if
f
not
in
index_fields
]
spatial_coordinates
=
{
f
.
spatial_dimensions
for
f
in
non_index_fields
}
assert
len
(
spatial_coordinates
)
==
1
,
"
Non-index fields do not have the same number of spatial coordinates
"
spatial_coordinates
=
list
(
spatial_coordinates
)[
0
]
def
get_coordinate_symbol_assignment
(
name
):
for
index_field
in
index_fields
:
assert
isinstance
(
index_field
.
dtype
,
StructType
),
"
Index fields have to have a struct datatype
"
data_type
=
index_field
.
dtype
if
data_type
.
has_element
(
name
):
rhs
=
index_field
[
0
](
name
)
lhs
=
TypedSymbol
(
name
,
BasicType
(
data_type
.
get_element_type
(
name
)))
return
SympyAssignment
(
lhs
,
rhs
)
raise
ValueError
(
"
Index %s not found in any of the passed index fields
"
%
(
name
,))
coordinate_symbol_assignments
=
[
get_coordinate_symbol_assignment
(
n
)
for
n
in
coordinate_names
[:
spatial_coordinates
]]
coordinate_typed_symbols
=
[
eq
.
lhs
for
eq
in
coordinate_symbol_assignments
]
assignments
=
coordinate_symbol_assignments
+
assignments
# make 1D loop over index fields
loop_body
=
Block
([])
loop_node
=
LoopOverCoordinate
(
loop_body
,
coordinate_to_loop_over
=
0
,
start
=
0
,
stop
=
index_fields
[
0
].
shape
[
0
])
for
assignment
in
assignments
:
loop_body
.
append
(
assignment
)
function_body
=
Block
([
loop_node
])
ast
=
KernelFunction
(
function_body
,
None
,
function_name
,
backend
=
'
llvm
'
)
read_only_fields
=
set
([
f
.
name
for
f
in
fields_read
-
fields_written
])
fixed_coordinate_mapping
=
{
f
.
name
:
coordinate_typed_symbols
for
f
in
non_index_fields
}
resolve_field_accesses
(
ast
,
read_only_fields
,
field_to_fixed_coordinates
=
fixed_coordinate_mapping
)
move_constants_before_loop
(
ast
)
desympy_ast
(
ast
)
insert_casts
(
ast
)
ast
.
compile
=
partial
(
make_python_function
,
ast
)
return
ast
This diff is collapsed.
Click to expand it.
llvm/llvmjit.py
+
0
−
18
View file @
20897779
...
@@ -105,24 +105,6 @@ class Jit(object):
...
@@ -105,24 +105,6 @@ class Jit(object):
pmb
.
populate
(
pm
)
pmb
.
populate
(
pm
)
pm
.
run
(
self
.
llvmmod
)
pm
.
run
(
self
.
llvmmod
)
def
optimize_polly
(
self
,
opt
):
if
shutil
.
which
(
opt
)
is
None
:
print
(
'
Path to the executable is wrong
'
)
return
canonicalize
=
subprocess
.
Popen
([
opt
,
'
-polly-canonicalize
'
],
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
)
analyze
=
subprocess
.
Popen
(
[
opt
,
'
-polly-codegen
'
,
'
-polly-vectorizer=polly
'
,
'
-polly-parallel
'
,
'
-polly-process-unprofitable
'
,
'
-f
'
],
stdin
=
canonicalize
.
stdout
,
stdout
=
subprocess
.
PIPE
)
canonicalize
.
communicate
(
input
=
self
.
llvmmod
.
as_bitcode
())
optimize
=
subprocess
.
Popen
([
opt
,
'
-O3
'
,
'
-f
'
],
stdin
=
analyze
.
stdout
,
stdout
=
subprocess
.
PIPE
)
opts
,
_
=
optimize
.
communicate
()
llvmmod
=
llvm
.
parse_bitcode
(
opts
)
llvmmod
.
verify
()
self
.
llvmmod
=
llvmmod
def
compile
(
self
):
def
compile
(
self
):
fptr
=
{}
fptr
=
{}
for
func
in
self
.
module
.
functions
:
for
func
in
self
.
module
.
functions
:
...
...
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