root/ompi/mca/topo/base/topo_base_frame.c

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

DEFINITIONS

This source file includes following definitions.
  1. mca_topo_base_module_construct
  2. mca_topo_base_module_destruct
  3. mca_topo_base_close
  4. mca_topo_base_open
  5. mca_topo_base_neighbor_count

   1 /*
   2  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2013 The University of Tennessee and The University
   6  *                         of Tennessee Research Foundation.  All rights
   7  *                         reserved.
   8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
   9  *                         University of Stuttgart.  All rights reserved.
  10  * Copyright (c) 2004-2005 The Regents of the University of California.
  11  *                         All rights reserved.
  12  * Copyright (c) 2012-2013 Los Alamos National Security, Inc.  All rights reserved.
  13  * Copyright (c) 2012-2013 Inria.  All rights reserved.
  14  * Copyright (c) 2014      Research Organization for Information Science
  15  *                         and Technology (RIST). All rights reserved.
  16  * $COPYRIGHT$
  17  *
  18  * Additional copyrights may follow
  19  *
  20  * $HEADER$
  21  */
  22 
  23 #include "ompi_config.h"
  24 
  25 #include <stdio.h>
  26 
  27 #include "ompi/constants.h"
  28 #include "opal/class/opal_list.h"
  29 #include "opal/util/output.h"
  30 #include "ompi/mca/mca.h"
  31 #include "opal/mca/base/base.h"
  32 
  33 
  34 #include "ompi/mca/topo/base/base.h"
  35 
  36 /*
  37  * The static-component.h is generated by the configure script. It contains
  38  * statements and the definition of an array of pointers to each component's
  39  * public mca_base_component_t struct.
  40  */
  41 #include "ompi/mca/topo/base/static-components.h"
  42 
  43 static void mca_topo_base_module_construct(mca_topo_base_module_t * topo) {
  44     memset(&(topo->mtc), 0, sizeof(topo->mtc));
  45 }
  46 
  47 static void mca_topo_base_module_destruct(mca_topo_base_module_t * topo) {
  48     /* topo->mtc is an union of pointers to opal_object_t.
  49        In order to release it, we just have to call OBJ_RELEASE on any of the member,
  50        (cart in this case) and the appropriate object destructor will be called */
  51     if (NULL != topo->mtc.cart) {
  52         OBJ_RELEASE(topo->mtc.cart);
  53     }
  54 }
  55 
  56 OBJ_CLASS_INSTANCE(mca_topo_base_module_t, opal_object_t,
  57                    mca_topo_base_module_construct,
  58                    mca_topo_base_module_destruct);
  59 
  60 static int mca_topo_base_close(void)
  61 {
  62     return mca_base_framework_components_close(&ompi_topo_base_framework, NULL);
  63 }
  64 
  65 /**
  66  * Function for finding and opening either all the MCA topo components, or
  67  * the one that specifically requested via a MCA parameter.
  68  */
  69 static int mca_topo_base_open(mca_base_open_flag_t flags)
  70 {
  71     return mca_base_framework_components_open(&ompi_topo_base_framework, flags);
  72 }
  73 
  74 int mca_topo_base_neighbor_count (ompi_communicator_t *comm, int *indegree, int *outdegree) {
  75   if (!OMPI_COMM_IS_TOPO(comm)) {
  76     return OMPI_ERR_BAD_PARAM;
  77   }
  78 
  79   if (OMPI_COMM_IS_CART(comm)) {
  80     /* cartesian */
  81     /* outdegree is always 2*ndims because we need to iterate over
  82        empty buffers for MPI_PROC_NULL */
  83     *outdegree = *indegree = 2 * comm->c_topo->mtc.cart->ndims;
  84   } else if (OMPI_COMM_IS_GRAPH(comm)) {
  85     /* graph */
  86     int rank, nneighbors;
  87 
  88     rank = ompi_comm_rank (comm);
  89     mca_topo_base_graph_neighbors_count (comm, rank, &nneighbors);
  90 
  91     *outdegree = *indegree = nneighbors;
  92   } else if (OMPI_COMM_IS_DIST_GRAPH(comm)) {
  93     /* graph */
  94     *indegree = comm->c_topo->mtc.dist_graph->indegree;
  95     *outdegree = comm->c_topo->mtc.dist_graph->outdegree;
  96   }
  97 
  98   return OMPI_SUCCESS;
  99 }
 100 
 101 MCA_BASE_FRAMEWORK_DECLARE(ompi, topo, "OMPI Topo", NULL,
 102                            mca_topo_base_open, mca_topo_base_close,
 103                            mca_topo_base_static_components, 0);
 104 

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