upc_all_broadcast
functionCopies a block of memory
#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);
The upc_all_broadcast
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 nbytes
.
nbytes
must be strictly greater than 0.
upc_all_broadcast
function treats the src
pointer as if it pointed to a
shared memory area with the type:
shared [] char[nbytes]
The effect is equivalent to copying the entire array pointed to by src
to each
block of nbytes
bytes of a shared array dst
with the type:
shared [nbytes] char[nbytes * THREADS]
The target of the dst
pointer must have affinity to thread 0.
The dst
pointer is treated as if it has phase 0.
#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;
#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 );
(A[3],A[4])
is broadcast to (B[0],B[1]), (B[10],B[11]),
(B[20],B[21]), ..., (B[NELEMS*(THREADS-1)],B[NELEMS*(THREADS-1)+1]).
#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;