|
21 | 21 | * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved.
|
22 | 22 | * Copyright (c) 2018 Triad National Security, LLC. All rights
|
23 | 23 | * reserved.
|
24 |
| - * Copyright (c) 2019-2021 Google, Inc. All rights reserved. |
| 24 | + * Copyright (c) 2019-2025 Google, Inc. All rights reserved. |
25 | 25 | * Copyright (c) 2021 Nanook Consulting. All rights reserved.
|
26 | 26 | * Copyright (c) 2022 IBM Corporation. All rights reserved.
|
27 | 27 | * Copyright (c) 2022 Computer Architecture and VLSI Systems (CARV)
|
|
36 | 36 |
|
37 | 37 | #include "opal/mca/btl/base/btl_base_error.h"
|
38 | 38 | #include "opal/mca/threads/mutex.h"
|
| 39 | +#include "opal/util/bit_ops.h" |
39 | 40 | #include "opal/util/output.h"
|
40 | 41 | #include "opal/util/printf.h"
|
41 | 42 |
|
@@ -182,7 +183,7 @@ static int mca_btl_sm_component_register(void)
|
182 | 183 |
|
183 | 184 | mca_btl_sm_component.fbox_size = 4096;
|
184 | 185 | (void) mca_base_component_var_register(&mca_btl_sm_component.super.btl_version, "fbox_size",
|
185 |
| - "Size of per-peer fast transfer buffers (default: 4k)", |
| 186 | + "Size of per-peer fast transfer buffers. Must be a power of two (default: 4k)", |
186 | 187 | MCA_BASE_VAR_TYPE_UNSIGNED_INT, NULL, 0,
|
187 | 188 | MCA_BASE_VAR_FLAG_SETTABLE, OPAL_INFO_LVL_5,
|
188 | 189 | MCA_BASE_VAR_SCOPE_LOCAL,
|
@@ -324,8 +325,10 @@ mca_btl_sm_component_init(int *num_btls, bool enable_progress_threads, bool enab
|
324 | 325 | component->segment_size = (2 << 20);
|
325 | 326 | }
|
326 | 327 |
|
327 |
| - component->fbox_size = (component->fbox_size + MCA_BTL_SM_FBOX_ALIGNMENT_MASK) |
328 |
| - & ~MCA_BTL_SM_FBOX_ALIGNMENT_MASK; |
| 328 | + if (component->fbox_size & (component->fbox_size - 1)) { |
| 329 | + BTL_VERBOSE(("fast box size must be a power of two, rounding up to next power of two.")); |
| 330 | + component->fbox_size = opal_next_poweroftwo_inclusive(component->fbox_size); |
| 331 | + } |
329 | 332 |
|
330 | 333 | if (component->segment_size > (1ul << MCA_BTL_SM_OFFSET_BITS)) {
|
331 | 334 | component->segment_size = 2ul << MCA_BTL_SM_OFFSET_BITS;
|
|
0 commit comments