This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "MPICH primary repository". The branch, master has been updated via 725ffc91efbfc7414be7de9b26f5f01bdd6a7cce (commit) via a55f4f42b385aa679eb9970061b2e6bac3974cf1 (commit) from 4058ce40d15ef5ce8ba2ce3b90ec0ae3e0568af9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://git.mpich.org/mpich.git/commitdiff/725ffc91efbfc7414be7de9b26f5f01bdd... commit 725ffc91efbfc7414be7de9b26f5f01bdd6a7cce Author: Michael Blocksome <[email protected]> Date: Wed May 28 13:13:19 2014 -0500 pamid: fix win_shared_query diff --git a/src/mpid/pamid/include/mpidi_datatypes.h b/src/mpid/pamid/include/mpidi_datatypes.h index 73cbb3a..de191b1 100644 --- a/src/mpid/pamid/include/mpidi_datatypes.h +++ b/src/mpid/pamid/include/mpidi_datatypes.h @@ -441,6 +441,7 @@ typedef struct MPIDI_Win_info uint32_t disp_unit; /**< Node's exposure window displacement units */ pami_memregion_t memregion; /**< Memory region descriptor for each node */ uint32_t memregion_used; + MPI_Aint base_size; /**< Node's exposure window base size in bytes */ } MPIDI_Win_info; typedef pthread_mutex_t MPIDI_SHM_MUTEX; diff --git a/src/mpid/pamid/src/onesided/mpid_win_allocate_shared.c b/src/mpid/pamid/src/onesided/mpid_win_allocate_shared.c index be8e2e5..bdb241f 100644 --- a/src/mpid/pamid/src/onesided/mpid_win_allocate_shared.c +++ b/src/mpid/pamid/src/onesided/mpid_win_allocate_shared.c @@ -354,6 +354,7 @@ MPID_getSharedSegment(MPI_Aint size, win->mpid.info[rank].base_addr = NULL; } win->base = win->mpid.info[rank].base_addr; + win->mpid.info[rank].base_size = size; /* set mutex_lock address and initialize it */ win->mpid.shm->mutex_lock = (pthread_mutex_t *) win->mpid.shm->base_addr; @@ -378,6 +379,7 @@ MPID_getSharedSegment(MPI_Aint size, /* calculate total number of bytes needed */ for (i = 0; i < comm_size; ++i) { + win->mpid.info[i].base_size = tmp_buf[i]; len = tmp_buf[i]; if (*noncontig) /* Round up to next page size */ @@ -508,20 +510,19 @@ MPID_Win_allocate_shared(MPI_Aint size, if (mpi_errno != MPI_SUCCESS) return mpi_errno; - win->mpid.info[0].base_addr = win->base; if (comm_size > 1) { - char *cur_base = (*win_ptr)->base; - for (i = 1; i < comm_size; ++i) { - if (size) { + char *cur_base = (*win_ptr)->base; + for (i = 0; i < comm_size; ++i) { + if (win->mpid.info[i].base_size) { if (noncontig) /* Round up to next page size */ - win->mpid.info[i].base_addr =(void *) ((MPI_Aint) cur_base + (MPI_Aint) MPIDI_ROUND_UP_PAGESIZE(size,pageSize)); - else - win->mpid.info[i].base_addr = (void *) ((MPI_Aint) cur_base + (MPI_Aint) size); - cur_base = win->mpid.info[i].base_addr; - } else { - win->mpid.info[i].base_addr = NULL; - } + win->mpid.info[i].base_addr =(void *) ((MPI_Aint) cur_base + (MPI_Aint) MPIDI_ROUND_UP_PAGESIZE(size,pageSize)); + else + win->mpid.info[i].base_addr = (void *) ((MPI_Aint) cur_base + (MPI_Aint) size); + cur_base = win->mpid.info[i].base_addr; + } else { + win->mpid.info[i].base_addr = NULL; + } } } diff --git a/src/mpid/pamid/src/onesided/mpid_win_shared_query.c b/src/mpid/pamid/src/onesided/mpid_win_shared_query.c index 21e70fd..aef5458 100644 --- a/src/mpid/pamid/src/onesided/mpid_win_shared_query.c +++ b/src/mpid/pamid/src/onesided/mpid_win_shared_query.c @@ -39,13 +39,25 @@ int MPID_Win_shared_query(MPID_Win *win, int rank, MPI_Aint *size, int *disp_unit, void *base_ptr) { - int mpi_errno = MPI_SUCCESS; + int i, mpi_errno = MPI_SUCCESS; static char FCNAME[] = "MPID_Win_shared_query"; MPIU_ERR_CHKANDSTMT((win->create_flavor != MPI_WIN_FLAVOR_SHARED), mpi_errno, MPI_ERR_RMA_FLAVOR, return mpi_errno, "**rmaflavor"); - *((void **) base_ptr) = (void *) win->base; - *size = win->size; - *disp_unit = win->disp_unit; + + if (rank == MPI_PROC_NULL) { + for (i=0; i<win->comm_ptr->local_size; ++i) { + if (win->mpid.info[i].base_size != 0) { + *((void **) base_ptr) = win->mpid.info[i].base_addr; + *size = win->mpid.info[i].base_size; + *disp_unit = win->mpid.info[i].disp_unit; + break; + } + } + } else { + *((void **) base_ptr) = win->mpid.info[rank].base_addr; + *size = win->mpid.info[rank].base_size; + *disp_unit = win->mpid.info[rank].disp_unit; + } return mpi_errno; } http://git.mpich.org/mpich.git/commitdiff/a55f4f42b385aa679eb9970061b2e6bac3... commit a55f4f42b385aa679eb9970061b2e6bac3974cf1 Author: Michael Blocksome <[email protected]> Date: Wed May 28 12:08:22 2014 -0500 pamid: fix win_allocate_shared error handling Fixes #2101 diff --git a/src/mpid/pamid/src/onesided/mpid_win_allocate_shared.c b/src/mpid/pamid/src/onesided/mpid_win_allocate_shared.c index c9a93fe..be8e2e5 100644 --- a/src/mpid/pamid/src/onesided/mpid_win_allocate_shared.c +++ b/src/mpid/pamid/src/onesided/mpid_win_allocate_shared.c @@ -154,16 +154,15 @@ int GetPageSize(void *addr, ulong *pageSize) return 0; } -void * +int MPID_getSharedSegment_mmap(MPID_Win * win) { - void * base_addr; int rank, rc, fd; int mpi_errno = MPI_SUCCESS; int errflag = FALSE; int first = 0; - snprintf (win->mpid.shm->shm_key, 63, "/mpich/comm-%d/win_shared", win->comm_ptr->context_id); + snprintf (win->mpid.shm->shm_key, 63, "/mpich.comm-%d.win_shared", win->comm_ptr->context_id); rc = shm_open (win->mpid.shm->shm_key, O_RDWR | O_CREAT | O_EXCL, 0600); if (0 == rc) { @@ -177,17 +176,13 @@ MPID_getSharedSegment_mmap(MPID_Win * win) rc = ftruncate (fd, win->mpid.shm->segment_len); MPIU_ERR_CHKANDJUMP((rc == -1), mpi_errno, MPI_ERR_RMA_SHARED, "**rmashared"); - - base_addr = mmap (NULL, win->mpid.shm->segment_len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - if (base_addr == NULL || base_addr == MAP_FAILED || base_addr == (void *) -1) { /* error */ - if (0 == rank) shm_unlink (win->mpid.shm->shm_key); - MPIU_ERR_CHKANDJUMP((win->mpid.shm->shm_id == -1), mpi_errno, MPI_ERR_RMA_SHARED, "**rmashared"); - } + win->mpid.shm->base_addr = mmap (NULL, win->mpid.shm->segment_len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + MPIU_ERR_CHKANDJUMP((win->mpid.shm->base_addr == MAP_FAILED), mpi_errno, MPI_ERR_RMA_SHARED, "**rmashared"); close (fd); /* no longer needed */ /* set mutex_lock address and initialize it */ - win->mpid.shm->mutex_lock = (MPIDI_SHM_MUTEX *) base_addr; + win->mpid.shm->mutex_lock = (MPIDI_SHM_MUTEX *) win->mpid.shm->base_addr; if (1 == first) { MPIDI_SHM_MUTEX_INIT(win); } @@ -198,14 +193,15 @@ MPID_getSharedSegment_mmap(MPID_Win * win) win->mpid.shm->allocated = 1; fn_exit: - return base_addr; + return mpi_errno; /* --BEGIN ERROR HANDLING-- */ fn_fail: + shm_unlink (win->mpid.shm->shm_key); goto fn_exit; /* --END ERROR HANDLING-- */ } -void * +int MPID_getSharedSegment_sysv(MPID_Win * win) { int mpi_errno = MPI_SUCCESS; @@ -214,7 +210,6 @@ MPID_getSharedSegment_sysv(MPID_Win * win) int rank; char *cp; int shm_flag = IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR; - void * base_addr; shm_key = (uint32_t) -1; @@ -272,11 +267,11 @@ MPID_getSharedSegment_sysv(MPID_Win * win) win->mpid.shm->shm_id = shmget(shm_key, win->mpid.shm->segment_len, shm_flag); MPIU_ERR_CHKANDJUMP((win->mpid.shm->shm_id == -1), mpi_errno, MPI_ERR_RMA_SHARED, "**rmashared"); - base_addr = (void *) shmat(win->mpid.shm->shm_id,0,0); - MPIU_ERR_CHKANDJUMP((base_addr == (void*) -1), mpi_errno,MPI_ERR_BUFFER, "**bufnull"); + win->mpid.shm->base_addr = (void *) shmat(win->mpid.shm->shm_id,0,0); + MPIU_ERR_CHKANDJUMP((win->mpid.shm->base_addr == (void*) -1), mpi_errno,MPI_ERR_BUFFER, "**bufnull"); /* set mutex_lock address and initialize it */ - win->mpid.shm->mutex_lock = (MPIDI_SHM_MUTEX *) base_addr; + win->mpid.shm->mutex_lock = (MPIDI_SHM_MUTEX *) win->mpid.shm->base_addr; MPIDI_SHM_MUTEX_INIT(win); /* successfully created shm segment - shared the key with other tasks */ @@ -288,15 +283,15 @@ MPID_getSharedSegment_sysv(MPID_Win * win) win->mpid.shm->shm_id = shmget(shm_key, 0, 0); if (win->mpid.shm->shm_id != -1) { /* shm segment is available */ - base_addr = (void *) shmat(win->mpid.shm->shm_id,0,0); + win->mpid.shm->base_addr = (void *) shmat(win->mpid.shm->shm_id,0,0); } - win->mpid.shm->mutex_lock = (MPIDI_SHM_MUTEX *) base_addr; + win->mpid.shm->mutex_lock = (MPIDI_SHM_MUTEX *) win->mpid.shm->base_addr; } win->mpid.shm->allocated = 1; fn_exit: - return base_addr; + return mpi_errno; /* --BEGIN ERROR HANDLING-- */ fn_fail: goto fn_exit; @@ -401,12 +396,13 @@ MPID_getSharedSegment(MPI_Aint size, * data buffer - possibly padded if non-contiguous. */ #ifdef USE_SYSV_SHM - win->mpid.shm->base_addr = MPID_getSharedSegment_sysv(win); + mpi_errno = MPID_getSharedSegment_sysv(win); #elif USE_MMAP_SHM - win->mpid.shm->base_addr = MPID_getSharedSegment_mmap(win); + mpi_errno = MPID_getSharedSegment_mmap(win); #else MPID_Abort(NULL, MPI_ERR_RMA_SHARED, -1, "RMA shared segment error"); #endif + if (mpi_errno) MPIU_ERR_POP(mpi_errno); /* increment the shared counter */ win->mpid.shm->shm_count=(int *)((MPI_Aint) win->mpid.shm->mutex_lock + (MPI_Aint) sizeof(MPIDI_SHM_MUTEX)); @@ -504,7 +500,9 @@ MPID_Win_allocate_shared(MPI_Aint size, mpi_errno=CheckSpaceType(win_ptr,info,&noncontig); comm_size = (*win_ptr)->comm_ptr->local_size; - MPID_getSharedSegment(size, disp_unit,comm_ptr, win_ptr, &pageSize, &noncontig); + mpi_errno = MPID_getSharedSegment(size, disp_unit,comm_ptr, win_ptr, &pageSize, &noncontig); + if (mpi_errno != MPI_SUCCESS) + return mpi_errno; mpi_errno = MPIDI_Win_allgather(size,win_ptr); if (mpi_errno != MPI_SUCCESS) ----------------------------------------------------------------------- Summary of changes: src/mpid/pamid/include/mpidi_datatypes.h | 1 + .../pamid/src/onesided/mpid_win_allocate_shared.c | 65 ++++++++++---------- .../pamid/src/onesided/mpid_win_shared_query.c | 20 +++++- 3 files changed, 49 insertions(+), 37 deletions(-) hooks/post-receive -- MPICH primary repository