Advertisement
Guest User

Untitled

a guest
Oct 30th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <omp.h>
  4. #define N 4
  5.  
  6. int main(int argc, char *argv[]) {
  7.  
  8.     std::vector<std::vector<int>> Threads(N, std::vector<int>());
  9.     std::cout << "Working on " << N << " threads " <<std::endl;
  10.     #pragma omp parallel for num_threads(N) schedule(static, 3)
  11.     for(int i = 0; i < 9; i++) {
  12.         Threads[omp_get_thread_num()].push_back(i);
  13.     }
  14.  
  15.     std::cout << "         Iterations    " << std::endl;
  16.     for (int i(0); i < N; i++) {
  17.         std::cout << "Thread " << i << " : ";
  18.         for(int j(0); j < Threads[i].size(); j++) {
  19.             std::cout << Threads[i][j] << " ";
  20.         }
  21.         std::cout << "\n";
  22.     }
  23.  
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement