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