Skip to content

Fix _sendrecv_get_destinations todo: loop only over neighbours - #350

Merged
max-models merged 19 commits into
develfrom
fix-_sendrecv_get_destinations-loop-only-over-neighbours
Aug 22, 2026
Merged

Fix _sendrecv_get_destinations todo: loop only over neighbours#350
max-models merged 19 commits into
develfrom
fix-_sendrecv_get_destinations-loop-only-over-neighbours

Conversation

@max-models

@max-models max-models commented Aug 17, 2026

Copy link
Copy Markdown
Member
  • Added _compute_neighbor_ranks(), computed once at __init__
  • _sendrecv_get_destinations now checks neighbor ranks first, and only falls back to checking the rest if some markers remain unmatched
  • self.markers[send_inds] and self._sorting_etas[send_inds] are now gathered once (see candidates, etas_to_send) instead of being re-gathered on every rank-loop iteration.

Improvements (Np=4,000,000):

  • 4 ranks: 1.07x speedup
  • 8 ranks: 1.34x speedup
  • 16 ranks: 1.57x speedup

Merge after #348

@max-models
max-models marked this pull request as ready for review August 18, 2026 09:00
@max-models
max-models requested a review from spossann August 18, 2026 09:00
spossann
spossann previously approved these changes Aug 18, 2026

@spossann spossann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for this. For testing, it would make a lot of sense to run the unit tests on 1, 2, 3 and 4 ranks, to test different topologies. However:

  1. Some tests would probably have to be adapted, maybe even the default params file.
  2. Would it be too costly to run the unit tests four times?

@max-models

Copy link
Copy Markdown
Member Author

Thanks for this. For testing, it would make a lot of sense to run the unit tests on 1, 2, 3 and 4 ranks, to test different topologies. However:

  1. Some tests would probably have to be adapted, maybe even the default params file.
  2. Would it be too costly to run the unit tests four times?

Good questions, I'm worried that there will not be a big difference for 1-4 ranks since the number or ranks vs number of neighbours are the same. But I can try to come up with a benchmark.

@spossann

Copy link
Copy Markdown
Member

Thanks for this. For testing, it would make a lot of sense to run the unit tests on 1, 2, 3 and 4 ranks, to test different topologies. However:

  1. Some tests would probably have to be adapted, maybe even the default params file.
  2. Would it be too costly to run the unit tests four times?

Good questions, I'm worried that there will not be a big difference for 1-4 ranks since the number or ranks vs number of neighbours are the same. But I can try to come up with a benchmark.

I was thinking more about topology: with 3 ranks you get one interior rank (without domain boundary), with 4 ranks you get a 2x2 square. Maybe such tests could be useful, however not specific to the neighbours. Anyhow this would be for a different PR.

@max-models

Copy link
Copy Markdown
Member Author

Thanks for this. For testing, it would make a lot of sense to run the unit tests on 1, 2, 3 and 4 ranks, to test different topologies. However:

  1. Some tests would probably have to be adapted, maybe even the default params file.
  2. Would it be too costly to run the unit tests four times?

Good questions, I'm worried that there will not be a big difference for 1-4 ranks since the number or ranks vs number of neighbours are the same. But I can try to come up with a benchmark.

I was thinking more about topology: with 3 ranks you get one interior rank (without domain boundary), with 4 ranks you get a 2x2 square. Maybe such tests could be useful, however not specific to the neighbours. Anyhow this would be for a different PR.

Ah ok! Yes this could easily be done with --oversubscribe. But maybe it's enough to set up some unittests just for this function and test them with a few different configurations. Running all the unittests sounds like too much to me.

@spossann

Copy link
Copy Markdown
Member

Thanks for this. For testing, it would make a lot of sense to run the unit tests on 1, 2, 3 and 4 ranks, to test different topologies. However:

  1. Some tests would probably have to be adapted, maybe even the default params file.
  2. Would it be too costly to run the unit tests four times?

Good questions, I'm worried that there will not be a big difference for 1-4 ranks since the number or ranks vs number of neighbours are the same. But I can try to come up with a benchmark.

I was thinking more about topology: with 3 ranks you get one interior rank (without domain boundary), with 4 ranks you get a 2x2 square. Maybe such tests could be useful, however not specific to the neighbours. Anyhow this would be for a different PR.

Ah ok! Yes this could easily be done with --oversubscribe. But maybe it's enough to set up some unittests just for this function and test them with a few different configurations. Running all the unittests sounds like too much to me.

Indeed, I would like to see all unit tests in pic/tests that are not marked with mpi_skip to be run on 1, 2, 3 and 4 ranks, respectively.

@max-models
max-models marked this pull request as draft August 19, 2026 17:52
@max-models

Copy link
Copy Markdown
Member Author

Thanks for this. For testing, it would make a lot of sense to run the unit tests on 1, 2, 3 and 4 ranks, to test different topologies. However:

  1. Some tests would probably have to be adapted, maybe even the default params file.
  2. Would it be too costly to run the unit tests four times?

Good questions, I'm worried that there will not be a big difference for 1-4 ranks since the number or ranks vs number of neighbours are the same. But I can try to come up with a benchmark.

I was thinking more about topology: with 3 ranks you get one interior rank (without domain boundary), with 4 ranks you get a 2x2 square. Maybe such tests could be useful, however not specific to the neighbours. Anyhow this would be for a different PR.

Ah ok! Yes this could easily be done with --oversubscribe. But maybe it's enough to set up some unittests just for this function and test them with a few different configurations. Running all the unittests sounds like too much to me.

Indeed, I would like to see all unit tests in pic/tests that are not marked with mpi_skip to be run on 1, 2, 3 and 4 ranks, respectively.

Like this? 6559d2d

@spossann

Copy link
Copy Markdown
Member

Thanks for this. For testing, it would make a lot of sense to run the unit tests on 1, 2, 3 and 4 ranks, to test different topologies. However:

  1. Some tests would probably have to be adapted, maybe even the default params file.
  2. Would it be too costly to run the unit tests four times?

Good questions, I'm worried that there will not be a big difference for 1-4 ranks since the number or ranks vs number of neighbours are the same. But I can try to come up with a benchmark.

I was thinking more about topology: with 3 ranks you get one interior rank (without domain boundary), with 4 ranks you get a 2x2 square. Maybe such tests could be useful, however not specific to the neighbours. Anyhow this would be for a different PR.

Ah ok! Yes this could easily be done with --oversubscribe. But maybe it's enough to set up some unittests just for this function and test them with a few different configurations. Running all the unittests sounds like too much to me.

Indeed, I would like to see all unit tests in pic/tests that are not marked with mpi_skip to be run on 1, 2, 3 and 4 ranks, respectively.

Like this? 6559d2d

I think we need a new mark on the tests in pic/tests that we want to include, and then just test those with pytest -m new-mark ... for also 3 and 4 ranks.

@max-models
max-models force-pushed the fix-_sendrecv_get_destinations-loop-only-over-neighbours branch from 4241e02 to 88734aa Compare August 21, 2026 12:48
@max-models
max-models requested a review from spossann August 21, 2026 19:15
@max-models
max-models marked this pull request as ready for review August 21, 2026 19:15
@max-models
max-models merged commit 704cc00 into devel Aug 22, 2026
30 checks passed
@max-models
max-models deleted the fix-_sendrecv_get_destinations-loop-only-over-neighbours branch August 22, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants