Commit 20897779 authored by Jan Hönig's avatar Jan Hönig Committed by Martin Bauer
Browse files

Removed unused llvm code

parent 8788b468
from pystencils.astnodes import SympyAssignment, Block, LoopOverCoordinate, KernelFunction
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 pystencils.transformations import insert_casts
from functools import partial
from pystencils.llvm.llvmjit import make_python_function
......@@ -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
:return: abstract syntax tree
fields_read, fields_written, assignments = type_all_equations(assignments, type_info)
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:
function_body = Block([loop_node])
ast = KernelFunction(function_body, None, function_name, backend='llvm')
read_only_fields = set([ for f in fields_read - fields_written])
fixed_coordinate_mapping = { coordinate_typed_symbols for f in non_index_fields}
resolve_field_accesses(ast, read_only_fields, field_to_fixed_coordinates=fixed_coordinate_mapping)
ast.compile = partial(make_python_function, ast)
return ast
raise NotImplementedError
......@@ -105,24 +105,6 @@ class Jit(object):
def optimize_polly(self, opt):
if shutil.which(opt) is None:
print('Path to the executable is wrong')
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)
optimize = subprocess.Popen([opt, '-O3', '-f'], stdin=analyze.stdout, stdout=subprocess.PIPE)
opts, _ = optimize.communicate()
llvmmod = llvm.parse_bitcode(opts)
self.llvmmod = llvmmod
def compile(self):
fptr = {}
for func in self.module.functions:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment