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

« back to all changes in this revision

Viewing changes to ompi/mca/pml/csum/pml_csum_rdma.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
/*
 
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-2006 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
 
 
19
 
 
20
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
21
 
 
22
#include "ompi_config.h"
 
23
#include "ompi/constants.h"
 
24
#include "ompi/mca/pml/pml.h"
 
25
#include "ompi/mca/btl/btl.h"
 
26
#include "ompi/mca/bml/bml.h"
 
27
#include "orte/types.h"
 
28
#include "ompi/mca/mpool/mpool.h" 
 
29
#include "pml_csum.h"
 
30
#include "pml_csum_rdma.h"
 
31
 
 
32
/* Use this registration if no registration needed for a BTL instead of NULL.
 
33
 * This will help other code to distinguish case when memory is not registered
 
34
 * from case when registration is not needed */
 
35
static mca_mpool_base_registration_t pml_csum_dummy_reg;
 
36
 
 
37
/*
 
38
 * Check to see if memory is registered or can be registered. Build a 
 
39
 * set of registrations on the request.
 
40
 */
 
41
 
 
42
size_t mca_pml_csum_rdma_btls(
 
43
    mca_bml_base_endpoint_t* bml_endpoint,
 
44
    unsigned char* base,
 
45
    size_t size,
 
46
    mca_pml_csum_com_btl_t* rdma_btls)
 
47
{
 
48
    int num_btls = mca_bml_base_btl_array_get_size(&bml_endpoint->btl_rdma);
 
49
    double weight_total = 0;
 
50
    int num_btls_used = 0, n;
 
51
 
 
52
    /* shortcut when there are no rdma capable btls */
 
53
    if(num_btls == 0) {
 
54
        return 0;
 
55
    }
 
56
 
 
57
    /* check to see if memory is registered */        
 
58
    for(n = 0; n < num_btls && num_btls_used < mca_pml_csum.max_rdma_per_request;
 
59
            n++) {
 
60
        mca_bml_base_btl_t* bml_btl =
 
61
            mca_bml_base_btl_array_get_index(&bml_endpoint->btl_rdma,
 
62
                    (bml_endpoint->btl_rdma_index + n) % num_btls); 
 
63
        mca_mpool_base_registration_t* reg = NULL;
 
64
        mca_mpool_base_module_t *btl_mpool = bml_btl->btl->btl_mpool;
 
65
 
 
66
        if(NULL != btl_mpool) {
 
67
            if(!mca_pml_csum.leave_pinned) {
 
68
                /* look through existing registrations */
 
69
                btl_mpool->mpool_find(btl_mpool, base, size, &reg);
 
70
            } else {
 
71
                /* register the memory */
 
72
                btl_mpool->mpool_register(btl_mpool, base, size, 0, &reg);
 
73
            }
 
74
 
 
75
            if(NULL == reg)
 
76
                bml_btl = NULL; /* skip it */
 
77
        } else {
 
78
            /* if registration is not required use dummy registration */
 
79
            reg = &pml_csum_dummy_reg;
 
80
        }
 
81
 
 
82
        if(bml_btl != NULL) {
 
83
            rdma_btls[num_btls_used].bml_btl = bml_btl;
 
84
            rdma_btls[num_btls_used].btl_reg = reg;
 
85
            weight_total += bml_btl->btl_weight;
 
86
            num_btls_used++;
 
87
        }
 
88
    }
 
89
 
 
90
    /* if we don't use leave_pinned and all BTLs that already have this memory
 
91
     * registered amount to less then half of available bandwidth - fall back to
 
92
     * pipeline protocol */
 
93
    if(0 == num_btls_used || (!mca_pml_csum.leave_pinned && weight_total < 0.5))
 
94
        return 0;
 
95
 
 
96
    mca_pml_csum_calc_weighted_length(rdma_btls, num_btls_used, size,
 
97
            weight_total);
 
98
 
 
99
    bml_endpoint->btl_rdma_index = (bml_endpoint->btl_rdma_index + 1) % num_btls;
 
100
    return num_btls_used;
 
101
}
 
102
 
 
103
size_t mca_pml_csum_rdma_pipeline_btls( mca_bml_base_endpoint_t* bml_endpoint,
 
104
                                       size_t size,
 
105
                                       mca_pml_csum_com_btl_t* rdma_btls )
 
106
{
 
107
    int i, num_btls = mca_bml_base_btl_array_get_size(&bml_endpoint->btl_rdma);
 
108
    double weight_total = 0;
 
109
 
 
110
    for(i = 0; i < num_btls && i < mca_pml_csum.max_rdma_per_request; i++) {
 
111
        rdma_btls[i].bml_btl =
 
112
            mca_bml_base_btl_array_get_next(&bml_endpoint->btl_rdma);
 
113
        if(NULL != rdma_btls[i].bml_btl->btl->btl_mpool)
 
114
            rdma_btls[i].btl_reg = NULL;
 
115
        else
 
116
            rdma_btls[i].btl_reg = &pml_csum_dummy_reg;
 
117
 
 
118
        weight_total += rdma_btls[i].bml_btl->btl_weight;
 
119
    }
 
120
 
 
121
    mca_pml_csum_calc_weighted_length(rdma_btls, i, size, weight_total);
 
122
 
 
123
    return i;
 
124
}