|
24 | 24 | return OMPI_ERROR; \ |
25 | 25 | } |
26 | 26 |
|
| 27 | +/* macro to check whether UCX supports atomic operation on the size the operands */ |
| 28 | +#define ATOMIC_SIZE_SUPPORTED(_size) (sizeof(uint32_t) == _size || \ |
| 29 | + sizeof(uint64_t) == _size) |
| 30 | + |
27 | 31 | typedef struct ucx_iovec { |
28 | 32 | void *addr; |
29 | 33 | size_t len; |
@@ -384,9 +388,8 @@ bool use_atomic_op( |
384 | 388 | ompi_datatype_type_size(origin_dt, &origin_dt_bytes); |
385 | 389 | ompi_datatype_type_size(target_dt, &target_dt_bytes); |
386 | 390 | /* UCX only supports 32 and 64-bit operands atm */ |
387 | | - if (sizeof(uint64_t) >= origin_dt_bytes && |
388 | | - sizeof(uint32_t) <= origin_dt_bytes && |
389 | | - origin_dt_bytes == target_dt_bytes && |
| 391 | + if (ATOMIC_SIZE_SUPPORTED(origin_dt_bytes) && |
| 392 | + origin_dt_bytes == target_dt_bytes && |
390 | 393 | origin_count == target_count) { |
391 | 394 | return true; |
392 | 395 | } |
@@ -775,7 +778,7 @@ int ompi_osc_ucx_compare_and_swap(const void *origin_addr, const void *compare_a |
775 | 778 | } |
776 | 779 |
|
777 | 780 | ompi_datatype_type_size(dt, &dt_bytes); |
778 | | - if (4 == dt_bytes || 8 == dt_bytes) { |
| 781 | + if (ATOMIC_SIZE_SUPPORTED(dt_bytes)) { |
779 | 782 | // fast path using UCX atomic operations |
780 | 783 | return do_atomic_compare_and_swap(origin_addr, compare_addr, |
781 | 784 | result_addr, dt, target, |
@@ -830,7 +833,7 @@ int ompi_osc_ucx_fetch_and_op(const void *origin_addr, void *result_addr, |
830 | 833 | ompi_datatype_type_size(dt, &dt_bytes); |
831 | 834 |
|
832 | 835 | /* UCX atomics are only supported on 32 and 64 bit values */ |
833 | | - if ((64 == dt_bytes || 32 == dt_bytes) && |
| 836 | + if (ATOMIC_SIZE_SUPPORTED(dt_bytes) && |
834 | 837 | (op == &ompi_mpi_op_no_op.op || op == &ompi_mpi_op_replace.op || |
835 | 838 | op == &ompi_mpi_op_sum.op)) { |
836 | 839 | uint64_t value; |
|
0 commit comments