From c389f96258087dd65c559ab0409c2d1fff2b9b8e Mon Sep 17 00:00:00 2001 From: Emilien Bauer Date: Sat, 22 Jul 2023 12:11:57 +0100 Subject: [PATCH] Reverse stencil.apply inputs and try to name accordingly. Some tweaks of buffer handling on nd_nwave_devito_nodamp.py. --- devito/ir/ietxdsl/cluster_to_ssa.py | 2 +- devito/ir/ietxdsl/iet_ssa.py | 2 +- fast/nd_nwave_devito_nodamp.py | 11 +++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/devito/ir/ietxdsl/cluster_to_ssa.py b/devito/ir/ietxdsl/cluster_to_ssa.py index d6a4b71c54..2ffb0d1887 100644 --- a/devito/ir/ietxdsl/cluster_to_ssa.py +++ b/devito/ir/ietxdsl/cluster_to_ssa.py @@ -405,8 +405,8 @@ def match_and_rewrite(self, op: iet_ssa.Stencil, rewriter: PatternRewriter, /): for field in op.input_indices: rewriter.insert_op_before_matched_op(load_op := stencil.LoadOp.get(field)) - input_temps.append(load_op.res) load_op.res.name_hint = field.name_hint + "_temp" + input_temps.insert(0, load_op.res) rewriter.replace_matched_op( [ diff --git a/devito/ir/ietxdsl/iet_ssa.py b/devito/ir/ietxdsl/iet_ssa.py index f10859e3a2..1dcb65fb81 100644 --- a/devito/ir/ietxdsl/iet_ssa.py +++ b/devito/ir/ietxdsl/iet_ssa.py @@ -466,7 +466,7 @@ def get( stencil.TempType(len(shape), typ) ] * (time_buffers - 1)) - for block_arg, idx_arg in zip(block.args, time_indices): + for block_arg, idx_arg in zip(block.args, reversed(inputs)): name = SSAValue.get(idx_arg).name_hint if name is None: continue diff --git a/fast/nd_nwave_devito_nodamp.py b/fast/nd_nwave_devito_nodamp.py index 1c44b38e7f..b09a028031 100644 --- a/fast/nd_nwave_devito_nodamp.py +++ b/fast/nd_nwave_devito_nodamp.py @@ -115,20 +115,23 @@ def plot_3dfunc(u): initdata = u.data[:] # Run more with no sources now (Not supported in xdsl) -xdslop = XDSLOperator([stencil], name='XDSLOperator') +xdslop = Operator([stencil], name='DevitoOperator') xdslop.apply(time=time_range.num-1, dt=model.critical_dt) if len(shape) == 3: if args.plot: plot_3dfunc(u) -print(norm(u)) + +devito_output = u.copy() +print(f"devito output norm: {norm(devito_output)}") # Reset initial data u.data[:] = initdata # Run more with no sources now (Not supported in xdsl) -xdslop = XDSLOperator([stencil]) +xdslop = XDSLOperator([stencil], name='xDSLOperator') xdslop.apply(time=time_range.num-1, dt=model.critical_dt) -print(norm(u)) +xdsl_output = u.copy() +print(f"xdsl output norm: {norm(xdsl_output)}")