yt-project / libyt

In-situ analysis with yt
https://libyt.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
9 stars 3 forks source link

Check `yt` `save()` Function #38

Open cindytsai opened 2 years ago

cindytsai commented 2 years ago

Check yt Save Function

Description

In inline script, we need save() outside the if yt.is_root() clause, because annotate_cquiver (and other annotations) makes save does data IO. When doing data IO in libyt (using function inside io.py), each MPI rank must call the same method. See:

cindytsai commented 2 years ago

Possible Solution

Is it possible to move save() function inside if yt.is_root() by changing the code in yt.

Check

cindytsai commented 2 years ago

TODO

cindytsai commented 2 years ago

Possible Solutions

Option 1: Every operation should be put outside of is_root and only_on_root.

This is the easiest way, but we will need to give up its performance. We do this by making the write-to-file part in save only works on root rank. Namely, only root rank can write to disk, and the other rank does the redundant operation except libyt dataIO.

Option 2: One can put operation like save inside is_root and only_on_root, but instead of returning None on non-root rank, we make the other rank wait at libyt dataIO.

This is the original method, but it doesn't seem that simple at all. Because there are dataIO separating everywhere in the code, it is nearly impossible to backtrace all the operations that need dataIO, not to mention that we need to let yt know when should it wait at libyt dataIO. And this seems to be save function specific, not a general approach. If we wish to make it more general under these constraints, we need to find a way to make root rank calls an interruption at other rank, so that they know when should they be at libyt dataIO.

Notes and Things Worth Consideration: