This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch for PR libgomp/37938, IA64 specific.


On Thu, 2008-11-06 at 13:58 -0800, H.J. Lu wrote:
> On Thu, Nov 6, 2008 at 1:31 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> > On Thu, Nov 06, 2008 at 01:09:44PM -0800, H.J. Lu wrote:
> >> According to ia64 psABI, ia64 _sync_bool_compare_and_swap should
> >> have full barrier.  __sync_lock_test_and_set  has acquire barrier.
> >
> > Ok, then we have just one problematic __sync_lock_test_and_set
> > in whole libgomp.
> >
> > Would the following (untested) patch cure it?  Or we can use
> > __sync_synchronize (); val = __sync_lock_test_and_set (mutex, 0);
> > if we don't mind mf + xchg4.acq.
> >
> 
> > +extern void gomp_mutex_unlock_slow (gomp_mutex_t *mutex);
> > +static inline void gomp_mutex_unlock (gomp_mutex_t *mutex)
> > +{
> > +  /* On ia64, __sync_lock_test_and_set has acquire semantics,
> > +     while release semantics is needed for gomp_mutex_unlock.  */
> > +  int val;
> > +  __asm__ __volatile__ ("xchg4.rel %0 = [%1], r0;;"
> > +                       : "=r" (val) : "r" (mutex) : "memory");
> > +  if (__builtin_expect (val > 1, 0))
> > +    gomp_mutex_unlock_slow (mutex);
> > +}
> > +
> 
> There is no xchg4.rel.

So that leaves us with calling __sync_synchronize, which is where I
started except that instead of doing the mf inside of the
__sync_lock_test_and_set we do it outside with a seperate call to
__sync_synchronize.

Steve Ellcey
sje@cup.hp.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]