Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
aaa36f7
compiler: Augment caching and memoization
FabioLuporini Mar 24, 2026
c4864ca
compiler: Augment caching and tweak memoization heuristics
FabioLuporini Apr 2, 2026
77efae6
compiler: cache TimedAccess instances
FabioLuporini Apr 3, 2026
d41e2b3
compiler: Add heuristics to improve fusion lowering turnaround
FabioLuporini Apr 7, 2026
0541de4
compiler: Improve Cluster fusion implementation
FabioLuporini Apr 8, 2026
e123742
compiler: Avoid rebuilding IET if unnecessary
FabioLuporini Apr 8, 2026
d72b448
compiler: Fix propagation of transitive IET arg updates
FabioLuporini Apr 8, 2026
a6232b0
compiler: cache CGen printers by settings
FabioLuporini Apr 8, 2026
3466e0d
compiler: Enhance Scope to improve DDA turnaround
FabioLuporini Apr 9, 2026
b929454
compiler: Exploit the new Scope API
FabioLuporini Apr 9, 2026
fe171f4
compiler: include ClusterGroup ispace in equality semantics
FabioLuporini Apr 9, 2026
16aa3d9
compiler: Add update_args= contract to spare compilation time
FabioLuporini Apr 9, 2026
f29f238
compiler: Add heuristic for topofuse='maximal'
FabioLuporini Apr 10, 2026
acd5956
misc: Patch NVIDIA_VISIBLE_DEVICES and DeviceID
FabioLuporini Apr 10, 2026
815bd70
tools: Add DefaultFrozenDict
FabioLuporini Apr 15, 2026
0c060e5
compiler: Remove dead NodesExprs.dspace
FabioLuporini Apr 15, 2026
5bb7e6d
tools: Add reuse_if_unchanged and exploit it
FabioLuporini Apr 24, 2026
bccca1f
compiler: Split into EqBlock and Cluster
FabioLuporini Apr 27, 2026
c8b007b
compiler: Stash hash were essential for compilation performance
FabioLuporini Apr 28, 2026
7b33fa6
compiler: Exploit cached_hash
FabioLuporini Apr 28, 2026
0baada8
compiler: Retain original objects whenever possible
FabioLuporini Apr 28, 2026
e3c09da
compiler: Minimize reconstructions everywhere
FabioLuporini Apr 29, 2026
1d97e87
compiler: Memoize Fusion._key
FabioLuporini Apr 29, 2026
57de807
compiler: Avoid rebuilding Nodes when possible
FabioLuporini Apr 29, 2026
3b9640b
compiler: Memoize IET visitors
FabioLuporini Apr 29, 2026
307cdaf
compiler: Memoize IET engine
FabioLuporini Apr 30, 2026
c885f3f
compiler: Avoid reconstructions in IET visitors
FabioLuporini Apr 30, 2026
e287b7e
compiler: Memoize FindNodes
FabioLuporini Apr 30, 2026
388a587
compiler: Call finalize_args once at the end of the lowering
FabioLuporini May 12, 2026
21b9302
compiler: Rename _rebuild -> _reuse_if_untouched
FabioLuporini Jun 16, 2026
644b24e
compiler: Avoid useless renaming
FabioLuporini Jun 16, 2026
76ebc86
compiler: Refactor IREq
FabioLuporini Jun 16, 2026
eb7014d
compiler: isort happiness
FabioLuporini Jun 16, 2026
7c2dc7a
compiler: pep8 happiness
FabioLuporini Jun 16, 2026
78fb108
compiler: Comply with ruff
FabioLuporini Jun 16, 2026
431482c
compiler: Use placeholder dtype to compute repr
FabioLuporini Jun 16, 2026
0f93ef9
tests: Adjust visible_devices testing
FabioLuporini Jun 16, 2026
b5d4b7a
compiler: Simplify reuse_if_untouched
FabioLuporini Jun 17, 2026
e7afb05
compiler: Simplify get_printer
FabioLuporini Jun 17, 2026
4747f8c
Drop Tag.cached_hash as not safe
FabioLuporini Jun 17, 2026
58db5e0
tests: Use np.random.RandomState where necessary
FabioLuporini Jun 17, 2026
679734d
compiler: Fixup lower_async_objs
FabioLuporini Jun 17, 2026
f96ddcf
compiler: Refactor clean-up
FabioLuporini Jun 18, 2026
be11274
compiler: Remove dangerous updates_args feature
FabioLuporini Jun 18, 2026
1f261eb
compiler: Refactor fusion.py
FabioLuporini Jun 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions devito/arch/archinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ def parse_product_arch():
def get_visible_devices():
device_vars = (
'CUDA_VISIBLE_DEVICES',
'NVIDIA_VISIBLE_DEVICES',
'ROCR_VISIBLE_DEVICES',
'HIP_VISIBLE_DEVICES'
)
Expand Down
5 changes: 4 additions & 1 deletion devito/finite_differences/derivative.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

import sympy

