Commit 44526560 authored by Markus Holzer's avatar Markus Holzer
Browse files

Remove features which do not belong to this MR

parent 4141f192
Pipeline #30579 failed with stage
in 8 minutes and 35 seconds
......@@ -628,20 +628,6 @@ class VectorizedCustomSympyPrinter(CustomSympyPrinter):
return result
def _print_Add(self, expr, order=None):
def visit(summands):
if len(summands) == 2:
sign = summands[0].sign * summands[1].sign
func = self.instruction_set['-' + suffix] if sign == -1 else self.instruction_set['+' + suffix]
return func.format(summands[0].term, summands[1].term)
else:
elements = len(summands) // 2
if len(summands[:elements]) < 2:
func = self.instruction_set['-' + suffix] \
if summands[0].sign == -1 else self.instruction_set['+' + suffix]
return func.format(summands[0].term, visit(summands[elements:]))
else:
func = self.instruction_set['+' + suffix]
return func.format(visit(summands[:elements]), visit(summands[elements:]))
try:
result = self._scalarFallback('_print_Add', expr)
except Exception:
......@@ -676,13 +662,10 @@ class VectorizedCustomSympyPrinter(CustomSympyPrinter):
summands.insert(0, self.SummandInfo(1, "0"))
assert len(summands) >= 2
if len(summands) < 10:
processed = summands[0].term
for summand in summands[1:]:
func = self.instruction_set['-' + suffix] if summand.sign == -1 else self.instruction_set['+' + suffix]
processed = func.format(processed, summand.term)
else:
processed = visit(summands)
processed = summands[0].term
for summand in summands[1:]:
func = self.instruction_set['-' + suffix] if summand.sign == -1 else self.instruction_set['+' + suffix]
processed = func.format(processed, summand.term)
return processed
def _print_Pow(self, expr):
......
......@@ -18,7 +18,7 @@ AssignmentOrAstNodeList = List[Union[Assignment, ast.Node]]
def create_kernel(assignments: AssignmentOrAstNodeList, function_name: str = "kernel", type_info='double',
split_groups=(), iteration_slice=None, ghost_layers=None,
skip_independence_check=False, base_pointer_spec=None) -> KernelFunction:
skip_independence_check=False) -> KernelFunction:
"""Creates an abstract syntax tree for a kernel function, by taking a list of update rules.
Loops are created according to the field accesses in the equations.
......@@ -39,7 +39,6 @@ def create_kernel(assignments: AssignmentOrAstNodeList, function_name: str = "ke
all dimensions
skip_independence_check: don't check that loop iterations are independent. This is needed e.g. for
periodicity kernel, that access the field outside the iteration bounds. Use with care!
base_pointer_spec: specifies which field accesses are resolved by pointers see :func:`parse_base_pointer_info`
Returns:
AST node representing a function, that can be printed as C or CUDA code
......@@ -74,8 +73,7 @@ def create_kernel(assignments: AssignmentOrAstNodeList, function_name: str = "ke
typed_split_groups = [[type_symbol(s) for s in split_group] for split_group in split_groups]
split_inner_loop(ast_node, typed_split_groups)
if base_pointer_spec is None:
base_pointer_spec = [['spatialInner0'], ['spatialInner1']] if len(loop_order) >= 2 else [['spatialInner0']]
base_pointer_spec = [['spatialInner0'], ['spatialInner1']] if len(loop_order) >= 2 else [['spatialInner0']]
base_pointer_info = {field.name: parse_base_pointer_info(base_pointer_spec, loop_order,
field.spatial_dimensions, field.index_dimensions)
for field in fields_without_buffers}
......
......@@ -15,8 +15,7 @@ def create_cuda_kernel(assignments,
iteration_slice=None,
ghost_layers=None,
skip_independence_check=False,
use_textures_for_interpolation=True,
base_pointer_spec=None):
use_textures_for_interpolation=True):
assert assignments, "Assignments must not be empty!"
fields_read, fields_written, assignments = add_types(assignments, type_info, not skip_independence_check)
all_fields = fields_read.union(fields_written)
......@@ -74,8 +73,7 @@ def create_cuda_kernel(assignments,
implement_interpolations(ast, implement_by_texture_accesses=use_textures_for_interpolation)
if base_pointer_spec is None:
base_pointer_spec = [['spatialInner0']]
base_pointer_spec = [['spatialInner0']]
base_pointer_info = {f.name: parse_base_pointer_info(base_pointer_spec, [2, 1, 0],
f.spatial_dimensions, f.index_dimensions)
for f in all_fields}
......
......@@ -31,8 +31,7 @@ def create_kernel(assignments,
cpu_prepend_optimizations=[],
use_auto_for_assignments=False,
opencl_queue=None,
opencl_ctx=None,
base_pointer_spec=None):
opencl_ctx=None):
"""
Creates abstract syntax tree (AST) of kernel, using a list of update equations.
......@@ -58,7 +57,6 @@ def create_kernel(assignments,
gpu_indexing_params: dict with indexing parameters (constructor parameters of indexing class)
e.g. for 'block' one can specify '{'block_size': (20, 20, 10) }'
cpu_prepend_optimizations: list of extra optimizations to perform first on the AST
base_pointer_spec: specifies which field accesses are resolved by pointers see :func:`parse_base_pointer_info`
Returns:
abstract syntax tree (AST) object, that can either be printed as source code with `show_code` or
......@@ -96,7 +94,7 @@ def create_kernel(assignments,
from pystencils.cpu import add_openmp
ast = create_kernel(assignments, type_info=data_type, split_groups=split_groups,
iteration_slice=iteration_slice, ghost_layers=ghost_layers,
skip_independence_check=skip_independence_check, base_pointer_spec=base_pointer_spec)
skip_independence_check=skip_independence_check)
for optimization in cpu_prepend_optimizations:
optimization(ast)
omp_collapse = None
......@@ -121,8 +119,7 @@ def create_kernel(assignments,
indexing_creator=indexing_creator_from_params(gpu_indexing, gpu_indexing_params),
iteration_slice=iteration_slice, ghost_layers=ghost_layers,
skip_independence_check=skip_independence_check,
use_textures_for_interpolation=use_textures_for_interpolation,
base_pointer_spec=base_pointer_spec)
use_textures_for_interpolation=use_textures_for_interpolation)
if target == 'opencl':
from pystencils.opencl.opencljit import make_python_function
ast._backend = 'opencl'
......
Markdown is supported
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