SHARE
TWEET

Untitled

a guest Oct 15th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <omp.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     // private, shared, first private, last private - next
  10.     #pragma omp parallel
  11.     {
  12.         for (int i = 0; i < 10; i++) {
  13.             int tid = omp_get_thread_num();
  14.  
  15.             cout << "iteracja: " << i << " nr watku: " << tid << endl;
  16.         }
  17.     }
  18.    
  19.  
  20.     /*omp_set_num_threads(1);
  21.  
  22.     #pragma omp parallel
  23.     {
  24.         #pragma omp sections
  25.         {
  26.             #pragma omp section
  27.             {
  28.                 int tid = omp_get_thread_num();
  29.                 cout << "Tid: " << tid << endl;
  30.                 cout << "Hello World! " << endl;
  31.             }
  32.             #pragma omp section
  33.             {
  34.                 int tid = omp_get_thread_num();
  35.                 cout << "Tid: " << tid << endl;
  36.                 cout << "Hello World! " << endl;
  37.             }
  38.         }
  39.     }*/
  40.    
  41.     //cout << endl;
  42.  
  43.     //omp_set_num_threads(5);
  44.     //#pragma omp parallel
  45.     //{
  46.     //  int tid = omp_get_thread_num();
  47.     //  int threadNum = omp_get_num_threads();
  48.     //  if (tid == 0) {
  49.     //      cout << "Thread num: " << threadNum << endl;
  50.     //  }
  51.     //  //cout << "Hello World! " << tid << endl;
  52.     //}
  53. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top