@@ -39,19 +39,17 @@ def __init__(self,
3939 self .stress_path = stress_path
4040 self .categories_list = []
4141 self .categories_input = {}
42- self .parsed_tasks = []
42+ self .parsed_tasks = set ()
4343 self .files_map = {}
4444 self .tasks_map = {}
4545 self .cmd_counter = 1
46- self .out_files = []
46+ self .out_files = set ()
4747
4848 # find applications
49- self .apps = []
49+ self .apps = set ()
5050 for task in self .tasks .values ():
5151 self .tasks_map [task .task_id ] = task .name
52-
53- if task .name not in self .apps :
54- self .apps .append (task .name )
52+ self .apps .add (task .name )
5553
5654 out_count = 0
5755 for file in task .output_files :
@@ -137,7 +135,7 @@ def _find_categories_list(self, task_name: str, parent_task: Optional[str] = Non
137135 if parent_task .name not in self .categories_list :
138136 return
139137
140- self .parsed_tasks .append (task_name )
138+ self .parsed_tasks .add (task_name )
141139 category = self .tasks_map [task_name ]
142140 if category not in self .categories_list :
143141 self .categories_list .append (category )
@@ -156,16 +154,16 @@ def _add_tasks(self, category: str) -> None:
156154 :type category: str
157155 """
158156 num_tasks = 0
157+ num_children = 0
159158 input_files_cat = {}
160- parsed_input_files = []
159+ parsed_input_files = set ()
161160 self .script += f"int { category } __out[];\n "
162161
163- for task_name in self .tasks :
164- task = self .tasks [task_name ]
165-
162+ for task in self .tasks .values ():
166163 if task .name == category :
167164 # in/output files
168- input_files = []
165+ num_children = len (self .task_children [task .task_id ])
166+ input_files = set ()
169167 prefix = ""
170168
171169 for file in task .output_files :
@@ -176,8 +174,8 @@ def _add_tasks(self, category: str) -> None:
176174 if file .file_id not in parsed_input_files :
177175 input_files_cat .setdefault (cat_prefix , 0 )
178176 input_files_cat [cat_prefix ] += 1
179- parsed_input_files .append (file .file_id )
180- input_files .append (self .files_map [file .file_id ])
177+ parsed_input_files .add (file .file_id )
178+ input_files .add (self .files_map [file .file_id ])
181179 if not prefix :
182180 prefix = cat_prefix
183181
@@ -224,11 +222,13 @@ def _add_tasks(self, category: str) -> None:
224222 f" string of_{ self .cmd_counter } = sprintf(\" 0%s\" , co_{ self .cmd_counter } );\n " \
225223 f" { category } __out[i] = string2int(of_{ self .cmd_counter } );\n " \
226224 "}\n \n "
227- for i in range (num_tasks ):
228- self .out_files .append (f"{ self .output_folder .absolute ()} /data/{ category } _{ i } _output.txt" )
225+ if not num_children :
226+ for i in range (num_tasks ):
227+ self .out_files .add (f"{ self .output_folder .absolute ()} /data/{ category } _{ i } _output.txt" )
229228 else :
230229 out_file = f"{ self .output_folder .absolute ()} /data/{ category } _0_output.txt"
231- self .out_files .append (out_file )
230+ if not num_children :
231+ self .out_files .add (out_file )
232232 args = args .replace (
233233 ", of" , f", \" { out_file } \" " ).replace ("[i]" , "[0]" )
234234 self .script += f"string cmd_{ self .cmd_counter } = sprintf(command, \" { self .cpu_benchmark } \" , \" { category } \" , { args } );\n " \
0 commit comments