Extended Collective Operation
Introduction
MPI-1
¿¡¼´Â intrecommnunicator¸¦ À§ÇÑ collective communication°ú µÎ °¡Áö routineÁï
, »õ·Î¿î intracommunicator¸¦ »ý¼ºÇϱâ À§Çؼ MPI_INTERCOMM_CREATE¿Í MPI_COMM_DUP¸¦Á¦°øÇϰí
ÀÖ´Ù. ±×¸®°í Fortran°úÀÇ aliasing ¹®Á¦¸¦ ÇÇÇϱâ À§Çؼ collective operationÀ» À§ÇÑsend
¿Í receive buffer¸¦ °¢°¢ À¯ÁöÇÏ´Â °ÍÀÌ ÇÊ¿äÇß´Ù.MPI-2
¿¡¼´Â ÀÌ·¯ÇÑ intracommunicator¿¡ ´ëÇÑ collective routine°ú intercommunicator¸¦ »ý¼ºÇϱâ À§ÇÑroutine
±×¸®°í generalized all-to-all°ú exclusive scanÀ̶ó´Â routineÀ» È®ÀåÇß´Ù. ¸¹Àº intracommunicatorcollective routine
¿¡ ´ëÇÑ ÀûÀýÇÑ ¹öÆÛ¸¦ Á¤ÀÇÇÏ´Â ¹æ¹ýÀ» Á¦°øÇϰí ÀÖ´Ù.Intercommunicator Constructors
ÇöÀç
MPI interface¿¡´Â ´ÜÁö intercommunicator construction routine À» Á¦°øÇϰí ÀÖ´Ù.MPI_COMM_CREATE
¿Í MPI_COMM_SPLIT´Â ÇöÀç intracommunicator¿¡¸¸ Àû¿ëµÈ´Ù.¡¡
MPI_COMM_CREATE(comm_in, group, comm_out)
[ IN comm_in] original communicator (handle)
[ IN group] group of processes to be in new communicator (handle)
[ OUT comm_out] new communicator (handle)
¡¡

Group argument
´Â comm_outÀÌ µÉ input intercommunicatorÀÇ local groupÀÇ processµé¸¸À» Æ÷ÇÔÇϰí ÀÖ¾î¾ß ÇÑ´Ù.¸¸ÀÏ
¾î¶² group ÀÌ intercommunicatorÀÇ local group ¿¡¼ Àû¾îµµ ÇϳªÀÇ process¸¦ Æ÷ÇÔÇϰí ÀÖÁö ¾Ê´Ù¸é ¶Ç´Âgroup
¿¡¼ calling process°¡ Æ÷ÇԵǾî ÀÖÁö ¾Ê´Ù¸é MPI_COMM_NULLÀ» ¸®ÅÏÇÑ´Ù.¡¡
MPI_Comm inter_comm, new_inter_comm;
MPI_Group local_group, group;
int rank = 0; /* rank on left side to include in
new inter-comm */
/* Construct the original intercommunicator: "inter_comm" */
...
/* Construct the group of processes to be in new
intercommunicator */
if (/* I'm on the left side of the intercommunicator */) {
MPI_Comm_group ( inter_comm, &local_group );
MPI_Group_incl ( local_group, 1, &rank, &group );
MPI_Group_free ( &local_group );
}
else
MPI_Comm_group ( inter_comm, &group );
MPI_Comm_create ( inter_comm, group, &new_inter_comm );
MPI_Group_free( &group );
MPI_COMM_SPLIT(comm_in, color, key, comm_out)
[ IN comm_in] original communicator (handle)
[ IN color] control of subset assignment (integer)
[ IN key] control of rank assignment (integer)
[ OUT comm_out] new communicator (handle)
Intercommunicator
¿¡¼ MPI_COMM_SPLITÀÇ °á°ú´Â °°Àº colorÀÇ processµé·Î »õ·Î¿î intercommunicator ¸¦ ¸¸µå´Â °ÍÀÌ´Ù.Key value
´Â °¢°¢ÀÇ »ó´ë rank¸¦ ³ªÅ¸³½´Ù. ¸¸ÀÏ colorÀÌ ÇÑÂÊ¿¡ Á¤ÀǵǾî ÀÖÁö ¾Ê´Ù¸é MPI_COMM_NULLÀÌ ¸®Åϵǰí color°¡MPI_UNDEFINED·Î Á¤ÀÇµÈ process¿¡µµ MPI_COMM_NULLÀÌ ¸®ÅϵȴÙ.
¡¡
¡¡

