blob: e5e55caef2328164e2a9281247f9ad0fb65299d1 [file] [log] [blame]
<h2>The <code>upc_all_gather</code> function</h2>
<h4>Synopsis</h4>
<pre>
#include &lt;upc.h&gt;
#include &lt;upc_collective.h&gt;
void upc_all_gather(shared void * restrict dst,
shared const void * restrict src,
size_t nbytes,
upc_flag_t flags);
</pre>
<p>
<h4>Description</h4>
<p>
The <code>upc_all_gather </code> function
copies a block of shared memory that has
affinity to the ith thread to the ith block of a shared memory area that has
affinity to a single thread. The number of bytes in each block is <code>nbytes</code>.
<p><code>nbytes</code> must be strictly greater than 0.
<p>The upc all gather function treats the <code>src</code> pointer as if it pointed to a
shared memory area of <code>nbytes</code> bytes on each thread and therefore had type:
<pre>
shared [nbytes] char[nbytes * THREADS]
</pre>
<p>and it treats the <code>dst</code> pointer as if it pointed to a shared memory area with
the type:
<pre>
shared [] char[nbytes * THREADS]
</pre>
<p>The target of the <code>src</code> pointer must have affinity to thread 0.
<p>The <code>src</code> pointer is treated as if it has phase 0.
<p>For each thread i, the effect is equivalent to copying the block of <code>nbytes</code> bytes
pointed to by <code>src</code> that has affinity to thread i to the ith block of <code>nbytes</code>
bytes pointed to by <code>dst</code>.
<p>
<ul>
<li>EXAMPLE 1 <code>upc_all_gather </code> for the static THREADS translation environment.
<pre>
#include &lt;upc.h&gt;
#include &lt;upc_collective.h&gt;
#define NELEMS 10
shared [NELEMS] int A[NELEMS*THREADS];
shared [] int B[NELEMS*THREADS];
// Initialize A.
upc_all_gather( B, A, sizeof(int)*NELEMS,
UPC_IN_ALLSYNC | UPC_OUT_ALLSYNC );
</pre>
<li>EXAMPLE 2 <code>upc_all_gather </code> for the dynamic THREADS translation environment.
<pre>
#include &lt;upc.h&gt;
#include &lt;upc_collective.h&gt;
#define NELEMS 10
shared [NELEMS] int A[NELEMS*THREADS];
shared [] int *B;
B = (shared [] int *) upc_all_alloc(1,NELEMS*THREADS*sizeof(int));
// Initialize A.
upc_barrier;
upc_all_gather( B, A, sizeof(int)*NELEMS,
UPC_IN_NOSYNC | UPC_OUT_NOSYNC );
upc_barrier;
</pre>
<li>
<li>
</ul>
<p>&nbsp
<p>&nbsp
<p><a href="terms.html">Terms, definitions, and symbols</a><br><p><a href="index.html">Back to index of all UPC functions</a>