from devito.tools import Pickable, as_mapper, as_tuple, frozendict, is_integer
from devito.tools import (
Pickable, as_mapper, as_tuple, frozendict, is_integer, memoized_func
)
from devito.types.dimension import Dimension
from devito.types.utils import DimensionTuple
from devito.warnings import warn
Expand Down Expand Up @@ -557,6 +559,7 @@ def _evaluate(self, **kwargs):
def _eval_deriv(self):
return self._eval_fd(self.expr)

@memoized_func(scope='build')
def _eval_fd(self, expr, **kwargs):
"""
Evaluate the finite-difference approximation of the Derivative.
Expand Down
4 changes: 4 additions & 0 deletions devito/finite_differences/differentiable.py
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,10 @@ def compare(self, other):
def base(self):
return self.expr.func(*[a for a in self.expr.args if a is not self.weights])

@cached_property
def pivot(self):
return self.base.subs({d: 0 for d in self.dimensions})

@property
def weights(self):
return self._weights
Expand Down
5 changes: 3 additions & 2 deletions devito/finite_differences/finite_difference.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,15 @@ def make_derivative(expr, dim, fd_order, deriv_order, side, matvec, x0, coeffici
# `coefficients` method (`taylor` or `symbolic`)
if weights is None:
weights = fd_weights_registry[coefficients](expr, deriv_order, indices, x0)
if isinstance(weights, Iterable) and len(weights) != len(indices):
_, wdim, _ = process_weights(weights, expr, dim)
elif isinstance(weights, Iterable) and len(weights) != len(indices):
warning(f"Number of weights ({len(weights)}) does not match "
f"number of indices ({len(indices)}), reverting to Taylor")
scale = False
wdim = None
weights = fd_weights_registry['taylor'](expr, deriv_order, indices, x0)

# Did fd_weights_registry return a new Function/Expression instead of a values?
_, wdim, _ = process_weights(weights, expr, dim)
if wdim is not None:
weights = [weights._subs(wdim, i) for i in range(len(indices))]

Expand Down
6 changes: 5 additions & 1 deletion devito/finite_differences/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,14 @@ def make_stencil_dimension(expr, _min, _max):


@cacheit
def numeric_weights(function, deriv_order, indices, x0):
def _numeric_weights(deriv_order, indices, x0):
return finite_diff_weights(deriv_order, indices, x0)[-1][-1]


def numeric_weights(function, deriv_order, indices, x0):
return _numeric_weights(deriv_order, indices, x0)


fd_weights_registry = {'taylor': numeric_weights, 'standard': numeric_weights,
'symbolic': numeric_weights} # Backward compat for 'symbolic'
coeff_priority = {'taylor': 1, 'standard': 1}
Expand Down
20 changes: 14 additions & 6 deletions devito/ir/cgen/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
from devito.arch.compiler import AOMPCompiler
from devito.symbolics.inspection import has_integer_args, sympy_dtype
from devito.symbolics.queries import q_leaf
from devito.tools import ctypes_to_cstr, ctypes_vector_mapper, dtype_to_ctype
from devito.tools import (
ctypes_to_cstr, ctypes_vector_mapper, dtype_to_ctype, memoized_func
)
from devito.types.basic import AbstractFunction

__all__ = ['BasePrinter', 'ccode']
__all__ = ['BasePrinter', 'ccode', 'get_printer']


class BasePrinter(CodePrinter):
Expand Down Expand Up @@ -449,15 +451,20 @@ def _print_Fallback(self, expr):
sympy.printing.str.StrPrinter._print_Add = BasePrinter._print_Add


def ccode(expr, printer=None, **settings):
@memoized_func
def get_printer(printer, dtype):
return printer(settings={'dtype': dtype})


def ccode(expr, printer=None, dtype=None):
"""Generate C++ code from an expression.

Parameters
----------
expr : expr-like
The expression to be printed.
settings : dict
Options for code printing.
dtype : data-type, optional
Data type used by the printer.

Returns
-------
Expand All @@ -468,4 +475,5 @@ def ccode(expr, printer=None, **settings):
if printer is None:
from devito.passes.iet.languages.C import CPrinter
printer = CPrinter
return printer(settings=settings).doprint(expr, None)
dtype = printer._default_settings['dtype'] if dtype is None else dtype
return get_printer(printer, dtype).doprint(expr, None)
6 changes: 1 addition & 5 deletions devito/ir/clusters/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def _callback(self, clusters, dim, prefix):
is_parallel_atomic = False

scope = Scope(flatten(c.exprs for c in clusters))
for dep in scope.d_all_gen():
for dep in scope.d_all_gen(writes=scope.writes_tensor):
test00 = dep.is_indep(dim) and not dep.is_storage_related(dim)
test01 = all(dep.is_reduce_atmost(i) for i in prev)
if test00 and test01:
Expand All @@ -112,10 +112,6 @@ def _callback(self, clusters, dim, prefix):
is_parallel_indep &= (dep.distance_mapper.get(dim.root) == 0)
continue

if dep.function in scope.initialized:
# False alarm, the dependence is over a locally-defined symbol
continue

if dep.is_reduction:
is_parallel_atomic = True
continue
Expand Down
Loading
Loading