Open MPI logo

Open MPI Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Development mailing list

Subject: Re: [OMPI devel] openib btl thread safety warning
From: Christopher Yeoh (cyeoh_at_[hidden])
Date: 2010-05-03 00:10:04


Hi Jeff,

Sorry I've been on vacation so didn't reply sooner - some
comments below...

On Tue, 27 Apr 2010 16:50:49 -0400
Jeff Squyres <jsquyres_at_[hidden]> wrote:
> -----
> #if OPAL_ENABLE_DEBUG
> do {
> ftr->seq = ep->eager_rdma_remote.seq;
> } while (!OPAL_ATOMIC_CMPSET_32(&ep->eager_rdma_remote.seq,
> ftr->seq, ftr->seq+1)); #endif
> -----
>
> This line produces the following compiler warning:
>
> -----
> ./btl_openib_endpoint.h:505: warning: pointer targets in passing
> argument 1 of ‘opal_atomic_cmpset_32’ differ in signedness -----
>
> Line 505 is the ATOMIC_CMPSET line. Chris -- you last touched this
> line. Can you fix?

Previously the counter was incremented non atomically which
when run multithreaded caused spurious warnings about sequence numbers
not being correct.

Now I can get rid of the warnings if I change the line to:

        } while (!OPAL_ATOMIC_CMPSET_32((int32_t*)&ep->eager_rdma_remote.seq,
               (int32_t)ftr->seq, (int32_t)(ftr->seq+1)));

The problem is that the underlying atomic cmpset takes an signed int32_t
but the counter is a uint32_t.

I think its ok to just cast like this as it should still wrap correctly? Alternatively
could add an unsigned version of atomic_cmpset_32 but seems a bit like overkill
for what essentially is a bit of debug code. Any preference?

Regards,

Chris

-- 
cyeoh_at_[hidden]