ccm_alltoallv

CCM alltoall with variable amounts of data.

Routine:

ccm_alltoallv

Purpose:

Send different amounts of data from each task to all other tasks in a parallel application. Xout is overwritten on all tasks.

Minimal calling sequence:

call ccm_alltoallv(xin,xout,to_send,to_get)

Required Arguments:

xin :: integer, real, double precision, complex, logical, character array,intent (in)
The values in xin will be copied from every task to every other task in the parallel application.
xout :: integer, real, double precision, complex, logical, character scaler or array,intent (out)
The values distributed from each task will be placed in xout.
to_send :: integer, rank one array of size equal to the number of tasks in the parallel appliation,intent (in)
The number of values sent from a given task from each other task.
to_get :: integer, rank one array of size equal to the number of tasks in the parallel application,intent (in)
The number of values received by a given task from each other task.

Call with all Optional Arguments:

call ccm_alltoallv(xin,xout,to_send,to_get,send_off,get_off,the_err)
send_off :: integer, rank one array of size equal to the number of tasks in the parallel application,intent (in)
Location from where the data to be sent for a particular task is obtained, relative to the beginning of xin. If not given, then the values are sent from xin in the normal order, with the values for task n after those for task n-1.
get_off :: integer, rank one array of size equal to the number of tasks in the parallel application,intent (in)
Location of where the data from a particular task is placed, relative to the beginning of xout. If not given, then the values are placed in xout in normal task order, with values from task n after values from task n-1
the_err :: integer, intent (out)
Error code 0 = success, != 0 failure.
See Specifying Optional Arguments for the syntax for using optional arguments.

Notes:

Xin and xout can be any intrinsic Fortran data type: integer, real, double precision, complex, logical or, character. Both must be arrays.

First example:


program ccm_alltoallv_x1
    use ccm
    implicit none
    integer :: myid,numprocs,igot,i,j
    integer, allocatable :: xin(:),xout(:)
    integer ,allocatable :: to_send(:),to_get(:)
    real local_time,global_time
    call ccm_init(myid,numprocs)
    allocate(to_send(0:numprocs-1),to_get(0:numprocs-1))
    do i=0,numprocs-1
       to_send(i)=myid+i
    enddo
    allocate(xin(sum(to_send)))
    call ccm_alltoall(to_send,to_get)
    allocate(xout(sum(to_get)))
    xin=myid
    call ccm_alltoallv(xin,xout,to_send,to_get)  
    write(*,"("" i= "",i4,"" xout= "",20i3)")myid,xout
    call ccm_close()
end program

Example output on 4 processors


[ccm_host:~/ccm/source]% ccm_alltoall_x1
 i=    0 xout=   1  2  2  3  3  3
 i=    1 xout=   0  1  1  2  2  2  3  3  3  3
 i=    2 xout=   0  0  1  1  1  2  2  2  2  3  3  3  3  3
 i=    3 xout=   0  0  0  1  1  1  1  2  2  2  2  2  3  3  3  3  3  3
[ccm_host:~/ccm/source] % 

The call to ccm_init initializes the communication package. Space is allocated for the counts arrays, to_send and to_get. Each task sets the number of values it is going to send. These values are exchanged with the ccm_alltoall. Space is allocated for xin and xout. The values are exchanged with the ccm_alltoallv and finally printed. Ccm_close is called to close the package.

Second example:


program ccm_alltoallv_x2
    use ccm
    implicit none
    integer :: myid,numprocs,igot,i,j
    real, allocatable :: xin(:),xout(:)
    integer ,allocatable :: to_send(:),to_get(:),send_off(:),get_off(:)
    real local_time,global_time
    call ccm_init(myid,numprocs)
    allocate(to_send(numprocs),to_get(numprocs))
    allocate(send_off(numprocs),get_off(numprocs))
    to_send=1
    to_get=1
    allocate(xin(numprocs))
    allocate(xout(2*numprocs))
    xin=myid+10
    xout=0
    send_off(1)=0
    do i=2,numprocs
       send_off(i)=to_send(i-1)+send_off(i-1)
    enddo
    get_off(1)=0
    do i=2,numprocs
       get_off(i)=get_off(i-1)+2
    enddo
    call ccm_alltoallv(xin,xout,to_send,to_get,send_off,get_off)
    write(*,"("" i= "",i4,"" xout= "",8f6.1)")myid,xout   
    call ccm_close()
end program

Example output on 4 processors


[ccm_host:~/ccm/source]% ccm_alltoall_x1
 i=    0 xout=   10.0   0.0  11.0   0.0  12.0   0.0  13.0   0.0
 i=    1 xout=   10.0   0.0  11.0   0.0  12.0   0.0  13.0   0.0
 i=    2 xout=   10.0   0.0  11.0   0.0  12.0   0.0  13.0   0.0
 i=    3 xout=   10.0   0.0  11.0   0.0  12.0   0.0  13.0   0.0
[ccm_host:~/ccm/source] % 

The call to ccm_init initializes the communication package. The count and offset arrays are allocated. Each task will send and receive a single value to/from the other tasks. Send_off is set to the running total of the to_send array. On the receive side, the values will be stored with a space between them. Thus, get_off values are incremented by 2. Ccm_alltoallv is called to tranfer the values and they are printed. Note the space (0.0) between the received values. The call to ccm_close closes the communication package.

Error conditions:


If the error checking level is set to ccm_checksize the following error condition(s) are checked: These conditions may lead to a Underling communications error if not detected.
Back to API and user's guide