Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #561 from OP2/fix/non-determinism
Browse files Browse the repository at this point in the history
* fix/non-determinism:
  codegen: Fix non-determinism in assumptions ordering
  • Loading branch information
wence- committed May 1, 2019
2 parents ba54ab7 + c8c4dd0 commit 51d0509
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions pyop2/codegen/rep2loopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,16 @@ def generate(builder, wrapper_name=None):
if wrapper_name is None:
wrapper_name = "wrap_%s" % builder.kernel.name

pwaffd = isl.affs_from_space(assumptions.get_space())
assumptions = assumptions & pwaffd["start"].ge_set(pwaffd[0])
if builder.single_cell:
assumptions = assumptions & pwaffd["start"].lt_set(pwaffd["end"])
else:
assumptions = assumptions & pwaffd["start"].le_set(pwaffd["end"])
if builder.extruded:
assumptions = assumptions & pwaffd[parameters.layer_start].le_set(pwaffd[parameters.layer_end])
assumptions = reduce(operator.and_, assumptions.get_basic_sets())

wrapper = loopy.make_kernel(domains,
statements,
kernel_data=parameters.kernel_data,
Expand All @@ -443,15 +453,6 @@ def generate(builder, wrapper_name=None):
lang_version=(2018, 2),
name=wrapper_name)

# additional assumptions
if builder.single_cell:
wrapper = loopy.assume(wrapper, "start < end")
else:
wrapper = loopy.assume(wrapper, "start <= end")
wrapper = loopy.assume(wrapper, "start >= 0")
if builder.extruded:
wrapper = loopy.assume(wrapper, "{0} <= {1}".format(parameters.layer_start, parameters.layer_end))

# prioritize loops
for indices in context.index_ordering:
wrapper = loopy.prioritize_loops(wrapper, indices)
Expand Down

0 comments on commit 51d0509

Please sign in to comment.