/* Client code */
MPI_Comm multiple_server_comm;
MPI_Comm single_server_comm;
int color, rank, num_servers;
/* Create intercommunicator with clients and servers:
multiple_server_comm */
...
/* Find out the number of servers available */
MPI_Comm_remote_size ( multiple_server_comm, &num_servers );
/* Determine my color */
MPI_Comm_rank ( multiple_server_comm, &rank );
color = rank % num_servers;
/* Split the intercommunicator */
MPI_Comm_split ( multiple_server_comm, color, rank,
&single_server_comm );
The following is the corresponding server code:
/* Server code */
MPI_Comm multiple_client_comm;
MPI_Comm single_server_comm;
int rank;
/* Create intercommunicator with clients and servers:
multiple_client_comm */
...
/* Split the intercommunicator for a single server per group
of clients */
MPI_Comm_rank ( multiple_client_comm, &rank );
MPI_Comm_split ( multiple_client_comm, rank, 0,
&single_server_comm );
Extended Collective Operations
±âÁ¸ÀÇ
MPI-1¿¡¼ÀÇ collective operationÀº ´ÜÁö intracommunicator¿¡¸¸ Àû¿ëÀÌ µÇ¾úÁö¸¸ À̰ÍÀº intercommunicator·Î ±×´ë·Î È®ÀåÀÌ µÉ ¼ö°¡ ÀÖ´Ù.All-To-All :
¸ðµç process°¡ °á°ú¿¡ Âü°¡¸¦ ÇÏ°í ±× °á°ú¸¦ ¹Þ°Ô µÈ´Ù.All-To-One :
¸ðµç process°¡ °á°ú¿¡ Âü°¡¸¦ ÇÏÁö¸¸ ÇÑ process¸¸ ±× °á°ú¸¦ ¹Þ´Â´Ù.One-To-All :
ÇÑ process¸¸ °á°ú¿¡ Âü°¡¸¦ ÇÏ°í ¸ðµç process°¡ ±× °á°ú¸¦ ¹Þ´Â´Ù.Other :
À§ÀÇ °æ¿ì¿¡ ÇØ´çÇÏÁö ¾Ê´Â Collective operationExample
All-to-all :
ÇÑgroupÀÇ ¸ðµç ¸â¹ö·ÎºÎÅÍ µ¥ÀÌÅ͸¦ ¸ð¾Æ¼ ´Ù¸¥ groupÀÇ ¸â¹ö¿¡¼ °á°ú°¡ ³ªÅ¸³´Ù
.
One-to-all :
¾î¶² groupÀÇ ÇÑ ¸â¹ö·ÎºÎÅÍ µ¥ÀÌÅ͸¦ ¹Þ¾Æ¼ ´Ù¸¥ groupÀÇ ¸ðµç ¸â¹ö¿¡°Ô º¸³½´Ù
. À̰ÍÀº MPI_REDUCE_SCATTER°ú °°´Ù.
¡¡
Operations that Move Data
¸¹Àº
collective communication call¿¡ µÎ °¡Áö Ãß°¡µÈ °ÍÀÌ ÀÖ´Ù.
¡¡
Broadcast
MPI_BCAST(buffer, count, datatype, root, comm)
[ INOUT buffer] starting address of buffer (choice)
[ IN count] number of entries in buffer (integer)
[ IN datatype] data type of buffer (handle)
[ IN root] rank of broadcast root (integer)
[ IN comm] communicator (handle)
comm
ÀÌ intercommunicator¶ó¸é intercommunicatorÀÇ ¸ðµç process°¡ µÇ°í ¸¸ÀÏ group¶ó¸é root process°¡ µÈ´Ù.Root
´Â root¿¡ MPI_ROOT¸¦ ´Ù¸¥ °ÍÀº MPI_PROC_NULLÀ» passÇÑ´Ù.¡¡
Gather
MPI_GATHER(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm)
[ IN sendbuf] starting address of send buffer (choice)
[ IN sendcount] number of elements in send buffer (integer)
[ IN sendtype] data type of send buffer elements (handle)
[ OUT recvbuf] address of receive buffer (choice, significant only at root)
[ IN recvcount] number of elements for any single receive (integer, significant only at root)
[ IN recvtype] data type of recv buffer elements (handle, significant only at root)
[ IN root] rank of receiving process (integer)
[ IN comm] communicator (handle)
¡¡
MPI_GATHERV(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, root, comm)
[ IN sendbuf] starting address of send buffer (choice)
[ IN sendcount] number of elements in send buffer (integer)
[ IN sendtype] data type of send buffer elements (handle)
[ OUT recvbuf] address of receive buffer (choice, significant only at root)
[ IN recvcounts] integer array (of length group size) containing the number of elements that are received from each process (significant only at root)
[ IN displs] integer array (of length group size). Entry i specifies the displacement relative to recvbuf at which to place the incoming data from process i (significant only at root)
[ IN recvtype] data type of recv buffer elements (handle, significant only at root)
[ IN root] rank of receiving process (integer)
[ IN comm] communicator (handle)
¡¡
Scatter
MPI_SCATTER(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm)
[ IN sendbuf] address of send buffer (choice, significant only at root)
[ IN sendcount] number of elements sent to each process (integer, significant only at root)
[ IN sendtype] data type of send buffer elements (handle, significant only at root)
[ OUT recvbuf] address of receive buffer (choice)
[ IN recvcount] number of elements in receive buffer (integer)
[ IN recvtype] data type of receive buffer elements (handle)
[ IN root] rank of sending process (integer)
[ IN comm] communicator (handle)
¡¡
MPI_SCATTERV(sendbuf, sendcounts, displs, sendtype, recvbuf, recvcount, recvtype, root, comm)
[ IN sendbuf] address of send buffer (choice, significant only at root)
[ IN sendcounts] integer array (of length group size) specifying the number of elements to send to each processor
[ IN displs] integer array (of length group size). Entry i specifies the displacement (relative to sendbuf from which to take the outgoing data to process i
[ IN sendtype] data type of send buffer elements (handle)
[ OUT recvbuf] address of receive buffer (choice)
[ IN recvcount] number of elements in receive buffer (integer)
[ IN recvtype] data type of receive buffer elements (handle)
[ IN root] rank of sending process (integer)
[ IN comm] communicator (handle)
¡¡
All form and All-to-all
MPI_ALLGATHER(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm)
[ IN sendbuf] starting address of send buffer (choice)
[ IN sendcount] number of elements in send buffer (integer)
[ IN sendtype] data type of send buffer elements (handle)
[ OUT recvbuf] address of receive buffer (choice)
[ IN recvcount] number of elements received from any process (integer)
[ IN recvtype] data type of receive buffer elements (handle)
[ IN comm] communicator (handle)
¡¡
MPI_ALLGATHERV(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, comm)
[ IN sendbuf] starting address of send buffer (choice)
[ IN sendcount] number of elements in send buffer (integer)
[ IN sendtype] data type of send buffer elements (handle)
[ OUT recvbuf] address of receive buffer (choice)
[ IN recvcounts] integer array (of length group size) containing the number of elements that are received from each process
[ IN displs] integer array (of length group size). Entry i specifies the displacement (relative to recvbuf) at which to place the incoming data from process i
[ IN recvtype] data type of receive buffer elements (handle)
[ IN comm] communicator (handle)
¡¡
MPI_ALLTOALL(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm)
[ IN sendbuf] starting address of send buffer (choice)
[ IN sendcount] number of elements sent to each process (integer)
[ IN sendtype] data type of send buffer elements (handle)
[ OUT recvbuf] address of receive buffer (choice)
[ IN recvcount] number of elements received from any process (integer)
[ IN recvtype] data type of receive buffer elements (handle)
[ IN comm] communicator (handle)
¡¡
MPI_ALLTOALLV(sendbuf, sendcounts, sdispls, sendtype, recvbuf, recvcounts, rdispls, recvtype, comm)
[ IN sendbuf] starting address of send buffer (choice)
[ IN sendcounts] integer array equal to the group size specifying the number of elements to send to each processor
[ IN sdispls] integer array (of length group size). Entry j specifies the displacement (relative to sendbuf) from which to take the outgoing data destined for process j
[ IN sendtype] data type of send buffer elements (handle)
[ OUT recvbuf] address of receive buffer (choice)
[ IN recvcounts] integer array equal to the group size specifying the number of elements that can be received from each processor
[ IN rdispls] integer array (of length group size). Entry i specifies the displacement (relative to recvbuf) at which to place the incoming data from process i
[ IN recvtype] data type of receive buffer elements (handle)
[ IN comm] communicator (handle)
¡¡
Reductions
MPI_REDUCE(sendbuf, recvbuf, count, datatype, op, root, comm)
[ IN sendbuf] address of send buffer (choice)
[ OUT recvbuf] address of receive buffer (choice, significant only at root)
[ IN count] number of elements in send buffer (integer)
[ IN datatype] data type of elements of send buffer (handle)
[ IN op] reduce operation (handle)
[ IN root] rank of root process (integer)
[ IN comm] communicator (handle)
¡¡
MPI_ALLREDUCE(sendbuf, recvbuf, count, datatype, op, comm)
[ IN sendbuf] starting address of send buffer (choice)
[ OUT recvbuf] starting address of receive buffer (choice)
[ IN count] number of elements in send buffer (integer)
[ IN datatype] data type of elements of send buffer (handle)
[ IN op] operation (handle)
[ IN comm] communicator (handle)
¡¡
MPI_REDUCE_SCATTER(sendbuf, recvbuf, recvcounts, datatype, op, comm)
[ IN sendbuf] starting address of send buffer (choice)
[ OUT recvbuf] starting address of receive buffer (choice)
[ IN recvcounts] integer array specifying the number of elements in result distributed to each process. Array must be identical on all calling processes.
[ IN datatype] data type of elements of input buffer (handle)
[ IN op] operation (handle)
[ IN comm] communicator (handle)
¡¡
Other operations
MPI_BARRIER(comm)
[ IN comm] communicator (handle)
¡¡
MPI_SCAN(sendbuf, recvbuf, count, datatype, op, comm)
[ IN sendbuf] starting address of send buffer (choice)
[ OUT recvbuf] starting address of receive buffer (choice)
[ IN count] number of elements in input buffer (integer)
[ IN datatype] data type of elements of input buffer (handle)
[ IN op] operation (handle)
[ IN comm] communicator (handle)
¡¡
Generalized All-to-all Function
MPI_ALLTOALLW(sendbuf, sendcounts, sdispls, sendtypes, recvbuf, recvcounts, rdispls, recvtypes, comm)
[ IN sendbuf] starting address of send buffer (choice)
[ IN sendcounts] integer array equal to the group size specifying the number of elements to send to each processor (integer)
[ IN sdispls] integer array (of length group size). Entry j specifies the displacement in bytes (relative to sendbuf) from which to take the outgoing data destined for process j
[ IN sendtypes] array of datatypes (of length group size). Entry j specifies the type of data to send to process j (handle)
[ OUT recvbuf] address of receive buffer (choice)
[ IN recvcounts] integer array equal to the group size specifying the number of elements that can be received from each processor (integer)
[ IN rdispls] integer array (of length group size). Entry i specifies the displacement in bytes (relative to recvbuf) at which to place the incoming data from process i
[ IN recvtypes] array of datatypes (of length group size). Entry i specifies the type of data received from process i (handle)
[ IN comm] communicator (handle)
¡¡
Extensive Scan
MPI_EXSCAN(sendbuf, recvbuf, count, datatype, op, comm)
[ IN sendbuf] starting address of send buffer (choice)
[ OUT recvbuf] starting address of receive buffer (choice)
[ IN count] number of elements in input buffer (integer)
[ IN datatype] data type of elements of input buffer (handle)
[ IN op] operation (handle)
[ IN comm] intracommunicator (handle)