File: topo.h

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 (290 lines) | stat: -rw-r--r-- 11,750 bytes parent folder | download | duplicates (2)
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
/*
 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
 *                         University Research and Technology
 *                         Corporation.  All rights reserved.
 * Copyright (c) 2004-2005 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$
 */

#ifndef MCA_TOPO_H
#define MCA_TOPO_H

#include "ompi_config.h"

#include "mpi.h"
#include "opal/mca/mca.h"
#include "opal/mca/base/base.h"

/*
 * ******************************************************************
 * ********** Use in components that are of type topo v1.0.0 ********
 * ******************************************************************
 */
#define MCA_TOPO_BASE_VERSION_1_0_0 \
  /* topo v1.0 is chained to MCA v1.0 */ \
  MCA_BASE_VERSION_1_0_0, \
  /* topo v1.0 */ \
  "topo", 1, 0, 0
/*
 * ******************************************************************
 * **************************** Macro ends **************************
 * ******************************************************************
 */

/*
 * These are the component function prototypes. These function pointers
 * go into the component structure. These functions (query() and finalize()
 * are called during topo_base_select(). Each component is query() ied
 * and subsequently, all the unselected components are finalize() 'ed 
 * so that any *stuff* they did during query() can be undone. By
 * similar logic, finalize() is also called on the component which
 * was selected when the communicator is being destroyed.
 *
 * So, to sum it up, every component carries 4 functions:
 * 1. open() - called during MPI_INIT
 * 2. close() - called during MPI_FINALIZE
 * 3. query() - called to select a particular component
 * 4. finalize() - called when actions taken during query have 
 *                 to be undone
 */

/*
 * **************** component struct *******************************
 * *********** These functions go in the component struct **********
 * **************** component struct *******************************
 */ 
typedef int (*mca_topo_base_component_init_query_1_0_0_fn_t)
  (bool enable_progress_threads,
   bool enable_mpi_threads);

typedef struct mca_topo_base_module_1_0_0_t*
  (*mca_topo_base_component_comm_query_1_0_0_fn_t) (int *priority);
                                            
                            
typedef int (*mca_topo_base_component_comm_unquery_1_0_0_fn_t) 
  (struct ompi_communicator_t *comm);

/*
 * ****************** component struct ******************************
 * Structure for topo v1.0.0 components.This is chained to MCA v1.0.0
 * ****************** component struct ******************************
 */  
struct mca_topo_base_component_1_0_0_t {
    mca_base_component_t topom_version;
    mca_base_component_data_1_0_0_t topom_data;

    mca_topo_base_component_init_query_1_0_0_fn_t topom_init_query;
    mca_topo_base_component_comm_query_1_0_0_fn_t topom_comm_query;
    mca_topo_base_component_comm_unquery_1_0_0_fn_t topom_comm_unquery;
};
typedef struct mca_topo_base_component_1_0_0_t mca_topo_base_component_1_0_0_t;       
typedef mca_topo_base_component_1_0_0_t mca_topo_base_component_t;

/*
 * ******************************************************************
 * *********************** component struct ends here ***************
 * ******************************************************************
 */ 
/*
 * ******************************************************************
 * *********************** information structure  *******************
 * Note for component authors:
 * If you find that this is not the most convinient form of representing
 * your topology, then please feel free to define your own structure in 
 * which this structure is the first element. That way, type casting can 
 * used to communicate between 2 different topo components. Note that this 
 * representation must be filled up no matter what the actual topo
 * structure might be
 * ******************************************************************
 */ 

struct mca_topo_base_comm_1_0_0_t {

    /* The first section represents data which is passed on to the 
     * structure by the user when creating the topology. This info
     * is cached on so that if required another component can create the
     * topology again when comm_dup fails to pick the same component */

     int mtc_ndims_or_nnodes; /**< Number of cart dimensions */
     int *mtc_dims_or_index; /**< Cart dimensions */
     int *mtc_periods_or_edges; /**< whether this was a periodic cart */
     bool mtc_reorder; /**< Whether the re-ordering is allowed */

    /* The second section is used by the unity component since it does not 
     * hang its own structure off the communicator. Any component which wishes
     * to use the base/topo_base* functions to fill in their unimplemented
     * functions should and must fill this portion up */

     int *mtc_coords; /**< Cart coordinates */
};
typedef struct mca_topo_base_comm_1_0_0_t mca_topo_base_comm_1_0_0_t;
typedef mca_topo_base_comm_1_0_0_t mca_topo_base_comm_t;

/*
 * ******************************************************************
 * *********************** information structure   ******************
 * ******************************************************************
 */ 

struct ompi_proc_t;

/*
 * ***********************************************************************
 * ************************  Interface function definitions **************
 * These are the typedefs for the function pointers to various topology
 * backend functions which will be used by the various topology components
 * ***********************************************************************
 */
typedef int (*mca_topo_base_module_init_1_0_0_fn_t)
  (struct ompi_communicator_t *comm);
            
typedef int (*mca_topo_base_module_finalize_1_0_0_fn_t)
  (struct ompi_communicator_t *comm);

