From 359f80d9dd66838d7dc418512e1b84e6d9a11a1c Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 16 Oct 2025 14:55:51 -0700 Subject: [PATCH] #615: spec: add new methods to adding communication edges to spec --- src/lbaf/Utils/lbsJSONSpecFileMaker.py | 27 +++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/lbaf/Utils/lbsJSONSpecFileMaker.py b/src/lbaf/Utils/lbsJSONSpecFileMaker.py index 1e6745cd..29ad9d7f 100644 --- a/src/lbaf/Utils/lbsJSONSpecFileMaker.py +++ b/src/lbaf/Utils/lbsJSONSpecFileMaker.py @@ -5,7 +5,8 @@ from lbaf.Execution.lbsPhaseSpecification import ( PhaseSpecification, SharedBlockSpecification, RankSpecification, TaskSpecification, - PhaseSpecificationNormalizer + PhaseSpecificationNormalizer, + CommunicationSpecification ) class JSONSpecFileMaker: @@ -26,6 +27,7 @@ def __init__(self): "shared": 0, "rank": 0, "phase": 0, + "comm": 0, } self.id_sets = { @@ -33,6 +35,7 @@ def __init__(self): "shared": set(), "rank": set(), "phase": set(), + "comm": set(), } @@ -128,6 +131,15 @@ def createSharedBlock(self, self.shared_blocks[shared_id] = shared_block return shared_block + def createComm(self, to_obj : int, from_obj : int, size : float) -> CommunicationSpecification: + new_comm = CommunicationSpecification({ + 'size': size, + 'from': from_obj, + 'to': to_obj + }) + comm_id = self.checkID_(-1, "comm") + self.comms[comm_id] = new_comm + def createRank(self, id: int = -1, tasks: Union[List[int], List[TaskSpecification]] = None, @@ -222,3 +234,16 @@ def write(self, path: str = None): os.makedirs(os.path.dirname(path), exist_ok=True) with open(path, 'w') as output_file: yaml.dump(spec, output_file, default_flow_style=False) + + def makeSpecification(self, phase_id): + self.assertAllTasksHaveBeenAssigned_() + phase = PhaseSpecification({ + "tasks": self.tasks, + "shared_blocks": self.shared_blocks, + "communications": self.comms, + "ranks": self.ranks, + "id": phase_id + }) + norm = PhaseSpecificationNormalizer() + spec = norm.normalize(phase) + return spec