File: topo_unity.c

package info (click to toggle)
openmpi 1.2.7~rc2-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 41,300 kB
  • ctags: 24,303
  • sloc: ansic: 224,835; sh: 22,627; makefile: 7,037; cpp: 6,353; asm: 3,547; lex: 528; objc: 383; perl: 348; csh: 89; f90: 49; fortran: 47; tcl: 12
file content (128 lines) | stat: -rw-r--r-- 4,399 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
 *                         University Research and Technology
 *                         Corporation.  All rights reserved.
 * Copyright (c) 2004-2006 The University of Tennessee and The University
 *                         of Tennessee Research Foundation.  All rights
 *                         reserved.
 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 
 *                         University of Stuttgart.  All rights reserved.
 * Copyright (c) 2004-2005 The Regents of the University of California.
 *                         All rights reserved.
 * $COPYRIGHT$
 * 
 * Additional copyrights may follow
 * 
 * $HEADER$
 *
 * These symbols are in a file by themselves to provide nice linker
 * semantics. Since linkers generally pull in symbols by object fules,
 * keeping these symbols as the only symbols in this file prevents
 * utility programs such as "ompi_info" from having to import entire
 * modules just to query their version and parameters
 */
#include "ompi_config.h"


#include <stdio.h>

#include "mpi.h"
#include "ompi/communicator/communicator.h"
#include "ompi/mca/topo/topo.h"
#include "ompi/mca/topo/base/base.h"
#include "ompi/mca/topo/unity/topo_unity.h"

/*
 * *******************************************************************
 * ************************ actions structure ************************
 * *******************************************************************
 */
static mca_topo_base_module_1_0_0_t unity =  {
    mca_topo_unity_module_init, /* initalise after being selected */
    mca_topo_unity_module_finalize, /* close a module on a communicator */
    NULL, /* topo_cart_coords */
    NULL, /* topo_cart_create */
    NULL, /* topo_cart_get */
    NULL, /* topo_cartdim_get */
    mca_topo_unity_cart_map,
    NULL, /* topo_cart_rank */
    NULL, /* topo_cart_shift */
    NULL, /* topo_cart_sub */
    NULL, /* topo_graph_create */
    NULL, /* topo_graph_get */
    mca_topo_unity_graph_map,
    NULL, /* topo_graphdims_get */
    NULL, /* topo_graph_neighbors */
    NULL /* topo_graph_neighbors_count */
};
/*
 * *******************************************************************
 * ************************* structure ends **************************
 * *******************************************************************
 */

int mca_topo_unity_component_init_query(bool enable_progress_threads,
                                        bool enable_mpi_threads)
{
    /* Nothing to do */
   
   return OMPI_SUCCESS;
}      

struct mca_topo_base_module_1_0_0_t *
mca_topo_unity_component_comm_query (int *priority)
{
   /* this is the lowest module on the totem pole */
   *priority = 0;

   /* the check as to whether this is an inter communicator 
    * or and intra communicator has to be done before reaching
    * here. this is my solemn opinion. Therefore I am ignoring 
    * the checks here */
   return &unity;
}

int mca_topo_unity_component_comm_unquery (struct ompi_communicator_t *comm)
{    
   /* This function might be needed for some purposes later. for now it
    * does not have anything to do since there are no steps which need 
    * to be undone if this module is not selected */

   return OMPI_SUCCESS;
}

int mca_topo_unity_module_init (struct ompi_communicator_t *comm)
{
   /* This function is used to initialize the module on the communicator. We
    * need to hang the data off of the communicator. For this we still use the
    * same data structure which was defined in topo.h, mca_topo_comm_1_0_0_t. 
    * There are no additional things which we need. If some other module needs
    * to hang additional data, then it has to have this structure as the first
    * member and then extend. This is a must rule */

   struct mca_topo_base_comm_1_0_0_t *topo_data;

   /* allocate the data */

   comm->c_topo_comm = NULL;
   topo_data = (mca_topo_base_comm_1_0_0_t*)malloc(sizeof(struct mca_topo_base_comm_1_0_0_t));
   if (NULL == topo_data) {
       return OMPI_ERROR;
   }

   comm->c_topo_comm = topo_data;
   return OMPI_SUCCESS;
}

   
int mca_topo_unity_module_finalize (struct ompi_communicator_t *comm) 
{
    /* All we need to do for now is to remove the allocated data */
 
    if (NULL != comm->c_topo_comm) {
        free (comm->c_topo_comm);
        comm->c_topo = NULL;
    }

    return OMPI_SUCCESS;
}