## shmem_broadcast

#### Purpose

Broadcasts a block of data from one processing element (PE) to one or more target PEs.

#### C syntax

    #include <shmem.h>

    void shmem_broadcast(void *target, const void *source, size_t nlong, int PE_root, int PE_start, int logPE_stride, int PE_size, long *pSync);

#### Parameters

INPUT
target
  A symmetric data object used to receive the data broadcasted by the processing element specified by PE_start. For shmem_broadcast and shmem_broadcast64 the data type of target can be any type that has an element size of 64 bits.
source
  A symmetric data object that can be of any data type that is permissible for the target argument.
nlong
  The number of elements in source. For shmem_broadcast and shmem_broadcast64, this is the number of 64-bit words. For shmem_broadcast32 this is the number of 32-bit halfwords.
PE_root
  Zero-based ordinal of the PE, with respect to the active set, from which the data is copied. Must be greater than or equal to 0 and less than PE_size.
PE_start
  The lowest virtual PE number of the active set of PEs.
logPE_stride
  The log (base 2) of the stride between consecutive virtual PE numbers in the active set.
PE_size
  The number of PEs in the active set.
pSync
  A symmetric work array. In C/C++, pSync must be of type long and size _SHMEM_REDUCE_SYNC_SIZE. Every element of this array must be initialized with the value _SHMEM_SYNC_VALUE before any of the PEs in the active set enter the reduction routine

#### Description

The shmem_broadcast routine is a collective routine. They copy data object source on the processor specified by PE_root and store the values at target on the other PEs specified by the triplet PE_start, logPE_stride, PE_size. The data is not copied to the target area on the root PE. The values of arguments PE_root, PE_start, logPE_stride, and PE_size must be equal on all PEs in the active set. The same target and source data objects and the same pSync work array must be passed to all PEs in the active set.

Before any PE calls the broadcast functions, users have to ensure the following conditions exist:

The pSync arrays on all PEs in the active set is not still in use from a prior call to a broadcast function.

The target array on all PEs in the active set is ready to accept the broadcast data.

Upon returning from the broadcast function, the following conditions are true:

If the current PE is not the root PE, the target data array is updated.

The values in the pSync array are restored to the original values.

Each of these functions assumes that only PEs in the active set call the function. If a PE not in the active set calls the collective function, the behavior is undefined. On all PEs in the active set, the values of nlong, PE_root, PE_start, logPE_stride, and PE_size must be equal. And the same source, target, and pSync objects must be used on all PEs in the active set.

#### C examples

#### Related information

Subroutines: shmem_barrier, shmem_barrier_all

OpenSHMEM API Index