00001 #include <stdio.h>
00002 #include <omp.h>
00003
00004 extern void abort (void);
00005
00006 void
00007 parallel (int a, int b)
00008 {
00009 int bad, LASTPRIV, LASTPRIV_SEC;
00010 int i;
00011
00012 a = b = 3;
00013
00014 bad = 0;
00015
00016 #pragma omp parallel firstprivate (a,b) shared (bad) num_threads (5)
00017 {
00018 if (a != 3 || b != 3)
00019 bad = 1;
00020
00021 #pragma omp for lastprivate (LASTPRIV)
00022 for (i = 0; i < 10; i++)
00023 LASTPRIV = i;
00024
00025 #pragma omp sections lastprivate (LASTPRIV_SEC)
00026 {
00027 #pragma omp section
00028 { LASTPRIV_SEC = 3; }
00029
00030 #pragma omp section
00031 { LASTPRIV_SEC = 42; }
00032 }
00033
00034 }
00035
00036 if (LASTPRIV != 9)
00037 abort ();
00038
00039 if (LASTPRIV_SEC != 42)
00040 abort ();
00041
00042 if (bad)
00043 abort ();
00044 }
00045
00046 int main()
00047 {
00048 parallel (1, 2);
00049 return 0;
00050 }