When MPI is used on more than one process (
) the user needs to keep in mind that several copies of his script are executed at the same time
while data exchange is performed through the esys.escript module. At any time,
esys.escript assumes that an argument of the type int, float, str
and numpy has an identical value across all processors. All
values of these types returned by esys.escript have the same value on all processors.
If values produced by other modules are used as arguments the user has to make sure that the argument values are identical on all processors. For instance, the usage of a random number generator to create argument values bears the risk that the value may depend on the processor.
Special attention is required when using files on more then one processor as several processors access the file at the same time. Open a file for reading is safe, however the user has to make sure that the variables which are set from reading data from files are identical on all processors.
When writing data to a file it is important that only one processor is writing to
the file at any time. As all values in esys.escript are global it is sufficient
to write values on the processor with MPI rank 0 only.
The FileWriter class provides a convenient way to write global data
to a simple file. The following script writes to the file
'test.txt' on the processor with id 0 only:
It is highly recommendable to use this class rather than the build open
function as it will guarantee a script which will run in single processor mode as well as under MPI .
If there is the situation that on one of the processors is throwing an exception, for instance as opening a file for writing fails, the other processors are not automatically made aware of this as MPI is not handling exceptions. However, MPI will terminate the other processes but may not inform the user of the reason in an obvious way. The user needs to inspect the error output files to identify the exception.
esys@esscc.uq.edu.au