~ubuntu-branches/ubuntu/hardy/openmpi/hardy-updates

« back to all changes in this revision

Viewing changes to ompi/mca/topo/unity/topo_unity.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2006-10-15 00:46:11 UTC
  • Revision ID: james.westby@ubuntu.com-20061015004611-uuhxnaxyjmuxfd5h
Tags: upstream-1.1
ImportĀ upstreamĀ versionĀ 1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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-2005 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$
 
13
 * 
 
14
 * Additional copyrights may follow
 
15
 * 
 
16
 * $HEADER$
 
17
 *
 
18
 * These symbols are in a file by themselves to provide nice linker
 
19
 * semantics. Since linkers generally pull in symbols by object fules,
 
20
 * keeping these symbols as the only symbols in this file prevents
 
21
 * utility programs such as "ompi_info" from having to import entire
 
22
 * modules just to query their version and parameters
 
23
 */
 
24
#include "ompi_config.h"
 
25
 
 
26
 
 
27
#include <stdio.h>
 
28
 
 
29
#include "mpi.h"
 
30
#include "ompi/communicator/communicator.h"
 
31
#include "ompi/mca/topo/topo.h"
 
32
#include "ompi/mca/topo/base/base.h"
 
33
#include "ompi/mca/topo/unity/topo_unity.h"
 
34
 
 
35
/*
 
36
 * *******************************************************************
 
37
 * ************************ actions structure ************************
 
38
 * *******************************************************************
 
39
 */
 
40
static mca_topo_base_module_1_0_0_t unity =  {
 
41
    mca_topo_unity_module_init, /* initalise after being selected */
 
42
    mca_topo_unity_module_finalize, /* close a module on a communicator */
 
43
    NULL, /* topo_cart_coords */
 
44
    NULL, /* topo_cart_create */
 
45
    NULL, /* topo_cart_get */
 
46
    NULL, /* topo_cartdim_get */
 
47
    mca_topo_unity_cart_map,
 
48
    NULL, /* topo_cart_rank */
 
49
    NULL, /* topo_cart_shift */
 
50
    NULL, /* topo_cart_sub */
 
51
    NULL, /* topo_graph_create */
 
52
    NULL, /* topo_graph_get */
 
53
    mca_topo_unity_graph_map,
 
54
    NULL, /* topo_graphdims_get */
 
55
    NULL, /* topo_graph_neighbors */
 
56
    NULL /* topo_graph_neighbors_count */
 
57
};
 
58
/*
 
59
 * *******************************************************************
 
60
 * ************************* structure ends **************************
 
61
 * *******************************************************************
 
62
 */
 
63
 
 
64
int mca_topo_unity_component_init_query(bool enable_progress_threads,
 
65
                                        bool enable_mpi_threads)
 
66
{
 
67
    /* Nothing to do */
 
68
   
 
69
   return OMPI_SUCCESS;
 
70
}      
 
71
 
 
72
struct mca_topo_base_module_1_0_0_t *
 
73
mca_topo_unity_component_comm_query (int *priority)
 
74
{
 
75
   /* this is the lowest module on the totem pole */
 
76
   *priority = 0;
 
77
 
 
78
   /* the check as to whether this is an inter communicator 
 
79
    * or and intra communicator has to be done before reaching
 
80
    * here. this is my solemn opinion. Therefore I am ignoring 
 
81
    * the checks here */
 
82
   return &unity;
 
83
}
 
84
 
 
85
int mca_topo_unity_component_comm_unquery (struct ompi_communicator_t *comm)
 
86
{    
 
87
   /* This function might be needed for some purposes later. for now it
 
88
    * does not have anything to do since there are no steps which need 
 
89
    * to be undone if this module is not selected */
 
90
 
 
91
   return OMPI_SUCCESS;
 
92
}
 
93
 
 
94
int mca_topo_unity_module_init (struct ompi_communicator_t *comm)
 
95
{
 
96
   /* This function is used to initialize the module on the communicator. We
 
97
    * need to hang the data off of the communicator. For this we still use the
 
98
    * same data structure which was defined in topo.h, mca_topo_comm_1_0_0_t. 
 
99
    * There are no additional things which we need. If some other module needs
 
100
    * to hang additional data, then it has to have this structure as the first
 
101
    * member and then extend. This is a must rule */
 
102
 
 
103
   struct mca_topo_base_comm_1_0_0_t *topo_data;
 
104
 
 
105
   /* allocate the data */
 
106
 
 
107
   comm->c_topo_comm = NULL;
 
108
   topo_data = malloc(sizeof(struct mca_topo_base_comm_1_0_0_t));
 
109
   if (NULL == topo_data) {
 
110
       return OMPI_ERROR;
 
111
   }
 
112
 
 
113
   comm->c_topo_comm = topo_data;
 
114
   return OMPI_SUCCESS;
 
115
}
 
116
 
 
117
   
 
118
int mca_topo_unity_module_finalize (struct ompi_communicator_t *comm) 
 
119
{
 
120
    /* All we need to do for now is to remove the allocated data */
 
121
 
 
122
    if (NULL != comm->c_topo_comm) {
 
123
        free (comm->c_topo_comm);
 
124
        comm->c_topo = NULL;
 
125
    }
 
126
 
 
127
    return OMPI_SUCCESS;
 
128
}