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

  • 關於本站
  • 免責聲明