This source file includes following definitions.
- mca_topo_base_module_construct
- mca_topo_base_module_destruct
- mca_topo_base_close
- mca_topo_base_open
- mca_topo_base_neighbor_count
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 
  17 
  18 
  19 
  20 
  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 
  38 
  39 
  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     
  49 
  50 
  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 
  67 
  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     
  81     
  82 
  83     *outdegree = *indegree = 2 * comm->c_topo->mtc.cart->ndims;
  84   } else if (OMPI_COMM_IS_GRAPH(comm)) {
  85     
  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     
  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