NO

Author Topic: Support for atomic operations on doubles in OpenMP  (Read 3395 times)

Melirius

  • Guest
Support for atomic operations on doubles in OpenMP
« 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?

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: Support for atomic operations on doubles in OpenMP
« Reply #1 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.)
/Pelle

Melirius

  • Guest
Re: Support for atomic operations on doubles in OpenMP
« Reply #2 on: June 15, 2020, 08:42:15 PM »
Thanks a lot! I'm using critical sections as a workaround, but atomics should be faster.