svenreiche / Genesis-1.3-Version4

Time-dependent, 3D Code to simulate the amplification process of a Free-electron Laser.
GNU General Public License v3.0
53 stars 26 forks source link

syncing/handshaking with external programs #140

Closed ZeugAusHH closed 7 months ago

ZeugAusHH commented 7 months ago

Arriving at the newly introduced command block &simple_handshake (in the moment it has no parameters), the file g4_hs.wait is generated and the simulation process waits. Once the file g4_hs.resume appears in the working directory of the simulation run, the simulation resumes.

Currently this function is useful mainly for testing and debugging. Provided the capability to replace already existing fields is added to GENESIS (it appears that only a few modifications and checks have to be added to field loading code), this could for instance be used to propagate the dumped light field through a complex optical system with external software and then continue the GENESIS simulation with the result of the propagation process.

While in the moment the wait is done with MPI_Barrier, resulting in busy waiting (all cores at 100% CPU utilization when executed with OpenMPI), this behavior could be changed in the future.

svenreiche commented 7 months ago

Really nice addition. I would change that each core has the loop with 1 second sleep and then do a MPI-Broadcast from the root node to either wait another second or continue the execution.

ZeugAusHH commented 7 months ago

I have a code block that does that somewhere in my files. When I find it, I'll file another pull request to replace the busy waiting.

If I remember correctly, I think I used MPI_Isend/MPI_Irecv or so and periodic calls to MPI_Test (with sleeps between).