Skip to content

Commit 69ac92b

Browse files
committed
coll/han: parameterize the packing buf size and count
Allow the user to change the packing buffer size and how many maximum buffers will be allocated. Currently only han's alltoallv uses the buffers. Signed-off-by: Luke Robison <[email protected]>
1 parent a4a6ab1 commit 69ac92b

File tree

3 files changed

+38
-10
lines changed

3 files changed

+38
-10
lines changed

ompi/mca/coll/han/coll_han.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ typedef struct mca_coll_han_component_t {
294294
int max_dynamic_errors;
295295

296296
opal_free_list_t pack_buffers;
297+
int64_t han_packbuf_max_count;
298+
int64_t han_packbuf_bytes;
297299
} mca_coll_han_component_t;
298300

299301
/*
@@ -576,7 +578,4 @@ static inline struct mca_smsc_endpoint_t *mca_coll_han_get_smsc_endpoint (struct
576578
return (struct mca_smsc_endpoint_t *) proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_SMSC];
577579
}
578580

579-
#define COLL_HAN_PACKBUF_PAYLOAD_BYTES (128*1024)
580-
581-
582581
#endif /* MCA_COLL_HAN_EXPORT_H */

ompi/mca/coll/han/coll_han_alltoallv.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,20 +313,35 @@ static int alltoallv_sendrecv_w(
313313
ompi_request_t *requests[MAX_BUF_COUNT];
314314
opal_free_list_item_t *buf_items[MAX_BUF_COUNT];
315315

316-
size_t buf_len = COLL_HAN_PACKBUF_PAYLOAD_BYTES;
316+
size_t buf_len = mca_coll_han_component.han_packbuf_bytes;
317317
int nbufs = MAX_BUF_COUNT;
318318
for (int jbuf=0; jbuf<nbufs; jbuf++) {
319319
buf_items[jbuf] = opal_free_list_get(&mca_coll_han_component.pack_buffers);
320320
if (buf_items[jbuf] == NULL) {
321-
nbufs = jbuf - 1;
322-
opal_output_verbose(20, mca_coll_han_component.han_output,
323-
"Uh-oh, not enough buffers: %d\n",nbufs);
321+
nbufs = jbuf;
322+
opal_output_verbose(30, mca_coll_han_component.han_output,
323+
"alltoallv_sendrecv_w: Number of buffers reduced to %d instead of %d. "
324+
"Check mca parameter coll_han_packbuf_max_count (currently %ld).\n",
325+
nbufs, MAX_BUF_COUNT, mca_coll_han_component.han_packbuf_max_count);
324326
break;
325327
}
326328
}
329+
330+
/* although we could feasibly disqualify the higher-level alltoallv
331+
algorithm for these conditions, they represent invalid user parameters, so
332+
let's fail and tell the user why. */
327333
if (nbufs < 2) {
328334
opal_output_verbose(1, mca_coll_han_component.han_output,
329-
"ERROR: Need at least 2 buffers from mca_coll_han_component.pack_buffers!");
335+
"ERROR: Need at least 2 buffers from HAN pack buffers! "
336+
"Check mca parameter coll_han_packbuf_max_count (currently %ld)\n",
337+
mca_coll_han_component.han_packbuf_max_count);
338+
return MPI_ERR_NO_MEM;
339+
}
340+
if (buf_len < 16) {
341+
opal_output_verbose(1, mca_coll_han_component.han_output,
342+
"ERROR: Need a buffer that can hold at least 16 bytes! "
343+
"Check mca parameter coll_han_packbuf_bytes (currently %ld)\n",
344+
mca_coll_han_component.han_packbuf_bytes);
330345
return MPI_ERR_NO_MEM;
331346
}
332347

ompi/mca/coll/han/coll_han_component.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ static int han_open(void)
126126
/* opal_class_t *frag_class */
127127
OBJ_CLASS(opal_free_list_item_t),
128128
/* payload_buffer_size, payload_buffer_alignment */
129-
COLL_HAN_PACKBUF_PAYLOAD_BYTES, 8,
129+
mca_coll_han_component.han_packbuf_bytes, 8,
130130
/* num_elements_to_alloc, max_elements_to_alloc, num_elements_per_alloc */
131-
0, 32, 8,
131+
0, mca_coll_han_component.han_packbuf_max_count, 8,
132132
/* *mpool, rcache_reg_flags, *rcache, */
133133
NULL, 0, NULL,
134134
/* fn_t item_init, void *ctx */
@@ -456,6 +456,20 @@ static int han_register(void)
456456
MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
457457
OPAL_INFO_LVL_3,
458458
MCA_BASE_VAR_SCOPE_READONLY, &cs->han_reproducible);
459+
460+
cs->han_packbuf_bytes = 128*1024;
461+
(void) mca_base_component_var_register(c, "packbuf_bytes",
462+
"The number of bytes in each HAN packbuf.",
463+
MCA_BASE_VAR_TYPE_INT64_T, NULL, 0, 0,
464+
OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY,
465+
&cs->han_packbuf_bytes);
466+
cs->han_packbuf_max_count = 32;
467+
(void) mca_base_component_var_register(c, "packbuf_max_count",
468+
"The maximum number of packbufs that are allowed to be allocated.",
469+
MCA_BASE_VAR_TYPE_INT64_T, NULL, 0, 0,
470+
OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY,
471+
&cs->han_packbuf_max_count);
472+
459473
/*
460474
* Han algorithms MCA parameters for each collective.
461475
* Shows algorithms thanks to enumerator

0 commit comments

Comments
 (0)