Skip to content

Commit 8b82903

Browse files
authored
Merge pull request #8711 from awlauria/account_for_more_than_2_btls_v5.0.x
v5.0.x: osc/rdma: Account for more than 2 btls.
2 parents 73c5aee + 1f2c873 commit 8b82903

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

ompi/mca/osc/rdma/osc_rdma.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555

5656
#define RANK_ARRAY_COUNT(module) ((ompi_comm_size ((module)->comm) + (module)->node_count - 1) / (module)->node_count)
5757

58-
#define MCA_OSC_RDMA_MAX_USED_BTLS 2
58+
#define MCA_OSC_RDMA_BTLS_SIZE_INIT 4
5959

6060
enum {
6161
OMPI_OSC_RDMA_LOCKING_TWO_LEVEL,
@@ -260,7 +260,8 @@ struct ompi_osc_rdma_module_t {
260260
* non-RDMA BTLs. The typical usage is btl/sm + btl/tcp. In the future this
261261
* could be used to support multiple RDMA-capable BTLs but the memory registration
262262
* paths will need to be updated to pack/unpack multiple registration handles. */
263-
struct mca_btl_base_module_t *selected_btls[MCA_OSC_RDMA_MAX_USED_BTLS];
263+
struct mca_btl_base_module_t **selected_btls;
264+
uint8_t selected_btls_size;
264265
uint8_t btls_in_use;
265266

266267
/** Only true if one BTL is in use. Memory registration is only supported when
@@ -634,4 +635,14 @@ static inline mca_btl_base_module_t *ompi_osc_rdma_selected_btl (ompi_osc_rdma_m
634635
return module->selected_btls[btl_index];
635636
}
636637

638+
__opal_attribute_always_inline__
639+
static inline void ompi_osc_rdma_selected_btl_insert (ompi_osc_rdma_module_t *module, struct mca_btl_base_module_t *btl, uint8_t btl_index) {
640+
if(btl_index == module->selected_btls_size) {
641+
module->selected_btls_size *= 2;
642+
module->selected_btls = realloc(module->selected_btls, module->selected_btls_size * sizeof(struct mca_btl_base_module_t *));
643+
assert(NULL != module->selected_btls);
644+
}
645+
module->selected_btls[btl_index] = btl;
646+
}
647+
637648
#endif /* OMPI_OSC_RDMA_H */

ompi/mca/osc/rdma/osc_rdma_component.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ static int ompi_osc_rdma_query_alternate_btls (ompi_communicator_t *comm, ompi_o
947947
++btls_found;
948948
if (module) {
949949
mca_btl_base_am_rdma_init(item->btl_module);
950-
module->selected_btls[module->btls_in_use++] = item->btl_module;
950+
ompi_osc_rdma_selected_btl_insert(module, item->btl_module, module->btls_in_use++);
951951
}
952952

953953
}
@@ -974,7 +974,7 @@ static int ompi_osc_rdma_query_btls (ompi_communicator_t *comm, ompi_osc_rdma_mo
974974
btls_to_use = opal_argv_split (ompi_osc_rdma_btl_names, ',');
975975

976976
if (module) {
977-
module->selected_btls[0] = NULL;
977+
ompi_osc_rdma_selected_btl_insert(module, NULL, 0);
978978
module->btls_in_use = 0;
979979
module->use_memory_registration = false;
980980
}
@@ -1001,7 +1001,7 @@ static int ompi_osc_rdma_query_btls (ompi_communicator_t *comm, ompi_osc_rdma_mo
10011001

10021002
if (NULL != selected_btl) {
10031003
if (module) {
1004-
module->selected_btls[0] = selected_btl;
1004+
ompi_osc_rdma_selected_btl_insert(module, selected_btl, 0);
10051005
module->btls_in_use = 1;
10061006
module->use_memory_registration = selected_btl->btl_register_mem != NULL;
10071007
}
@@ -1118,7 +1118,7 @@ static int ompi_osc_rdma_query_btls (ompi_communicator_t *comm, ompi_osc_rdma_mo
11181118
}
11191119

11201120
if (module) {
1121-
module->selected_btls[0] = selected_btl;
1121+
ompi_osc_rdma_selected_btl_insert(module, selected_btl, 0);
11221122
module->btls_in_use = 1;
11231123
module->use_memory_registration = selected_btl->btl_register_mem != NULL;
11241124
}
@@ -1334,6 +1334,9 @@ static int ompi_osc_rdma_component_select (struct ompi_win_t *win, void **base,
13341334
module->acc_use_amo = mca_osc_rdma_component.acc_use_amo;
13351335
module->network_amo_max_count = mca_osc_rdma_component.network_amo_max_count;
13361336

1337+
module->selected_btls_size = MCA_OSC_RDMA_BTLS_SIZE_INIT;
1338+
module->selected_btls = calloc(module->selected_btls_size, sizeof(struct mca_btl_base_module_t *));
1339+
13371340
module->all_sync.module = module;
13381341

13391342
module->flavor = flavor;

ompi/mca/osc/rdma/osc_rdma_module.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ int ompi_osc_rdma_free(ompi_win_t *win)
141141
free (module->peer_array);
142142
free (module->outstanding_lock_array);
143143
free (module->free_after);
144+
free (module->selected_btls);
144145
free (module);
145146

146147
return OMPI_SUCCESS;

0 commit comments

Comments
 (0)