吃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!
");
  }
  return(0);
}

然后CPU占用接近100%了。

原文地址:https://www.cnblogs.com/bonelee/p/6616418.html