[mpich-commits] [mpich] MPICH primary repository branch, master, updated. v3.2a2-10-g0a69a9d

Service Account noreply at mpich.org
Thu Nov 20 16:36:53 CST 2014


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  0a69a9d0154b86b457ac991c44de58964c0b83b5 (commit)
       via  ea9d14fbc5a413dd7df272846f0ab76077f039c2 (commit)
      from  722d85a45740371c88fe7f08471ee7aca504fd6d (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/0a69a9d0154b86b457ac991c44de58964c0b83b5

commit 0a69a9d0154b86b457ac991c44de58964c0b83b5
Author: Min Si <msi at il.is.s.u-tokyo.ac.jp>
Date:   Wed Nov 19 14:49:06 2014 -0600

    Add tests for SHM detection in win_create.
    
    This program creates window with shm window buffer and checks the
    correctness of RMA operations issued through that window. It generates
    two tests with and without alloc_shm info, in which operations are
    issued out as SHM OP and as AM respectively.
    
    Signed-off-by: Xin Zhao <xinzhao3 at illinois.edu>

diff --git a/test/mpi/rma/Makefile.am b/test/mpi/rma/Makefile.am
index 2a02b67..1312d11 100644
--- a/test/mpi/rma/Makefile.am
+++ b/test/mpi/rma/Makefile.am
@@ -92,6 +92,8 @@ noinst_PROGRAMS =          \
     win_shared_noncontig   \
     win_shared_noncontig_put \
     win_shared_zerobyte    \
+    win_shared_create_allocshm    \
+    win_shared_create_no_allocshm \
     win_zero               \
     win_large_shm          \
     win_dynamic_acc        \
@@ -218,3 +220,7 @@ mutex_bench_shm_ordered_SOURCES  = mutex_bench.c mcs-mutex.c mcs-mutex.h
 
 linked_list_bench_lock_shr_nocheck_SOURCES  = linked_list_bench_lock_shr.c
 linked_list_bench_lock_shr_nocheck_CPPFLAGS = -DUSE_MODE_NOCHECK $(AM_CPPFLAGS)
+
+win_shared_create_allocshm_SOURCES = win_shared_create.c
+win_shared_create_no_allocshm_SOURCES = win_shared_create.c
+win_shared_create_allocshm_CPPFLAGS = -DUSE_INFO_ALLOC_SHM $(AM_CPPFLAGS)
diff --git a/test/mpi/rma/testlist.in b/test/mpi/rma/testlist.in
index f9bc0f2..32cd86b 100644
--- a/test/mpi/rma/testlist.in
+++ b/test/mpi/rma/testlist.in
@@ -75,6 +75,8 @@ manyrma2 2 timeLimit=500
 manyrma2_shm 2 timeLimit=500
 manyrma3 2
 win_shared 4 mpiversion=3.0
+win_shared_create_allocshm 4 mpiversion=3.0
+win_shared_create_no_allocshm 4 mpiversion=3.0
 win_shared_noncontig 4 mpiversion=3.0
 win_shared_noncontig_put 4 mpiversion=3.0
 win_zero 4 mpiversion=3.0
diff --git a/test/mpi/rma/win_shared_create.c b/test/mpi/rma/win_shared_create.c
new file mode 100644
index 0000000..eec22d6
--- /dev/null
+++ b/test/mpi/rma/win_shared_create.c
@@ -0,0 +1,140 @@
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ *
+ *  (C) 2014 by Argonne National Laboratory.
+ *      See COPYRIGHT in top-level directory.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <mpi.h>
+#include "mpitest.h"
+
+#define ELEM_PER_PROC 4
+int local_buf[ELEM_PER_PROC];
+
+const int verbose = 0;
+
+int main(int argc, char **argv)
+{
+    int i, rank, nproc;
+    int shm_rank, shm_nproc;
+    MPI_Aint size;
+    int errors = 0, all_errors = 0;
+    int **bases = NULL, *my_base = NULL;
+    int disp_unit;
+    MPI_Win shm_win = MPI_WIN_NULL, win = MPI_WIN_NULL;
+    MPI_Comm shm_comm = MPI_COMM_NULL;
+    MPI_Group shm_group = MPI_GROUP_NULL, world_group = MPI_GROUP_NULL;
+    int dst_shm_rank, dst_world_rank;
+    MPI_Info create_info = MPI_INFO_NULL;
+
+    MPI_Init(&argc, &argv);
+
+    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+    MPI_Comm_size(MPI_COMM_WORLD, &nproc);
+
+    MPI_Comm_split_type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, rank, MPI_INFO_NULL, &shm_comm);
+
+    MPI_Comm_rank(shm_comm, &shm_rank);
+    MPI_Comm_size(shm_comm, &shm_nproc);
+
+    /* Platform does not support shared memory, just return. */
+    if (shm_nproc < 2) {
+        goto exit;
+    }
+
+    /* Specify the last process in the node as the target process */
+    dst_shm_rank = shm_nproc - 1;
+    MPI_Comm_group(shm_comm, &shm_group);
+    MPI_Comm_group(MPI_COMM_WORLD, &world_group);
+    MPI_Group_translate_ranks(shm_group, 1, &dst_shm_rank, world_group, &dst_world_rank);
+
+    bases = calloc(shm_nproc, sizeof(int *));
+
+    /* Allocate shm window among local processes, then create a global window with
+     * those shm window buffers */
+    MPI_Win_allocate_shared(sizeof(int) * ELEM_PER_PROC, sizeof(int), MPI_INFO_NULL,
+                            shm_comm, &my_base, &shm_win);
+    if (verbose)
+        printf("%d -- allocate shared: my_base = %p, absolute base\n", shm_rank, my_base);
+
+    for (i = 0; i < shm_nproc; i++) {
+        MPI_Win_shared_query(shm_win, i, &size, &disp_unit, &bases[i]);
+        if (verbose)
+            printf("%d --    shared query: base[%d]=%p, size %ld, unit %d\n",
+                   shm_rank, i, bases[i], size, disp_unit);
+    }
+
+#ifdef USE_INFO_ALLOC_SHM
+    MPI_Info_create(&create_info);
+    MPI_Info_set(create_info, "alloc_shm", "true");
+#else
+    create_info = MPI_INFO_NULL;
+#endif
+
+    MPI_Win_create(my_base, sizeof(int) * ELEM_PER_PROC, sizeof(int), create_info, MPI_COMM_WORLD,
+                   &win);
+
+    /* Reset data */
+    for (i = 0; i < ELEM_PER_PROC; i++) {
+        my_base[i] = 0;
+        local_buf[i] = i + 1;
+    }
+
+    /* Do RMA through global window, then check value through shared window */
+    MPI_Win_lock_all(0, win);
+    MPI_Win_lock_all(0, shm_win);
+
+    if (shm_rank == 0) {
+        MPI_Put(&local_buf[0], 1, MPI_INT, dst_world_rank, 0, 1, MPI_INT, win);
+        MPI_Put(&local_buf[ELEM_PER_PROC - 1], 1, MPI_INT, dst_world_rank, ELEM_PER_PROC - 1, 1,
+                MPI_INT, win);
+        MPI_Win_flush(dst_world_rank, win);
+    }
+
+    MPI_Win_sync(shm_win);
+    MPI_Barrier(shm_comm);
+    MPI_Win_sync(shm_win);
+
+    if (bases[dst_shm_rank][0] != local_buf[0]) {
+        errors++;
+        printf("%d -- Got %d at rank %d index %d, expected %d\n", rank,
+               bases[dst_shm_rank][0], dst_shm_rank, 0, local_buf[0]);
+    }
+    if (bases[dst_shm_rank][ELEM_PER_PROC - 1] != local_buf[ELEM_PER_PROC - 1]) {
+        errors++;
+        printf("%d -- Got %d at rank %d index %d, expected %d\n", rank,
+               bases[dst_shm_rank][ELEM_PER_PROC - 1], dst_shm_rank,
+               ELEM_PER_PROC - 1, local_buf[ELEM_PER_PROC - 1]);
+    }
+
+    MPI_Win_unlock_all(shm_win);
+    MPI_Win_unlock_all(win);
+
+    MPI_Reduce(&errors, &all_errors, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
+
+    MPI_Win_free(&win);
+    MPI_Win_free(&shm_win);
+
+  exit:
+    if (rank == 0 && all_errors == 0)
+        printf(" No Errors\n");
+
+    if (create_info != MPI_INFO_NULL)
+        MPI_Info_free(&create_info);
+    if (shm_comm != MPI_COMM_NULL)
+        MPI_Comm_free(&shm_comm);
+    if (shm_group != MPI_GROUP_NULL)
+        MPI_Group_free(&shm_group);
+    if (world_group != MPI_GROUP_NULL)
+        MPI_Group_free(&world_group);
+
+    MPI_Finalize();
+
+    if (bases)
+        free(bases);
+
+    return 0;
+}

http://git.mpich.org/mpich.git/commitdiff/ea9d14fbc5a413dd7df272846f0ab76077f039c2

commit ea9d14fbc5a413dd7df272846f0ab76077f039c2
Author: Min Si <msi at il.is.s.u-tokyo.ac.jp>
Date:   Wed Nov 19 13:57:39 2014 -0600

    Add info check to avoid unnecessary SHM detection.
    
    If user does not explicitly set alloc_shm to TRUE in win_create, we
    should never detect SHM windows because of expensive overhead. However,
    current code does not check this info flag. This patch fixed it.
    
    Closes #2161
    
    Signed-off-by: Xin Zhao <xinzhao3 at illinois.edu>

diff --git a/src/mpid/ch3/src/ch3u_win_fns.c b/src/mpid/ch3/src/ch3u_win_fns.c
index 534516e..5339c4f 100644
--- a/src/mpid/ch3/src/ch3u_win_fns.c
+++ b/src/mpid/ch3/src/ch3u_win_fns.c
@@ -127,7 +127,8 @@ int MPIDI_CH3U_Win_create(void *base, MPI_Aint size, int disp_unit, MPID_Info *i
     mpi_errno = MPIDI_CH3U_Win_create_gather(base, size, disp_unit, info, comm_ptr, win_ptr);
     if (mpi_errno != MPI_SUCCESS) { MPIU_ERR_POP(mpi_errno); }
 
-    if (MPIDI_CH3U_Win_fns.detect_shm != NULL) {
+    if ((*win_ptr)->info_args.alloc_shm == TRUE
+            && MPIDI_CH3U_Win_fns.detect_shm != NULL) {
         /* Detect if shared buffers are specified for the processes in the
          * current node. If so, enable shm RMA.*/
         mpi_errno = MPIDI_CH3U_Win_fns.detect_shm(win_ptr);
diff --git a/src/mpid/ch3/src/mpid_rma.c b/src/mpid/ch3/src/mpid_rma.c
index 42b4521..f0a3ae4 100644
--- a/src/mpid/ch3/src/mpid_rma.c
+++ b/src/mpid/ch3/src/mpid_rma.c
@@ -104,6 +104,16 @@ int MPID_Win_create(void *base, MPI_Aint size, int disp_unit, MPID_Info * info,
 
     (*win_ptr)->base = base;
 
+    /* FOR CREATE, alloc_shm info is default to set to FALSE */
+    (*win_ptr)->info_args.alloc_shm = FALSE;
+    if (info != NULL) {
+        int alloc_shm_flag = 0;
+        char shm_alloc_value[MPI_MAX_INFO_VAL+1];
+        MPIR_Info_get_impl(info, "alloc_shm", MPI_MAX_INFO_VAL, shm_alloc_value, &alloc_shm_flag);
+        if ((alloc_shm_flag == 1) && (!strncmp(shm_alloc_value, "true", sizeof("true"))))
+            (*win_ptr)->info_args.alloc_shm = TRUE;
+    }
+
     mpi_errno = MPIDI_CH3U_Win_fns.create(base, size, disp_unit, info, comm_ptr, win_ptr);
     if (mpi_errno)
         MPIU_ERR_POP(mpi_errno);

-----------------------------------------------------------------------

Summary of changes:
 src/mpid/ch3/src/ch3u_win_fns.c  |    3 +-
 src/mpid/ch3/src/mpid_rma.c      |   10 +++
 test/mpi/rma/Makefile.am         |    6 ++
 test/mpi/rma/testlist.in         |    2 +
 test/mpi/rma/win_shared_create.c |  140 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 160 insertions(+), 1 deletions(-)
 create mode 100644 test/mpi/rma/win_shared_create.c


hooks/post-receive
-- 
MPICH primary repository


More information about the commits mailing list