|
26 | 26 | return OMPI_ERROR; \
|
27 | 27 | }
|
28 | 28 |
|
29 |
| -/* macro to check whether UCX supports atomic operation on the size the operands */ |
30 |
| -#define ATOMIC_SIZE_SUPPORTED(_remote_addr, _size) \ |
31 |
| - ((sizeof(uint32_t) == (_size) && !((_remote_addr) & 0x3)) || \ |
32 |
| - (sizeof(uint64_t) == (_size) && !((_remote_addr) & 0x7))) |
| 29 | +/* helper to check whether UCX supports atomic operation on the size the operands */ |
| 30 | +static inline __opal_attribute_always_inline__ bool is_atomic_size_supported(uint64_t remote_addr, |
| 31 | + size_t size) |
| 32 | +{ |
| 33 | + return ((sizeof(uint32_t) == size && !(remote_addr & 0x3)) || |
| 34 | + (sizeof(uint64_t) == size && !(remote_addr & 0x7))); |
| 35 | +} |
33 | 36 |
|
34 | 37 | typedef struct ucx_iovec {
|
35 | 38 | void *addr;
|
@@ -400,9 +403,8 @@ bool use_atomic_op(
|
400 | 403 | ompi_datatype_type_size(origin_dt, &origin_dt_bytes);
|
401 | 404 | ompi_datatype_type_size(target_dt, &target_dt_bytes);
|
402 | 405 | /* UCX only supports 32 and 64-bit operands atm */
|
403 |
| - if (ATOMIC_SIZE_SUPPORTED(remote_addr, origin_dt_bytes) && |
404 |
| - origin_dt_bytes == target_dt_bytes && |
405 |
| - origin_count == target_count) { |
| 406 | + if (is_atomic_size_supported(remote_addr, origin_dt_bytes) && |
| 407 | + origin_dt_bytes == target_dt_bytes && origin_count == target_count) { |
406 | 408 | return true;
|
407 | 409 | }
|
408 | 410 | }
|
@@ -794,7 +796,7 @@ int ompi_osc_ucx_compare_and_swap(const void *origin_addr, const void *compare_a
|
794 | 796 | }
|
795 | 797 |
|
796 | 798 | ompi_datatype_type_size(dt, &dt_bytes);
|
797 |
| - if (ATOMIC_SIZE_SUPPORTED(remote_addr, dt_bytes)) { |
| 799 | + if (is_atomic_size_supported(remote_addr, dt_bytes)) { |
798 | 800 | // fast path using UCX atomic operations
|
799 | 801 | return do_atomic_compare_and_swap(origin_addr, compare_addr,
|
800 | 802 | result_addr, dt, target,
|
@@ -850,7 +852,7 @@ int ompi_osc_ucx_fetch_and_op(const void *origin_addr, void *result_addr,
|
850 | 852 | ompi_datatype_type_size(dt, &dt_bytes);
|
851 | 853 |
|
852 | 854 | /* UCX atomics are only supported on 32 and 64 bit values */
|
853 |
| - if (ATOMIC_SIZE_SUPPORTED(remote_addr, dt_bytes) && |
| 855 | + if (is_atomic_size_supported(remote_addr, dt_bytes) && |
854 | 856 | (op == &ompi_mpi_op_no_op.op || op == &ompi_mpi_op_replace.op ||
|
855 | 857 | op == &ompi_mpi_op_sum.op)) {
|
856 | 858 | uint64_t value;
|
|
0 commit comments