Skip to content

Commit 6907eb8

Browse files
authored
Merge pull request pmodels#7637 from hzhou/2510_ofi_pipeline
ch4/ofi: force allocating cells in the pipeline algorithm Approved-by: Ken Raffenetti
2 parents 944881a + 78adeb8 commit 6907eb8

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

src/mpid/ch4/netmod/ofi/ofi_init.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,16 @@ categories :
475475
description : >-
476476
Specifies the number of chunk buffers for pipeline data transfer.
477477
478+
- name : MPIR_CVAR_CH4_OFI_PIPELINE_MAX_CHUNKS
479+
category : CH4_OFI
480+
type : int
481+
default : 1024
482+
class : none
483+
verbosity : MPI_T_VERBOSITY_USER_BASIC
484+
scope : MPI_T_SCOPE_LOCAL
485+
description : >-
486+
Specifies the max number of chunk buffers to be reserved for pipeline data transfer.
487+
478488
- name : MPIR_CVAR_CH4_OFI_GPU_SEND_ENGINE_TYPE
479489
category : CH4_OFI
480490
type : enum
@@ -1509,7 +1519,7 @@ int MPIDI_OFI_init_per_vci(int vci)
15091519
/* Create chunk buffer pool (for pipeline etc.) */
15101520
mpi_errno = MPIDU_genq_private_pool_create(MPIR_CVAR_CH4_OFI_PIPELINE_CHUNK_SZ,
15111521
MPIR_CVAR_CH4_OFI_PIPELINE_NUM_CHUNKS,
1512-
MPIR_CVAR_CH4_OFI_PIPELINE_NUM_CHUNKS,
1522+
MPIR_CVAR_CH4_OFI_PIPELINE_MAX_CHUNKS,
15131523
host_alloc_registered,
15141524
host_free_registered,
15151525
&MPIDI_OFI_global.per_vci[vci].pipeline_pool);

src/mpid/ch4/netmod/ofi/ofi_pipeline.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ static int pipeline_send_poll(MPIX_Async_thing thing)
197197
}
198198

199199
/* alloc a chunk */
200-
MPIDU_genq_private_pool_alloc_cell(MPIDI_OFI_global.per_vci[p->vci_local].pipeline_pool,
201-
&chunk_buf);
200+
MPIDU_genq_private_pool_force_alloc_cell(MPIDI_OFI_global.
201+
per_vci[p->vci_local].pipeline_pool, &chunk_buf);
202202
if (!chunk_buf) {
203203
goto fn_exit;
204204
}
@@ -371,8 +371,8 @@ static int pipeline_recv_poll(MPIX_Async_thing thing)
371371
}
372372

373373
/* alloc a chunk */
374-
MPIDU_genq_private_pool_alloc_cell(MPIDI_OFI_global.per_vci[p->vci_local].pipeline_pool,
375-
&chunk_buf);
374+
MPIDU_genq_private_pool_force_alloc_cell(MPIDI_OFI_global.
375+
per_vci[p->vci_local].pipeline_pool, &chunk_buf);
376376
if (!chunk_buf) {
377377
goto fn_exit;
378378
}

src/mpid/common/genq/mpidu_genq_private_pool.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ typedef struct MPIDU_genq_private_pool {
4343
MPIDU_genq_free_fn free_fn;
4444

4545
intptr_t num_blocks;
46-
intptr_t max_num_blocks;
46+
intptr_t max_num_blocks; /* as cells are alloc'ed, the pool may grow up to max_num_blocks.
47+
* NOTE: MPIDU_genq_private_pool_force_alloc_cell may increase max_num_blocks */
48+
intptr_t min_num_blocks; /* as cells are freed, the pool may shrink back to min_num_blocks */
4749
cell_block_s *cell_blocks;
4850
cell_block_s *free_blocks_head;
4951
cell_block_s *free_blocks_tail;
@@ -69,8 +71,10 @@ int MPIDU_genq_private_pool_create(intptr_t cell_size, intptr_t num_cells_in_blo
6971
if (max_num_cells == 0) {
7072
/* 0 means unlimited */
7173
pool_obj->max_num_blocks = 0;
74+
pool_obj->min_num_blocks = 1;
7275
} else {
7376
pool_obj->max_num_blocks = max_num_cells / num_cells_in_block;
77+
pool_obj->min_num_blocks = pool_obj->max_num_blocks;
7478
}
7579

7680
pool_obj->malloc_fn = malloc_fn;
@@ -278,9 +282,9 @@ int MPIDU_genq_private_pool_free_cell(MPIDU_genq_private_pool_t pool, void *cell
278282
if (block->num_used_cells == pool_obj->num_cells_in_block - 1) {
279283
append_free_blocks(pool_obj, block);
280284
} else if (block->num_used_cells == 0) {
281-
/* Avoid frequent re-allocation by preserving the last block.
285+
/* Avoid frequent re-allocation by preserving a minimum number of blocks.
282286
* All blocks will be freed when the pool is destroyed */
283-
if (pool_obj->num_blocks > 1 && pool_obj->max_num_blocks == 0) {
287+
if (pool_obj->num_blocks > pool_obj->min_num_blocks) {
284288
remove_free_blocks(pool_obj, block);
285289
DL_DELETE(pool_obj->cell_blocks, block);
286290
cell_block_free(pool_obj, block);

0 commit comments

Comments
 (0)