Skip to content

Commit

Permalink
simple_handshake: file manipulation only on rank 0
Browse files Browse the repository at this point in the history
Now all manipulation of files used for synchronization with the external program is done only on rank 0. This helps to exclude race conditions (although none were observed so far).
Also added info comment to file header.
  • Loading branch information
ZeugAusHH committed Jun 20, 2024
1 parent ec9eb01 commit 283352c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Util/SimpleHandshake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
* Was implemented to trigger processing of dumped field distribution
* before subsequent loading. Of course, the processing program needs
* to be already running...
*
* Note, C. Lechner, 2024-June:
* To exclude race conditions, all file operations on the files used
* to synchronize with the external program must be carried out
* only from one MPI process. We use rank zero.
*/

#include <fstream>
Expand Down Expand Up @@ -133,9 +138,11 @@ bool SimpleHandshake::doit(map<string,string> *arg, const string prefix)
// Delete any "resume" file that may still be there from a previous
// run before dropping the "wait" file (not handling the error
// that we get if there is no such file)
unlink(path_resume.c_str());
if(0==my_rank_) {
unlink(path_resume.c_str()); // CL: only on rank 0, to exclude any possibility for race condition
}
drop_file(path_wait);
wait_for_file(path_resume);
wait_for_file(path_resume); // !this function must be executed on all nodes to avoid deadlocks!

if(0==my_rank_) {
cout << endl;
Expand Down

0 comments on commit 283352c

Please sign in to comment.