[mpich-commits] [mpich] MPICH primary repository branch, master, updated. v3.1.3-222-g9f608cf

Service Account noreply at mpich.org
Fri Nov 14 09:12:35 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  9f608cfefa435e1e17d3f00e2d17b39cb81c1bc2 (commit)
       via  f4a578872e328dcd8bc42d46b8f6aed888da633a (commit)
       via  ac1fb3c720cdff545d48c2aec2832097b03fa36b (commit)
       via  4bb35606318186a56d950dc9043f4b6bd3cd0a57 (commit)
      from  88d34091a9e6cff45dbec9bdb80208fedb4d4231 (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/9f608cfefa435e1e17d3f00e2d17b39cb81c1bc2

commit 9f608cfefa435e1e17d3f00e2d17b39cb81c1bc2
Author: Pavan Balaji <balaji at anl.gov>
Date:   Thu Nov 13 13:05:05 2014 -0600

    Clean up event stashing.
    
    Now, when we pop an event, we queue up the buddy event (e.g., ACK for
    SEND) to return next.  This way, we don't need to search for the event
    everytime.  Since we know that there'll be at most one such pending
    event, we maintain a single event structure for this.
    
    Signed-off-by: Ken Raffenetti <raffenet at mcs.anl.gov>

diff --git a/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl.c b/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl.c
index 08b858d..6e58e8f 100644
--- a/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl.c
+++ b/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl.c
@@ -614,55 +614,8 @@ static int stash_event(struct rptl_op *op, ptl_event_t event)
 }
 
 
-#undef FUNCNAME
-#define FUNCNAME retrieve_event
-#undef FCNAME
-#define FCNAME MPIU_QUOTE(FUNCNAME)
-static int retrieve_event(ptl_event_t * event)
-{
-    struct rptl_target *target;
-    struct rptl_op *op;
-    int have_event = 0;
-    MPIDI_STATE_DECL(MPID_STATE_RETRIEVE_EVENT);
-
-    MPIDI_FUNC_ENTER(MPID_STATE_RETRIEVE_EVENT);
-
-    /* FIXME: this is an expensive loop over all pending operations
-     * everytime the user does an eqget */
-    for (target = rptl_info.target_list; target; target = target->next) {
-        for (op = target->data_op_list; op; op = op->next) {
-            if (op->events_ready) {
-                assert(op->op_type == RPTL_OP_PUT);
-                assert(op->u.put.send || op->u.put.ack);
-
-                if (op->u.put.send) {
-                    memcpy(event, op->u.put.send, sizeof(ptl_event_t));
-                    MPIU_Free(op->u.put.send);
-                    op->u.put.send = NULL;
-                }
-                else {
-                    memcpy(event, op->u.put.ack, sizeof(ptl_event_t));
-                    MPIU_Free(op->u.put.ack);
-                    op->u.put.ack = NULL;
-                }
-                event->user_ptr = op->u.put.user_ptr;
-
-                MPL_DL_DELETE(target->data_op_list, op);
-                rptli_op_free(op);
-
-                have_event = 1;
-                goto fn_exit;
-            }
-        }
-    }
-
-  fn_exit:
-    MPIDI_FUNC_EXIT(MPID_STATE_RETRIEVE_EVENT);
-    return have_event;
-
-  fn_fail:
-    goto fn_exit;
-}
+static ptl_event_t pending_event;
+static int pending_event_valid = 0;
 
 #undef FUNCNAME
 #define FUNCNAME MPID_nem_ptl_rptl_eqget
@@ -684,7 +637,9 @@ int MPID_nem_ptl_rptl_eqget(ptl_handle_eq_t eq_handle, ptl_event_t * event)
 
     /* before we poll the eq, we need to check if there are any
      * completed operations that need to be returned */
-    if (retrieve_event(event)) {
+    if (pending_event_valid) {
+        memcpy(event, &pending_event, sizeof(ptl_event_t));
+        pending_event_valid = 0;
         ret = PTL_OK;
         goto fn_exit;
     }
@@ -865,6 +820,21 @@ int MPID_nem_ptl_rptl_eqget(ptl_handle_eq_t eq_handle, ptl_event_t * event)
                 /* drop the send event */
                 ret = PTL_EQ_EMPTY;
             }
