Note that there are some explanatory texts on larger screens.

plurals
  1. POAn "atomic" call to cout in MPI
    primarykey
    data
    text
    <p>I am interested in whether there is a command or a technique within OpenMPI to have an atomic call to write to stdout (or, for that matter, any stream).</p> <p>What I have noticed is that during the execution of MPI programs, calls to write to cout (or other streams) can become confusing, as each proc may write whenever it gets to a certain section of code. When reporting results, a line can be written to by several procs, confusing the issue. So 2 different procs might do something like this:</p> <pre><code>//Proc 10 - results calculated somewhere above // result1 = 10 // result2 = 11 cout &lt;&lt; "My results are: " &lt;&lt; result1 &lt;&lt; " " &lt;&lt; resul2 &lt;&lt; endl; </code></pre> <p>and:</p> <pre><code>//Proc 20 - results calculated somewhere above // result1 = 20 // result2 = 21 cout &lt;&lt; "My results are: " &lt;&lt; result1 &lt;&lt; " " &lt;&lt; resul2 &lt;&lt; endl; </code></pre> <p>But the result might be:</p> <pre><code>My results are: 20 My results are: 10 11 21 </code></pre> <p>What I'm looking for is something like a "blocking" or atomic cout (as well as possibly writing to other streams, such as file streams). So once I start writing a to cout, it blocks until the end of the statement, or until endl or a flush to the stream is issued. If this were the case, I'd be guaranteed that the 2 lines would be separate (but, of course, I still wouldn't know which line would come first):</p> <pre><code>My results are: 20 21 My results are: 10 11 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload