且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

吃CPU的openmp 程序

更新时间:2022-09-18 18:42:52

吃CPU的openmp 程序
g++ -o eat -fopenmp eat.cpp

#include "stdio.h"

int main(int argc, char *argv[])
{
  #pragma omp parallel
  {
    while(1) {
        int c = 0;
        for(int i=0; i<(1<<30); ++i) {
           c += c*i;
        }
    }
    printf("hello multicore user!\n");
  }
  return(0);
}
吃CPU的openmp 程序

然后CPU占用接近100%了。















本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/bonelee/p/6616418.html,如需转载请自行联系原作者