Skip to content

Commit

Permalink
1. Adding a flag to track whether any process was parallelized
Browse files Browse the repository at this point in the history
2. Track execution time for each process
3. Modify Schedule.run() to generate feedback messages based on the flag and execution time status.
  • Loading branch information
GawyWOOOHOOO committed Dec 5, 2024
1 parent 00a5017 commit a1ab0b0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions compiler/pash_compilation_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def __init__(self):

## A map that keeps mappings between proc_id and (input_ir, width, exec_time)
self.process_id_input_ir_map = {}
self.parallelized_flag = False
## This is a map from input IRs, i.e., locations in the code, to a list of process_ids
self.input_ir_to_process_id_map = {}

Expand Down Expand Up @@ -354,6 +355,7 @@ def compile_and_add(self, compiled_script_file, var_file, input_ir_file):
else:
self.running_procs += 1


## Get the time before we start executing (roughly) to determine how much time this command execution will take
command_exec_start_time = datetime.now()
self.process_id_input_ir_map[process_id].set_start_exec_time(
Expand Down Expand Up @@ -420,6 +422,8 @@ def handle_exit(self, input_cmd):
exec_time = (command_finish_exec_time - command_start_exec_time) / timedelta(
milliseconds=1
)
command_start_exec_time = self.process_id_input_ir_map[process_id].get_start_exec_time()
exec_time = (command_finish_exec_time - command_start_exec_time) / timedelta(milliseconds=1)
log("Process:", process_id, "exited. Exec time was:", exec_time)
self.handle_time_measurement(process_id, exec_time)
self.remove_process(process_id)
Expand Down Expand Up @@ -509,6 +513,16 @@ def run(self):
self.parse_and_run_cmd(input_cmd)

self.connection_manager.close()
if not self.parallelized_flag:
log("No parts of the input script were parallelized. Ensure commands are annotated for parallelization.")
elif all(
proc_info.exec_time is not None and proc_info.exec_time < 1
for proc_info in self.process_id_input_ir_map.values()
):
log("Some script fragments were parallelized, but their execution times were negligible.")
log("Consider optimizing your script to include longer-running tasks.")
else:
log("Parallelization completed successfully.")
shutdown()


Expand Down

0 comments on commit a1ab0b0

Please sign in to comment.