typedef int (*mca_topo_base_module_cart_coords_fn_t) 
                    (struct ompi_communicator_t *comm, 
                     int rank, 
                     int maxdims, 
                     int *coords);

typedef int (*mca_topo_base_module_cart_create_fn_t)
                    (mca_topo_base_comm_t *topo_data,
                     int *proc_count, 
                     struct ompi_proc_t **proc_pointers,
                     int *new_rank,
                     int ndims, 
                     int *dims, 
                     int *periods, 
                     bool redorder);

typedef int (*mca_topo_base_module_cart_get_fn_t)
                    (struct ompi_communicator_t *comm, 
                     int maxdims, 
                     int *dims,
                     int *periods, 
                     int *coords);

typedef int (*mca_topo_base_module_cartdim_get_fn_t)
                    (struct ompi_communicator_t *comm,
                     int *ndims);

typedef int (*mca_topo_base_module_cart_map_fn_t)
                    (struct ompi_communicator_t *comm, 
                     int ndims, 
                     int *dims,
                     int *periods, 
                     int *newrank);

typedef int (*mca_topo_base_module_cart_rank_fn_t)
                    (struct ompi_communicator_t *comm, 
                     int *coords, 
                     int *rank);

typedef int (*mca_topo_base_module_cart_shift_fn_t)
                    (struct ompi_communicator_t *comm, 
                     int direction, 
                     int disp,
                     int *rank_source, 
                     int *rank_dest);

typedef int (*mca_topo_base_module_cart_sub_fn_t)
                    (struct ompi_communicator_t *comm, 
                     int *remain_dims, 
                     struct ompi_communicator_t ** new_comm);

typedef int (*mca_topo_base_module_graph_create_fn_t)
                    (mca_topo_base_comm_t *topo_data, 
                     int *proc_count,
                     struct ompi_proc_t **proc_pointers,
                     int *new_rank,
                     int nnodes, 
                     int *index, 
                     int *edges, 
                     bool reorder);

typedef int (*mca_topo_base_module_graph_get_fn_t)
                    (struct ompi_communicator_t *comm, 
                     int maxindex, 
                     int maxedges, 
                     int *index, 
                     int *edges);

typedef int (*mca_topo_base_module_graph_map_fn_t)
                    (struct ompi_communicator_t *comm, 
                     int nnodes, 
                     int *index, 
                     int *edges, 
                     int *newrank);

typedef int (*mca_topo_base_module_graphdims_get_fn_t)
                    (struct ompi_communicator_t *comm, 
                     int *nnodes, 
                     int *nnedges);

typedef int (*mca_topo_base_module_graph_neighbors_fn_t)
                    (struct ompi_communicator_t *comm, 
                     int rank, 
                     int maxneighbors, 
                     int *neighbors);

typedef int (*mca_topo_base_module_graph_neighbors_count_fn_t)
                    (struct ompi_communicator_t *comm, 
                     int rank, 
                     int *nneighbors);

/*
 * ***********************************************************************
 * ******************** Interface function definitions end  **************
 * ***********************************************************************
 */ 

/*
 * ***********************************************************************
 * ***************************  module structure *************************
 * ***********************************************************************
 */ 
struct mca_topo_base_module_1_0_0_t {
    /* 
     * Per-communicator initialization function. This is called only
     * on the module which is selected. The finalize corresponding to
     * this function is present on the component struct above 
     */
    mca_topo_base_module_init_1_0_0_fn_t topo_module_init;
    mca_topo_base_module_finalize_1_0_0_fn_t topo_module_finalize;

    /* Graph related functions */
    mca_topo_base_module_cart_coords_fn_t topo_cart_coords;
    mca_topo_base_module_cart_create_fn_t topo_cart_create;
    mca_topo_base_module_cart_get_fn_t topo_cart_get;
    mca_topo_base_module_cartdim_get_fn_t topo_cartdim_get;
    mca_topo_base_module_cart_map_fn_t topo_cart_map;
    mca_topo_base_module_cart_rank_fn_t topo_cart_rank;
    mca_topo_base_module_cart_shift_fn_t topo_cart_shift;
    mca_topo_base_module_cart_sub_fn_t topo_cart_sub;
    mca_topo_base_module_graph_create_fn_t topo_graph_create;
    mca_topo_base_module_graph_get_fn_t topo_graph_get;
    mca_topo_base_module_graph_map_fn_t topo_graph_map;
    mca_topo_base_module_graphdims_get_fn_t topo_graphdims_get;
    mca_topo_base_module_graph_neighbors_fn_t topo_graph_neighbors;
    mca_topo_base_module_graph_neighbors_count_fn_t topo_graph_neighbors_count;
};
typedef struct mca_topo_base_module_1_0_0_t mca_topo_base_module_1_0_0_t;
typedef mca_topo_base_module_1_0_0_t mca_topo_base_module_t;
/*
 * ***********************************************************************
 * *******************  component actions structure ends *****************
 * ***********************************************************************
 */ 

    
#endif /* MCA_TOPO_H */