Open MPI logo

Open MPI Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Development mailing list

Subject: Re: [OMPI devel] IB warnings
From: N.M. Maclaren (nmm1_at_[hidden])
Date: 2010-07-20 08:35:17


On Jul 20 2010, Jeff Squyres wrote:
>
>> > Also, it seems like the 3rd parameter could be problematic if it ever
>> > goes larger than 2B -- it'll increment in the wrong direction, won't
>> > it?
>>
>> Not on most systems.
>
> Ah -- I just checked -- the associativity of + and (cast) are equal, and
> are right to left. So it should be ok.

No, they aren't! That's unary plus. Cast binds more strongly. The reason
that it is OK is that uint32_t and int32_t are required to be twos'
complement.

> But still, for defensive
> programming purposes, I'd prefer this:
>
> } while
> (!OPAL_ATOMIC_CMPSET_32((int32_t*)&ep->eager_rdma_remote.seq,
> (int32_t)ftr->seq,
> (int32_t)(ftr->seq+1)));

That parses differently, but is semantically equivalent with twos'
complement and quiet wrapping on overflow. I agree that it's a bit cleaner.

Regards,
Nick Maclaren.