| <h2>The <code>upc_all_broadcast</code> function</h2> |
| <h4>Purpose</h4> |
| <p>Copies a block of memory |
| <h4>Synopsis</h4> |
| <pre> |
| #include <upc.h> |
| #include <upc_collective.h> |
| void upc_all_broadcast(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_broadcast </code> function |
| copies a block of memory with affinity to |
| a single thread to a block of shared memory on each thread. The number of |
| bytes in each block is <code>nbytes</code>. |
| <p><code>nbytes</code> must be strictly greater than 0. |
| <p><code>upc_all_broadcast </code> function treats the <code>src</code> pointer as if it pointed to a |
| shared memory area with the type: |
| <pre> |
| shared [] char[nbytes] |
| </pre> |
| <p>The effect is equivalent to copying the entire array pointed to by <code>src</code> to each |
| block of <code>nbytes</code> bytes of a shared array <code>dst</code> with the type: |
| <pre> |
| shared [nbytes] char[nbytes * THREADS] |
| </pre> |
| <p>The target of the <code>dst</code> pointer must have affinity to thread 0. |
| <p>The <code>dst</code> pointer is treated as if it has phase 0. |
| |
| <ul> |
| <li>EXAMPLE 1 shows upc_all_broadcast |
| |
| <pre> |
| #include <upc.h> |
| #include <upc_collective.h> |
| shared int A[THREADS]; |
| shared int B[THREADS]; |
| // Initialize A. |
| upc_barrier; |
| upc_all_broadcast( B, &A[1], sizeof(int), |
| UPC_IN_NOSYNC | UPC_OUT_NOSYNC ); |
| upc_barrier; |
| </pre> |
| |
| <li>EXAMPLE 2: |
| |
| <pre> |
| #include <upc.h> |
| #include <upc_collective.h> |
| #define NELEMS 10 |
| shared [] int A[NELEMS]; |
| shared [NELEMS] int B[NELEMS*THREADS]; |
| // Initialize A. |
| upc_all_broadcast( B, A, sizeof(int)*NELEMS, |
| UPC_IN_ALLSYNC | UPC_OUT_ALLSYNC ); |
| </pre> |
| <li>EXAMPLE 3 shows <code>(A[3],A[4])</code> is broadcast to <code>(B[0],B[1]), (B[10],B[11]), |
| (B[20],B[21]), ..., (B[NELEMS*(THREADS-1)],B[NELEMS*(THREADS-1)+1]).</code> |
| |
| <pre> |
| #include <upc.h> |
| #include <upc_collective.h> |
| #define NELEMS 10 |
| shared [NELEMS] int A[NELEMS*THREADS]; |
| shared [NELEMS] int B[NELEMS*THREADS]; |
| // Initialize A. |
| upc_barrier; |
| upc_all_broadcast( B, &A[3], sizeof(int)*2, |
| UPC_IN_NOSYNC | UPC_OUT_NOSYNC ); |
| upc_barrier; |
| </pre> |
| </ul> |
| <p>  |
| <p>  |
| <p><a href="terms.html">Terms, definitions, and symbols</a><br> |
| <p><a href="index.html">Back to index of all UPC functions</a> |