Re: [OMPI users] Check equality of a value in all MPI ranks

2022-02-17 Thread Niranda Perera via users
Thanks Joseph! I think that's a nifty trick! :-) On Thu, Feb 17, 2022 at 4:57 PM Joseph Schuchart via users < users@lists.open-mpi.org> wrote: > Hi Niranda, > > A pattern I have seen in several places is to allreduce the pair p = > {-x,x} with MPI_MIN or MPI_MAX. If in the resulting pair p[0] ==

Re: [OMPI users] Check equality of a value in all MPI ranks

2022-02-17 Thread Joseph Schuchart via users
Hi Niranda, A pattern I have seen in several places is to allreduce the pair p = {-x,x} with MPI_MIN or MPI_MAX. If in the resulting pair p[0] == -p[1], then everyone has the same value. If not, at least one rank had a different value. Example: ``` bool is_same(int x) {   int p[2];   p[0] =