This is the mail archive of the gcc-help@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: Atomic floats on x86_64


On Mon, Nov 10, 2014 at 10:32 AM, Andrew Haley <aph@redhat.com> wrote:
> On 11/10/2014 12:50 PM, NightStrike wrote:
>> On Mon, Nov 10, 2014 at 3:58 AM, Andrew Haley <aph@redhat.com> wrote:
>>> On 09/11/14 18:56, NightStrike wrote:
>>>> Is it a bug that I can atomically store a float using __atomic_store,
>>>> but not __atomic_store_n?  I'd really like to be able to do it without
>>>> the extra layer of indirection and the extra requirement of a temp
>>>> variable that I don't need.
>>>
>>> I don't get this.  Can you explain a bit more, or provide a test case?
>>> There shouldn't be any loss of performance.
>>
>> For me, it's not a matter of performance (at least I hope, I didn't
>> measure).  It's more a matter of convenience.  I can't just atomically
>> stick a literal into a float.  I have to create temp variables
>> instead.
>
> This stuff is part of C11.  Given that what you need is
>
>     float b;
>     atomic_store_explicit(&b, 5.0f, memory_order_release);
>
> I'm having a very difficult time understanding what problem in GCC
> you're trying to solve.  If you really insist on using an old GCC
> or an old standard you can use a trivial inline function.

I'm not using an old gcc, I'm using 4.9.1.

And, it was my understanding that using the builtins was an allowable
way to get atomic functionality in C99.

Further, discussions on IRC a bit ago advised me that I need to use
the builtins if I want to use atomic operations on data shared between
C and C++.  If I use the C11 functions, then I can't do that.

The problem isn't too complicated.  The atomic builtins don't support
floating point types directly, only generally through pointers.  It
seems like that would be natural to improve upon.


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