Share memory across MPI nodes to prevent unecessary copying
<p>I have an algorithm where in each iteration each node has to calculate a segment of an array, where each element of <code>x_</code> depends on all the elements of <code>x</code>.</p>

<p><code>x_[i] = some_func(x)  // each x_[i] depends on the entire x</code></p>

<p>That is, each iteration takes <code>x</code> and calculates <code>x_</code>, which will be the new <code>x</code> for the next iteration.</p>

<p>A way of paralelizing this is MPI would be to split <code>x_</code> between the nodes and have an <code>Allgather</code> call after the calculation of <code>x_</code> so that each processor would send its <code>x_</code> to the appropriate location in <code>x</code> in all the other processors, then repeat. This is very inefficient since it requires an expensive <code>Allgather</code> call every iteration, not to mention it requires as many copies of <code>x</code> as there are nodes.</p>

<p>I've thought of an alternative way that doesn't require copying. If the program is running on a single machine, with shared RAM, would it be possible to just share the <code>x_</code> between the nodes (without copying)? That is, after calculating <code>x_</code> each processor would make it visible to the other nodes, which could then use it as their <code>x</code> for the next iteration without needing to make several copies. I can design the algorithm so that no processor accesses the same <code>x_</code> at the same time, which is why making a private copy for each node is overkill.</p>

<p>I guess what I'm asking is: can I share memory in MPI simply by tagging an array as shared-between-nodes, as opposed to manually making a copy for each node? (for simplicity assume I'm running on one CPU)</p>