Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

OMP Bad Behaviour

By: a guest on Aug 10th, 2012  |  syntax: C++  |  size: 0.33 KB  |  views: 38  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <iostream>
  2. #include "Windows.h"
  3.  
  4. using namespace std;
  5.  
  6. int main(){
  7.         int x = 0;
  8.         for (int i=0; i<100000; i++){ //pretend main loop
  9. #pragma omp parallel for schedule(dynamic,50) reduction(+ : x)
  10.                 for (int p=0; p<10000; p++){
  11.                         x++;
  12.                 }
  13.                 cout << "X = " << x << "\nNow sleeping for 50ms.\n";
  14.                 Sleep(50);
  15.         }
  16. };
clone this paste RAW Paste Data