Skip to content

Commit

Permalink
Add _barrier to avoid race condition for share mem I/O
Browse files Browse the repository at this point in the history
  • Loading branch information
josephzhang8 committed Dec 12, 2024
1 parent 1c88cac commit afc1638
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Hydro/misc_subs.F90
Original file line number Diff line number Diff line change
Expand Up @@ -823,8 +823,10 @@ subroutine other_hot_init(time)
!First 2 vars are bcast from rank 0 of comm, which must be a member of myrank_node=0?
call mpi_bcast(th_dt3,nthfiles3,rtype,0,comm,istat)
call mpi_bcast(th_time3,2*nthfiles3,rtype,0,comm,istat)
#ifndef SH_MEM_COMM
#ifdef SH_MEM_COMM
!For share mem, ath3 is already filled
call mpi_barrier(comm_node, istat)
#else
call mpi_bcast(ath3,max(1,nsources,nsinks)*ntracers*2*nthfiles3,MPI_REAL4,0,comm,istat)
#endif
endif
Expand Down
4 changes: 3 additions & 1 deletion src/Hydro/schism_step.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1680,10 +1680,12 @@ subroutine schism_step(it)
endif !if_source
endif !time
endif !nsinks

! Finished reading; bcast from rank 0 of comm (which must be a member of myrank_node=0)
call mpi_bcast(th_time3,2*nthfiles3,rtype,0,comm,istat)
#ifdef SH_MEM_COMM
! ath3 data now in shared buffer, no longer necessary to broadcast
! ath3 data in shared buffer, no longer necessary to broadcast
!Sync to ensure the buffer is filled
call mpi_barrier(comm_node, istat)
#else
call mpi_bcast(ath3,max(1,nsources,nsinks)*ntracers*2*nthfiles3,MPI_REAL4,0,comm,istat)
Expand Down
2 changes: 1 addition & 1 deletion src/Readme.beta_notes
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ git versions:
161. `ca44ba0` (1 May 2024): fixed bugs in vegetation&marsh module (uninited sav_h0 etc)
162. `cfb58a5` [5 July 2024] replace fatal errors with warning in btrack (no intersecting edges). These are exaordinary exceptions that occur rarely.
163. `2f88fc5` (7 Aug 2024): changed horizontal diffusion method to filter;
164. `` (Dec 2024): added share memory communicator for efficient bcast
164. `c441ace` (12 Dec 2024): added share memory communicator for efficient bcast;

================================================================================================
(D) Auto-test history:
Expand Down

0 comments on commit afc1638

Please sign in to comment.