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
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.
14
* Additional copyrights may follow
20
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
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"
30
#include "pml_csum_rdma.h"
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;
38
* Check to see if memory is registered or can be registered. Build a
39
* set of registrations on the request.
42
size_t mca_pml_csum_rdma_btls(
43
mca_bml_base_endpoint_t* bml_endpoint,
46
mca_pml_csum_com_btl_t* rdma_btls)
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;
52
/* shortcut when there are no rdma capable btls */
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;
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;
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, ®);
71
/* register the memory */
72
btl_mpool->mpool_register(btl_mpool, base, size, 0, ®);
76
bml_btl = NULL; /* skip it */
78
/* if registration is not required use dummy registration */
79
reg = &pml_csum_dummy_reg;
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;
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))
96
mca_pml_csum_calc_weighted_length(rdma_btls, num_btls_used, size,
99
bml_endpoint->btl_rdma_index = (bml_endpoint->btl_rdma_index + 1) % num_btls;
100
return num_btls_used;
103
size_t mca_pml_csum_rdma_pipeline_btls( mca_bml_base_endpoint_t* bml_endpoint,
105
mca_pml_csum_com_btl_t* rdma_btls )
107
int i, num_btls = mca_bml_base_btl_array_get_size(&bml_endpoint->btl_rdma);
108
double weight_total = 0;
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;
116
rdma_btls[i].btl_reg = &pml_csum_dummy_reg;
118
weight_total += rdma_btls[i].bml_btl->btl_weight;
121
mca_pml_csum_calc_weighted_length(rdma_btls, i, size, weight_total);