Re: Atomic floats on x86_64

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/10/2014 03:49 PM, NightStrike wrote:
> On Mon, Nov 10, 2014 at 10:32 AM, Andrew Haley <aph@xxxxxxxxxx> wrote:
>> On 11/10/2014 12:50 PM, NightStrike wrote:
>>> On Mon, Nov 10, 2014 at 3:58 AM, Andrew Haley <aph@xxxxxxxxxx> 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.

It is. The builtins are what they are, however, and we now have a
*portable* way to get the atomic behaviour we used to have to use
GCC-specific hacks for.

> 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.

What do you believe a __builtin does but a standard atomic does not do?

> 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.

The only natural thing at this point is waiting for the nonstandard
GCC atomics to die.  We'll have to support them forever, of course,
but what is the point of extending them in 2014?

And what's wrong with a trivial inline function?

Andrew.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux