Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
077346c
compiler: Augment caching and memoization
FabioLuporini Mar 24, 2026
61f9155
compiler: Augment caching and tweak memoization heuristics
FabioLuporini Apr 2, 2026
7193656
compiler: cache TimedAccess instances
FabioLuporini Apr 3, 2026
050993c
compiler: Add heuristics to improve fusion lowering turnaround
FabioLuporini Apr 7, 2026
559eacd
compiler: Improve Cluster fusion implementation
FabioLuporini Apr 8, 2026
dbf450b
compiler: Avoid rebuilding IET if unnecessary
FabioLuporini Apr 8, 2026
7fc26a8
compiler: Fix propagation of transitive IET arg updates
FabioLuporini Apr 8, 2026
e93e987
compiler: cache CGen printers by settings
FabioLuporini Apr 8, 2026
47b05fe
compiler: Enhance Scope to improve DDA turnaround
FabioLuporini Apr 9, 2026
49543fe
compiler: Exploit the new Scope API
FabioLuporini Apr 9, 2026
e989cdb
compiler: include ClusterGroup ispace in equality semantics
FabioLuporini Apr 9, 2026
1a89d1d
compiler: Add update_args= contract to spare compilation time
FabioLuporini Apr 9, 2026
0544a8d
compiler: Add heuristic for topofuse='maximal'
FabioLuporini Apr 10, 2026
29af630
misc: Patch NVIDIA_VISIBLE_DEVICES and DeviceID
FabioLuporini Apr 10, 2026
c1c46a4
tools: Add DefaultFrozenDict
FabioLuporini Apr 15, 2026
8f753f4
compiler: Remove dead NodesExprs.dspace
FabioLuporini Apr 15, 2026
6cf0665
tools: Add reuse_if_unchanged and exploit it
FabioLuporini Apr 24, 2026
3736683
compiler: Split into EqBlock and Cluster
FabioLuporini Apr 27, 2026
f4ffe3f
compiler: Stash hash were essential for compilation performance
FabioLuporini Apr 28, 2026
7acbb9b
compiler: Exploit cached_hash
FabioLuporini Apr 28, 2026
4970ac2
compiler: Retain original objects whenever possible
FabioLuporini Apr 28, 2026
285d2d9
compiler: Minimize reconstructions everywhere
FabioLuporini Apr 29, 2026
8af6cec
compiler: Memoize Fusion._key
FabioLuporini Apr 29, 2026
70ee877
compiler: Avoid rebuilding Nodes when possible
FabioLuporini Apr 29, 2026
d127dc7
compiler: Memoize IET visitors
FabioLuporini Apr 29, 2026
07bcb2f
compiler: Memoize IET engine
FabioLuporini Apr 30, 2026
7d3debd
compiler: Avoid reconstructions in IET visitors
FabioLuporini Apr 30, 2026
54c2b2a
compiler: Memoize FindNodes
FabioLuporini Apr 30, 2026
6ac9b20
compiler: Call finalize_args once at the end of the lowering
FabioLuporini May 12, 2026
5ac388f
compiler: Rename _rebuild -> _reuse_if_untouched
FabioLuporini Jun 16, 2026
1746856
compiler: Avoid useless renaming
FabioLuporini Jun 16, 2026
006faa9
compiler: Refactor IREq
FabioLuporini Jun 16, 2026
93356a4
compiler: isort happiness
FabioLuporini Jun 16, 2026
432538c
compiler: pep8 happiness
FabioLuporini Jun 16, 2026
21f8660
compiler: Comply with ruff
FabioLuporini Jun 16, 2026
357df58
compiler: Use placeholder dtype to compute repr
FabioLuporini Jun 16, 2026
ddaf3cb
tests: Adjust visible_devices testing
FabioLuporini Jun 16, 2026
43eda36
compiler: Simplify reuse_if_untouched
FabioLuporini Jun 17, 2026
4df4cb5
compiler: Simplify get_printer
FabioLuporini Jun 17, 2026
4ddf48b
Drop Tag.cached_hash as not safe
FabioLuporini Jun 17, 2026
8fc9ca5
tests: Use np.random.RandomState where necessary
FabioLuporini Jun 17, 2026
31edc62
compiler: Fixup lower_async_objs
FabioLuporini Jun 17, 2026
be96718
compiler: Refactor clean-up
FabioLuporini Jun 18, 2026
91b2d83
compiler: Remove dangerous updates_args feature
FabioLuporini Jun 18, 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