Hyluss

[OpenMP] Schedule

Nov 29th, 2017
356
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. // prir lab2iPol.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <time.h>
  8. #include <omp.h>
  9.  
  10.  
  11. int _tmain(int argc, _TCHAR* argv[])
  12. {
  13.      int i, n, id, chunk_size;
  14.      n = 10; chunk_size = 5;
  15.     #pragma omp parallel default(none) private(i, id) shared(n, chunk_size)
  16.      {
  17.         #pragma omp single
  18.          {
  19.              printf("Program jest wykonywany na %d watkach.\n", omp_get_num_threads());
  20.          }
  21.     #pragma omp for schedule(static, chunk_size)
  22.          for (i = 0; i < n; i++)
  23.          {
  24.              id = omp_get_thread_num();
  25.             printf("Iteracja %d wykonana przez watek nr. %d.\n", i, id);
  26.          }
  27.      }
  28.      return 0;
  29. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment