Skip to content

Commit

Permalink
use dict for pending_recv_identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasdiener committed Jun 27, 2024
1 parent 4135433 commit 3825b1c
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions meshmode/distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,12 @@ def __enter__(self):
# the pickling ourselves.

# to know when we're done
self.pending_recv_identifiers = [
(irbi.local_part_id, irbi.remote_part_id)
for irbi in self.inter_rank_bdry_info]
self.pending_recv_identifiers = {
(irbi.local_part_id, irbi.remote_part_id): i
for i, irbi in enumerate(self.inter_rank_bdry_info)}

assert len(self.pending_recv_identifiers) \
== len(self.inter_rank_bdry_info) \
== len(set(self.pending_recv_identifiers))
== len(self.inter_rank_bdry_info)

self.send_reqs = [
self._internal_mpi_comm.isend(
Expand Down Expand Up @@ -334,7 +333,7 @@ def complete_some(self):
while nrecvs > 0:
r = self._internal_mpi_comm.recv(status=status)
key = (r[1], r[0])
loc = self.pending_recv_identifiers.index(key)
loc = self.pending_recv_identifiers[key]
assert data[loc] is None
assert source_ranks[loc] is None
data[loc] = r
Expand Down Expand Up @@ -377,7 +376,7 @@ def complete_some(self):
group_factory=self.bdry_grp_factory),
remote_group_infos=remote_group_infos))

self.pending_recv_identifiers.remove((local_part_id, remote_part_id))
del self.pending_recv_identifiers[(local_part_id, remote_part_id)]

assert not self.pending_recv_identifiers
MPI.Request.waitall(self.send_reqs)
Expand Down

0 comments on commit 3825b1c

Please sign in to comment.