The PCU communication interface. More...
Functions | |
int | PCU_Comm_Init (void) |
Initializes the PCU library. | |
int | PCU_Comm_Free (void) |
Frees all PCU library structures. | |
int | PCU_Comm_Self (void) |
Returns the communication rank of the calling thread. | |
int | PCU_Comm_Peers (void) |
Returns the number of threads in the program. | |
void | PCU_Comm_Begin (void) |
Begins a PCU communication phase. | |
int | PCU_Comm_Pack (int to_rank, const void *data, size_t size) |
Packs data to be sent to to_rank. | |
int | PCU_Comm_Send (void) |
Sends all buffers for this communication phase. | |
bool | PCU_Comm_Listen (void) |
Tries to receive a buffer for this communication phase. | |
int | PCU_Comm_Sender (void) |
Returns in * from_rank the sender of the current received buffer. | |
bool | PCU_Comm_Unpacked (void) |
Returns true if the current received buffer has been unpacked. | |
int | PCU_Comm_Unpack (void *data, size_t size) |
Unpacks a block of data from the current received buffer. | |
void | PCU_Barrier (void) |
Blocking barrier over all threads. | |
void | PCU_Add_Doubles (double *p, size_t n) |
Performs an Allreduce sum of double arrays. | |
void | PCU_Min_Doubles (double *p, size_t n) |
Performs an Allreduce minimum of double arrays. | |
void | PCU_Max_Doubles (double *p, size_t n) |
Performs an Allreduce maximum of double arrays. | |
void | PCU_Add_Ints (int *p, size_t n) |
Performs an Allreduce sum of integers. | |
void | PCU_Add_Longs (long *p, size_t n) |
Performs an Allreduce sum of long integers. | |
void | PCU_Exscan_Ints (int *p, size_t n) |
Performs an exclusive prefix sum of integer arrays. | |
void | PCU_Exscan_Longs (long *p, size_t n) |
See PCU_Exscan_Ints. | |
void | PCU_Min_Ints (int *p, size_t n) |
Performs an Allreduce minimum of int arrays. | |
void | PCU_Max_Ints (int *p, size_t n) |
Performs an Allreduce maximum of int arrays. | |
int | PCU_Or (int c) |
Performs a parallel logical OR reduction. | |
int | PCU_Proc_Self (void) |
Returns the unique rank of the calling process. | |
int | PCU_Proc_Peers (void) |
Returns the number of processes. | |
int | PCU_Comm_Rank (int *rank) |
Similar to PCU_Comm_Self, returns the rank as an argument. | |
int | PCU_Comm_Size (int *size) |
Similar to PCU_Comm_Peers, returns the size as an argument. | |
bool | PCU_Comm_Initialized (void) |
Returns true iff PCU has been initialized. | |
int | PCU_Comm_Start (PCU_Method method) |
Deprecated, see PCU_Comm_Begin. | |
int | PCU_Comm_Packed (int to_rank, size_t *size) |
Returns in * size the number of bytes being sent to to_rank. | |
int | PCU_Comm_Write (int to_rank, const void *data, size_t size) |
Packs a message to be sent to to_rank. | |
bool | PCU_Comm_Receive (void) |
Convenience wrapper over Listen and Unpacked. | |
bool | PCU_Comm_Read (int *from_rank, void **data, size_t *size) |
Receives a message for this communication phase. | |
void | PCU_Debug_Open (void) |
Open file debugN.txt, where N = PCU_Comm_Self(). | |
void | PCU_Debug_Print (const char *format,...) |
like fprintf, contents go to debugN.txt | |
int | PCU_Comm_From (int *from_rank) |
Similar to PCU_Comm_Sender, returns the rank as an argument. | |
int | PCU_Comm_Received (size_t *size) |
Returns in * size the bytes in the current received buffer. | |
void * | PCU_Comm_Extract (size_t size) |
Extracts a block of data from the current received buffer. | |
void | PCU_Switch_Comm (MPI_Comm new_comm) |
Reinitializes PCU with a new MPI communicator. | |
MPI_Comm | PCU_Get_Comm (void) |
Return the current MPI communicator. | |
double | PCU_Time (void) |
Return the time in seconds since some time in the past. |
The PCU communication interface.
void PCU_Add_Doubles | ( | double * | p, | |
size_t | n | |||
) |
Performs an Allreduce sum of double arrays.
This function must be called by all ranks at the same time. p must point to an array of n doubles. After this call, p[i] will contain the sum of all p[i]'s given by each rank.
void PCU_Comm_Begin | ( | void | ) |
Begins a PCU communication phase.
This function must be called by all threads in the MPI job at the beginning of each phase of communication. After calling this function, each thread may call functions like PCU_Comm_Pack or PCU_Comm_Write.
void* PCU_Comm_Extract | ( | size_t | size | ) |
Extracts a block of data from the current received buffer.
This function should be called after a successful PCU_Comm_Receive. The next size bytes of the current received buffer are unpacked, and an internal pointer to that data is returned. The returned pointer must not be freed by the user.
int PCU_Comm_Free | ( | void | ) |
Frees all PCU library structures.
This function must be called by all MPI processes after all other calls to PCU, and before calling MPI_Finalize.
int PCU_Comm_Init | ( | void | ) |
Initializes the PCU library.
This function must be called by all MPI processes before calling any other PCU functions. MPI_Init or MPI_Init_thread should be called before this function.
bool PCU_Comm_Listen | ( | void | ) |
Tries to receive a buffer for this communication phase.
Either this function or PCU_Comm_Read should be called at least once by all threads during the communication phase, after PCU_Comm_Send is called. The result will be false if and only if the communication phase is over and there are no more buffers to receive. Otherwise, a buffer was received. Its contents are retrievable through PCU_Comm_Unpack, and its metadata through PCU_Comm_Sender and PCU_Comm_Received. Users should unpack all data from this buffer before calling this function again, because the previously received buffer is destroyed by the call.
int PCU_Comm_Pack | ( | int | to_rank, | |
const void * | data, | |||
size_t | size | |||
) |
Packs data to be sent to to_rank.
This function appends the block of size bytes starting at data to the buffer being sent to to_rank. This function should be called after PCU_Comm_Start and before PCU_Comm_Send.
int PCU_Comm_Packed | ( | int | to_rank, | |
size_t * | size | |||
) |
Returns in * size the number of bytes being sent to to_rank.
Returns the size of the buffer being sent to to_rank. This function should be called after PCU_Comm_Start and before PCU_Comm_Send.
int PCU_Comm_Peers | ( | void | ) |
Returns the number of threads in the program.
when called from a non-threaded MPI process, this function is equivalent to MPI_Comm_size(MPI_COMM_WORLD,size).
bool PCU_Comm_Read | ( | int * | from_rank, | |
void ** | data, | |||
size_t * | size | |||
) |
Receives a message for this communication phase.
This function tries to receive a message packed by PCU_Comm_Write. If a the communication phase is over and there are no more messages to receive, this function returns false. Otherwise, * from_rank will be the rank which sent the message, data will point to the start of the message data, and size will be the number of bytes of message data. If this function is used, PCU_Comm_Receive should not be used. Note that the address * data points into a PCU buffer, so it is strongly recommended that this data be read and not modified.
int PCU_Comm_Received | ( | size_t * | size | ) |
Returns in * size the bytes in the current received buffer.
This function should be called after a successful PCU_Comm_Receive. The size returned will be the total received size regardless of how much unpacking has been done.
int PCU_Comm_Self | ( | void | ) |
Returns the communication rank of the calling thread.
when called from a non-threaded MPI process, this function is equivalent to MPI_Comm_rank(MPI_COMM_WORLD,rank).
Ranks are consecutive from 0 to for a program with processes and threads per process. Ranks are contiguous within a process, so that the threads in process are numbered from to .
int PCU_Comm_Send | ( | void | ) |
Sends all buffers for this communication phase.
This function should be called by all threads in the MPI job after calls to PCU_Comm_Pack or PCU_Comm_Write and before calls to PCU_Comm_Listen or PCU_Comm_Read. All buffers from this thread are sent out and receiving may begin after this call.
int PCU_Comm_Sender | ( | void | ) |
Returns in * from_rank the sender of the current received buffer.
This function should be called after a successful PCU_Comm_Listen.
int PCU_Comm_Unpack | ( | void * | data, | |
size_t | size | |||
) |
Unpacks a block of data from the current received buffer.
This function should be called after a successful PCU_Comm_Listen. data must point to a block of memory of at least size bytes, into which the next size bytes of the current received buffer will be written. Subsequent calls will begin unpacking where this call left off, so that the entire received buffer can be unpacked by a sequence of calls to this function. Users must ensure that there remain size bytes to be unpacked, PCU_Comm_Unpacked can help with this.
bool PCU_Comm_Unpacked | ( | void | ) |
Returns true if the current received buffer has been unpacked.
This function should be called after a successful PCU_Comm_Listen.
int PCU_Comm_Write | ( | int | to_rank, | |
const void * | data, | |||
size_t | size | |||
) |
Packs a message to be sent to to_rank.
This function packs a message into the buffer being sent to to_rank. Messages packed by this function can be received using the function PCU_Comm_Read. This function should be called after PCU_Comm_Start and before PCU_Comm_Send. If this function is used, PCU_Comm_Pack should not be used.
void PCU_Exscan_Ints | ( | int * | p, | |
size_t | n | |||
) |
Performs an exclusive prefix sum of integer arrays.
This function must be called by all ranks at the same time. p must point to an array of n integers. After this call, p[i] will contain the sum of all p[i]'s given by ranks lower than the calling rank.
MPI_Comm PCU_Get_Comm | ( | void | ) |
Return the current MPI communicator.
Returns the communicator given to the most recent PCU_Switch_Comm call, or MPI_COMM_WORLD otherwise.
void PCU_Switch_Comm | ( | MPI_Comm | new_comm | ) |
Reinitializes PCU with a new MPI communicator.
All of PCU's logic is based off two duplicates of this communicator, so you can safely get PCU to act on sub-groups of processes using this function. This call should be collective over all processes in the previous communicator.