Skip to content

Commit 008227c

Browse files
committed
#607: completed implementation of homing cost, tested it, created PR608
1 parent 0c0f228 commit 008227c

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

src/lbaf/Applications/LBAF_app.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,11 @@ def __print_statistics(self, phase: Phase, phase_name: str, work_model: WorkMode
390390
f"{phase_name} node maximum memory usage",
391391
self.__logger)
392392
if r_shared_mem_stats.get_maximum():
393+
lbstats.print_function_statistics(
394+
phase.get_ranks(),
395+
lambda x: x.get_homing(),
396+
f"{phase_name} homing cost",
397+
self.__logger)
393398
lbstats.print_function_statistics(
394399
phase.get_ranks(),
395400
lambda x: x.get_homed_blocks_ratio(),

src/lbaf/Model/lbsPhase.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,8 @@ def populate_from_samplers(self, n_ranks, n_objects, t_sampler, v_sampler, c_deg
457457
raise SystemExit(1)
458458

459459
# Compute and report communication volume statistics
460-
print_function_statistics(v_sent, lambda x: x, "communication volumes", self.__logger)
460+
print_function_statistics(
461+
v_sent, lambda x: x, "communication volumes", self.__logger)
461462

462463
# Create given number of ranks
463464
self.__ranks = [Rank(self.__logger, r_id) for r_id in range(n_ranks)]

src/lbaf/Model/lbsRank.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,14 @@ def get_number_of_homed_blocks(self) -> float:
181181
b.get_home_id() == self.get_id()
182182
for b in self.get_shared_blocks())
183183

184+
@qoi
185+
def get_homing(self) -> float:
186+
"""Return homing cost on rank."""
187+
val : float = 0.0
188+
return val + sum(
189+
b.get_size() for b in self.get_shared_blocks()
190+
if self.get_id() != b.get_home_id())
191+
184192
@qoi
185193
def get_number_of_uprooted_blocks(self) -> float:
186194
"""Return number of uprooted memory blocks on rank."""
@@ -285,22 +293,21 @@ def get_alpha(self) -> float:
285293
def get_load(self) -> float:
286294
"""Return total load on rank."""
287295
val : float = 0.0
288-
val += sum(o.get_load() for o in self.__migratable_objects.union(self.__sentinel_objects))
289-
return val
296+
return val + sum(
297+
o.get_load()
298+
for o in self.__migratable_objects.union(self.__sentinel_objects))
290299

291300
@qoi
292301
def get_migratable_load(self) -> float:
293302
"""Return migratable load on rank."""
294303
val : float = 0.0
295-
val += sum(o.get_load() for o in self.__migratable_objects)
296-
return val
304+
return val + sum(o.get_load() for o in self.__migratable_objects)
297305

298306
@qoi
299307
def get_sentinel_load(self) -> float:
300308
"""Return sentinel load on rank."""
301309
val : float = 0.0
302-
val += sum(o.get_load() for o in self.__sentinel_objects)
303-
return val
310+
return val + sum(o.get_load() for o in self.__sentinel_objects)
304311

305312
@qoi
306313
def get_received_volume(self) -> float:
@@ -314,7 +321,9 @@ def get_received_volume(self) -> float:
314321
continue
315322

316323
# Add total volume received from non-local objects
317-
volume += sum(v for k, v in o.get_communicator().get_received().items() if k not in obj_set)
324+
volume += sum(
325+
v for k, v in o.get_communicator().get_received().items()
326+
if k not in obj_set)
318327

319328
# Return computed volume
320329
return volume
@@ -359,14 +368,6 @@ def get_max_memory_usage(self) -> float:
359368
"""Return maximum memory usage on rank."""
360369
return self.__size + self.get_shared_memory() + self.get_max_object_level_memory()
361370

362-
@qoi
363-
def get_homing(self) -> float:
364-
"""Return homing cost on rank."""
365-
val : float = 0.0
366-
367-
# To be implemented
368-
return val
369-
370371
def __get_qoi_name(self, qoi_ftn) -> str:
371372
"""Return the QOI name from the given QOI getter function"""
372373
qoi_name = qoi_ftn[4:] if qoi_ftn.startswith("get_") else qoi_ftn

0 commit comments

Comments
 (0)