Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symbols generated by Devito should be generated using a symbol registry #2292

Open
EdCaunt opened this issue Jan 4, 2024 · 0 comments
Open
Labels

Comments

@EdCaunt
Copy link
Contributor

EdCaunt commented Jan 4, 2024

Symbols generated within Devito currently do not have guaranteed unique names, potentially producing inadvertent clashes which result in cryptic errors being raised.

Devito currently makes use of counters (among other means) to create unique names for internally-generated symbols. However, there is nothing preventing clashes either with other generated symbols or those defined by the user.

It would be beneficial to have a registry of symbols to generate unique names in a consistent manner, to be used throughout the codebase.

This functionality could potentially be introduced as a mixin class where needed.

Possible approach:

@cached_property
def name(self):
    if self._name is None:
         return compute_deterministic_hash(self._hashable_content()))
    else:
         return self._name 

or alternatively when setting name:

self._name = self._registry.get_unique_name(name)

where get_unique_name adds an increment to the supplied name as required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants