diff --git a/src/pystencils/__init__.py b/src/pystencils/__init__.py index f5cb3e10b646dd6ead4673827d0166c9f0f9e5ea..5baf97b6b5fb60c57e0ee088276de07493002f1e 100644 --- a/src/pystencils/__init__.py +++ b/src/pystencils/__init__.py @@ -19,6 +19,7 @@ from .kernel_decorator import kernel, kernel_config from .kernelcreation import create_kernel, create_staggered_kernel from .backend.kernelfunction import KernelFunction from .backend.jit import no_jit +from .backend.exceptions import KernelConstraintsError from .slicing import make_slice from .spatial_coordinates import ( x_, @@ -54,6 +55,7 @@ __all__ = [ "create_kernel", "create_staggered_kernel", "KernelFunction", + "KernelConstraintsError", "Target", "no_jit", "show_code", diff --git a/src/pystencils/alignedarray.py b/src/pystencils/alignedarray.py index 63bdb3a5f1324a099bbd82fd666bfaec11eeb5af..4e315af787b4b988d3d523c5098c97c02e6f5205 100644 --- a/src/pystencils/alignedarray.py +++ b/src/pystencils/alignedarray.py @@ -1,3 +1,4 @@ +# flake8: noqa import numpy as np @@ -17,10 +18,12 @@ def aligned_empty(shape, byte_alignment=True, dtype=np.float64, byte_offset=0, o align_inner_coordinate: if True, the start of the innermost coordinate lines are aligned as well """ if byte_alignment is True or byte_alignment == 'cacheline': - from pystencils.backends.simd_instruction_sets import (get_supported_instruction_sets, get_cacheline_size, - get_vector_instruction_set) + # from pystencils.backends.simd_instruction_sets import (get_supported_instruction_sets, get_cacheline_size, + # get_vector_instruction_set) - instruction_sets = get_supported_instruction_sets() + # instruction_sets = get_supported_instruction_sets() + # TODO `get_supported_instruction_sets` has to be reimplemented + instruction_sets = None if instruction_sets is None: byte_alignment = 64 elif byte_alignment == 'cacheline': diff --git a/src/pystencils/boundaries/boundaryhandling.py b/src/pystencils/boundaries/boundaryhandling.py index f171d56091f69fbd1bef2a2edc4cf844a96a9f40..c7657ec51e5d0386087455e8ff927ef56dff0384 100644 --- a/src/pystencils/boundaries/boundaryhandling.py +++ b/src/pystencils/boundaries/boundaryhandling.py @@ -36,12 +36,9 @@ class FlagInterface: >>> dh = create_data_handling((4, 5)) >>> fi = FlagInterface(dh, 'flag_field', np.uint8) >>> assert dh.has_data('flag_field') - >>> fi.reserve_next_flag() - 2 - >>> fi.reserve_flag(4) - 4 - >>> fi.reserve_next_flag() - 8 + >>> assert fi.reserve_next_flag() == 2 + >>> assert fi.reserve_flag(4) == 4 + >>> assert fi.reserve_next_flag() == 8 """ def __init__(self, data_handling, flag_field_name, dtype=DEFAULT_FLAG_TYPE): diff --git a/src/pystencils/datahandling/serial_datahandling.py b/src/pystencils/datahandling/serial_datahandling.py index 4eb341df52b93050efef3791d32939fb33d31883..ba705f4b9f665ea9eaf81ad42863196c25901df8 100644 --- a/src/pystencils/datahandling/serial_datahandling.py +++ b/src/pystencils/datahandling/serial_datahandling.py @@ -344,11 +344,11 @@ class SerialDataHandling(DataHandling): if target == Target.CPU: def result_functor(): for arr_name, func in zip(names, result): - func(pdfs=self.cpu_arrays[arr_name]) + func(self.cpu_arrays[arr_name]) else: def result_functor(): for arr_name, func in zip(names, result): - func(pdfs=self.gpu_arrays[arr_name]) + func(self.gpu_arrays[arr_name]) return result_functor diff --git a/src/pystencils/display_utils.py b/src/pystencils/display_utils.py index 301cdef0f106fc2dbaef6f016b21e14c5e34911d..7f110c9c06f97fd37f17e734f5501f856216e56f 100644 --- a/src/pystencils/display_utils.py +++ b/src/pystencils/display_utils.py @@ -9,7 +9,6 @@ from .backend.jit import KernelWrapper def to_dot(expr: sp.Expr, graph_style: Optional[Dict[str, Any]] = None, short=True): """Show a sympy or pystencils AST as dot graph""" - from pystencils.sympyextensions.astnodes import Node try: import graphviz except ImportError: @@ -18,12 +17,15 @@ def to_dot(expr: sp.Expr, graph_style: Optional[Dict[str, Any]] = None, short=Tr graph_style = {} if graph_style is None else graph_style - if isinstance(expr, Node): - from pystencils.backends.dot import print_dot - return graphviz.Source(print_dot(expr, short=short, graph_attr=graph_style)) - else: + # if isinstance(expr, Node): + # from pystencils.backends.dot import print_dot + # return graphviz.Source(print_dot(expr, short=short, graph_attr=graph_style)) + if isinstance(expr, sp.Basic): from sympy.printing.dot import dotprint return graphviz.Source(dotprint(expr, graph_attr=graph_style)) + else: + # TODO Implement dot / graphviz exporter for new backend AST + raise NotImplementedError("Printing of AST nodes for the new backend is not implemented yet") def highlight_cpp(code: str): diff --git a/src/pystencils/runhelper/db.py b/src/pystencils/runhelper/db.py index 466b9dc14cbc05a18fb895fd7b83b979fddde185..dd413a5e405771822d36611d1068936b74ee334c 100644 --- a/src/pystencils/runhelper/db.py +++ b/src/pystencils/runhelper/db.py @@ -8,7 +8,7 @@ import six from blitzdb.backends.file.backend import serializer_classes from blitzdb.backends.file.utils import JsonEncoder -from pystencils.cpu.cpujit import get_compiler_config +from pystencils.backend.jit.legacy_cpu import get_compiler_config from pystencils import CreateKernelConfig, Target, Field import json diff --git a/src/pystencils/simplificationfactory.py b/src/pystencils/simplificationfactory.py index 869454ecf0f4e1ab05f79b7370a2d22f30c1dcdb..68eb22d59a460aae6ef4c6bba50bbd9f0acacb83 100644 --- a/src/pystencils/simplificationfactory.py +++ b/src/pystencils/simplificationfactory.py @@ -1,4 +1,4 @@ -from pystencils.sympyextensions import ( +from pystencils.simp import ( SimplificationStrategy, insert_constants, insert_symbol_times_minus_one, diff --git a/src/pystencils/sympyextensions/integer_functions.py b/src/pystencils/sympyextensions/integer_functions.py index 3b215266eac147ea3082a0536e180728201d6b3e..eb3bb4ccc79d06d54e320bb0b442ea7dad1c670a 100644 --- a/src/pystencils/sympyextensions/integer_functions.py +++ b/src/pystencils/sympyextensions/integer_functions.py @@ -78,10 +78,6 @@ class modulo_floor(sp.Function): 8 >>> modulo_floor(12, 4) 12 - >>> from pystencils import TypedSymbol - >>> a, b = TypedSymbol("a", "int64"), TypedSymbol("b", "int32") - >>> modulo_floor(a, b).to_c(str) - '(int64_t)((a) / (b)) * (b)' """ nargs = 2 is_integer = True @@ -111,10 +107,6 @@ class modulo_ceil(sp.Function): 12 >>> modulo_ceil(12, 4) 12 - >>> from pystencils import TypedSymbol - >>> a, b = TypedSymbol("a", "int64"), TypedSymbol("b", "int32") - >>> modulo_ceil(a, b).to_c(str) - '((a) % (b) == 0 ? a : ((int64_t)((a) / (b))+1) * (b))' """ nargs = 2 is_integer = True @@ -142,10 +134,6 @@ class div_ceil(sp.Function): 3 >>> div_ceil(8, 4) 2 - >>> from pystencils import TypedSymbol - >>> a, b = TypedSymbol("a", "int64"), TypedSymbol("b", "int32") - >>> div_ceil(a, b).to_c(str) - '( (a) % (b) == 0 ? (int64_t)(a) / (int64_t)(b) : ( (int64_t)(a) / (int64_t)(b) ) +1 )' """ nargs = 2 is_integer = True @@ -173,10 +161,6 @@ class div_floor(sp.Function): 2 >>> div_floor(8, 4) 2 - >>> from pystencils import TypedSymbol - >>> a, b = TypedSymbol("a", "int64"), TypedSymbol("b", "int32") - >>> div_floor(a, b).to_c(str) - '((int64_t)(a) / (int64_t)(b))' """ nargs = 2 is_integer = True diff --git a/src/pystencils/utils.py b/src/pystencils/utils.py index 98331e7e5f561405cee99c3422b9f232747ecfcb..de98e44316e259c81bbcc3b3ce2aa7c490f7a5e8 100644 --- a/src/pystencils/utils.py +++ b/src/pystencils/utils.py @@ -82,8 +82,7 @@ def boolean_array_bounding_box(boolean_array): >>> a = np.zeros((4, 4), dtype=bool) >>> a[1:-1, 1:-1] = True - >>> boolean_array_bounding_box(a) - [(1, 3), (1, 3)] + >>> assert boolean_array_bounding_box(a) == [(1, 3), (1, 3)] """ dim = boolean_array.ndim shape = boolean_array.shape