Omp Atomic Feature Depends on GCC 10.3.0 or Later
The omp atomic feature depends on the libgcc of the GCC. If the GCC version is earlier than 10.3.0, the running result may be abnormal. To use the feature, ensure that the GCC version meets the requirements or add the -rtlib=compiler-rt compilation option. The following is an example of using the omp atomic feature:
1 2 3 4 5 6 7 8 9 | void foo(double *Ptr, double M, double N) { double sum = 0; #pragma omp parallel for for (int i = 0; i < 100; ++i){ Ptr[i] = i+(M*2 + N); #pragma omp atomic sum += Ptr[i]; } } |
Parent topic: OpenMP Compatibility