+            else {
+                /* if the message is over the data portal, we'll
+                 * return the send event.  if the user asked for an
+                 * ACK, we will enqueue the ack to be returned
+                 * next. */
+                if (op->u.put.ack_req & PTL_ACK_REQ) {
+                    /* only one event should be pending */
+                    assert(pending_event_valid == 0);
+                    memcpy(&pending_event, op->u.put.ack, sizeof(ptl_event_t));
+                    pending_event_valid = 1;
+                }
+                MPIU_Free(op->u.put.ack);
+                MPL_DL_DELETE(op->target->data_op_list, op);
+                rptli_op_free(op);
+            }
         }
 
         else if (event->type == PTL_EVENT_ACK && op->u.put.send) {
@@ -876,25 +846,40 @@ int MPID_nem_ptl_rptl_eqget(ptl_handle_eq_t eq_handle, ptl_event_t * event)
             op->events_ready = 1;
             event->user_ptr = op->u.put.user_ptr;
 
-            /* if the message is over the control portal, ignore ACK
-             * event */
+            /* if the message is over the control portal, ignore both
+             * events */
             if (op->u.put.pt_type == RPTL_PT_CONTROL) {
+                /* drop the send event */
                 MPIU_Free(op->u.put.send);
                 MPL_DL_DELETE(op->target->control_op_list, op);
                 rptli_op_free(op);
+
+                /* drop the ack event */
                 ret = PTL_EQ_EMPTY;
             }
+            else {
+                /* if the message is over the data portal, we'll
+                 * return the send event.  if the user asked for an
+                 * ACK, we will enqueue the ack to be returned
+                 * next. */
+                if (op->u.put.ack_req & PTL_ACK_REQ) {
+                    /* user asked for an ACK, so return it to the user
+                     * and queue up the SEND event for next time */
+                    memcpy(&pending_event, op->u.put.send, sizeof(ptl_event_t));
+                    MPIU_Free(op->u.put.send);
+                    assert(pending_event_valid == 0);
+                    pending_event_valid = 1;
+                }
+                else {
+                    /* user didn't ask for an ACK, overwrite the ACK
+                     * event with the pending send event */
+                    memcpy(event, op->u.put.send, sizeof(ptl_event_t));
+                    MPIU_Free(op->u.put.send);
 
-            /* if the user did not ask for an ACK discard this event
-             * and return the send event. */
-            else if (!(op->u.put.ack_req & PTL_ACK_REQ)) {
-                memcpy(event, op->u.put.send, sizeof(ptl_event_t));
-                MPIU_Free(op->u.put.send);
-
-                /* set the event user pointer again, since we copied
-                 * over the original event */
-                event->user_ptr = op->u.put.user_ptr;
-
+                    /* set the event user pointer again, since we
+                     * copied over the original event */
+                    event->user_ptr = op->u.put.user_ptr;
+                }
                 /* we should be in the data op list */
                 MPL_DL_DELETE(op->target->data_op_list, op);
                 rptli_op_free(op);

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

commit f4a578872e328dcd8bc42d46b8f6aed888da633a
Author: Pavan Balaji <balaji at anl.gov>
Date:   Thu Nov 13 12:46:42 2014 -0600

    On an error drop all existing events for that op.
    
    We were stashing events when the origin receives a NACK.  This is
    unnecessary since we retransmit the op and never use those stashed
    events.
    
    Signed-off-by: Ken Raffenetti <raffenet at mcs.anl.gov>

diff --git a/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl.c b/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl.c
index 6bbe304..08b858d 100644
--- a/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl.c
+++ b/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl.c
@@ -807,21 +807,16 @@ int MPID_nem_ptl_rptl_eqget(ptl_handle_eq_t eq_handle, ptl_event_t * event)
                 assert(!(event->type == PTL_EVENT_SEND && op->u.put.send));
                 assert(!(event->type == PTL_EVENT_ACK && op->u.put.ack));
 
-                /* if we have received both events, discard them.
-                 * otherwise, stash the one we received while waiting
-                 * for the other. */
-                if (event->type == PTL_EVENT_SEND && op->u.put.ack) {
+                /* discard pending events, since we will retransmit
+                 * this op anyway */
+                if (op->u.put.ack) {
                     MPIU_Free(op->u.put.ack);
                     op->u.put.ack = NULL;
                 }
-                else if (event->type == PTL_EVENT_ACK && op->u.put.send) {
+                if (op->u.put.send) {
                     MPIU_Free(op->u.put.send);
                     op->u.put.send = NULL;
                 }
-                else {
-                    ret = stash_event(op, *event);
-                    RPTLU_ERR_POP(ret, "error stashing event\n");
-                }
             }
 
             if (op->op_type == RPTL_OP_PUT)

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

commit ac1fb3c720cdff545d48c2aec2832097b03fa36b
Author: Pavan Balaji <balaji at anl.gov>
Date:   Thu Nov 13 12:45:46 2014 -0600

    Additional comments to explain what we are doing.
    
    Signed-off-by: Ken Raffenetti <raffenet at mcs.anl.gov>

diff --git a/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl.c b/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl.c
index 3b603b7..6bbe304 100644
--- a/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl.c
+++ b/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl.c
@@ -859,12 +859,15 @@ int MPID_nem_ptl_rptl_eqget(ptl_handle_eq_t eq_handle, ptl_event_t * event)
             op->events_ready = 1;
             event->user_ptr = op->u.put.user_ptr;
 
-            /* if the message is over the control portal, ignore the
-             * ACK event */
+            /* if the message is over the control portal, ignore both
+             * events */
             if (op->u.put.pt_type == RPTL_PT_CONTROL) {
+                /* drop the ack event */
                 MPIU_Free(op->u.put.ack);
                 MPL_DL_DELETE(op->target->control_op_list, op);
                 rptli_op_free(op);
+
+                /* drop the send event */
                 ret = PTL_EQ_EMPTY;
             }
         }

http://git.mpich.org/mpich.git/commitdiff/4bb35606318186a56d950dc9043f4b6bd3cd0a57

commit 4bb35606318186a56d950dc9043f4b6bd3cd0a57
Author: Pavan Balaji <balaji at anl.gov>
Date:   Wed Nov 12 20:41:08 2014 -0600

    rportals code refactoring.
    
    1. Moved op management to a different file.
    
    2. Move rptl_info to an extern, so it can be shared by multiple files.
    
    3. Separate out rptl initialization routines.
    
    Signed-off-by: Ken Raffenetti <raffenet at mcs.anl.gov>

diff --git a/src/mpid/ch3/channels/nemesis/netmod/portals4/Makefile.mk b/src/mpid/ch3/channels/nemesis/netmod/portals4/Makefile.mk
index 06c26d1..764e821 100644
--- a/src/mpid/ch3/channels/nemesis/netmod/portals4/Makefile.mk
+++ b/src/mpid/ch3/channels/nemesis/netmod/portals4/Makefile.mk
@@ -16,7 +16,9 @@ mpi_core_sources +=					\
     src/mpid/ch3/channels/nemesis/netmod/portals4/ptl_nm.c	        \
     src/mpid/ch3/channels/nemesis/netmod/portals4/ptl_send.c            \
     src/mpid/ch3/channels/nemesis/netmod/portals4/ptl_lmt.c             \
-    src/mpid/ch3/channels/nemesis/netmod/portals4/rptl.c
+    src/mpid/ch3/channels/nemesis/netmod/portals4/rptl.c                \
+    src/mpid/ch3/channels/nemesis/netmod/portals4/rptl_init.c           \
+    src/mpid/ch3/channels/nemesis/netmod/portals4/rptl_op.c
 
 noinst_HEADERS +=                                                \
     src/mpid/ch3/channels/nemesis/netmod/portals4/ptl_impl.h     \
diff --git a/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl.c b/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl.c
index cbcc81c..3b603b7 100644
--- a/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl.c
+++ b/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl.c
@@ -60,15 +60,7 @@
 #define IDS_ARE_EQUAL(t1, t2) \
     (t1.phys.nid == t2.phys.nid && t1.phys.pid == t2.phys.pid)
 
-static struct {
-    struct rptl *rptl_list;
-    struct rptl_target *target_list;
-
-    int world_size;
-    uint64_t origin_events_left;
-    int (*get_target_info) (int rank, ptl_process_t * id, ptl_pt_index_t local_data_pt,
-                            ptl_pt_index_t * target_data_pt, ptl_pt_index_t * target_control_pt);
-} rptl_info;
+struct rptl_info rptl_info;
 
 
 #undef FUNCNAME
@@ -118,292 +110,6 @@ static int find_target(ptl_process_t id, struct rptl_target **target)
 }
 
 
-#undef FUNCNAME
-#define FUNCNAME MPID_nem_ptl_rptl_init
-#undef FCNAME
-#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPID_nem_ptl_rptl_init(int world_size, uint64_t max_origin_events,
-                           int (*get_target_info) (int rank, ptl_process_t * id,
-                                                   ptl_pt_index_t local_data_pt,
-                                                   ptl_pt_index_t * target_data_pt,
-                                                   ptl_pt_index_t * target_control_pt))
-{
-    int ret = PTL_OK;
-    MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_PTL_RPTL_INIT);
-
-    MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_PTL_RPTL_INIT);
-
-    rptl_info.rptl_list = NULL;
-    rptl_info.target_list = NULL;
-
-    rptl_info.world_size = world_size;
-    rptl_info.origin_events_left = max_origin_events;
-    rptl_info.get_target_info = get_target_info;
-
-  fn_exit:
-    MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_PTL_RPTL_INIT);
-    return ret;
-
-  fn_fail:
-    goto fn_exit;
-}
-
-
-#undef FUNCNAME
-#define FUNCNAME MPID_nem_ptl_rptl_drain_eq
-#undef FCNAME
-#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPID_nem_ptl_rptl_drain_eq(int eq_count, ptl_handle_eq_t *eq)
-{
-    int ret = PTL_OK;
-    ptl_event_t event;
-    struct rptl_op_pool_segment *op_segment;
-    int i;
-    struct rptl_target *target, *t;
-    MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_PTL_RPTL_FINALIZE);
-
-    MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_PTL_RPTL_FINALIZE);
-
-    for (target = rptl_info.target_list; target; target = target->next) {
-        while (target->control_op_list || target->data_op_list) {
-            for (i = 0; i < eq_count; i++) {
-                /* read and ignore all events */
-                ret = MPID_nem_ptl_rptl_eqget(eq[i], &event);
-                if (ret == PTL_EQ_EMPTY)
-                    ret = PTL_OK;
-                RPTLU_ERR_POP(ret, "Error calling MPID_nem_ptl_rptl_eqget\n");
-            }
-        }
-    }
-
-    for (target = rptl_info.target_list; target;) {
-        assert(target->data_op_list == NULL);
-        assert(target->control_op_list == NULL);
-
-        while (target->op_segment_list) {
-            op_segment = target->op_segment_list;
-            MPL_DL_DELETE(target->op_segment_list, op_segment);
-            MPIU_Free(op_segment);
-        }
-
-        t = target->next;
-        MPIU_Free(target);
-        target = t;
-    }
-
-  fn_exit:
-    MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_PTL_RPTL_FINALIZE);
-    return ret;
-
-  fn_fail:
-    goto fn_exit;
-}
-
-
-#undef FUNCNAME
-#define FUNCNAME post_empty_buffer
-#undef FCNAME
-#define FCNAME MPIU_QUOTE(FUNCNAME)
-static inline int post_empty_buffer(ptl_handle_ni_t ni_handle, ptl_pt_index_t pt,
-                                    ptl_handle_me_t * me_handle)
-{
-    int ret;
-    ptl_me_t me;
-    ptl_process_t id;
-    MPIDI_STATE_DECL(MPID_STATE_POST_EMPTY_BUFFER);
-
-    MPIDI_FUNC_ENTER(MPID_STATE_POST_EMPTY_BUFFER);
-
-    id.phys.nid = PTL_NID_ANY;
-    id.phys.pid = PTL_PID_ANY;
-
-    me.start = NULL;
-    me.length = 0;
-    me.ct_handle = PTL_CT_NONE;
-    me.uid = PTL_UID_ANY;
-    me.options = (PTL_ME_OP_PUT | PTL_ME_OP_GET | PTL_ME_USE_ONCE | PTL_ME_IS_ACCESSIBLE |
-                  PTL_ME_EVENT_LINK_DISABLE | PTL_ME_EVENT_UNLINK_DISABLE);
-    me.match_id = id;
-    me.match_bits = 0;
-    me.ignore_bits = 0;
-    me.min_free = 0;
-
-    ret = PtlMEAppend(ni_handle, pt, &me, PTL_PRIORITY_LIST, NULL, me_handle);
-    RPTLU_ERR_POP(ret, "Error appending empty buffer to priority list\n");
-
-  fn_exit:
-    MPIDI_FUNC_EXIT(MPID_STATE_POST_EMPTY_BUFFER);
-    return ret;
-
-  fn_fail:
-    goto fn_exit;
-}
-
-
-#undef FUNCNAME
-#define FUNCNAME MPID_nem_ptl_rptl_ptinit
-#undef FCNAME
-#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPID_nem_ptl_rptl_ptinit(ptl_handle_ni_t ni_handle, ptl_handle_eq_t eq_handle, ptl_pt_index_t data_pt,
-                             ptl_pt_index_t control_pt)
-{
-    int ret = PTL_OK;
-    struct rptl *rptl;
-    int mpi_errno = MPI_SUCCESS;
-    int i;
-    ptl_md_t md;
-    MPIU_CHKPMEM_DECL(2);
-    MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_PTL_RPTL_PTINIT);
-
-    MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_PTL_RPTL_PTINIT);
-
-
-    /* setup the parts of rptls that can be done before world size or
-     * target information */
-    MPIU_CHKPMEM_MALLOC(rptl, struct rptl *, sizeof(struct rptl), mpi_errno, "rptl");
-    MPL_DL_APPEND(rptl_info.rptl_list, rptl);
-
-    rptl->local_state = RPTL_LOCAL_STATE_ACTIVE;
-    rptl->pause_ack_counter = 0;
-
-    rptl->data.ob_max_count = 0;
-    rptl->data.ob_curr_count = 0;
-
-    rptl->data.pt = data_pt;
-    rptl->control.pt = control_pt;
-
-    rptl->ni = ni_handle;
-    rptl->eq = eq_handle;
-
-    md.start = 0;
-    md.length = (ptl_size_t) (-1);
-    md.options = 0x0;
-    md.eq_handle = rptl->eq;
-    md.ct_handle = PTL_CT_NONE;
-    ret = PtlMDBind(rptl->ni, &md, &rptl->md);
-    RPTLU_ERR_POP(ret, "Error binding new global MD\n");
-
-    /* post world_size number of empty buffers on the control portal */
-    if (rptl->control.pt != PTL_PT_ANY) {
-        MPIU_CHKPMEM_MALLOC(rptl->control.me, ptl_handle_me_t *,
-                            2 * rptl_info.world_size * sizeof(ptl_handle_me_t), mpi_errno,
-                            "rptl target info");
-        for (i = 0; i < 2 * rptl_info.world_size; i++) {
-            ret = post_empty_buffer(rptl->ni, rptl->control.pt, &rptl->control.me[i]);
-            RPTLU_ERR_POP(ret, "Error in post_empty_buffer\n");
-        }
-        rptl->control.me_idx = 0;
-    }
-
-  fn_exit:
-    MPIU_CHKPMEM_COMMIT();
-    MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_PTL_RPTL_PTINIT);
-    return ret;
-
-  fn_fail:
-    if (mpi_errno)
-        ret = PTL_FAIL;
-    MPIU_CHKPMEM_REAP();
-    goto fn_exit;
-}
-
-
-#undef FUNCNAME
-#define FUNCNAME MPID_nem_ptl_rptl_ptfini
-#undef FCNAME
-#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPID_nem_ptl_rptl_ptfini(ptl_pt_index_t pt_index)
-{
-    int i;
-    int ret = PTL_OK;
-    struct rptl *rptl;
-    MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_PTL_RPTL_PTFINI);
-
-    MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_PTL_RPTL_PTFINI);
-
-    /* find the right rptl */
-    for (rptl = rptl_info.rptl_list; rptl && rptl->data.pt != pt_index; rptl = rptl->next);
-    assert(rptl);
-
-    /* free control portals that were created */
-    if (rptl->control.pt != PTL_PT_ANY) {
-        for (i = 0; i < rptl_info.world_size * 2; i++) {
-            ret = PtlMEUnlink(rptl->control.me[i]);
-            RPTLU_ERR_POP(ret, "Error unlinking control buffers\n");
-        }
-        MPIU_Free(rptl->control.me);
-    }
-
-    MPL_DL_DELETE(rptl_info.rptl_list, rptl);
-    MPIU_Free(rptl);
-
-  fn_exit:
-    MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_PTL_RPTL_PTFINI);
-    return ret;
-
-  fn_fail:
-    goto fn_exit;
-}
-
-
-#undef FUNCNAME
-#define FUNCNAME alloc_op
-#undef FCNAME
-#define FCNAME MPIU_QUOTE(FUNCNAME)
-static int alloc_op(struct rptl_op **op, struct rptl_target *target)
-{
-    int ret = PTL_OK;
-    struct rptl_op_pool_segment *op_segment;
-    int mpi_errno = MPI_SUCCESS;
-    int i;
-    MPIU_CHKPMEM_DECL(1);
-    MPIDI_STATE_DECL(MPID_STATE_ALLOC_OP);
-
-    MPIDI_FUNC_ENTER(MPID_STATE_ALLOC_OP);
-
-    assert(target);
-
-    if (target->op_pool == NULL) {
-        MPIU_CHKPMEM_MALLOC(op_segment, struct rptl_op_pool_segment *, sizeof(struct rptl_op_pool_segment),
-                            mpi_errno, "op pool segment");
-        MPL_DL_APPEND(target->op_segment_list, op_segment);
-
-        for (i = 0; i < RPTL_OP_POOL_SEGMENT_COUNT; i++)
-            MPL_DL_APPEND(target->op_pool, &op_segment->op[i]);
-    }
-
-    *op = target->op_pool;
-    MPL_DL_DELETE(target->op_pool, *op);
-
-  fn_exit:
-    MPIU_CHKPMEM_COMMIT();
-    MPIDI_FUNC_EXIT(MPID_STATE_ALLOC_OP);
-    return ret;
-
-  fn_fail:
-    if (mpi_errno)
-        ret = PTL_FAIL;
-    MPIU_CHKPMEM_REAP();
-    goto fn_exit;
-}
-
-
-#undef FUNCNAME
-#define FUNCNAME free_op
-#undef FCNAME
-#define FCNAME MPIU_QUOTE(FUNCNAME)
-static void free_op(struct rptl_op *op)
-{
-    MPIDI_STATE_DECL(MPID_STATE_FREE_OP);
-
-    MPIDI_FUNC_ENTER(MPID_STATE_FREE_OP);
-
-    MPL_DL_APPEND(op->target->op_pool, op);
-
-    MPIDI_FUNC_EXIT(MPID_STATE_FREE_OP);
-}
-
-
 static int rptl_put(ptl_handle_md_t md_handle, ptl_size_t local_offset, ptl_size_t length,
                     ptl_ack_req_t ack_req, ptl_process_t target_id, ptl_pt_index_t pt_index,
                     ptl_match_bits_t match_bits, ptl_size_t remote_offset, void *user_ptr,
@@ -620,7 +326,7 @@ static int rptl_put(ptl_handle_md_t md_handle, ptl_size_t local_offset, ptl_size
     ret = find_target(target_id, &target);
     RPTLU_ERR_POP(ret, "error finding target structure\n");
 
-    ret = alloc_op(&op, target);
+    ret = rptli_op_alloc(&op, target);
     RPTLU_ERR_POP(ret, "error allocating op\n");
 
     op->op_type = RPTL_OP_PUT;
@@ -694,7 +400,7 @@ int MPID_nem_ptl_rptl_get(ptl_handle_md_t md_handle, ptl_size_t local_offset, pt
     ret = find_target(target_id, &target);
     RPTLU_ERR_POP(ret, "error finding target structure\n");
 
-    ret = alloc_op(&op, target);
+    ret = rptli_op_alloc(&op, target);
     RPTLU_ERR_POP(ret, "error allocating op\n");
 
     op->op_type = RPTL_OP_GET;
@@ -942,7 +648,7 @@ static int retrieve_event(ptl_event_t * event)
                 event->user_ptr = op->u.put.user_ptr;
 
                 MPL_DL_DELETE(target->data_op_list, op);
-                free_op(op);
+                rptli_op_free(op);
 
                 have_event = 1;
                 goto fn_exit;
@@ -1048,11 +754,11 @@ int MPID_nem_ptl_rptl_eqget(ptl_handle_eq_t eq_handle, ptl_event_t * event)
         ret = PTL_EQ_EMPTY;
 
         /* the message came in on the control PT, repost it */
-        tmp_ret = post_empty_buffer(rptl->ni, rptl->control.pt,
+        tmp_ret = rptli_post_control_buffer(rptl->ni, rptl->control.pt,
                                     &rptl->control.me[rptl->control.me_idx]);
         if (tmp_ret) {
             ret = tmp_ret;
-            RPTLU_ERR_POP(ret, "Error returned from post_empty_buffer\n");
+            RPTLU_ERR_POP(ret, "Error returned from rptli_post_control_buffer\n");
         }
         rptl->control.me_idx++;
         if (rptl->control.me_idx >= 2 * rptl_info.world_size)
@@ -1141,7 +847,7 @@ int MPID_nem_ptl_rptl_eqget(ptl_handle_eq_t eq_handle, ptl_event_t * event)
 
             /* GET operations only go into the data op list */
             MPL_DL_DELETE(op->target->data_op_list, op);
-            free_op(op);
+            rptli_op_free(op);
         }
 
         else if (event->type == PTL_EVENT_SEND && op->u.put.ack) {
@@ -1158,7 +864,7 @@ int MPID_nem_ptl_rptl_eqget(ptl_handle_eq_t eq_handle, ptl_event_t * event)
             if (op->u.put.pt_type == RPTL_PT_CONTROL) {
                 MPIU_Free(op->u.put.ack);
                 MPL_DL_DELETE(op->target->control_op_list, op);
-                free_op(op);
+                rptli_op_free(op);
                 ret = PTL_EQ_EMPTY;
             }
         }
@@ -1177,7 +883,7 @@ int MPID_nem_ptl_rptl_eqget(ptl_handle_eq_t eq_handle, ptl_event_t * event)
             if (op->u.put.pt_type == RPTL_PT_CONTROL) {
                 MPIU_Free(op->u.put.send);
                 MPL_DL_DELETE(op->target->control_op_list, op);
-                free_op(op);
+                rptli_op_free(op);
                 ret = PTL_EQ_EMPTY;
             }
 
@@ -1193,7 +899,7 @@ int MPID_nem_ptl_rptl_eqget(ptl_handle_eq_t eq_handle, ptl_event_t * event)
 
                 /* we should be in the data op list */
                 MPL_DL_DELETE(op->target->data_op_list, op);
-                free_op(op);
+                rptli_op_free(op);
             }
         }
 
diff --git a/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl.h b/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl.h
index 7ce31d9..f99523c 100644
--- a/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl.h
+++ b/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl.h
@@ -160,28 +160,44 @@ struct rptl_target {
     struct rptl_target *prev;
 };
 
+struct rptl_info {
+    struct rptl *rptl_list;
+    struct rptl_target *target_list;
+
+    int world_size;
+    uint64_t origin_events_left;
+    int (*get_target_info) (int rank, ptl_process_t * id, ptl_pt_index_t local_data_pt,
+                            ptl_pt_index_t * target_data_pt, ptl_pt_index_t * target_control_pt);
+};
+
+extern struct rptl_info rptl_info;
+
+
+/* initialization */
 int MPID_nem_ptl_rptl_init(int world_size, uint64_t max_origin_events,
                            int (*get_target_info) (int rank, ptl_process_t * id,
                                                    ptl_pt_index_t local_data_pt,
                                                    ptl_pt_index_t * target_data_pt,
                                                    ptl_pt_index_t * target_control_pt));
-
 int MPID_nem_ptl_rptl_drain_eq(int eq_count, ptl_handle_eq_t *eq);
-
 int MPID_nem_ptl_rptl_ptinit(ptl_handle_ni_t ni_handle, ptl_handle_eq_t eq_handle, ptl_pt_index_t data_pt,
                              ptl_pt_index_t control_pt);
-
 int MPID_nem_ptl_rptl_ptfini(ptl_pt_index_t pt_index);
+int rptli_post_control_buffer(ptl_handle_ni_t ni_handle, ptl_pt_index_t pt,
+                              ptl_handle_me_t * me_handle);
+
+/* op management */
+int rptli_op_alloc(struct rptl_op **op, struct rptl_target *target);
+void rptli_op_free(struct rptl_op *op);
 
+/* communication */
 int MPID_nem_ptl_rptl_put(ptl_handle_md_t md_handle, ptl_size_t local_offset, ptl_size_t length,
                           ptl_ack_req_t ack_req, ptl_process_t target_id, ptl_pt_index_t pt_index,
                           ptl_match_bits_t match_bits, ptl_size_t remote_offset, void *user_ptr,
                           ptl_hdr_data_t hdr_data);
-
 int MPID_nem_ptl_rptl_get(ptl_handle_md_t md_handle, ptl_size_t local_offset, ptl_size_t length,
                           ptl_process_t target_id, ptl_pt_index_t pt_index,
                           ptl_match_bits_t match_bits, ptl_size_t remote_offset, void *user_ptr);
-
 int MPID_nem_ptl_rptl_eqget(ptl_handle_eq_t eq_handle, ptl_event_t * event);
 
 #endif /* RPTL_H_INCLUDED */
diff --git a/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl_init.c b/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl_init.c
new file mode 100644
index 0000000..9262c5e
--- /dev/null
+++ b/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl_init.c
@@ -0,0 +1,235 @@
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ *  (C) 2014 by Argonne National Laboratory.
+ *      See COPYRIGHT in top-level directory.
+ */
+
+#include "ptl_impl.h"
+#include "rptl.h"
+
+#undef FUNCNAME
+#define FUNCNAME rptli_post_control_buffer
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+int rptli_post_control_buffer(ptl_handle_ni_t ni_handle, ptl_pt_index_t pt,
+                              ptl_handle_me_t * me_handle)
+{
+    int ret;
+    ptl_me_t me;
+    ptl_process_t id;
+    MPIDI_STATE_DECL(MPID_STATE_RPTLI_POST_CONTROL_BUFFER);
+
+    MPIDI_FUNC_ENTER(MPID_STATE_RPTLI_POST_CONTROL_BUFFER);
+
+    id.phys.nid = PTL_NID_ANY;
+    id.phys.pid = PTL_PID_ANY;
+
+    me.start = NULL;
+    me.length = 0;
+    me.ct_handle = PTL_CT_NONE;
+    me.uid = PTL_UID_ANY;
+    me.options = (PTL_ME_OP_PUT | PTL_ME_OP_GET | PTL_ME_USE_ONCE | PTL_ME_IS_ACCESSIBLE |
+                  PTL_ME_EVENT_LINK_DISABLE | PTL_ME_EVENT_UNLINK_DISABLE);
+    me.match_id = id;
+    me.match_bits = 0;
+    me.ignore_bits = 0;
+    me.min_free = 0;
+
+    ret = PtlMEAppend(ni_handle, pt, &me, PTL_PRIORITY_LIST, NULL, me_handle);
+    RPTLU_ERR_POP(ret, "Error appending empty buffer to priority list\n");
+
+  fn_exit:
+    MPIDI_FUNC_EXIT(MPID_STATE_RPTLI_POST_CONTROL_BUFFER);
+    return ret;
+
+  fn_fail:
+    goto fn_exit;
+}
+
+
+#undef FUNCNAME
+#define FUNCNAME MPID_nem_ptl_rptl_init
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+int MPID_nem_ptl_rptl_init(int world_size, uint64_t max_origin_events,
+                           int (*get_target_info) (int rank, ptl_process_t * id,
+                                                   ptl_pt_index_t local_data_pt,
+                                                   ptl_pt_index_t * target_data_pt,
+                                                   ptl_pt_index_t * target_control_pt))
+{
+    int ret = PTL_OK;
+    MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_PTL_RPTL_INIT);
+
+    MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_PTL_RPTL_INIT);
+
+    rptl_info.rptl_list = NULL;
+    rptl_info.target_list = NULL;
+
+    rptl_info.world_size = world_size;
+    rptl_info.origin_events_left = max_origin_events;
+    rptl_info.get_target_info = get_target_info;
+
+  fn_exit:
+    MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_PTL_RPTL_INIT);
+    return ret;
+
+  fn_fail:
+    goto fn_exit;
+}
+
+
+#undef FUNCNAME
+#define FUNCNAME MPID_nem_ptl_rptl_drain_eq
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+int MPID_nem_ptl_rptl_drain_eq(int eq_count, ptl_handle_eq_t *eq)
+{
+    int ret = PTL_OK;
+    ptl_event_t event;
+    struct rptl_op_pool_segment *op_segment;
+    int i;
+    struct rptl_target *target, *t;
+    MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_PTL_RPTL_FINALIZE);
+
+    MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_PTL_RPTL_FINALIZE);
+
+    for (target = rptl_info.target_list; target; target = target->next) {
+        while (target->control_op_list || target->data_op_list) {
+            for (i = 0; i < eq_count; i++) {
+                /* read and ignore all events */
+                ret = MPID_nem_ptl_rptl_eqget(eq[i], &event);
+                if (ret == PTL_EQ_EMPTY)
+                    ret = PTL_OK;
+                RPTLU_ERR_POP(ret, "Error calling MPID_nem_ptl_rptl_eqget\n");
+            }
+        }
+    }
+
+    for (target = rptl_info.target_list; target;) {
+        assert(target->data_op_list == NULL);
+        assert(target->control_op_list == NULL);
+
+        while (target->op_segment_list) {
+            op_segment = target->op_segment_list;
+            MPL_DL_DELETE(target->op_segment_list, op_segment);
+            MPIU_Free(op_segment);
+        }
+
+        t = target->next;
+        MPIU_Free(target);
+        target = t;
+    }
+
+  fn_exit:
+    MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_PTL_RPTL_FINALIZE);
+    return ret;
+
+  fn_fail:
+    goto fn_exit;
+}
+
+
+#undef FUNCNAME
+#define FUNCNAME MPID_nem_ptl_rptl_ptinit
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+int MPID_nem_ptl_rptl_ptinit(ptl_handle_ni_t ni_handle, ptl_handle_eq_t eq_handle, ptl_pt_index_t data_pt,
+                             ptl_pt_index_t control_pt)
+{
+    int ret = PTL_OK;
+    struct rptl *rptl;
+    int mpi_errno = MPI_SUCCESS;
+    int i;
+    ptl_md_t md;
+    MPIU_CHKPMEM_DECL(2);
+    MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_PTL_RPTL_PTINIT);
+
+    MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_PTL_RPTL_PTINIT);
+
+
+    /* setup the parts of rptls that can be done before world size or
+     * target information */
+    MPIU_CHKPMEM_MALLOC(rptl, struct rptl *, sizeof(struct rptl), mpi_errno, "rptl");
+    MPL_DL_APPEND(rptl_info.rptl_list, rptl);
+
+    rptl->local_state = RPTL_LOCAL_STATE_ACTIVE;
+    rptl->pause_ack_counter = 0;
+
+    rptl->data.ob_max_count = 0;
+    rptl->data.ob_curr_count = 0;
+
+    rptl->data.pt = data_pt;
+    rptl->control.pt = control_pt;
+
+    rptl->ni = ni_handle;
+    rptl->eq = eq_handle;
+
+    md.start = 0;
+    md.length = (ptl_size_t) (-1);
+    md.options = 0x0;
+    md.eq_handle = rptl->eq;
+    md.ct_handle = PTL_CT_NONE;
+    ret = PtlMDBind(rptl->ni, &md, &rptl->md);
+    RPTLU_ERR_POP(ret, "Error binding new global MD\n");
+
+    /* post world_size number of empty buffers on the control portal */
+    if (rptl->control.pt != PTL_PT_ANY) {
+        MPIU_CHKPMEM_MALLOC(rptl->control.me, ptl_handle_me_t *,
+                            2 * rptl_info.world_size * sizeof(ptl_handle_me_t), mpi_errno,
+                            "rptl target info");
+        for (i = 0; i < 2 * rptl_info.world_size; i++) {
+            ret = rptli_post_control_buffer(rptl->ni, rptl->control.pt, &rptl->control.me[i]);
+            RPTLU_ERR_POP(ret, "Error in rptli_post_control_buffer\n");
+        }
+        rptl->control.me_idx = 0;
+    }
+
+  fn_exit:
+    MPIU_CHKPMEM_COMMIT();
+    MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_PTL_RPTL_PTINIT);
+    return ret;
+
+  fn_fail:
+    if (mpi_errno)
+        ret = PTL_FAIL;
+    MPIU_CHKPMEM_REAP();
+    goto fn_exit;
+}
+
+
+#undef FUNCNAME
+#define FUNCNAME MPID_nem_ptl_rptl_ptfini
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+int MPID_nem_ptl_rptl_ptfini(ptl_pt_index_t pt_index)
+{
+    int i;
+    int ret = PTL_OK;
+    struct rptl *rptl;
+    MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_PTL_RPTL_PTFINI);
+
+    MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_PTL_RPTL_PTFINI);
+
+    /* find the right rptl */
+    for (rptl = rptl_info.rptl_list; rptl && rptl->data.pt != pt_index; rptl = rptl->next);
+    assert(rptl);
+
+    /* free control portals that were created */
+    if (rptl->control.pt != PTL_PT_ANY) {
+        for (i = 0; i < rptl_info.world_size * 2; i++) {
+            ret = PtlMEUnlink(rptl->control.me[i]);
+            RPTLU_ERR_POP(ret, "Error unlinking control buffers\n");
+        }
+        MPIU_Free(rptl->control.me);
+    }
+
+    MPL_DL_DELETE(rptl_info.rptl_list, rptl);
+    MPIU_Free(rptl);
+
+  fn_exit:
+    MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_PTL_RPTL_PTFINI);
+    return ret;
+
+  fn_fail:
+    goto fn_exit;
+}
diff --git a/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl_op.c b/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl_op.c
new file mode 100644
index 0000000..44a287c
--- /dev/null
+++ b/src/mpid/ch3/channels/nemesis/netmod/portals4/rptl_op.c
@@ -0,0 +1,65 @@
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ *  (C) 2014 by Argonne National Laboratory.
+ *      See COPYRIGHT in top-level directory.
+ */
+
+#include "ptl_impl.h"
+#include "rptl.h"
+
+#undef FUNCNAME
+#define FUNCNAME rptli_op_alloc
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+int rptli_op_alloc(struct rptl_op **op, struct rptl_target *target)
+{
+    int ret = PTL_OK;
+    struct rptl_op_pool_segment *op_segment;
+    int mpi_errno = MPI_SUCCESS;
+    int i;
+    MPIU_CHKPMEM_DECL(1);
+    MPIDI_STATE_DECL(MPID_STATE_RPTLI_OP_ALLOC);
+
+    MPIDI_FUNC_ENTER(MPID_STATE_RPTLI_OP_ALLOC);
+
+    assert(target);
+
+    if (target->op_pool == NULL) {
+        MPIU_CHKPMEM_MALLOC(op_segment, struct rptl_op_pool_segment *, sizeof(struct rptl_op_pool_segment),
+                            mpi_errno, "op pool segment");
+        MPL_DL_APPEND(target->op_segment_list, op_segment);
+
+        for (i = 0; i < RPTL_OP_POOL_SEGMENT_COUNT; i++)
+            MPL_DL_APPEND(target->op_pool, &op_segment->op[i]);
+    }
+
+    *op = target->op_pool;
+    MPL_DL_DELETE(target->op_pool, *op);
+
+  fn_exit:
+    MPIU_CHKPMEM_COMMIT();
+    MPIDI_FUNC_EXIT(MPID_STATE_RPTLI_OP_ALLOC);
+    return ret;
+
+  fn_fail:
+    if (mpi_errno)
+        ret = PTL_FAIL;
+    MPIU_CHKPMEM_REAP();
+    goto fn_exit;
+}
+
+
+#undef FUNCNAME
+#define FUNCNAME rptli_op_free
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+void rptli_op_free(struct rptl_op *op)
+{
+    MPIDI_STATE_DECL(MPID_STATE_RPTLI_OP_FREE);
+
+    MPIDI_FUNC_ENTER(MPID_STATE_RPTLI_OP_FREE);
+
+    MPL_DL_APPEND(op->target->op_pool, op);
+
+    MPIDI_FUNC_EXIT(MPID_STATE_RPTLI_OP_FREE);
+}

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

Summary of changes:
 .../channels/nemesis/netmod/portals4/Makefile.mk   |    4 +-
 .../ch3/channels/nemesis/netmod/portals4/rptl.c    |  441 +++-----------------
 .../ch3/channels/nemesis/netmod/portals4/rptl.h    |   26 +-
 .../channels/nemesis/netmod/portals4/rptl_init.c   |  235 +++++++++++
 .../ch3/channels/nemesis/netmod/portals4/rptl_op.c |   65 +++
 5 files changed, 389 insertions(+), 382 deletions(-)
 create mode 100644 src/mpid/ch3/channels/nemesis/netmod/portals4/rptl_init.c
 create mode 100644 src/mpid/ch3/channels/nemesis/netmod/portals4/rptl_op.c


hooks/post-receive
-- 
MPICH primary repository


More information about the commits mailing list