127 |
In general a script based on the \escript module does not require modifications when running under \MPI. However, one needs to be careful if other modules are used. |
In general a script based on the \escript module does not require modifications when running under \MPI. However, one needs to be careful if other modules are used. |
128 |
|
|
129 |
When \MPI is used on more than one process ($\var{nn} \cdot \var{np} >1$) the user needs to keep in mind that several copies of his script are executed at the same time |
When \MPI is used on more than one process ($\var{nn} \cdot \var{np} >1$) the user needs to keep in mind that several copies of his script are executed at the same time |
130 |
\footnote{In case of OpenMP only one copy is running but \escript temporarily spawns threads.} while data exchange is performed through the \escript module. At any time, |
\footnote{In case of OpenMP only one copy is running but \escript temporarily spawns threads.} while data exchange is performed through the \escript module. |
131 |
\escript assumes that an argument of the type \var{int}, \var{float}, \var{str} |
|
132 |
and \numpy has an identical value across all processors. All |
This has three main implications: |
133 |
values of these types returned by \escript have the same value on all processors. |
\begin{enumerate} |
134 |
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. |
\item most arguments (\var{Data} excluded) should the same values on all processors. eg \var{int}, \var{float}, \var{str} |
135 |
|
and \numpy parameters. |
136 |
|
\item the same operations will be called on processors. |
137 |
|
\item different processors may store different amounts of information. |
138 |
|
\end{enumerate} |
139 |
|
|
140 |
|
With a few exceptions\footnote{getTupleForDataPoint}, values of types \var{int}, \var{float}, \var{str} |
141 |
|
and \numpy returned by \escript will have the same value on all processors. |
142 |
|
If values produced by other modules are used as arguments, the user has to make sure that the argument values are identical |
143 |
|
on all processors. For instance, the usage of a random number generator to create argument values bears the risk that |
144 |
|
the value may depend on the processor. |
145 |
|
|
146 |
|
Some operations in \escript require communication with all processors executing the job. |
147 |
|
It is not always obvious which operations these are. |
148 |
|
For example, \var{Lsup} returns the largest value on all processors. |
149 |
|
\var{getValue} on \var{Locator} may refer to a value stored on another processor. |
150 |
|
For this reason it is better if scripts do not have conditional operations (which manipulate data) based on which processor the script is on. |
151 |
|
Crashing or hanging scripts can be an indication that this has happened. |
152 |
|
|
153 |
|
It is not always possible to divide data evenly amongst processors. |
154 |
|
In fact some processors might not have any data at all. |
155 |
|
Try to avoid writing scripts which iterate over data points, |
156 |
|
instead try to describe the operation you wish to perform as a whole. |
157 |
|
|
158 |
Special attention is required when using files on more than one processor as |
Special attention is required when using files on more than one processor as |
159 |
several processors access the file at the same time. Opening a file for |
several processors access the file at the same time. Opening a file for |
172 |
f.write('test message') |
f.write('test message') |
173 |
f.close() |
f.close() |
174 |
\end{python} |
\end{python} |
175 |
It is highly recommendable to use this class rather than the built-in \function{open} |
We strongly recommend using this class rather than the built-in \function{open} |
176 |
function as it will guarantee a script which will run in single processor mode as well as under \MPI. |
function as it will guarantee a script which will run in single processor mode as well as under \MPI. |
177 |
|
|
178 |
If there is the situation that one of the processors is throwing an exception, |
If there is the situation that one of the processors is throwing an exception, |
179 |
for instance as opening a file for writing fails, the other processors |
for instance as opening a file for writing fails, the other processors |
180 |
are not automatically made aware of this as \MPI |
are not automatically made aware of this since \MPI |
181 |
is not handling exceptions. However, \MPI will terminate the other processes but |
dioes not handle exceptions. |
182 |
|
However, \MPI will terminate the other processes but |
183 |
may not inform the user of the reason in an obvious way. The user needs to inspect the |
may not inform the user of the reason in an obvious way. The user needs to inspect the |
184 |
error output files to identify the exception. |
error output files to identify the exception. |