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

mpi: Add basic2 mode #2307

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

mpi: Add basic2 mode #2307

wants to merge 12 commits into from

Conversation

georgebisbas
Copy link
Contributor

Preallocated buffers using MPIMsg.
An MPIMsgEnriched version for send/recv, will follow

@georgebisbas georgebisbas added the MPI mpi-related label Feb 10, 2024
@georgebisbas georgebisbas self-assigned this Feb 10, 2024
@georgebisbas georgebisbas reopened this Feb 10, 2024
@georgebisbas georgebisbas marked this pull request as draft February 10, 2024 18:14
Copy link

codecov bot commented Feb 10, 2024

Codecov Report

Attention: Patch coverage is 98.14815% with 3 lines in your changes missing coverage. Please review.

Project coverage is 87.29%. Comparing base (41d04ed) to head (28825e1).

Files with missing lines Patch % Lines
devito/mpi/routines.py 98.03% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master    #2307    +/-   ##
========================================
  Coverage   87.29%   87.29%            
========================================
  Files         238      238            
  Lines       45382    45510   +128     
  Branches     4031     4049    +18     
========================================
+ Hits        39616    39729   +113     
- Misses       5083     5096    +13     
- Partials      683      685     +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@georgebisbas georgebisbas force-pushed the basic2mpi branch 4 times, most recently from ff919e2 to 895cef3 Compare February 16, 2024 18:40
@georgebisbas georgebisbas marked this pull request as ready for review February 16, 2024 18:55
@georgebisbas georgebisbas requested a review from EdCaunt February 16, 2024 18:55
devito/mpi/routines.py Show resolved Hide resolved
devito/mpi/routines.py Outdated Show resolved Hide resolved

return SendRecv('sendrecv%s' % key, iet, parameters, bufg, bufs)

def _call_sendrecv(self, name, *args, msg=None, haloid=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you need a haloid here ? never had to use it. What makes this mode require it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Similarly to the same method in OverlapHalo. Each call to sendrecv has its own message indexedpointer

devito/mpi/routines.py Show resolved Hide resolved
devito/mpi/routines.py Outdated Show resolved Hide resolved
devito/mpi/routines.py Show resolved Hide resolved
mapper[(d0, side, region)] = (sizes)

i = 0
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.

why not :

for i, halo in enumerate(self.halos):

like we have in the other message types?

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 followed the basic style, which does not have yet a method to cleanup the redundant halos as in diag2 for example:
e.g.:

        # Only retain the halos required by the Diag scheme
        halos = sorted(i for i in hse.halos if isinstance(i.dim, tuple))

I tried this but did not manage to get it working nicely.

@@ -801,7 +801,7 @@ def test_trivial_eq_2d(self):
assert np.all(f.data_ro_domain[0, :-1, -1:] == side)
assert np.all(f.data_ro_domain[0, -1:, :-1] == side)

@pytest.mark.parallel(mode=[(8, 'basic'), (8, 'diag'), (8, 'overlap'),
@pytest.mark.parallel(mode=[(8, 'basic'), (8, 'basic2'), (8, 'diag'), (8, 'overlap'),
Copy link
Contributor

Choose a reason for hiding this comment

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

I would drop basic here and below... or overlap perhaps. These tests can be quite expensive

@georgebisbas georgebisbas force-pushed the basic2mpi branch 4 times, most recently from 5a5e826 to c266e14 Compare April 9, 2024 17:35
@@ -1185,6 +1297,16 @@ def _as_number(self, v, args):
assert args is not None
return int(subs_op_args(v, args))

def _allocate_buffers(self, f, shape, entry):
Copy link
Contributor

Choose a reason for hiding this comment

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

This could use some whitespace to make it more readable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree, added a docstring as well

if d in fixed:
continue

if (d, LEFT) in self.halos:
Copy link
Contributor

Choose a reason for hiding this comment

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

for side in (LEFT, RIGHT):
    if (d, side) in self.halos:
        entry = self.value[i]
        i += 1
        shape = mapper[(d, side, OWNED)]
        self._allocate_buffers(f, shape, entry)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed, thanks

Copy link
Contributor

@EdCaunt EdCaunt left a comment

Choose a reason for hiding this comment

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

Is documentation required somewhere to explain what the new Basic2 mode does?

if d in fixed:
continue

name = ''.join('r' if i is d else 'c' for i in distributor.dimensions)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: lname and rname would be preferable to overwriting name imo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree, thanks!

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

Successfully merging this pull request may close these issues.

3 participants