我要评分
获取效率
正确性
完整性
易理解

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 it, ensure that the GCC version requirements are met. 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];
    }
}