Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 17 additions & 1 deletion devito/arch/archinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from packaging.version import InvalidVersion, parse

from devito.logger import warning
from devito.tools import all_equal, as_tuple, memoized_func
from devito.tools import all_equal, as_tuple, frozendict, memoized_func

__all__ = [ # noqa: RUF022
'platform_registry', 'get_cpu_info', 'get_gpu_info', 'get_visible_devices',
Expand Down Expand Up @@ -855,6 +855,13 @@ def supports(self, query, language=None):
"""
return False

@cached_property
def digest(self):
fields = ('brand', 'logical', 'physical')
cpuinfo = get_cpu_info()
# TODO: Is it necessary to homogenise brand info?
return frozendict({k: cpuinfo[k] for k in fields})


class Cpu64(Platform):

Expand Down Expand Up @@ -1093,6 +1100,15 @@ def limits(self, compiler=None, language=None):
'max-block-dims': 3,
}

@cached_property
def digest(self):
fields = ('architecture', 'product', 'vendor')
gpuinfo = get_gpu_info()
mapper = {k: gpuinfo[k] for k in fields}
mapper['mem.total'] = gpuinfo['mem.total']()

return frozendict(mapper)


class IntelDevice(Device):

Expand Down
10 changes: 10 additions & 0 deletions devito/operator/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ def __new__(cls, expressions, **kwargs):
cls._check_kwargs(**kwargs)
expressions = cls._sanitize_exprs(expressions, **kwargs)

# Hook for retrieval of preexisting operators
# TODO: should this emit timing info if an operator is retrieved

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only in the hook, I'd say? so I guess you can drop this TODO comment...

maybe_op = cls._retrieve_op(expressions, **kwargs)
if maybe_op:
return maybe_op

# Lower to a JIT-compilable object
with timed_region('op-compile') as r:
try:
Expand Down Expand Up @@ -215,6 +221,10 @@ def _sanitize_exprs(cls, expressions, **kwargs):

return expressions

@classmethod
def _retrieve_op(cls, expressions, **kwargs):
return

@classmethod
def _build(cls, expressions, **kwargs):
# Python- (i.e., compile-) and C-level (i.e., run-time) performance
Expand Down
3 changes: 3 additions & 0 deletions devito/types/equation.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ def xreplace(self, rules):
return self.func(self.lhs.xreplace(rules), self.rhs.xreplace(rules))

def __str__(self):
if self._subdomain is not None:
return (f"{self.__class__.__name__}({self.lhs}, {self.rhs},"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpicking, this part of the fstring is identical to the one you return if no subdomain is present...

f" subdomain={self._subdomain})")
return f"{self.__class__.__name__}({self.lhs}, {self.rhs})"

__repr__ = __str__
Expand Down
Loading