File: test2.c

package info (click to toggle)
opari 1.1%2Bdfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 728 kB
  • sloc: cpp: 2,005; ansic: 901; f90: 252; makefile: 128; sh: 86; fortran: 50
file content (83 lines) | stat: -rw-r--r-- 1,263 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <stdio.h>
#ifdef _OPENMP
  #include <omp.h>
#endif

int main() {
  int i;

 #pragma omp parallel
 {
   printf("parallel\n");
   #pragma omp for nowait
   for(i=0; i<4; ++i) {
     printf("do nowait %d\n", i);
   }

   #pragma omp barrier

   #pragma omp for
   for(i=0; i<4; ++i) {
     printf("do %d\n", i);
   }

   #pragma omp sections nowait
   {
     #pragma omp section
     printf("section nowait 1\n");
     #pragma omp section
     { printf("section nowait 2\n"); }
   }

   #pragma omp master
   {
     printf("master\n");
   }

   #pragma omp critical
   {
     printf("critical\n");
   }

   #pragma omp critical(foobar)
   {
     printf("critical\n");
   }

   #pragma omp atomic
   /* -------------- */
   /* do this atomic */
   i += 1;
   /* -------------- */

   #pragma omp single
   {
     printf("single\n");
   }

   #pragma omp sections
   {
     #pragma omp section
     { printf("section 1\n"); }
     #pragma omp section
     printf("section 2\n");
   }
 }

 printf("sequential1\n");

 #pragma omp parallel for
 for(i=0; i<4; ++i) {
   printf("pdo %d\n", i);
 }

 printf("sequential2\n");

 #pragma omp parallel sections
 {
   #pragma omp section
   printf("psection 1\n");
   #pragma omp section
   printf("psection 2\n");
 }
}