Atomic floats on x86_64
NightStrike
nightstrike@gmail.com
Mon Nov 10 12:50:00 GMT 2014
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.
int main(void) {
// Works fine:
int a;
__atomic_store_n(&a, 5, __ATOMIC_RELEASE);
// Error: incompatible type for argument 1 of ‘__atomic_store_n’
float b;
__atomic_store_n(&b, 5.0f, __ATOMIC_RELEASE);
// Works fine:
float c = 5.0f;
__atomic_store(&b, &c, __ATOMIC_RELEASE);
return 0;
}
More information about the Gcc-help
mailing list