From 65b50d1f37c943c2184106d0fd2c97b0596671bb Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Tue, 12 Nov 2019 00:30:29 -0600 Subject: [PATCH 1/3] Update leap for dagrt 2019.3 language changes --- examples/adaptive-rk/adaptive-rk.py | 1 - examples/implicit_euler/implicit_euler.py | 5 +---- examples/semi-implicit-rk/semi-implicit-rk.py | 1 - leap/__init__.py | 2 -- leap/implicit.py | 4 ++-- leap/multistep/__init__.py | 6 ------ leap/multistep/multirate/__init__.py | 19 ------------------- leap/rk/__init__.py | 9 --------- leap/rk/imex.py | 1 - leap/transform.py | 3 --- leap/version.py | 2 +- setup.py | 2 +- 12 files changed, 5 insertions(+), 50 deletions(-) diff --git a/examples/adaptive-rk/adaptive-rk.py b/examples/adaptive-rk/adaptive-rk.py index 3cba6ca..936d92d 100755 --- a/examples/adaptive-rk/adaptive-rk.py +++ b/examples/adaptive-rk/adaptive-rk.py @@ -140,7 +140,6 @@ def demo_rk_adaptive(): # Update dt based on the error estimate err_est = norm(y_lo - y_hi) order = 3 - cb.reset_dep_tracking() cb(dt, 0.9 * dt * (tol / err_est) ** (1 / order)) # Adapt the step size with cb.if_(err_est, "<=", tol): diff --git a/examples/implicit_euler/implicit_euler.py b/examples/implicit_euler/implicit_euler.py index b2f2d5e..63e03f3 100644 --- a/examples/implicit_euler/implicit_euler.py +++ b/examples/implicit_euler/implicit_euler.py @@ -53,9 +53,7 @@ class ImplicitEulerMethod(Method): with CodeBuilder(label="primary") as cb: self._make_primary(cb) - code = DAGCode.create_with_steady_phase( - dep_on=cb.phase_dependencies, - statements=cb.statements) + code = DAGCode.create_with_steady_phase(statements=cb.statements) from leap.implicit import replace_AssignImplicit @@ -80,5 +78,4 @@ class ImplicitEulerMethod(Method): builder.yield_state(self.state, self.component_id, self.t + self.dt, 'final') - builder.reset_dep_tracking() builder.assign(self.t, self.t + self.dt) diff --git a/examples/semi-implicit-rk/semi-implicit-rk.py b/examples/semi-implicit-rk/semi-implicit-rk.py index 2988af9..f940f69 100755 --- a/examples/semi-implicit-rk/semi-implicit-rk.py +++ b/examples/semi-implicit-rk/semi-implicit-rk.py @@ -90,7 +90,6 @@ def demo_rk_implicit(): solve_component=k2, expression=k2 - f(t + dt, y + dt * ((1 - gamma) * k1 + gamma * k2)), # noqa guess=k1) - cb.reset_dep_tracking() cb(y, y + dt * ((1 - gamma) * k1 + gamma * k2)) cb(t, t + dt) cb.yield_state(y, "y", t, None) diff --git a/leap/__init__.py b/leap/__init__.py index a078a13..df957dd 100644 --- a/leap/__init__.py +++ b/leap/__init__.py @@ -144,13 +144,11 @@ class TwoOrderAdaptiveMethodMixin(Method): cb.raise_(TimeStepUnderflow) with cb.else_(): cb.fail_step() - cb.reset_dep_tracking() with cb.else_(): # This updates :
should not be set before this is called. self.finish_nonadaptive(cb, high_order_estimate, low_order_estimate) - cb.reset_dep_tracking() cb(self.dt, Min((0.9 * self.dt * rel_error ** (-1 / self.high_order), self.max_dt_growth * self.dt))) diff --git a/leap/implicit.py b/leap/implicit.py index 17beeff..ee10a64 100644 --- a/leap/implicit.py +++ b/leap/implicit.py @@ -51,13 +51,13 @@ def replace_AssignImplicit(dag, solver_hooks): from collections import defaultdict solver_hooks = defaultdict(lambda: hook) - new_statements = [] - from dagrt.language import Assign, AssignImplicit new_phases = {} for phase_name, phase in dag.phases.items(): + new_statements = [] + for stmt in phase.statements: if not isinstance(stmt, AssignImplicit): diff --git a/leap/multistep/__init__.py b/leap/multistep/__init__.py index 619b3ca..8cd44d7 100644 --- a/leap/multistep/__init__.py +++ b/leap/multistep/__init__.py @@ -135,8 +135,6 @@ def _emit_func_family_operation(cb, name_gen, for j in range(len(function_family)*len(function_family)): cb(sig_array[j], 0) - cb.reset_dep_tracking() - for i in range(len(function_family)): cb(sig_array[i*(nfunctions+1)], sigma[i]**-1) @@ -297,7 +295,6 @@ class AdamsBashforthMethod(Method): t_end = 1 cb_primary(rhs_var, self.eval_rhs(self.t, self.state)) - cb_primary.reset_dep_tracking() history = self.history + [rhs_var] ab_sum = emit_ab_integration( @@ -313,13 +310,11 @@ class AdamsBashforthMethod(Method): # Rotate history and time history. for i in range(self.hist_length - 1): - cb_primary.reset_dep_tracking() cb_primary(self.history[i], history[i + 1]) if not self.static_dt: cb_primary(self.time_history[i], time_history_data[i + 1]) - cb_primary.reset_dep_tracking() cb_primary(self.t, self.t + self.dt) cb_primary.yield_state(expression=self.state, component_id=self.component_id, @@ -400,7 +395,6 @@ class AdamsBashforthMethod(Method): # Merge the values of the RHSs. rk_comb = sum(coeff * rhss[j] for j, coeff in enumerate(rk_coeffs)) - cb.reset_dep_tracking() state_est = self.state + self.dt * rk_comb if self.state_filter is not None: diff --git a/leap/multistep/multirate/__init__.py b/leap/multistep/multirate/__init__.py index 6792ecc..54bca48 100644 --- a/leap/multistep/multirate/__init__.py +++ b/leap/multistep/multirate/__init__.py @@ -539,8 +539,6 @@ class MultiRateMultiStepMethod(Method): # }}} - cb.reset_dep_tracking() - component_state_ests = {} for icomp, (comp_name, component_rhss) in enumerate( @@ -576,8 +574,6 @@ class MultiRateMultiStepMethod(Method): component_state_ests[comp_name] = state_var - cb.reset_dep_tracking() - for component_name in self.component_names: state = component_state_ests[component_name] if self.is_ode_component[component_name]: @@ -588,8 +584,6 @@ class MultiRateMultiStepMethod(Method): cb(var(""+component_name), state) - cb.reset_dep_tracking() - cb(self.t, self.t + self.dt/self.nsubsteps) # }}} @@ -712,18 +706,13 @@ class MultiRateMultiStepMethod(Method): # }}} - cb.reset_dep_tracking() - if isubstep == 0: with cb.if_(self.bootstrap_step, "==", bootstrap_steps): cb.switch_phase("primary") cb.restart_step() - cb.reset_dep_tracking() - self.emit_small_rk_step(cb, name_prefix, name_gen, current_rhss) - cb.reset_dep_tracking() cb(self.bootstrap_step, self.bootstrap_step + 1) return cb @@ -1081,16 +1070,12 @@ class MultiRateMultiStepMethod(Method): # }}} - cb.reset_dep_tracking() - log_hist_state() end_states = [ get_state(component_name, self.nsubsteps) for component_name in self.component_names] - cb.reset_dep_tracking() - # {{{ commit temp history to permanent history def commit_temp_hist_vars(): @@ -1104,13 +1089,11 @@ class MultiRateMultiStepMethod(Method): temp_time_vars[comp_name, irhs][-rhs.history_length:]): cb(time_var, time_expr) - cb.reset_dep_tracking() for hist_var, hist_expr in zip( self.history_vars[key], temp_hist_vars[comp_name, irhs][-rhs.history_length:]): cb(hist_var, hist_expr) - cb.reset_dep_tracking() commit_temp_hist_vars() @@ -1125,8 +1108,6 @@ class MultiRateMultiStepMethod(Method): cb(var(""+component_name), state) - cb.reset_dep_tracking() - cb(self.t, self.t + self.dt) # }}} diff --git a/leap/rk/__init__.py b/leap/rk/__init__.py index 6b38592..9d5061e 100644 --- a/leap/rk/__init__.py +++ b/leap/rk/__init__.py @@ -336,8 +336,6 @@ class ButcherTableauMethod(Method): estimate_vars[iest], state_est) - cb.reset_dep_tracking() - # This updates . self.finish(cb, estimate_coeff_set_names, estimate_vars) @@ -350,8 +348,6 @@ class ButcherTableauMethod(Method): self.c, stage_coeff_sets[name])): cb(last_rhss[name], stage_rhs_vars[name][-1]) - cb.reset_dep_tracking() - cb_primary = cb # }}} @@ -366,7 +362,6 @@ class ButcherTableauMethod(Method): def finish(self, cb, estimate_names, estimate_vars): cb(self.state, estimate_vars[0]) cb.yield_state(self.state, self.component_id, self.t + self.dt, 'final') - cb.reset_dep_tracking() cb(self.t, self.t + self.dt) # }}} @@ -612,7 +607,6 @@ class EmbeddedButcherTableauMethod( cb(self.state, est) cb.yield_state(self.state, self.component_id, self.t + self.dt, 'final') - cb.reset_dep_tracking() cb(self.t, self.t + self.dt) # }}} @@ -776,7 +770,6 @@ class LSRK4Method(Method): with CodeBuilder("primary") as cb: for a, b, c in self.coeffs: - cb.reset_dep_tracking() cb(rhs_val, rhs_func(t=t + c*dt, **{comp_id: state})) cb(residual, a*residual + dt*rhs_val) new_state_expr = state + b * residual @@ -784,11 +777,9 @@ class LSRK4Method(Method): if self.state_filter is not None: new_state_expr = self.state_filter(**{comp_id: new_state_expr}) - cb.reset_dep_tracking() cb(state, new_state_expr) cb.yield_state(state, comp_id, t + dt, 'final') - cb.reset_dep_tracking() cb(t, t + dt) cb_primary = cb diff --git a/leap/rk/imex.py b/leap/rk/imex.py index 5c0183f..af66315 100644 --- a/leap/rk/imex.py +++ b/leap/rk/imex.py @@ -152,7 +152,6 @@ class KennedyCarpenterIMEXRungeKuttaMethodBase( cb(self.state, est) cb.yield_state(self.state, self.component_id, self.t + self.dt, 'final') - cb.reset_dep_tracking() cb(self.t, self.t + self.dt) diff --git a/leap/transform.py b/leap/transform.py index 60083e4..c321af0 100644 --- a/leap/transform.py +++ b/leap/transform.py @@ -135,21 +135,18 @@ def strang_splitting(dag1, dag2, stepping_phase): """ new_phases[phase_name] = ExecutionPhase( next_phase=s2_name, - depends_on=phase1.depends_on, statements=( _update_t_by_dt_factor(0, _elide_yield_state( phase1_half_dt)))) new_phases[s2_name] = ExecutionPhase( next_phase=s3_name, - depends_on=phase2.depends_on, statements=( _update_t_by_dt_factor(1/2, _elide_yield_state( substed_s2_stmts)))) new_phases[s3_name] = ExecutionPhase( next_phase=phase1.next_phase, - depends_on=phase1.depends_on, statements=phase1_half_dt) else: from dagrt.transform import fuse_two_phases diff --git a/leap/version.py b/leap/version.py index b8345dc..74bb455 100644 --- a/leap/version.py +++ b/leap/version.py @@ -1,2 +1,2 @@ -VERSION = (2019, 2) +VERSION = (2019, 3) VERSION_TEXT = ".".join(str(i) for i in VERSION) diff --git a/setup.py b/setup.py index db14a32..b530f09 100644 --- a/setup.py +++ b/setup.py @@ -45,7 +45,7 @@ def main(): "pytools>=2014.1", "pymbolic>=2014.1", "pytest>=2.3", - "dagrt>=2019.2", + "dagrt>=2019.3", "mako", "six", ], -- GitLab From 821c2e6875424736bd1da1ac85ddf654b8025140 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Tue, 12 Nov 2019 00:31:22 -0600 Subject: [PATCH 2/3] Point requirements.txt to dagrt lang-changes-for-paper branch --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e22f333..0dea92f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ git+git://github.com/inducer/pytools git+git://github.com/inducer/pymbolic -git+https://gitlab.tiker.net/inducer/dagrt.git \ No newline at end of file +git+https://gitlab.tiker.net/inducer/dagrt.git@lang-changes-for-paper -- GitLab From 408735db3bb6454bb26d07868a415538cc310da6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kl=C3=B6ckner?= Date: Tue, 19 Nov 2019 01:43:55 +0100 Subject: [PATCH 3/3] Re-point dagrt back to master in requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 0dea92f..e22f333 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ git+git://github.com/inducer/pytools git+git://github.com/inducer/pymbolic -git+https://gitlab.tiker.net/inducer/dagrt.git@lang-changes-for-paper +git+https://gitlab.tiker.net/inducer/dagrt.git \ No newline at end of file -- GitLab