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

Communicator refactor #496

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9dc3a6e
towards generic communicators
bknueven Mar 7, 2025
da2e00b
work towards automatic field length computation
bknueven Mar 7, 2025
ad1f6b9
automatically register send fields based on class attributes
bknueven Mar 7, 2025
dd91f14
remove has_*_spokes
bknueven Mar 7, 2025
d89676c
more generic receive logic
bknueven Mar 7, 2025
f5baab5
remove converger_spoke_types
bknueven Mar 7, 2025
3d7b47e
communicators exchange send data
bknueven Mar 7, 2025
d846615
remove optional_recieve_fields
bknueven Mar 7, 2025
c547777
fix API for register_extension_recv_field
bknueven Mar 7, 2025
4d3b668
unifying register_receive_fields
bknueven Mar 7, 2025
f2ff331
better validation; code cleanup
bknueven Mar 10, 2025
36b1a0e
remove *_to_* methods; nothing was really pushed anyways...
bknueven Mar 10, 2025
8675a82
add coverage for RC rho
bknueven Mar 10, 2025
c4b4efc
update RC rho for PR #476
bknueven Mar 10, 2025
4e2085e
remove hub_from_spoke
bknueven Mar 10, 2025
091a2c8
remove spoke_from_hub
bknueven Mar 10, 2025
2769a54
fixing a few bugs
bknueven Mar 10, 2025
a94c2dd
extensions have to do nearly everything anyways; might as well be exp…
bknueven Mar 11, 2025
3948b2f
spokes can get DUALS and NONANTs from whereever, as long as the provi…
bknueven Mar 11, 2025
62a3da9
cleaning up windows; errata
bknueven Mar 26, 2025
a549c7d
Use `Free` for older version of mpi4py
bknueven Mar 26, 2025
1a0ceb8
bring back explicit window creation / distruction
bknueven Mar 26, 2025
5fdb1f0
look up nonants/cost in cross scenario spoke
bknueven Mar 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
spokes can get DUALS and NONANTs from whereever, as long as the provi…
…der is unique
  • Loading branch information
bknueven committed Mar 11, 2025
commit 3948b2f0a1f8ab3fee4c54d715f7a5d83568ba55
33 changes: 14 additions & 19 deletions mpisppy/cylinders/spoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,9 @@ class Spoke(SPCommunicator):
send_fields = (*SPCommunicator.send_fields, )
receive_fields = (*SPCommunicator.receive_fields, Field.SHUTDOWN, )

def __init__(self, spbase_object, fullcomm, strata_comm, cylinder_comm, communicators, options=None):

super().__init__(spbase_object, fullcomm, strata_comm, cylinder_comm, communicators, options)

self.last_call_to_got_kill_signal = time.time()

return

def _got_kill_signal(self):
shutdown_buf = self.receive_buffers[self._make_key(Field.SHUTDOWN, 0)]
if shutdown_buf.is_new():
shutdown = (shutdown_buf[0] == 1.0)
else:
shutdown = False
## End if
return shutdown
return (shutdown_buf.is_new() and shutdown_buf[0] == 1.0)

def got_kill_signal(self):
""" Spoke should call this method at least every iteration
Expand All @@ -58,7 +45,6 @@ def main(self):
def update_receive_buffers(self):
for (key, recv_buf) in self.receive_buffers.items():
field, rank = self._split_key(key)
# The below code will need to be updated for spoke to spoke communication
self.get_receive_buffer(recv_buf, field, rank)
## End for
return
Expand Down Expand Up @@ -142,6 +128,15 @@ def nonant_len_type(self) -> Field:
# TODO: Make this a static method?
pass

def register_receive_fields(self) -> None:
super().register_receive_fields()
nonant_len_ranks = self.fields_to_ranks[self.nonant_len_type()]
if len(nonant_len_ranks) > 1:
raise RuntimeError(
f"More than one cylinder to select from for {self.nonant_len_type()}!"
)
self._receive_rank = nonant_len_ranks[0]


class InnerBoundSpoke(_BoundSpoke):
""" For Spokes that provide an inner bound through self.bound to the
Expand Down Expand Up @@ -182,7 +177,7 @@ def nonant_len_type(self) -> Field:
@property
def localWs(self):
"""Returns the local copy of the weights"""
key = self._make_key(Field.DUALS, 0)
key = self._make_key(Field.DUALS, self._receive_rank)
return self.receive_buffers[key].value_array()

@property
Expand All @@ -191,7 +186,7 @@ def new_Ws(self):
the weights has been updated since
the last call to got_kill_signal
"""
key = self._make_key(Field.DUALS, 0)
key = self._make_key(Field.DUALS, self._receive_rank)
return self.receive_buffers[key].is_new()


Expand Down Expand Up @@ -223,15 +218,15 @@ def nonant_len_type(self) -> Field:
@property
def localnonants(self):
"""Returns the local copy of the nonants"""
key = self._make_key(Field.NONANT, 0)
key = self._make_key(Field.NONANT, self._receive_rank)
return self.receive_buffers[key].value_array()

@property
def new_nonants(self):
"""Returns True if the local copy of
the nonants has been updated since
the last call to got_kill_signal"""
key = self._make_key(Field.NONANT, 0)
key = self._make_key(Field.NONANT, self._receive_rank)
return self.receive_buffers[key].is_new()


Expand Down
Loading