Enhance MPI scheduler to start/kill slaves only once and return function results
def start_slaves(mpi_service,logger_lvl="INFO", enable_console=False):
if mpi_service.rank != 0:
mpi_status = MPI.Status()
while 1:
# waiting sending works by master
msg = mpi_service.comm.recv(source=0, tag=MPI.ANY_TAG, status=mpi_status)
if msg is None:
print("Slave killed ({})".format(mpi_service.rank))
return
[task_job, task_param] = msg
print("Received {}{}".format(task_job,task_param))
slave_log = serviceLogger.Log_task(logger_lvl, enable_console)
print("Starting job")
slave_complete_log, start_date, end_date,resp = launchTask(task_job,
task_param,
slave_log,
mpi_service)
mpi_service.comm.send([mpi_service.rank, [start_date, end_date, slave_complete_log,resp]], dest=0, tag=0)
start_slaves(mpi_service,"DEBUG")
if mpi_service.rank == 0:
print("Starting work")
tiles = parse_input_data()
mpi_schedule_job_array(JobArray(create_tile_dir,tiles), mpi_service,"/home/mp/michelj//scratch/logs","DEBUG")
tiles = mpi_schedule_job_array(JobArray(generate_common_masks,tiles), mpi_service,"/home/mp/michelj//scratch/logs","DEBUG")
for tile in tiles:
print("Mask: {}".format(tile.common_mask))
kill_slaves(mpi_service)