Skip to content
Snippets Groups Projects
Commit 01221072 authored by Markus Holzer's avatar Markus Holzer
Browse files

Double write field access not allowed anymore

parent d58ba8df
1 merge request!292Rebase of pystencils Type System
This diff is collapsed.
......@@ -35,7 +35,7 @@ class KernelConstraintsCheck:
"""
FieldAndIndex = namedtuple('FieldAndIndex', ['field', 'index'])
def __init__(self, check_independence_condition, check_double_write_condition=True):
def __init__(self, check_independence_condition=True, check_double_write_condition=True):
self.scopes = NestedScopes()
self.field_writes = defaultdict(set)
self.fields_read = set()
......@@ -98,7 +98,11 @@ class KernelConstraintsCheck:
def update_accesses_lhs(self, lhs):
if isinstance(lhs, Field.Access):
fai = self.FieldAndIndex(lhs.field, lhs.index)
if self.check_double_write_condition and lhs.offsets in self.field_writes[fai]:
raise ValueError(f"Field {lhs.field.name} is written twice at the same location")
self.field_writes[fai].add(lhs.offsets)
if self.check_double_write_condition and len(self.field_writes[fai]) > 1:
raise ValueError(
f"Field {lhs.field.name} is written at two different locations")
......
......@@ -128,8 +128,8 @@ def create_domain_kernel(assignments: Union[AssignmentCollection, NodeCollection
# FUTURE WORK from here we shouldn't NEED sympy
# --- check constrains
check = KernelConstraintsCheck(check_independence_condition=config.skip_independence_check,
check_double_write_condition=config.allow_double_writes)
check = KernelConstraintsCheck(check_independence_condition=not config.skip_independence_check,
check_double_write_condition=not config.allow_double_writes)
check.visit(assignments)
if isinstance(assignments, AssignmentCollection):
......
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