@@ -111,6 +111,39 @@ def compute(self, rank: Rank):
111111 rank .get_sent_volume (),
112112 rank .get_homing ())
113113
114+ def __update_bounds (self , r_snd : Rank , r_rcv : Rank , o_snd : list , o_rcv : list ):
115+ """Update verification of bounds if objects are to be sent and received."""
116+ # Distinguish between upper bound QOIs
117+ for k , v in self .__upper_bounds .items ():
118+ if k == "max_memory_usage" :
119+ # Initialize post-transfer set of objects
120+ o_new = set ()
121+
122+ # Node-level upper bound
123+ if self .__node_bounds :
124+ n_snd = r_snd .get_node ()
125+ o_new = n_snd .get_objects ()
126+ # Updated objects only if transfer is not node-local
127+ if n_snd != r_rcv .get_node ():
128+ o_new = (o_new .difference (o_snd )).union (o_rcv )
129+
130+ # Rank-level upper bound
131+ else :
132+ o_new = (r_snd .get_objects ().difference (o_snd )).union (o_rcv )
133+
134+ # Compute new set of blocks and check upper bound
135+ b_new = set (o .get_shared_block () for o in o_new if o .get_shared_block ())
136+ return b_new and (sum (b .get_size () for b in b_new ) > v )
137+
138+ else :
139+ # Ignore unsupported upper bound types
140+ self .__logger .warning (
141+ f"Upper bound update formula not supported for { k } , ignoring it." )
142+ return False
143+
144+ # Bounds are satisfied by default
145+ return False
146+
114147 def __update_load (self , rank : Rank , o_snd : list , o_rcv : list ):
115148 """Update total load if objects are to be sent and received."""
116149 return rank .get_load () - sum (
@@ -271,12 +304,16 @@ def __update_homing(self, rank: Rank, o_snd: list, o_rcv: list):
271304 # Return updated homing cost
272305 return homing
273306
274- def update (self , rank : Rank , o_snd : list , o_rcv : list ):
307+ def update (self , r_snd : Rank , r_rcv : Rank , o_snd : list , o_rcv : list ):
275308 """Update work if objects are to be sent and received."""
309+ # Check whether strict bounds are satisfied
310+ if self .__update_bounds (r_snd , r_rcv , o_snd , o_rcv ):
311+ return math .inf
312+
276313 # Return combination of load and volumes
277314 return self .affine_combination (
278- rank .get_alpha (),
279- self .__update_load (rank , o_snd , o_rcv ),
280- self .__update_received (rank , o_snd , o_rcv ),
281- self .__update_sent (rank , o_snd , o_rcv ),
282- self .__update_homing (rank , o_snd , o_rcv ))
315+ r_snd .get_alpha (),
316+ self .__update_load (r_snd , o_snd , o_rcv ),
317+ self .__update_received (r_snd , o_snd , o_rcv ),
318+ self .__update_sent (r_snd , o_snd , o_rcv ),
319+ self .__update_homing (r_snd , o_snd , o_rcv ))
0 commit comments