root/ompi/mca/common/ompio/common_ompio_request.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. mca_common_ompio_request_free
  2. mca_common_ompio_request_cancel
  3. mca_common_ompio_request_construct
  4. mca_common_ompio_request_destruct
  5. mca_common_ompio_request_init
  6. mca_common_ompio_request_fini
  7. mca_common_ompio_request_alloc
  8. mca_common_ompio_register_progress
  9. mca_common_ompio_progress

   1 /* -*- Mode: C; c-basic-offset:4 ; -*- */
   2 /*
   3  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2016 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
  10  *                         University of Stuttgart.  All rights reserved.
  11  * Copyright (c) 2004-2005 The Regents of the University of California.
  12  *                         All rights reserved.
  13  * Copyright (c) 2008-2019 University of Houston. All rights reserved.
  14  * $COPYRIGHT$
  15  *
  16  * Additional copyrights may follow
  17  *
  18  * $HEADER$
  19  */
  20 
  21 #include "common_ompio_request.h"
  22 #include "common_ompio_buffer.h"
  23 
  24 static void mca_common_ompio_request_construct(mca_ompio_request_t* req);
  25 static void mca_common_ompio_request_destruct(mca_ompio_request_t *req);
  26 
  27 bool mca_common_ompio_progress_is_registered=false;
  28 /*
  29  * Global list of requests for this component
  30  */
  31 opal_list_t mca_common_ompio_pending_requests = {{0}};
  32 
  33 
  34 
  35 static int mca_common_ompio_request_free ( struct ompi_request_t **req)
  36 {
  37     mca_ompio_request_t *ompio_req = ( mca_ompio_request_t *)*req;
  38     if ( NULL != ompio_req->req_tbuf ) {
  39         if ( MCA_OMPIO_REQUEST_READ == ompio_req->req_type ){
  40             struct iovec decoded_iov;
  41             uint32_t iov_count=1;
  42             size_t pos=0;
  43 
  44             decoded_iov.iov_base = ompio_req->req_tbuf;
  45             decoded_iov.iov_len  = ompio_req->req_size;
  46             opal_convertor_unpack (&ompio_req->req_convertor, &decoded_iov, &iov_count, &pos );
  47         }
  48         mca_common_ompio_release_buf ( NULL, ompio_req->req_tbuf );
  49     }
  50     if ( NULL != ompio_req->req_free_fn ) {
  51         ompio_req->req_free_fn (ompio_req );
  52     }
  53     opal_list_remove_item (&mca_common_ompio_pending_requests, &ompio_req->req_item);
  54 
  55     OBJ_RELEASE (*req);
  56     *req = MPI_REQUEST_NULL;
  57     return OMPI_SUCCESS;
  58 }
  59 
  60 static int mca_common_ompio_request_cancel ( struct ompi_request_t *req, int flag)
  61 {
  62     return OMPI_SUCCESS;
  63 }
  64 
  65 OBJ_CLASS_INSTANCE(mca_ompio_request_t, ompi_request_t,
  66                    mca_common_ompio_request_construct,
  67                    mca_common_ompio_request_destruct);
  68 
  69 void mca_common_ompio_request_construct(mca_ompio_request_t* req)
  70 {
  71     OMPI_REQUEST_INIT (&(req->req_ompi), false );
  72     req->req_ompi.req_free   = mca_common_ompio_request_free;
  73     req->req_ompi.req_cancel = mca_common_ompio_request_cancel;
  74     req->req_ompi.req_type   = OMPI_REQUEST_IO;
  75     req->req_data            = NULL;
  76     req->req_tbuf            = NULL;
  77     req->req_size            = 0;
  78     req->req_progress_fn     = NULL;
  79     req->req_free_fn         = NULL;
  80 
  81     OBJ_CONSTRUCT(&req->req_item, opal_list_item_t);
  82     opal_list_append (&mca_common_ompio_pending_requests, &req->req_item);
  83     return;
  84 }
  85 void mca_common_ompio_request_destruct(mca_ompio_request_t* req)
  86 {
  87     OMPI_REQUEST_FINI ( &(req->req_ompi));
  88     OBJ_DESTRUCT (&req->req_item);
  89     if ( NULL != req->req_data ) {
  90         free (req->req_data);
  91     }
  92 
  93     return;
  94 }
  95 
  96 void mca_common_ompio_request_init ( void ) 
  97 {
  98     /* Create the list of pending requests */
  99     OBJ_CONSTRUCT(&mca_common_ompio_pending_requests, opal_list_t);
 100     return;
 101 }
 102 
 103 void mca_common_ompio_request_fini ( void ) 
 104 {
 105     /* Destroy the list of pending requests */
 106     /* JMS: Good opprotunity here to list out all the IO requests that
 107        were not destroyed / completed upon MPI_FINALIZE */
 108 
 109     OBJ_DESTRUCT(&mca_common_ompio_pending_requests);
 110     return;
 111 }
 112 
 113 void mca_common_ompio_request_alloc ( mca_ompio_request_t **req, mca_ompio_request_type_t type )
 114 {
 115     mca_ompio_request_t *ompio_req = NULL;
 116 
 117     ompio_req = OBJ_NEW(mca_ompio_request_t);
 118     ompio_req->req_type = type;
 119     ompio_req->req_ompi.req_state = OMPI_REQUEST_ACTIVE;
 120 
 121     *req=ompio_req;
 122 
 123     return;
 124 }
 125 
 126 void mca_common_ompio_register_progress ( void ) 
 127 {
 128     if ( false == mca_common_ompio_progress_is_registered) {
 129         opal_progress_register (mca_common_ompio_progress);
 130         mca_common_ompio_progress_is_registered=true;
 131     }
 132     return;
 133 }
 134 int mca_common_ompio_progress ( void )
 135 {
 136     mca_ompio_request_t *req=NULL;
 137     opal_list_item_t *litem=NULL;
 138     int completed=0;
 139 
 140     OPAL_LIST_FOREACH(litem, &mca_common_ompio_pending_requests, opal_list_item_t) {
 141         req = GET_OMPIO_REQ_FROM_ITEM(litem);
 142         if( REQUEST_COMPLETE(&req->req_ompi) ) {
 143             continue;
 144         }
 145         if ( NULL != req->req_progress_fn ) {
 146             if ( req->req_progress_fn(req) ) {
 147                 completed++;
 148                 ompi_request_complete (&req->req_ompi, true);
 149                 /* The fbtl progress function is expected to set the
 150                  * status elements
 151                  */
 152             }
 153         }
 154 
 155     }
 156 
 157     return completed;
 158 }

/* [<][>][^][v][top][bottom][index][help] */