upc_all_permute
- Date:
05-03-2013
NAME
upc_all_permute - Collectively permutes shared memory
SYNOPSIS
void upc_all_permute( shared void * restrict dst, shared const void * restrict src,
shared const int *perm, size_t nbytes, upc_flag_t flags );
IMPLEMENTATION
Cray Linux Environment (CLE)
DESCRIPTION
The upc_all_permute collective function copies a block of memory from a shared memory area (src) that has affinity to the i-th thread to a block of shared memory (dst) that has affinity to thread perm[i]. The number of bytes in each block is nbytes, where nbytes > 0. perm[0..THREADS-1] must contain THREADS distinct values: 0, 1,…,THREADS-1.
The upc_all_permute function treats the src pointer and the dst pointer as if each pointed to a shared memory area of nbytes bytes on each thread and therefore had type:
shared [nbytes] char[nbytes * THREADS]
The targets of the src, perm, and dst pointers must have affinity to thread 0. The src and dst pointers are treated as if they have phase 0.
The effect is equivalent to copying the block of nbytes bytes that has affinity to thread i pointed to by src to the block of nbytes bytes that has affinity to thread perm[i] pointed to by dst.
Controlling Data Synchronization
The argument flag is of type upc_flag_t and is used to specify the data synchronization semantics for the collective function. The value of flag is formed by or-ing together a constant of the form UPC_IN_XSYNC and a constant of the form UPC_OUT_YSYNC, where X and Y may be NO, MY, or ALL. If X is:
- NO
The function may begin to read or write data when the first thread has entered the collective function call.
- MY
The function may begin to read or write only data which has affinity to threads that have entered the collective function call.
- ALL
The function may begin to read or write data only after all threads have entered the function call.
And if Y is:
- NO
The function may read and write data until the last thread has returned from the collective function call.
- MY
The function call may return in a thread only after all reads and writes of data with affinity to the thread are complete.
- ALL
The function call may return only after all reads and writes of data are complete.
For further information, see upc_flag_t(3c).
EXAMPLES
#include <upc.h>
#include <upc_collective.h>
#define NELEMS 10
shared [NELEMS] int A[NELEMS*THREADS], B[NELEMS*THREADS];
shared int P[THREADS];
// Initialize A and P.
upc_barrier;
upc_all_permute( B, A, P, sizeof(int)*NELEMS,
UPC_IN_NOSYNC | UPC_OUT_NOSYNC );
upc_barrier;
SEE ALSO
intro_pgas(7), upc_all_broadcast(3c), upc_all_exchange(3c), upc_all_gather(3c), upc_all_gather_all(3c), upc_all_reduce(3c), upc_all_scatter(3c), upc_flag_t(3c)