Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - #include <iostream>
 - #include <vector>
 - #include <omp.h>
 - #define N 4
 - int main(int argc, char *argv[]) {
 - std::vector<std::vector<int>> Threads(N, std::vector<int>());
 - std::cout << "Working on " << N << " threads " <<std::endl;
 - #pragma omp parallel for num_threads(N) schedule(static, 3)
 - for(int i = 0; i < 9; i++) {
 - Threads[omp_get_thread_num()].push_back(i);
 - }
 - std::cout << " Iterations " << std::endl;
 - for (int i(0); i < N; i++) {
 - std::cout << "Thread " << i << " : ";
 - for(int j(0); j < Threads[i].size(); j++) {
 - std::cout << Threads[i][j] << " ";
 - }
 - std::cout << "\n";
 - }
 - return 0;
 - }
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment