~james-page/ubuntu/precise/openmpi1.5/new

« back to all changes in this revision

Viewing changes to ompi/mca/pml/csum/pml_csum_component.c

  • Committer: Bazaar Package Importer
  • Author(s): Manuel Prinz
  • Date: 2009-04-23 14:01:21 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090423140121-vsi3pqa6g30j4qiy
Tags: 1.3.2-1
* New upstream release. (Closes: #520597, #515116)
  - Manpage and VampirTrace patches removed, included upstream.
* Fixed build issues on Alpha. Huge thanks to Arthur Loiret for providing
  access to his machines for testing! (Closes: #510845, #517543)
* Fixed build issues on Sparc. (Closes: #519725)
* Fixed manpage-has-errors-from-man lintian warnings.
* Faked SONAME change by renaming library package. (Closes: #512616)
* Made libopenmpi-dev depend on libibverbs-dev. (Closes: #522153)
* Support for "nocheck" build option in debian/rules.
* Updated Standards-Version in debian/control.
* Changed section of libopenmpi-dbg to "debug".
* Updated debian/copyright.

* Dirk Eddelbuettel removed himself from Uploaders. The team thanks Dirk
  for his long-term contribution and effort to get Open MPI back to life.
  I personally thank Dirk for encouraging me to become a Debian Developer
  and his support and mentoring on that way and beyond.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; c-basic-offset:4 ; -*- */
 
2
/*
 
3
 * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
 
4
 *                         University Research and Technology
 
5
 *                         Corporation.  All rights reserved.
 
6
 * Copyright (c) 2004-2009 The University of Tennessee and The University
 
7
 *                         of Tennessee Research Foundation.  All rights
 
8
 *                         reserved.
 
9
 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 
 
10
 *                         University of Stuttgart.  All rights reserved.
 
11
 * Copyright (c) 2004-2005 The Regents of the University of California.
 
12
 *                         All rights reserved.
 
13
 * Copyright (c) 2009      IBM Corporation.  All rights reserved.
 
14
 * Copyright (c) 2009      Los Alamos National Security, LLC.  All rights
 
15
 *                         reserved. 
 
16
 * Copyright (c) 2007-2009 Cisco Systems, Inc.  All rights reserved.
 
17
 * $COPYRIGHT$
 
18
 * 
 
19
 * Additional copyrights may follow
 
20
 * 
 
21
 * $HEADER$
 
22
 */
 
23
 
 
24
#include "ompi_config.h"
 
25
#include "opal/sys/cache.h"
 
26
#include "opal/event/event.h"
 
27
#include "mpi.h"
 
28
#include "ompi/runtime/params.h"
 
29
#include "ompi/datatype/convertor.h"
 
30
#include "ompi/mca/pml/pml.h"
 
31
#include "opal/mca/base/mca_base_param.h"
 
32
 
 
33
#include "orte/util/show_help.h"
 
34
 
 
35
#include "ompi/mca/pml/base/pml_base_bsend.h"
 
36
#include "pml_csum.h"
 
37
#include "pml_csum_hdr.h"
 
38
#include "pml_csum_sendreq.h"
 
39
#include "pml_csum_recvreq.h"
 
40
#include "pml_csum_rdmafrag.h"
 
41
#include "pml_csum_recvfrag.h"
 
42
#include "ompi/mca/bml/base/base.h" 
 
43
#include "pml_csum_component.h"
 
44
#include "ompi/mca/allocator/base/base.h"
 
45
 
 
46
OBJ_CLASS_INSTANCE( mca_pml_csum_pckt_pending_t,
 
47
                    ompi_free_list_item_t,
 
48
                    NULL,
 
49
                    NULL );
 
50
 
 
51
static int mca_pml_csum_component_open(void);
 
52
static int mca_pml_csum_component_close(void);
 
53
static mca_pml_base_module_t*
 
54
mca_pml_csum_component_init( int* priority, bool enable_progress_threads,
 
55
                            bool enable_mpi_threads );
 
56
static int mca_pml_csum_component_fini(void);
 
57
 
 
58
mca_pml_base_component_2_0_0_t mca_pml_csum_component = {
 
59
 
 
60
    /* First, the mca_base_component_t struct containing meta
 
61
       information about the component itself */
 
62
 
 
63
    {
 
64
      MCA_PML_BASE_VERSION_2_0_0,
 
65
    
 
66
      "csum", /* MCA component name */
 
67
      OMPI_MAJOR_VERSION,  /* MCA component major version */
 
68
      OMPI_MINOR_VERSION,  /* MCA component minor version */
 
69
      OMPI_RELEASE_VERSION,  /* MCA component release version */
 
70
      mca_pml_csum_component_open,  /* component open */
 
71
      mca_pml_csum_component_close  /* component close */
 
72
    },
 
73
    {
 
74
        /* The component is checkpoint ready */
 
75
        MCA_BASE_METADATA_PARAM_CHECKPOINT
 
76
    },
 
77
 
 
78
    mca_pml_csum_component_init,  /* component init */
 
79
    mca_pml_csum_component_fini   /* component finalize */
 
80
    
 
81
};
 
82
 
 
83
void *mca_pml_csum_seg_alloc( struct mca_mpool_base_module_t* mpool,
 
84
                             size_t* size,
 
85
                             mca_mpool_base_registration_t** registration);
 
86
 
 
87
void mca_pml_csum_seg_free( struct mca_mpool_base_module_t* mpool,
 
88
                           void* segment );
 
89
 
 
90
static inline int mca_pml_csum_param_register_int(
 
91
    const char* param_name,
 
92
    int default_value)
 
93
{
 
94
    int id = mca_base_param_register_int("pml","csum",param_name,NULL,default_value);
 
95
    int param_value = default_value;
 
96
    mca_base_param_lookup_int(id,&param_value);
 
97
    return param_value;
 
98
}
 
99
 
 
100
static int mca_pml_csum_component_open(void)
 
101
{
 
102
    mca_allocator_base_component_t* allocator_component;
 
103
 
 
104
    mca_pml_csum.free_list_num =
 
105
        mca_pml_csum_param_register_int("free_list_num", 4);
 
106
    mca_pml_csum.free_list_max =
 
107
        mca_pml_csum_param_register_int("free_list_max", -1);
 
108
    mca_pml_csum.free_list_inc =
 
109
        mca_pml_csum_param_register_int("free_list_inc", 64);
 
110
    mca_pml_csum.send_pipeline_depth =
 
111
        mca_pml_csum_param_register_int("send_pipeline_depth", 3);
 
112
    mca_pml_csum.recv_pipeline_depth =
 
113
        mca_pml_csum_param_register_int("recv_pipeline_depth", 4);
 
114
    mca_pml_csum.rdma_put_retries_limit =
 
115
        mca_pml_csum_param_register_int("rdma_put_retries_limit", 5);
 
116
    mca_pml_csum.max_rdma_per_request =
 
117
        mca_pml_csum_param_register_int("max_rdma_per_request", 4);
 
118
    mca_pml_csum.max_send_per_range =
 
119
        mca_pml_csum_param_register_int("max_send_per_range", 4);
 
120
 
 
121
    mca_pml_csum.unexpected_limit =
 
122
        mca_pml_csum_param_register_int("unexpected_limit", 128);
 
123
 
 
124
    mca_base_param_reg_string(&mca_pml_csum_component.pmlm_version,
 
125
                              "allocator",
 
126
                              "Name of allocator component for unexpected messages",
 
127
                              false, false,
 
128
                              "bucket",
 
129
                              &mca_pml_csum.allocator_name);
 
130
 
 
131
    allocator_component = mca_allocator_component_lookup( mca_pml_csum.allocator_name );
 
132
    if(NULL == allocator_component) {
 
133
        opal_output(0, "mca_pml_csum_component_open: can't find allocator: %s\n", mca_pml_csum.allocator_name);
 
134
        return OMPI_ERROR;
 
135
    }
 
136
 
 
137
    mca_pml_csum.allocator = allocator_component->allocator_init(true,
 
138
                                                                mca_pml_csum_seg_alloc,
 
139
                                                                mca_pml_csum_seg_free, NULL);
 
140
    if(NULL == mca_pml_csum.allocator) {
 
141
        opal_output(0, "mca_pml_csum_component_open: unable to initialize allocator\n");
 
142
        return OMPI_ERROR;
 
143
    }
 
144
 
 
145
    return mca_bml_base_open(); 
 
146
}
 
147
 
 
148
 
 
149
static int mca_pml_csum_component_close(void)
 
150
{
 
151
    int rc;
 
152
 
 
153
    if (OMPI_SUCCESS != (rc = mca_bml_base_close())) {
 
154
         return rc;
 
155
    }
 
156
    if (NULL != mca_pml_csum.allocator_name) {
 
157
        free(mca_pml_csum.allocator_name);
 
158
    }
 
159
 
 
160
    return OMPI_SUCCESS;
 
161
}
 
162
 
 
163
 
 
164
static mca_pml_base_module_t*
 
165
mca_pml_csum_component_init( int* priority, 
 
166
                            bool enable_progress_threads,
 
167
                            bool enable_mpi_threads )
 
168
{
 
169
    opal_output_verbose( 10, 0, "in csum, my priority is 0\n");
 
170
 
 
171
    /* select us only if we are specified */
 
172
    if((*priority) > 0) { 
 
173
        *priority = 0;
 
174
        return NULL;
 
175
    }
 
176
    *priority = 0;
 
177
    
 
178
    if(OMPI_SUCCESS != mca_bml_base_init( enable_progress_threads, 
 
179
                                         enable_mpi_threads)) {
 
180
        return NULL;
 
181
    }
 
182
    
 
183
    /* Set this here (vs in component_open()) because
 
184
     ompi_mpi_leave_pinned* may have been set after MCA params were
 
185
     read (e.g., by the openib btl) */
 
186
    mca_pml_csum.leave_pinned = (1 == ompi_mpi_leave_pinned);
 
187
    mca_pml_csum.leave_pinned_pipeline = (int) ompi_mpi_leave_pinned_pipeline;
 
188
    
 
189
    return &mca_pml_csum.super;
 
190
}
 
191
 
 
192
int mca_pml_csum_component_fini(void)
 
193
{
 
194
    int rc;
 
195
 
 
196
    /* Shutdown BML */
 
197
    if(OMPI_SUCCESS != (rc = mca_bml.bml_finalize()))
 
198
        return rc;
 
199
 
 
200
    if(!mca_pml_csum.enabled)
 
201
        return OMPI_SUCCESS; /* never selected.. return success.. */  
 
202
    mca_pml_csum.enabled = false;  /* not anymore */
 
203
 
 
204
    OBJ_DESTRUCT(&mca_pml_csum.rdma_pending);
 
205
    OBJ_DESTRUCT(&mca_pml_csum.pckt_pending);
 
206
    OBJ_DESTRUCT(&mca_pml_csum.recv_pending);
 
207
    OBJ_DESTRUCT(&mca_pml_csum.send_pending);
 
208
    OBJ_DESTRUCT(&mca_pml_csum.non_existing_communicator_pending);
 
209
    OBJ_DESTRUCT(&mca_pml_csum.buffers);
 
210
    OBJ_DESTRUCT(&mca_pml_csum.pending_pckts);
 
211
    OBJ_DESTRUCT(&mca_pml_csum.recv_frags);
 
212
    OBJ_DESTRUCT(&mca_pml_csum.rdma_frags);
 
213
    OBJ_DESTRUCT(&mca_pml_csum.lock);
 
214
 
 
215
    if(OMPI_SUCCESS != (rc = mca_pml_csum.allocator->alc_finalize(mca_pml_csum.allocator))) {
 
216
        return rc;
 
217
    }
 
218
 
 
219
#if 0
 
220
    if (mca_pml_base_send_requests.fl_num_allocated !=
 
221
        mca_pml_base_send_requests.super.opal_list_length) {
 
222
        opal_output(0, "csum send requests: %d allocated %d returned\n",
 
223
                    mca_pml_base_send_requests.fl_num_allocated,
 
224
                    mca_pml_base_send_requests.super.opal_list_length);
 
225
    }
 
226
    if (mca_pml_base_recv_requests.fl_num_allocated !=
 
227
        mca_pml_base_recv_requests.super.opal_list_length) {
 
228
        opal_output(0, "csum recv requests: %d allocated %d returned\n",
 
229
                    mca_pml_base_recv_requests.fl_num_allocated,
 
230
                    mca_pml_base_recv_requests.super.opal_list_length);
 
231
    }
 
232
#endif
 
233
 
 
234
    return OMPI_SUCCESS;
 
235
}
 
236
 
 
237
void *mca_pml_csum_seg_alloc( struct mca_mpool_base_module_t* mpool,
 
238
                             size_t* size,
 
239
                             mca_mpool_base_registration_t** registration) { 
 
240
    return malloc(*size);
 
241
}
 
242
 
 
243
void mca_pml_csum_seg_free( struct mca_mpool_base_module_t* mpool,
 
244
                           void* segment ) { 
 
245
    free(segment);
 
246
}