Hi all,

Say I have some int `x`. I want to check if all MPI ranks get the same
value for `x`. What's a good way to achieve this using MPI collectives?

The simplest I could think of is, broadcast rank0's `x`, do the comparison,
and allreduce-LAND the comparison result. This requires two collective
operations.
```python
...
x = ... # each rank may produce different values for x
x_bcast = comm.bcast(x, root=0)
all_equal = comm.allreduce(x==x_bcast, op=MPI.LAND)
if not all_equal:
   raise Exception()
...
```
Is there a better way to do this?


-- 
Niranda Perera
https://niranda.dev/
@n1r44 <https://twitter.com/N1R44>

Reply via email to