logo
  • 教程列表
  • SO官方文档
  • 开始使用 openmp
    • 汇编
    • 使用 OpenMP 并行 hello world
    • 工作共享构造 - For 循环的示例
    • 减少例子
  1. StackOverflow 文档
  2. openmp 教程
  3. 开始使用 openmp
  4. 减少例子

减少例子

Created: November-22, 2018

#include <omp.h>
void main ()
{     
    int i;       
    double ZZ, func(), res=0.0;

    #pragma omp parallel for reduction(+:res) private(ZZ) 
    for (i=0; i< 1000; i++){
        ZZ = func(I);
        res = res + ZZ; 
    }
}

在最后一行:实际上添加到私有副本,然后在循环后组合。编译器负责细节。

  • 工作共享构造 - For 循环的示例

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 关于我们
  • 免责声明