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

Misc code generation improvements #2001

Merged
merged 15 commits into from Sep 20, 2022
Merged

Misc code generation improvements #2001

merged 15 commits into from Sep 20, 2022

Conversation

FabioLuporini
Copy link
Contributor

This is mostly about avoiding premature lowering so that we have the necessary info in pro to perform compilation

@codecov
Copy link

codecov bot commented Sep 17, 2022

Codecov Report

Merging #2001 (2c331cb) into master (a647eca) will decrease coverage by 0.06%.
The diff coverage is 59.58%.

@@            Coverage Diff             @@
##           master    #2001      +/-   ##
==========================================
- Coverage   87.91%   87.85%   -0.07%     
==========================================
  Files         214      214              
  Lines       36613    36710      +97     
  Branches     5538     5550      +12     
==========================================
+ Hits        32189    32250      +61     
- Misses       3907     3942      +35     
- Partials      517      518       +1     
Impacted Files Coverage Δ
devito/operator/operator.py 90.75% <ø> (-0.04%) ⬇️
devito/passes/iet/orchestration.py 28.75% <0.00%> (ø)
tests/test_gpu_common.py 1.47% <0.00%> (-0.03%) ⬇️
devito/passes/clusters/asynchrony.py 11.28% <2.38%> (-0.88%) ⬇️
devito/ir/support/syncs.py 61.53% <36.84%> (-0.44%) ⬇️
examples/seismic/source.py 83.33% <66.66%> (-0.67%) ⬇️
devito/types/basic.py 94.50% <75.00%> (-0.38%) ⬇️
devito/tools/data_structures.py 66.66% <83.33%> (+0.35%) ⬆️
devito/passes/iet/engine.py 91.01% <84.09%> (-1.21%) ⬇️
devito/passes/clusters/buffering.py 95.28% <88.46%> (+0.32%) ⬆️
... and 11 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.


def __eq__(self, other):
return (type(self) == type(other) and
all(i == j for i, j in zip(self.args, other.args)))
return (type(self) is type(other) and
Copy link
Contributor

Choose a reason for hiding this comment

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

can this be neater?

devito/passes/iet/engine.py Show resolved Hide resolved
@property
def symbolic_nbytes(self):
# TODO: one day we'll have to fix the types/ vs extended_sympy/ thing
from devito.symbolics import SizeOf # noqa
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this here is due to circular dependency?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, unavoidable until we perform a systmematic restructuing of types/ and symbolics/

g = TimeFunction(name='g', grid=grid)

idx = time + 1
s = Indirection(name='ofs0', mapped=idx)
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure I appreciate the need for this indirection class...need to see better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

unused in OSS, but used in PRO

I however added it here , along with a suitable test, because I foresee its use in OSS as well


v = i
def key(i):
for p, cls in enumerate(priority, 1):
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be better with priority as a Dict so that we can easily add new ones with explicit priorities?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good, changing

def _(i, mapper, counter):
base = 'f'

kwargs = {k: getattr(i, k, None) for k in i.__rkwargs__}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there corner cases where an object doesn't have its own rkwargs defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

they all inherit from Reconstructable so we should be good

kwargs['name'] = '%s%d' % (base, counter[base])
kwargs['initializer'] = None
kwargs['alias'] = True
v = i._rebuild(**kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this a bit redundant/overkill? __rkwargs__ will be processed by _rebuild so there is no need to do it here, name/initializer/alias should be the only ones needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

jeeeeezzz ! True!


kwargs = {k: getattr(i, k, None) for k in i.__rkwargs__}
kwargs['name'] = '%s%d' % (base, counter[base])
v = type(i).__base__(**kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

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

No rebuild for Array?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

my bad, see comment below (TLDR: I'm a stupid)

args = [getattr(i, k, None) for k in i.__rargs__]
args[0] = '%s%d' % (base, counter[base])
kwargs = {k: getattr(i, k, None) for k in i.__rkwargs__}
v = i.func(*args, **kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

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

same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, this is all leftovers from the old implementation!

That's a really great catch

I'm gonna do this properly now


kwargs = {k: getattr(i, k, None) for k in i.__rkwargs__}
kwargs['name'] = '%s%d' % (base, counter[base])
v = i._rebuild(**kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

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

Only name needed not rkwargs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

absolutely yes

@@ -1624,51 +1627,3 @@ def _arg_values(self, **kwargs):
raise InvalidArgument("Illegal runtime value for `%s`" % self.name)
else:
raise InvalidArgument("TempFunction `%s` lacks override" % self.name)


class AliasFunction(DiscreteFunction):
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

Copy link
Contributor

@mloubout mloubout left a comment

Choose a reason for hiding this comment

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

Looks good, left some comments

@FabioLuporini
Copy link
Contributor Author

@mloubout should be all sorted now have a look

@FabioLuporini FabioLuporini merged commit 6e1dcc5 into master Sep 20, 2022
@FabioLuporini FabioLuporini deleted the layered-overhaul branch September 20, 2022 13:19
@FabioLuporini
Copy link
Contributor Author

Merged thanks

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

Successfully merging this pull request may close these issues.

None yet

3 participants