吃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占用接近100%了。

posted @ 2017-03-25 10:46  bonelee  阅读(581)  评论(0编辑  收藏  举报