Changeset 3530af


Ignore:
Timestamp:
08/23/12 10:07:17 (20 months ago)
Author:
James Dinan <dinan@…>
Branches:
master
Children:
aa8a7a
Parents:
aa77aa
Message:

[svn-r10142] Shared mem window: added disp_unit, fixed size=0.

Added the missing disp_unit argument (was added in a later revision of the MPI
3.0 spec) and fixed a bug in base pointer calculations when processes pass a
size of 0. Added a test case to test MPI-2 ops on shared memory windows.

Reviewer: buntinas

Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • src/include/mpi.h.in

    r697ce8 r3530af  
    998998int MPIX_Win_allocate(MPI_Aint size, int disp_unit, MPI_Info info, 
    999999                      MPI_Comm comm, void *baseptr, MPI_Win *win); 
    1000 int MPIX_Win_allocate_shared(MPI_Aint size, MPI_Info info, MPI_Comm comm, 
     1000int MPIX_Win_allocate_shared(MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, 
    10011001                             void *baseptr, MPI_Win *win); 
    10021002int MPIX_Win_shared_query(MPI_Win win, int rank, MPI_Aint *size, int *disp_unit, void *baseptr); 
     
    14451445int PMPIX_Win_allocate(MPI_Aint size, int disp_unit, MPI_Info info, 
    14461446                       MPI_Comm comm, void *baseptr, MPI_Win *win); 
    1447 int PMPIX_Win_allocate_shared(MPI_Aint size, MPI_Info info, MPI_Comm comm, 
     1447int PMPIX_Win_allocate_shared(MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, 
    14481448                              void *baseptr, MPI_Win *win); 
    14491449int PMPIX_Win_shared_query(MPI_Win win, int rank, MPI_Aint *size, int *disp_unit, void *baseptr); 
  • src/include/mpiimpl.h

    r7a13e4 r3530af  
    32213221int MPID_Win_allocate(MPI_Aint size, int disp_unit, MPID_Info *info, 
    32223222                      MPID_Comm *comm, void *baseptr, MPID_Win **win); 
    3223 int MPID_Win_allocate_shared(MPI_Aint size, MPID_Info *info_ptr, MPID_Comm *comm_ptr, 
     3223int MPID_Win_allocate_shared(MPI_Aint size, int disp_unit, MPID_Info *info_ptr, MPID_Comm *comm_ptr, 
    32243224                             void **base_ptr, MPID_Win **win_ptr); 
    32253225int MPID_Win_shared_query(MPI_Win win, int rank, MPI_Aint *size, 
  • src/mpi/rma/win_allocate_shared.c

    r7745a6 r3530af  
    5656.N MPI_ERR_SIZE 
    5757@*/ 
    58 int MPIX_Win_allocate_shared(MPI_Aint size, MPI_Info info, MPI_Comm comm, 
     58int MPIX_Win_allocate_shared(MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, 
    5959                             void *baseptr, MPI_Win *win) 
    6060{ 
     
    6666 
    6767    MPIR_ERRTEST_INITIALIZED_ORDIE(); 
    68      
     68 
    6969    MPIU_THREAD_CS_ENTER(ALLFUNC,); 
    7070    MPID_MPI_RMA_FUNC_ENTER(MPID_STATE_MPIX_WIN_ALLOCATE_SHARED); 
     
    9696            MPID_Comm_valid_ptr( comm_ptr, mpi_errno ); 
    9797            if (mpi_errno != MPI_SUCCESS) goto fn_fail; 
    98             if (size < 0) 
    99                 mpi_errno = MPIR_Err_create_code( MPI_SUCCESS, 
    100                                                   MPIR_ERR_RECOVERABLE, 
    101                                                   FCNAME, __LINE__, 
    102                                                   MPI_ERR_SIZE, 
    103                                                   "**rmasize", 
    104                                                   "**rmasize %d", size); 
    105             if (size > 0 && baseptr == NULL) 
    106                 mpi_errno = MPIR_Err_create_code( MPI_SUCCESS,  
    107                                                   MPIR_ERR_RECOVERABLE,  
    108                                                   FCNAME, __LINE__,  
    109                                                   MPI_ERR_ARG, 
    110                                                   "**nullptr", 
    111                                                   "**nullptr %s", 
    112                                                   "NULL base pointer is invalid when size is nonzero");   
     98 
     99            MPIU_ERR_CHKANDJUMP1(disp_unit != 0, mpi_errno, MPI_ERR_ARG, 
     100                                 "**arg", "**arg %s", "disp_unit must be positive"); 
     101 
     102            MPIU_ERR_CHKANDJUMP1(size < 0, mpi_errno, MPI_ERR_SIZE, 
     103                                 "**rmasize", "**rmasize %d", size); 
     104 
     105            MPIU_ERR_CHKANDJUMP1(size > 0 && baseptr == NULL, mpi_errno, MPI_ERR_ARG, 
     106                                 "**nullptr", "**nullptr %s", 
     107                                 "NULL base pointer is invalid when size is nonzero"); 
     108 
    113109            if (mpi_errno != MPI_SUCCESS) goto fn_fail; 
    114110        } 
     
    118114 
    119115    /* ... body of routine ...  */ 
    120      
    121     mpi_errno = MPID_Win_allocate_shared(size, info_ptr, comm_ptr, baseptr, &win_ptr); 
     116 
     117    mpi_errno = MPID_Win_allocate_shared(size, disp_unit, info_ptr, comm_ptr, baseptr, &win_ptr); 
    122118    if (mpi_errno != MPI_SUCCESS) goto fn_fail; 
    123119 
  • src/mpid/ch3/channels/nemesis/src/ch3_win_fns.c

    rb79630 r3530af  
    1818#endif 
    1919 
    20 static int MPIDI_CH3I_Win_allocate_shared(MPI_Aint size, MPID_Info *info, MPID_Comm *comm_ptr, 
     20static int MPIDI_CH3I_Win_allocate_shared(MPI_Aint size, int disp_unit, MPID_Info *info, MPID_Comm *comm_ptr, 
    2121                                          void **base_ptr, MPID_Win **win_ptr); 
    2222 
     
    4444#undef FCNAME 
    4545#define FCNAME MPIDI_QUOTE(FUNCNAME) 
    46 static int MPIDI_CH3I_Win_allocate_shared(MPI_Aint size, MPID_Info *info, MPID_Comm *comm_ptr, 
    47                                           void **base_ptr, MPID_Win **win_ptr) 
     46static int MPIDI_CH3I_Win_allocate_shared(MPI_Aint size, int disp_unit, MPID_Info *info, 
     47                                          MPID_Comm *comm_ptr, void **base_ptr, MPID_Win **win_ptr) 
    4848{ 
    4949    int mpi_errno = MPI_SUCCESS; 
     
    8484    MPIU_CHKPMEM_MALLOC((*win_ptr)->disp_units, int *, comm_size*sizeof(int), 
    8585                        mpi_errno, "(*win_ptr)->disp_units"); 
    86     for (i=0; i<comm_size; i++) (*win_ptr)->disp_units[i] = 1; 
    8786 
    8887    MPIU_CHKPMEM_MALLOC((*win_ptr)->all_win_handles, MPI_Win *, 
     
    9796    /* get the sizes of the windows and window objectsof 
    9897       all processes.  allocate temp. buffer for communication */ 
    99     MPIU_CHKLMEM_MALLOC(tmp_buf, MPI_Aint *, 2*comm_size*sizeof(MPI_Aint), mpi_errno, "tmp_buf"); 
     98    MPIU_CHKLMEM_MALLOC(tmp_buf, MPI_Aint *, 3*comm_size*sizeof(MPI_Aint), mpi_errno, "tmp_buf"); 
    10099 
    101100    /* FIXME: This needs to be fixed for heterogeneous systems */ 
    102     tmp_buf[2*rank]   = (MPI_Aint) size; 
    103     tmp_buf[2*rank+1] = (MPI_Aint) (*win_ptr)->handle; 
     101    tmp_buf[3*rank]   = (MPI_Aint) size; 
     102    tmp_buf[3*rank+1] = (MPI_Aint) disp_unit; 
     103    tmp_buf[3*rank+2] = (MPI_Aint) (*win_ptr)->handle; 
    104104 
    105105    mpi_errno = MPIR_Allgather_impl(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, 
    106                                     tmp_buf, 2 * sizeof(MPI_Aint), MPI_BYTE, 
     106                                    tmp_buf, 3 * sizeof(MPI_Aint), MPI_BYTE, 
    107107                                    (*win_ptr)->comm_ptr, &errflag); 
    108108    MPIU_INSTR_DURATION_END(wincreate_allgather); 
     
    114114    for (i = 0; i < comm_size; ++i) { 
    115115        (*win_ptr)->sizes[i]           = tmp_buf[k++]; 
     116        (*win_ptr)->disp_units[i]      = (int) tmp_buf[k++]; 
    116117        (*win_ptr)->all_win_handles[i] = (MPI_Win) tmp_buf[k++]; 
    117118 
     
    173174 
    174175    /* compute the base addresses of each process within the shared memory segment */ 
    175     (*win_ptr)->shm_base_addrs[0] = (*win_ptr)->shm_base_addr; 
    176     for (i = 1; i < comm_size; ++i) { 
    177         if ((*win_ptr)->sizes[i]) { 
    178             if (noncontig) 
    179                 (*win_ptr)->shm_base_addrs[i] = (char *)(*win_ptr)->shm_base_addrs[i-1] + 
    180                     MPIDI_CH3_ROUND_UP_PAGESIZE((*win_ptr)->sizes[i-1]); 
    181             else 
    182                 (*win_ptr)->shm_base_addrs[i] = (char *)(*win_ptr)->shm_base_addrs[i-1] + (*win_ptr)->sizes[i-1]; 
    183         } else { 
    184             (*win_ptr)->shm_base_addrs[i] = NULL; /* FIXME: Is this right? */ 
     176    { 
     177        char *cur_base = (*win_ptr)->shm_base_addr; 
     178        (*win_ptr)->shm_base_addrs[0] = (*win_ptr)->shm_base_addr; 
     179        for (i = 1; i < comm_size; ++i) { 
     180            if ((*win_ptr)->sizes[i]) { 
     181                if (noncontig) { 
     182                    (*win_ptr)->shm_base_addrs[i] = cur_base + MPIDI_CH3_ROUND_UP_PAGESIZE((*win_ptr)->sizes[i-1]); 
     183                } else { 
     184                    (*win_ptr)->shm_base_addrs[i] = cur_base + (*win_ptr)->sizes[i-1]; 
     185                } 
     186                cur_base = (*win_ptr)->shm_base_addrs[i]; 
     187            } else { 
     188                (*win_ptr)->shm_base_addrs[i] = NULL; /* FIXME: Is this right? */ 
     189            } 
    185190        } 
    186191    } 
     
    190195    /* get the base addresses of the windows.  Note we reuse tmp_buf from above 
    191196       since it's at least as large as we need it for this allgather. */ 
    192  
    193     /* FIXME: This needs to be fixed for heterogeneous systems */ 
    194     tmp_buf[rank] = (MPI_Aint) (*win_ptr)->base; 
     197    tmp_buf[rank] = MPIU_PtrToAint((*win_ptr)->base); 
    195198 
    196199    mpi_errno = MPIR_Allgather_impl(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, 
    197                                     tmp_buf, sizeof(MPI_Aint), MPI_BYTE, 
     200                                    tmp_buf, 1, MPI_AINT, 
    198201                                    (*win_ptr)->comm_ptr, &errflag); 
    199202    if (mpi_errno) MPIU_ERR_POP(mpi_errno); 
     
    201204 
    202205    for (i = 0; i < comm_size; ++i) 
    203         (*win_ptr)->base_addrs[i] = (void *)(tmp_buf[i]); 
     206        (*win_ptr)->base_addrs[i] = MPIU_AintToPtr(tmp_buf[i]); 
    204207 
    205208    *base_ptr = (*win_ptr)->base; 
  • src/mpid/ch3/include/mpidimpl.h

    rb79630 r3530af  
    11211121    int (*create)(void *, MPI_Aint, int, MPID_Info *, MPID_Comm *, MPID_Win **); 
    11221122    int (*allocate)(MPI_Aint, int, MPID_Info *, MPID_Comm *, void *, MPID_Win **); 
    1123     int (*allocate_shared)(MPI_Aint, MPID_Info *, MPID_Comm *, void **, MPID_Win **); 
     1123    int (*allocate_shared)(MPI_Aint, int, MPID_Info *, MPID_Comm *, void **, MPID_Win **); 
    11241124    int (*create_dynamic)(MPID_Info *, MPID_Comm *, MPID_Win **); 
    11251125} MPIDI_CH3U_Win_fns_t; 
     
    11361136int MPIDI_CH3U_Win_allocate(MPI_Aint size, int disp_unit, MPID_Info *info, 
    11371137                           MPID_Comm *comm, void *baseptr, MPID_Win **win); 
    1138 int MPIDI_CH3U_Win_allocate_shared(MPI_Aint size, MPID_Info *info_ptr, MPID_Comm *comm_ptr, 
    1139                                   void **baseptr, MPID_Win **win_ptr); 
     1138int MPIDI_CH3U_Win_allocate_shared(MPI_Aint size, int disp_unit, MPID_Info *info_ptr, 
     1139                                   MPID_Comm *comm_ptr, void **baseptr, MPID_Win **win_ptr); 
    11401140int MPIDI_CH3U_Win_create_dynamic(MPID_Info *info, MPID_Comm *comm, MPID_Win **win); 
    11411141 
  • src/mpid/ch3/src/ch3u_win_fns.c

    rb79630 r3530af  
    8989 
    9090    mpi_errno = MPIR_Allgather_impl(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, 
    91                                     tmp_buf, 4 * sizeof(MPI_Aint), MPI_BYTE, 
     91                                    tmp_buf, 4, MPI_AINT, 
    9292                                    (*win_ptr)->comm_ptr, &errflag); 
    9393    MPIU_INSTR_DURATION_END(wincreate_allgather); 
     
    168168#undef FCNAME 
    169169#define FCNAME MPIDI_QUOTE(FUNCNAME) 
    170 int MPIDI_CH3U_Win_allocate_shared(MPI_Aint size, MPID_Info *info, MPID_Comm *comm_ptr, 
     170int MPIDI_CH3U_Win_allocate_shared(MPI_Aint size, int disp_unit, MPID_Info *info, MPID_Comm *comm_ptr, 
    171171                                  void **base_ptr, MPID_Win **win_ptr) 
    172172{ 
  • src/mpid/ch3/src/mpid_rma.c

    rb79630 r3530af  
    187187#undef FCNAME 
    188188#define FCNAME MPIDI_QUOTE(FUNCNAME) 
    189 int MPID_Win_allocate_shared(MPI_Aint size, MPID_Info *info, MPID_Comm *comm_ptr, 
     189int MPID_Win_allocate_shared(MPI_Aint size, int disp_unit, MPID_Info *info, MPID_Comm *comm_ptr, 
    190190                             void **base_ptr, MPID_Win **win_ptr) 
    191191{ 
     
    196196    MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPID_WIN_ALLOCATE_SHARED); 
    197197 
    198     mpi_errno = win_init(size, 1, MPIX_WIN_FLAVOR_SHARED, MPIX_WIN_UNIFIED, info, comm_ptr, win_ptr); 
    199     if (mpi_errno) MPIU_ERR_POP(mpi_errno); 
    200  
    201     mpi_errno = MPIDI_CH3U_Win_fns.allocate_shared(size, info, comm_ptr, base_ptr, win_ptr); 
     198    mpi_errno = win_init(size, disp_unit, MPIX_WIN_FLAVOR_SHARED, MPIX_WIN_UNIFIED, info, comm_ptr, win_ptr); 
     199    if (mpi_errno) MPIU_ERR_POP(mpi_errno); 
     200 
     201    mpi_errno = MPIDI_CH3U_Win_fns.allocate_shared(size, disp_unit, info, comm_ptr, base_ptr, win_ptr); 
    202202    if (mpi_errno != MPI_SUCCESS) MPIU_ERR_POP(mpi_errno); 
    203203 
  • test/mpi/rma/Makefile.am

    raa77aa r3530af  
    7979    win_shared             \ 
    8080    win_shared_noncontig   \ 
     81    win_shared_noncontig_put \ 
    8182    get_acc_local 
    8283 
  • test/mpi/rma/testlist

    raa77aa r3530af  
    6464win_shared 4 strict=false 
    6565win_shared_noncontig 4 strict=false 
     66win_shared_noncontig_put 4 strict=false 
    6667get_acc_local 1 strict=false 
  • test/mpi/rma/win_shared.c

    r19a9e3 r3530af  
    4646 
    4747    /* Allocate ELEM_PER_PROC integers for each process */ 
    48     MPIX_Win_allocate_shared(sizeof(int)*ELEM_PER_PROC, MPI_INFO_NULL,  
     48    MPIX_Win_allocate_shared(sizeof(int)*ELEM_PER_PROC, sizeof(int), MPI_INFO_NULL,  
    4949                             shm_comm, &my_base, &shm_win); 
    5050 
  • test/mpi/rma/win_shared_noncontig.c

    r19a9e3 r3530af  
    4949 
    5050    /* Allocate ELEM_PER_PROC integers for each process */ 
    51     MPIX_Win_allocate_shared(sizeof(int)*ELEM_PER_PROC, alloc_shared_info,  
     51    MPIX_Win_allocate_shared(sizeof(int)*ELEM_PER_PROC, sizeof(int), alloc_shared_info,  
    5252                             shm_comm, &my_base, &shm_win); 
    5353 
Note: See TracChangeset for help on using the changeset viewer.