55from lbaf .Execution .lbsPhaseSpecification import (
66 PhaseSpecification , SharedBlockSpecification ,
77 RankSpecification , TaskSpecification ,
8- PhaseSpecificationNormalizer
8+ PhaseSpecificationNormalizer ,
9+ CommunicationSpecification
910)
1011
1112class JSONSpecFileMaker :
@@ -26,13 +27,15 @@ def __init__(self):
2627 "shared" : 0 ,
2728 "rank" : 0 ,
2829 "phase" : 0 ,
30+ "comm" : 0 ,
2931 }
3032
3133 self .id_sets = {
3234 "seq" : set (),
3335 "shared" : set (),
3436 "rank" : set (),
3537 "phase" : set (),
38+ "comm" : set (),
3639 }
3740
3841
@@ -128,6 +131,15 @@ def createSharedBlock(self,
128131 self .shared_blocks [shared_id ] = shared_block
129132 return shared_block
130133
134+ def createComm (self , to_obj : int , from_obj : int , size : float ) -> CommunicationSpecification :
135+ new_comm = CommunicationSpecification ({
136+ 'size' : size ,
137+ 'from' : from_obj ,
138+ 'to' : to_obj
139+ })
140+ comm_id = self .checkID_ (- 1 , "comm" )
141+ self .comms [comm_id ] = new_comm
142+
131143 def createRank (self ,
132144 id : int = - 1 ,
133145 tasks : Union [List [int ], List [TaskSpecification ]] = None ,
@@ -222,3 +234,16 @@ def write(self, path: str = None):
222234 os .makedirs (os .path .dirname (path ), exist_ok = True )
223235 with open (path , 'w' ) as output_file :
224236 yaml .dump (spec , output_file , default_flow_style = False )
237+
238+ def makeSpecification (self , phase_id ):
239+ self .assertAllTasksHaveBeenAssigned_ ()
240+ phase = PhaseSpecification ({
241+ "tasks" : self .tasks ,
242+ "shared_blocks" : self .shared_blocks ,
243+ "communications" : self .comms ,
244+ "ranks" : self .ranks ,
245+ "id" : phase_id
246+ })
247+ norm = PhaseSpecificationNormalizer ()
248+ spec = norm .normalize (phase )
249+ return spec
0 commit comments