Pelles C forum

Pelles C => Feature requests => Topic started by: Melirius on June 13, 2020, 09:04:35 PM

Title: Support for atomic operations on doubles in OpenMP
Post by: Melirius on June 13, 2020, 09:04:35 PM
Hey, I found out that atomic operations on doubles are not permitted on x64 architecture in Pelles C 9.00 giving error #2513. Example:

Code: [Select]
double x[100] = {1}, sum = 0;
#pragma omp parallel for
for(int i = 0; i < 100; ++i)
#pragma omp atomic
  sum += x[i];

Is it possible to implement them?
Title: Re: Support for atomic operations on doubles in OpenMP
Post by: Pelle on June 14, 2020, 06:33:23 PM
It should be possible, at least by (mis)using integer instructions, but it's too late for the upcoming version 10.
Will have to wait until another version (it's not exactly a five minute job).

(I think there were some concerns about floating-point atomics when _Atomic was added to C11, but I no longer remember the details.)
Title: Re: Support for atomic operations on doubles in OpenMP
Post by: Melirius on June 15, 2020, 08:42:15 PM
Thanks a lot! I'm using critical sections as a workaround, but atomics should be faster.