Skip to content

Commit 65ff79f

Browse files
committed
Add MPI routine to tell workers when a new iteration starts
This commit adds a new routine to Main_MPI that allows the main task to communicate to workers that a new inversion iteration is starting. It currently is not called anywhere in ModEM. The workers keep track themselves of the iteration number. This routine is intended to provide a space where the main task and all workers can coordinate specific tasks. Specifically, this will allow us the ability to call ModEM_memory_get_all to record all total memory usage across all tasks.
1 parent 225e798 commit 65ff79f

1 file changed

Lines changed: 41 additions & 1 deletion

File tree

f90/MPI/Main_MPI.f90

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,40 @@ Subroutine Master_job_Distribute_userdef_control(ctrl, comm)
14551455

14561456
end Subroutine Master_job_Distribute_userdef_control
14571457

1458+
1459+
subroutine Master_job_send_inv_iteration(iteration_num, comm)
1460+
1461+
implicit none
1462+
1463+
integer, intent(in) :: iteration_num
1464+
integer, intent(in), optional :: comm
1465+
integer :: task, size_current, comm_current
1466+
1467+
if (present(comm)) then
1468+
if (comm .eq. MPI_COMM_NULL) then
1469+
comm_current = comm_world
1470+
else
1471+
comm_current = comm
1472+
endif
1473+
else
1474+
comm_current = comm_world
1475+
end if
1476+
call MPI_COMM_SIZE( comm_current, size_current, ierr )
1477+
1478+
worker_job_task % what_to_do = 'ITER_NUM'
1479+
worker_job_task % per_index = -1
1480+
worker_job_task % pol_index = -1
1481+
call create_worker_job_task_place_holder
1482+
call Pack_worker_job_task
1483+
1484+
do task = 1, size_current - 1
1485+
call MPI_SEND(worker_job_package, Nbytes, MPI_PACKED, task, FROM_MASTER, comm_current, ierr)
1486+
end do
1487+
1488+
write(0,*) "New Iteration: ", iteration_number
1489+
1490+
end subroutine Master_job_send_inv_iteration
1491+
14581492
!######################### Master_job_Clean Memory ##########################
14591493
Subroutine Master_job_Clean_Memory(comm)
14601494

@@ -1827,7 +1861,7 @@ Subroutine Worker_job(sigma,d)
18271861

18281862
Integer :: iper,ipol,i,des_index
18291863
Integer :: per_index,per_index_pre
1830-
Integer :: pol_index, stn_index
1864+
Integer :: pol_index, stn_index, iteration_number
18311865
Integer :: eAll_vec_size
18321866
Integer :: comm_current, rank_current
18331867
Integer :: cpu_only_ranks
@@ -1854,6 +1888,7 @@ Subroutine Worker_job(sigma,d)
18541888

18551889
nTx=d%nTx
18561890
recv_loop=0
1891+
iteration_number = 0
18571892
previous_message=''
18581893
write(node_info,'(a5,i3.3,a4)') 'node[',taskid,']: '
18591894

@@ -2565,6 +2600,11 @@ Subroutine Worker_job(sigma,d)
25652600
if (associated(group_sizes)) then
25662601
deallocate(group_sizes)
25672602
endif
2603+
elseif (trim(worker_job_task%what_to_do) .eq. 'ITER_NUM' ) then
2604+
2605+
iteration_number = iteration_number + 1
2606+
write(0,*) "New Iteration: ", iteration_number
2607+
25682608
elseif (trim(worker_job_task%what_to_do) .eq. 'STOP' ) then
25692609
! clear all the temp packages and stop
25702610
if (associated(sigma_para_vec)) then

0 commit comments

Comments
 (0)