root/ompi/mca/coll/base/coll_base_frame.c

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

DEFINITIONS

This source file includes following definitions.
  1. coll_base_module_construct
  2. coll_base_module_destruct
  3. coll_base_comm_construct
  4. coll_base_comm_destruct
  5. ompi_coll_base_comm_get_reqs

   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-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) 2013      Los Alamos National Security, LLC. All rights
  14  *                         reserved.
  15  * Copyright (c) 2014      Research Organization for Information Science
  16  *                         and Technology (RIST). All rights reserved.
  17  * Copyright (c) 2017      IBM Corporation. All rights reserved.
  18  * $COPYRIGHT$
  19  *
  20  * Additional copyrights may follow
  21  *
  22  * $HEADER$
  23  */
  24 
  25 
  26 #include "ompi_config.h"
  27 #include <stdio.h>
  28 
  29 #include "ompi/constants.h"
  30 #include "ompi/mca/mca.h"
  31 #include "opal/util/output.h"
  32 #include "opal/mca/base/base.h"
  33 
  34 
  35 #include "ompi/mca/coll/coll.h"
  36 #include "ompi/mca/coll/base/base.h"
  37 #include "ompi/mca/coll/base/coll_base_functions.h"
  38 
  39 /*
  40  * The following file was created by configure.  It contains extern
  41  * statements and the definition of an array of pointers to each
  42  * component's public mca_base_component_t struct.
  43  */
  44 #include "ompi/mca/coll/base/static-components.h"
  45 
  46 /*
  47  * Ensure all function pointers are NULL'ed out to start with
  48  */
  49 static void coll_base_module_construct(mca_coll_base_module_t *m)
  50 {
  51     /* zero out all functions */
  52     memset ((char *) m + sizeof (m->super), 0, sizeof (*m) - sizeof (m->super));
  53     m->coll_module_disable = NULL;
  54     m->base_data = NULL;
  55 }
  56 
  57 static void
  58 coll_base_module_destruct(mca_coll_base_module_t *module)
  59 {
  60     if (NULL != module->base_data) {
  61         OBJ_RELEASE(module->base_data);
  62     }
  63 }
  64 
  65 OBJ_CLASS_INSTANCE(mca_coll_base_module_t, opal_object_t,
  66                    coll_base_module_construct, coll_base_module_destruct);
  67 
  68 
  69 static void
  70 coll_base_comm_construct(mca_coll_base_comm_t *data)
  71 {
  72     memset ((char *) data + sizeof (data->super), 0, sizeof (*data) - sizeof (data->super));
  73 }
  74 
  75 static void
  76 coll_base_comm_destruct(mca_coll_base_comm_t *data)
  77 {
  78     if( NULL != data->mcct_reqs ) {
  79         ompi_coll_base_free_reqs( data->mcct_reqs, data->mcct_num_reqs );
  80         free(data->mcct_reqs);
  81         data->mcct_reqs = NULL;
  82         data->mcct_num_reqs = 0;
  83     }
  84     assert(0 == data->mcct_num_reqs);
  85 
  86     /* free any cached information that has been allocated */
  87     if (data->cached_ntree) { /* destroy general tree if defined */
  88         ompi_coll_base_topo_destroy_tree (&data->cached_ntree);
  89     }
  90     if (data->cached_bintree) { /* destroy bintree if defined */
  91         ompi_coll_base_topo_destroy_tree (&data->cached_bintree);
  92     }
  93     if (data->cached_bmtree) { /* destroy bmtree if defined */
  94         ompi_coll_base_topo_destroy_tree (&data->cached_bmtree);
  95     }
  96     if (data->cached_in_order_bmtree) { /* destroy bmtree if defined */
  97         ompi_coll_base_topo_destroy_tree (&data->cached_in_order_bmtree);
  98     }
  99     if (data->cached_kmtree) { /* destroy kmtree if defined */
 100         ompi_coll_base_topo_destroy_tree (&data->cached_kmtree);
 101     }
 102     if (data->cached_chain) { /* destroy general chain if defined */
 103         ompi_coll_base_topo_destroy_tree (&data->cached_chain);
 104     }
 105     if (data->cached_pipeline) { /* destroy pipeline if defined */
 106         ompi_coll_base_topo_destroy_tree (&data->cached_pipeline);
 107     }
 108     if (data->cached_in_order_bintree) { /* destroy in order bintree if defined */
 109         ompi_coll_base_topo_destroy_tree (&data->cached_in_order_bintree);
 110     }
 111 }
 112 
 113 OBJ_CLASS_INSTANCE(mca_coll_base_comm_t, opal_object_t,
 114                    coll_base_comm_construct, coll_base_comm_destruct);
 115 
 116 ompi_request_t** ompi_coll_base_comm_get_reqs(mca_coll_base_comm_t* data, int nreqs)
 117 {
 118     if( 0 == nreqs ) return NULL;
 119 
 120     if( data->mcct_num_reqs < nreqs ) {
 121         data->mcct_reqs = (ompi_request_t**)realloc(data->mcct_reqs, sizeof(ompi_request_t*) * nreqs);
 122 
 123         if( NULL != data->mcct_reqs ) {
 124             for( int i = data->mcct_num_reqs; i < nreqs; i++ )
 125                 data->mcct_reqs[i] = MPI_REQUEST_NULL;
 126             data->mcct_num_reqs = nreqs;
 127         } else
 128             data->mcct_num_reqs = 0;  /* nothing to return */
 129     }
 130     return data->mcct_reqs;
 131 }
 132 
 133 MCA_BASE_FRAMEWORK_DECLARE(ompi, coll, "Collectives", NULL, NULL, NULL,
 134                            mca_coll_base_static_components, 0);

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