📜  openMP 中的多个循环推导 - 无论代码示例

📅  最后修改于: 2022-03-11 14:56:27.689000             🧑  作者: Mango

代码示例1
#include 
#include 

int main(){
    double sum_i = 0, max_i = -1;
    #pragma omp parallel for reduction(+:sum_i) reduction(max:max_i)
    for (int i=0; i<5000; i++){
        sum_i += i;
        if (i > max_i)
            max_i = i;
    }
    std::cout << "Sum = " << sum_i << std::endl;
    std::cout << "Max = " << max_i << std::endl;
    return 0;
}