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

compiler: Misc compiler fixes and improvements -- part II #2138

Merged
merged 22 commits into from
Jun 7, 2023

Conversation

FabioLuporini
Copy link
Contributor

No description provided.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@codecov
Copy link

codecov bot commented May 31, 2023

Codecov Report

Merging #2138 (9636366) into master (0678627) will decrease coverage by 0.02%.
The diff coverage is 92.01%.

@@            Coverage Diff             @@
##           master    #2138      +/-   ##
==========================================
- Coverage   87.09%   87.08%   -0.02%     
==========================================
  Files         223      223              
  Lines       39689    39830     +141     
  Branches     5147     5168      +21     
==========================================
+ Hits        34567    34685     +118     
- Misses       4544     4567      +23     
  Partials      578      578              
Impacted Files Coverage Δ
devito/arch/compiler.py 39.34% <0.00%> (ø)
devito/ir/iet/algorithms.py 83.87% <0.00%> (ø)
tests/test_gpu_common.py 1.46% <3.03%> (+0.08%) ⬆️
devito/types/utils.py 94.11% <50.00%> (-5.89%) ⬇️
devito/ir/stree/algorithms.py 90.68% <56.25%> (-2.57%) ⬇️
devito/types/basic.py 93.35% <80.00%> (-0.43%) ⬇️
devito/mpi/routines.py 93.18% <84.61%> (-0.52%) ⬇️
devito/mpi/halo_scheme.py 93.68% <88.88%> (-0.51%) ⬇️
tests/test_pickle.py 99.62% <99.61%> (+0.02%) ⬆️
devito/ir/clusters/algorithms.py 95.33% <100.00%> (+0.01%) ⬆️
... and 13 more

... and 3 files with indirect coverage changes

@FabioLuporini FabioLuporini changed the title compiler: Misc fixes and improvements compiler: Misc compiler fixes and improvements -- part II May 31, 2023
Copy link
Contributor

@georgebisbas georgebisbas left a comment

Choose a reason for hiding this comment

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

What was the problem with u.dx2? Is there an issue somewhere about this?

@FabioLuporini
Copy link
Contributor Author

What was the problem with u.dx2? Is there an issue somewhere about this?

These were PRO issues, and all new tests therefore a in PRO

That said, I can assure you that there's no new feature here in OSS territory that hasn't been equipped with at least one test. Most changes here are compilation-related generalisations and improvements which are stress-tested by what de-facto are higher-order regression tests in PRO

# it doesn't need to wrap any subtree. Thus, a WaitLock acts like
# a barrier to what follows inside `d`
NodeSync(syncs, tip)
return tip
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpicking, Since this doesn't really return anything it'd me slightly more consistent to have

tip = NodeSync(syncs, tip)
return

Copy link
Contributor Author

Choose a reason for hiding this comment

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

improved and fixed 👍

@@ -527,7 +527,9 @@ def function(self):
def imask(self):
return self._imask

@cached_property
# TODO: cached_property here will break our pickling tests for reasons that
Copy link
Contributor

Choose a reason for hiding this comment

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

out of curiosity which test?

Copy link
Contributor Author

@FabioLuporini FabioLuporini Jun 5, 2023

Choose a reason for hiding this comment

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

PRO tests landing with the fix-udx2-MPI branch in PRO. For future reference: they are test_layered_funcs.py::TestMisc::test_pickling and test_composite_funcs.py::TestMisc::test_pickling

devito/tools/abc.py Outdated Show resolved Hide resolved
@@ -203,6 +211,13 @@ def _mem_shared(self):
def _mem_constant(self):
return self._scope == 'constant'

@property
Copy link
Contributor

Choose a reason for hiding this comment

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

Move to AbstractFunction I'd say

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will see how I can improve things. Note that DiscreteFunction has a _distributor attribute too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

perhaps this should be hoisted to the superclass:

https://github.com/devitocodes/devito/blob/master/devito/types/dense.py#L177-L181

...

Copy link
Contributor

Choose a reason for hiding this comment

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

I think so yes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

devito/types/misc.py Outdated Show resolved Hide resolved
@@ -1,3 +1,5 @@
import cloudpickle as pickle
Copy link
Contributor

Choose a reason for hiding this comment

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

We might want to do both picklle and cloudpickle as parameters for all pickling tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AFAICT, cloudpickle >>> pickle though

Anyway, how would you implement it? Thinking about it, and it doesn't sound obvious... does it?

@@ -1343,6 +1350,25 @@ def test_npthreads(self):
assert op.arguments(time_M=2, npthreads0=5)


class TestMisc(object):

def test_pickling(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

That should be in test_pickle but I guess it's easier for gpu to dso it here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mmhh in my view, the GPU tests are "more specific" than the pickling tests

Just like some MPI tests are found outside of test_mpi.py

@@ -1,7 +1,7 @@
import pytest
import numpy as np
from sympy import Symbol
import pickle
import cloudpickle as pickle
Copy link
Contributor

Choose a reason for hiding this comment

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

As above, import both and make all tests for each

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah maybe i see what you mean now... are you saying something like

import pickle as pickle0
import cloudpickle as pickle1

@pytest.parametrize('pickle', [pickle0, pickle1])
def test_...(...):
    ...

?

isn't it overkill?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes what I mean. Since there seems to be breaking difference between those two pickling implementation I think it would be safer to have it yeah. THese are very cheap tests so it shouldn't be an issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah. The point, though, is that even if cloudpickle didn't work, then pickle still surely wouldn't, at least with PRO, because pickle can't pickle (sorry...) lambda functions

BTW, the other interesting candidate is dill

Anyway, since it's a minor change, I'm happy to test both cloudpickle and pickle here in OSS. Will try to do it tomorrow

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done. Please take a look, I've restructured a few things

@FabioLuporini
Copy link
Contributor Author

@mloubout update: addressed your comments and rebased on latest master

Copy link
Contributor

@georgebisbas georgebisbas left a comment

Choose a reason for hiding this comment

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

Not sure I have something to comment. Should I look into something specific that you believe needs more attention?

@@ -338,35 +338,37 @@ def _make_all(self, f, hse, msg):

def _make_copy(self, f, hse, key, swap=False):
dims = [d.root for d in f.dimensions if d not in hse.loc_indices]
ofs = [Symbol(name='o%s' % d.root, is_const=True) for d in f.dimensions]
Copy link
Contributor

Choose a reason for hiding this comment

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

That's the same symbol as grid.origin, doesn't seem to create an issue anywhere but seems risky

@FabioLuporini FabioLuporini merged commit aedc3b9 into master Jun 7, 2023
@FabioLuporini FabioLuporini deleted the fix-udx2-MPI branch June 7, 2023 21:53
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.

3 participants