root/ompi/request/request.c

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

DEFINITIONS

This source file includes following definitions.
  1. ompi_request_construct
  2. ompi_request_destruct
  3. ompi_request_null_free
  4. ompi_request_null_cancel
  5. ompi_request_empty_free
  6. ompi_request_persistent_noop_free
  7. ompi_request_init
  8. ompi_request_finalize
  9. ompi_request_persistent_noop_create

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   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-2017 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2004-2007 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) 2006-2013 Cisco Systems, Inc.  All rights reserved.
  14  * Copyright (c) 2009      Sun Microsystems, Inc.  All rights reserved.
  15  * Copyright (c) 2012      Oak Ridge National Labs.  All rights reserved.
  16  * Copyright (c) 2015      Los Alamos National Security, LLC.  All rights
  17  *                         reserved.
  18  * Copyright (c) 2015      Research Organization for Information Science
  19  *                         and Technology (RIST). All rights reserved.
  20  * Copyright (c) 2018      FUJITSU LIMITED.  All rights reserved.
  21  * $COPYRIGHT$
  22  *
  23  * Additional copyrights may follow
  24  *
  25  * $HEADER$
  26  */
  27 
  28 #include "ompi_config.h"
  29 
  30 #include "ompi/communicator/communicator.h"
  31 #include "opal/class/opal_object.h"
  32 #include "ompi/request/request.h"
  33 #include "ompi/request/request_default.h"
  34 #include "ompi/constants.h"
  35 
  36 opal_pointer_array_t             ompi_request_f_to_c_table = {{0}};
  37 ompi_predefined_request_t        ompi_request_null = {{{{{0}}}}};
  38 ompi_predefined_request_t        *ompi_request_null_addr = &ompi_request_null;
  39 ompi_request_t                   ompi_request_empty = {{{{0}}}};
  40 ompi_status_public_t             ompi_status_empty = {0};
  41 ompi_request_fns_t               ompi_request_functions = {
  42     ompi_request_default_test,
  43     ompi_request_default_test_any,
  44     ompi_request_default_test_all,
  45     ompi_request_default_test_some,
  46     ompi_request_default_wait,
  47     ompi_request_default_wait_any,
  48     ompi_request_default_wait_all,
  49     ompi_request_default_wait_some
  50 };
  51 
  52 static void ompi_request_construct(ompi_request_t* req)
  53 {
  54     /* don't call _INIT, we don't to set the request to _INACTIVE and there will
  55      * be no matching _FINI invocation */
  56     req->req_state        = OMPI_REQUEST_INVALID;
  57     req->req_complete     = false;
  58     req->req_persistent   = false;
  59     req->req_start        = NULL;
  60     req->req_free         = NULL;
  61     req->req_cancel       = NULL;
  62     req->req_complete_cb  = NULL;
  63     req->req_complete_cb_data = NULL;
  64     req->req_f_to_c_index = MPI_UNDEFINED;
  65     req->req_mpi_object.comm = (struct ompi_communicator_t*) NULL;
  66 }
  67 
  68 static void ompi_request_destruct(ompi_request_t* req)
  69 {
  70     assert( MPI_UNDEFINED == req->req_f_to_c_index );
  71     assert( OMPI_REQUEST_INVALID == req->req_state );
  72 }
  73 
  74 static int ompi_request_null_free(ompi_request_t** request)
  75 {
  76     return OMPI_SUCCESS;
  77 }
  78 
  79 static int ompi_request_null_cancel(ompi_request_t* request, int flag)
  80 {
  81     return OMPI_SUCCESS;
  82 }
  83 
  84 static int ompi_request_empty_free(ompi_request_t** request)
  85 {
  86     *request = &ompi_request_null.request;
  87     return OMPI_SUCCESS;
  88 }
  89 
  90 static int ompi_request_persistent_noop_free(ompi_request_t** request)
  91 {
  92     OMPI_REQUEST_FINI(*request);
  93     (*request)->req_state = OMPI_REQUEST_INVALID;
  94     OBJ_RELEASE(*request);
  95     *request = &ompi_request_null.request;
  96     return OMPI_SUCCESS;
  97 }
  98 
  99 
 100 OBJ_CLASS_INSTANCE(
 101     ompi_request_t,
 102     opal_free_list_item_t,
 103     ompi_request_construct,
 104     ompi_request_destruct);
 105 
 106 
 107 int ompi_request_init(void)
 108 {
 109 
 110     OBJ_CONSTRUCT(&ompi_request_null, ompi_request_t);
 111     OBJ_CONSTRUCT(&ompi_request_f_to_c_table, opal_pointer_array_t);
 112     if( OPAL_SUCCESS != opal_pointer_array_init(&ompi_request_f_to_c_table,
 113                                                 0, OMPI_FORTRAN_HANDLE_MAX, 32) ) {
 114         return OMPI_ERROR;
 115     }
 116     ompi_request_null.request.req_type = OMPI_REQUEST_NULL;
 117     ompi_request_null.request.req_status.MPI_SOURCE = MPI_ANY_SOURCE;
 118     ompi_request_null.request.req_status.MPI_TAG = MPI_ANY_TAG;
 119     ompi_request_null.request.req_status.MPI_ERROR = MPI_SUCCESS;
 120     ompi_request_null.request.req_status._ucount = 0;
 121     ompi_request_null.request.req_status._cancelled = 0;
 122 
 123     ompi_request_null.request.req_complete = REQUEST_COMPLETED;
 124     ompi_request_null.request.req_state = OMPI_REQUEST_INACTIVE;
 125     ompi_request_null.request.req_persistent = false;
 126     ompi_request_null.request.req_f_to_c_index =
 127         opal_pointer_array_add(&ompi_request_f_to_c_table, &ompi_request_null);
 128     ompi_request_null.request.req_start = NULL; /* should not be called */
 129     ompi_request_null.request.req_free = ompi_request_null_free;
 130     ompi_request_null.request.req_cancel = ompi_request_null_cancel;
 131     ompi_request_null.request.req_mpi_object.comm = &ompi_mpi_comm_world.comm;
 132 
 133     if (0 != ompi_request_null.request.req_f_to_c_index) {
 134         return OMPI_ERR_REQUEST;
 135     }
 136 
 137     /* We need a way to distinguish between the user provided
 138      * MPI_REQUEST_NULL to MPI_Wait* and a non-active (MPI_PROC_NULL)
 139      * request passed to any P2P non-blocking function.
 140      *
 141      * The main difference to ompi_request_null is
 142      * req_state being OMPI_REQUEST_ACTIVE, so that MPI_Waitall
 143      * does not set the status to ompi_status_empty and the different
 144      * req_free function, which resets the
 145      * request to MPI_REQUEST_NULL.
 146      * The req_cancel function need not be changed.
 147      */
 148     OBJ_CONSTRUCT(&ompi_request_empty, ompi_request_t);
 149     ompi_request_empty.req_type = OMPI_REQUEST_NULL;
 150     ompi_request_empty.req_status.MPI_SOURCE = MPI_PROC_NULL;
 151     ompi_request_empty.req_status.MPI_TAG = MPI_ANY_TAG;
 152     ompi_request_empty.req_status.MPI_ERROR = MPI_SUCCESS;
 153     ompi_request_empty.req_status._ucount = 0;
 154     ompi_request_empty.req_status._cancelled = 0;
 155 
 156     ompi_request_empty.req_complete = REQUEST_COMPLETED;
 157     ompi_request_empty.req_state = OMPI_REQUEST_ACTIVE;
 158     ompi_request_empty.req_persistent = false;
 159     ompi_request_empty.req_f_to_c_index =
 160         opal_pointer_array_add(&ompi_request_f_to_c_table, &ompi_request_empty);
 161     ompi_request_empty.req_start = NULL; /* should not be called */
 162     ompi_request_empty.req_free = ompi_request_empty_free;
 163     ompi_request_empty.req_cancel = ompi_request_null_cancel;
 164     ompi_request_empty.req_mpi_object.comm = &ompi_mpi_comm_world.comm;
 165 
 166     if (1 != ompi_request_empty.req_f_to_c_index) {
 167         return OMPI_ERR_REQUEST;
 168     }
 169 
 170     ompi_status_empty.MPI_SOURCE = MPI_ANY_SOURCE;
 171     ompi_status_empty.MPI_TAG = MPI_ANY_TAG;
 172     ompi_status_empty.MPI_ERROR = MPI_SUCCESS;
 173     ompi_status_empty._ucount = 0;
 174     ompi_status_empty._cancelled = 0;
 175 
 176     return OMPI_SUCCESS;
 177 }
 178 
 179 
 180 int ompi_request_finalize(void)
 181 {
 182     OMPI_REQUEST_FINI( &ompi_request_null.request );
 183     OBJ_DESTRUCT( &ompi_request_null.request );
 184     OMPI_REQUEST_FINI( &ompi_request_empty );
 185     OBJ_DESTRUCT( &ompi_request_empty );
 186     OBJ_DESTRUCT( &ompi_request_f_to_c_table );
 187     return OMPI_SUCCESS;
 188 }
 189 
 190 
 191 int ompi_request_persistent_noop_create(ompi_request_t** request)
 192 {
 193     ompi_request_t *req;
 194 
 195     req = OBJ_NEW(ompi_request_t);
 196     if (NULL == req) {
 197         return OMPI_ERR_OUT_OF_RESOURCE;
 198     }
 199 
 200     /* Other fields were initialized by the constructor for
 201        ompi_request_t */
 202     req->req_type = OMPI_REQUEST_NOOP;
 203     req->req_status = ompi_request_empty.req_status;
 204     req->req_complete = REQUEST_COMPLETED;
 205     req->req_state = OMPI_REQUEST_INACTIVE;
 206     req->req_persistent = true;
 207     req->req_free = ompi_request_persistent_noop_free;
 208 
 209     *request = req;
 210     return OMPI_SUCCESS;
 211 }

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