A.7 使用 reduction 子句

下面的示例演示减少子句 (在第 28 页) 的第2.7.2.6部分 :

#pragma omp parallel for private(i) shared(x, y, n) \
                         reduction(+: a, b)
    for (i=0; i<n; i++) {
        a = a + x[i];
        b = b + y[i];
    }