This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: volatile qualifier hurts single-threaded optimized case
> > static inline _Atomic_word
> > __attribute__ ((__unused__))
> >- __exchange_and_add_dispatch(volatile _Atomic_word* __mem, int __val)
> >+ __exchange_and_add_dispatch(_Atomic_word* __mem, int __val)
> >
> >
> Agreed, but doing this means that in the improvements to rope that
> Richard (and Hans) also want we have to call __exchange_and_add and
> __atomic_add directly, because in that case the involved memory
> locations are volatile and have to remain like that per Hans desiderata,
> I gather.
I find this somewhat confusing, but am going to go ahead with this, as
I have other fixes in the pipeline for this file.
Of course, it would be nice if everybody calls the dispatch functions
directly, since this idea removes having to wrap in __GTHREADS etc.
This interface should not penalize single-thread, however.
If people want to do more specialized accesses, for instance when
threads are already assumed, or memory is already volatile, and want to
call down into __exchange_and_add and __atomic_add that seems
reasonable to me.
I believe Richard says as much in his follow up email.
This is going to be documented, as it's now complicated. (More
complicated?) That's one of the patches I've got going....
> More generally, the original __exchange_and_add and
> __atomic_add could be used also together with volatile memory and now
> calling the "old" functions becomes necessary, we should document that
> somewhere (if it weren't for this reason, everyone should always go
> through the dispatchers).
Yep.
best,
benjamin