aboutsummaryrefslogtreecommitdiff
path: root/final/testsuite/c
diff options
context:
space:
mode:
Diffstat (limited to 'final/testsuite/c')
-rw-r--r--final/testsuite/c/has_openmp.c30
-rw-r--r--final/testsuite/c/omp_atomic.c434
-rw-r--r--final/testsuite/c/omp_barrier.c41
-rw-r--r--final/testsuite/c/omp_critical.c42
-rw-r--r--final/testsuite/c/omp_flush.c50
-rw-r--r--final/testsuite/c/omp_for_collapse.c56
-rw-r--r--final/testsuite/c/omp_for_firstprivate.c55
-rw-r--r--final/testsuite/c/omp_for_lastprivate.c52
-rw-r--r--final/testsuite/c/omp_for_nowait.c57
-rw-r--r--final/testsuite/c/omp_for_ordered.c60
-rw-r--r--final/testsuite/c/omp_for_private.c64
-rw-r--r--final/testsuite/c/omp_for_reduction.c429
-rw-r--r--final/testsuite/c/omp_for_schedule_auto.c55
-rw-r--r--final/testsuite/c/omp_for_schedule_dynamic.c111
-rw-r--r--final/testsuite/c/omp_for_schedule_guided.c225
-rw-r--r--final/testsuite/c/omp_for_schedule_static.c165
-rw-r--r--final/testsuite/c/omp_for_schedule_static_3.c212
-rw-r--r--final/testsuite/c/omp_get_num_threads.c39
-rw-r--r--final/testsuite/c/omp_get_wtick.c24
-rw-r--r--final/testsuite/c/omp_get_wtime.c38
-rw-r--r--final/testsuite/c/omp_in_parallel.c51
-rw-r--r--final/testsuite/c/omp_lock.c45
-rw-r--r--final/testsuite/c/omp_master.c37
-rw-r--r--final/testsuite/c/omp_master_3.c44
-rw-r--r--final/testsuite/c/omp_nest_lock.c45
-rw-r--r--final/testsuite/c/omp_nested.c42
-rw-r--r--final/testsuite/c/omp_parallel_copyin.c47
-rw-r--r--final/testsuite/c/omp_parallel_default.c44
-rw-r--r--final/testsuite/c/omp_parallel_firstprivate.c48
-rw-r--r--final/testsuite/c/omp_parallel_for_firstprivate.c36
-rw-r--r--final/testsuite/c/omp_parallel_for_if.c38
-rw-r--r--final/testsuite/c/omp_parallel_for_lastprivate.c34
-rw-r--r--final/testsuite/c/omp_parallel_for_ordered.c62
-rw-r--r--final/testsuite/c/omp_parallel_for_private.c48
-rw-r--r--final/testsuite/c/omp_parallel_for_reduction.c280
-rw-r--r--final/testsuite/c/omp_parallel_if.c40
-rw-r--r--final/testsuite/c/omp_parallel_num_threads.c46
-rw-r--r--final/testsuite/c/omp_parallel_private.c50
-rw-r--r--final/testsuite/c/omp_parallel_reduction.c278
-rw-r--r--final/testsuite/c/omp_parallel_sections_firstprivate.c49
-rw-r--r--final/testsuite/c/omp_parallel_sections_lastprivate.c70
-rw-r--r--final/testsuite/c/omp_parallel_sections_private.c65
-rw-r--r--final/testsuite/c/omp_parallel_sections_reduction.c568
-rw-r--r--final/testsuite/c/omp_parallel_shared.c43
-rw-r--r--final/testsuite/c/omp_section_firstprivate.c52
-rw-r--r--final/testsuite/c/omp_section_lastprivate.c73
-rw-r--r--final/testsuite/c/omp_section_private.c69
-rw-r--r--final/testsuite/c/omp_sections_nowait.c66
-rw-r--r--final/testsuite/c/omp_sections_reduction.c613
-rw-r--r--final/testsuite/c/omp_single.c43
-rw-r--r--final/testsuite/c/omp_single_copyprivate.c50
-rw-r--r--final/testsuite/c/omp_single_nowait.c60
-rw-r--r--final/testsuite/c/omp_single_private.c56
-rw-r--r--final/testsuite/c/omp_task.c52
-rw-r--r--final/testsuite/c/omp_task_final.c52
-rw-r--r--final/testsuite/c/omp_task_firstprivate.c51
-rw-r--r--final/testsuite/c/omp_task_if.c43
-rw-r--r--final/testsuite/c/omp_task_imp_firstprivate.c51
-rw-r--r--final/testsuite/c/omp_task_private.c53
-rw-r--r--final/testsuite/c/omp_task_shared.c47
-rw-r--r--final/testsuite/c/omp_task_untied.c69
-rw-r--r--final/testsuite/c/omp_taskwait.c75
-rw-r--r--final/testsuite/c/omp_taskyield.c59
-rw-r--r--final/testsuite/c/omp_test_lock.c47
-rw-r--r--final/testsuite/c/omp_test_nest_lock.c48
-rw-r--r--final/testsuite/c/omp_threadprivate.c97
-rw-r--r--final/testsuite/c/omp_threadprivate_for.c44
67 files changed, 6219 insertions, 0 deletions
diff --git a/final/testsuite/c/has_openmp.c b/final/testsuite/c/has_openmp.c
new file mode 100644
index 0000000..983a973
--- /dev/null
+++ b/final/testsuite/c/has_openmp.c
@@ -0,0 +1,30 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the OpenMp support.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>_OPENMP</ompts:directive>
+<ompts:testcode>
+#include <stdio.h>
+
+#include "omp_testsuite.h"
+
+int <ompts:testcode:functionname>has_openmp</ompts:testcode:functionname>(FILE * logFile){
+ <ompts:orphan:vars>
+ int rvalue = 0;
+ </ompts:orphan:vars>
+
+ <ompts:orphan>
+ <ompts:check>
+#ifdef _OPENMP
+ rvalue = 1;
+#endif
+ </ompts:check>
+ <ompts:crosscheck>
+#if 0
+ rvalue = 1;
+#endif
+ </ompts:crosscheck>
+ </ompts:orphan>
+ return (rvalue);
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_atomic.c b/final/testsuite/c/omp_atomic.c
new file mode 100644
index 0000000..6c2d1aa
--- /dev/null
+++ b/final/testsuite/c/omp_atomic.c
@@ -0,0 +1,434 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp atomic directive by counting up a variable in a parallelized loop with an atomic directive.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp atomic</ompts:directive>
+<ompts:testcode>
+#include <stdio.h>
+#include <unistd.h>
+#include <math.h>
+
+#include "omp_testsuite.h"
+#include "omp_my_sleep.h"
+
+int <ompts:testcode:functionname>omp_atomic</ompts:testcode:functionname> (FILE * logFile)
+{
+ <ompts:orphan:vars>
+ int sum;
+ int diff;
+ double dsum = 0;
+ double dt = 0.5; /* base of geometric row for + and - test*/
+ double ddiff;
+ int product;
+ int x;
+ int *logics;
+ int bit_and = 1;
+ int bit_or = 0;
+ int exclusiv_bit_or = 0;
+ </ompts:orphan:vars>
+
+#define DOUBLE_DIGITS 20 /* dt^DOUBLE_DIGITS */
+#define MAX_FACTOR 10
+#define KNOWN_PRODUCT 3628800 /* 10! */
+ int j;
+ int known_sum;
+ int known_diff;
+ int known_product;
+ int result = 0;
+ int logic_and = 1;
+ int logic_or = 0;
+ double dknown_sum;
+ double rounding_error = 1.E-9;
+ double dpt, div;
+ int logicsArray[LOOPCOUNT];
+ logics = logicsArray;
+
+ sum = 0;
+ diff = 0;
+ product = 1;
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int i;
+#pragma omp for
+ for (i = 1; i <= LOOPCOUNT; i++)
+ {
+ <ompts:check>#pragma omp atomic</ompts:check>
+ sum += i;
+ }
+ </ompts:orphan>
+ }
+ known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2;
+ if (known_sum != sum)
+ {
+ fprintf (logFile,
+ "Error in sum with integers: Result was %d instead of %d.\n",
+ sum, known_sum);
+ result++;
+ }
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int i;
+#pragma omp for
+ for (i = 0; i < LOOPCOUNT; i++)
+ {
+ <ompts:check>#pragma omp atomic</ompts:check>
+ diff -= i;
+ }
+ </ompts:orphan>
+ }
+ known_diff = ((LOOPCOUNT - 1) * LOOPCOUNT) / 2 * -1;
+ if (diff != known_diff)
+ {
+ fprintf (logFile,
+ "Error in difference with integers: Result was %d instead of 0.\n",
+ diff);
+ result++;
+ }
+
+ /* Tests for doubles */
+ dsum = 0;
+ dpt = 1;
+
+ for (j = 0; j < DOUBLE_DIGITS; ++j)
+ {
+ dpt *= dt;
+ }
+ dknown_sum = (1 - dpt) / (1 -dt);
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int i;
+#pragma omp for
+ for (i = 0; i < DOUBLE_DIGITS; ++i)
+ {
+ <ompts:check>#pragma omp atomic</ompts:check>
+ dsum += pow (dt, i);
+ }
+ </ompts:orphan>
+ }
+
+ if (dsum != dknown_sum && (fabs (dsum - dknown_sum) > rounding_error))
+ {
+ fprintf (logFile,
+ "Error in sum with doubles: Result was %f instead of: %f (Difference: %E)\n",
+ dsum, dknown_sum, dsum - dknown_sum);
+ result++;
+ }
+
+ dpt = 1;
+
+ for (j = 0; j < DOUBLE_DIGITS; ++j)
+ {
+ dpt *= dt;
+ }
+ ddiff = (1 - dpt) / (1 - dt);
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int i;
+#pragma omp for
+ for (i = 0; i < DOUBLE_DIGITS; ++i)
+ {
+ <ompts:check>#pragma omp atomic</ompts:check>
+ ddiff -= pow (dt, i);
+ }
+ </ompts:orphan>
+ }
+ if (fabs (ddiff) > rounding_error)
+ {
+ fprintf (logFile,
+ "Error in difference with doubles: Result was %E instead of 0.0\n",
+ ddiff);
+ result++;
+ }
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int i;
+#pragma omp for
+ for (i = 1; i <= MAX_FACTOR; i++)
+ {
+ <ompts:check>#pragma omp atomic</ompts:check>
+ product *= i;
+ }
+ </ompts:orphan>
+ }
+
+ known_product = KNOWN_PRODUCT;
+ if (known_product != product)
+ {
+ fprintf (logFile,
+ "Error in product with integers: Result was %d instead of %d\n",
+ product, known_product);
+ result++;
+ }
+
+ product = KNOWN_PRODUCT;
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int i;
+#pragma omp for
+ for (i = 1; i <= MAX_FACTOR; ++i)
+ {
+ <ompts:check>#pragma omp atomic</ompts:check>
+ product /= i;
+ }
+ </ompts:orphan>
+ }
+
+ if (product != 1)
+ {
+ fprintf (logFile,
+ "Error in product division with integers: Result was %d instead of 1\n",
+ product);
+ result++;
+ }
+
+ div = 5.0E+5;
+#pragma omp parallel
+ {
+ int i;
+#pragma omp for
+ for (i = 1; i <= MAX_FACTOR; i++)
+ {
+ <ompts:check>#pragma omp atomic</ompts:check>
+ div /= i;
+ }
+ }
+
+ if (fabs(div-0.137787) >= 1.0E-4 )
+ {
+ result++;
+ fprintf (logFile,
+ "Error in division with double: Result was %f instead of 0.137787\n", div);
+ }
+
+ x = 0;
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int i;
+#pragma omp for
+ for (i = 0; i < LOOPCOUNT; ++i)
+ {
+ <ompts:check>#pragma omp atomic</ompts:check>
+ x++;
+ }
+ </ompts:orphan>
+ }
+
+ if (x != LOOPCOUNT)
+ {
+ result++;
+ fprintf (logFile, "Error in ++\n");
+ }
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int i;
+#pragma omp for
+ for (i = 0; i < LOOPCOUNT; ++i)
+ {
+ <ompts:check>#pragma omp atomic</ompts:check>
+ x--;
+ }
+ </ompts:orphan>
+ }
+
+ if (x != 0)
+ {
+ result++;
+ fprintf (logFile, "Error in --\n");
+ }
+
+ for (j = 0; j < LOOPCOUNT; ++j)
+ {
+ logics[j] = 1;
+ }
+ bit_and = 1;
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int i;
+#pragma omp for
+ for (i = 0; i < LOOPCOUNT; ++i)
+ {
+ <ompts:check>#pragma omp atomic</ompts:check>
+ bit_and &= logics[i];
+ }
+ </ompts:orphan>
+ }
+
+ if (!bit_and)
+ {
+ result++;
+ fprintf (logFile, "Error in BIT AND part 1\n");
+ }
+
+ bit_and = 1;
+ logics[LOOPCOUNT / 2] = 0;
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int i;
+#pragma omp for
+ for (i = 0; i < LOOPCOUNT; ++i)
+ {
+ <ompts:check>#pragma omp atomic</ompts:check>
+ bit_and &= logics[i];
+ }
+ </ompts:orphan>
+ }
+
+ if (bit_and)
+ {
+ result++;
+ fprintf (logFile, "Error in BIT AND part 2\n");
+ }
+
+ for (j = 0; j < LOOPCOUNT; j++)
+ {
+ logics[j] = 0;
+ }
+ bit_or = 0;
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int i;
+#pragma omp for
+ for (i = 0; i < LOOPCOUNT; ++i)
+ {
+ <ompts:check>#pragma omp atomic</ompts:check>
+ bit_or |= logics[i];
+ }
+ </ompts:orphan>
+ }
+
+ if (bit_or)
+ {
+ result++;
+ fprintf (logFile, "Error in BIT OR part 1\n");
+ }
+ bit_or = 0;
+ logics[LOOPCOUNT / 2] = 1;
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int i;
+#pragma omp for
+ for (i = 0; i < LOOPCOUNT; ++i)
+ {
+ <ompts:check>#pragma omp atomic</ompts:check>
+ bit_or |= logics[i];
+ }
+ </ompts:orphan>
+ }
+
+ if (!bit_or)
+ {
+ result++;
+ fprintf (logFile, "Error in BIT OR part 2\n");
+ }
+
+ for (j = 0; j < LOOPCOUNT; j++)
+ {
+ logics[j] = 0;
+ }
+ exclusiv_bit_or = 0;
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int i;
+#pragma omp for
+ for (i = 0; i < LOOPCOUNT; ++i)
+ {
+ <ompts:check>#pragma omp atomic</ompts:check>
+ exclusiv_bit_or ^= logics[i];
+ }
+ </ompts:orphan>
+ }
+
+ if (exclusiv_bit_or)
+ {
+ result++;
+ fprintf (logFile, "Error in EXCLUSIV BIT OR part 1\n");
+ }
+
+ exclusiv_bit_or = 0;
+ logics[LOOPCOUNT / 2] = 1;
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int i;
+#pragma omp for
+ for (i = 0; i < LOOPCOUNT; ++i)
+ {
+ <ompts:check>#pragma omp atomic</ompts:check>
+ exclusiv_bit_or ^= logics[i];
+ }
+ </ompts:orphan>
+ }
+
+ if (!exclusiv_bit_or)
+ {
+ result++;
+ fprintf (logFile, "Error in EXCLUSIV BIT OR part 2\n");
+ }
+
+ x = 1;
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int i;
+#pragma omp for
+ for (i = 0; i < 10; ++i)
+ {
+ <ompts:check>#pragma omp atomic</ompts:check>
+ x <<= 1;
+ }
+ </ompts:orphan>
+ }
+
+ if ( x != 1024)
+ {
+ result++;
+ fprintf (logFile, "Error in <<\n");
+ x = 1024;
+ }
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int i;
+#pragma omp for
+ for (i = 0; i < 10; ++i)
+ {
+ <ompts:check>#pragma omp atomic</ompts:check>
+ x >>= 1;
+ }
+ </ompts:orphan>
+ }
+
+ if (x != 1)
+ {
+ result++;
+ fprintf (logFile, "Error in >>\n");
+ }
+
+ return (result == 0);
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_barrier.c b/final/testsuite/c/omp_barrier.c
new file mode 100644
index 0000000..df669e2
--- /dev/null
+++ b/final/testsuite/c/omp_barrier.c
@@ -0,0 +1,41 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp barrier directive. The test creates several threads and sends one of them sleeping before setting a flag. After the barrier the other ones do some little work depending on the flag.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp barrier</ompts:directive>
+<ompts:testcode>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "omp_testsuite.h"
+#include "omp_my_sleep.h"
+
+int <ompts:testcode:functionname>omp_barrier</ompts:testcode:functionname> (FILE * logFile)
+{
+ <ompts:orphan:vars>
+ int result1;
+ int result2;
+ </ompts:orphan:vars>
+
+ result1 = 0;
+ result2 = 0;
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int rank;
+ rank = omp_get_thread_num ();
+ if (rank ==1) {
+ my_sleep(SLEEPTIME_LONG);
+ result2 = 3;
+ }
+<ompts:check>#pragma omp barrier</ompts:check>
+ if (rank == 2) {
+ result1 = result2;
+ }
+ </ompts:orphan>
+ }
+ printf("result1=%d\n",result1);
+ return (result1 == 3);
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_critical.c b/final/testsuite/c/omp_critical.c
new file mode 100644
index 0000000..cb3f264
--- /dev/null
+++ b/final/testsuite/c/omp_critical.c
@@ -0,0 +1,42 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp critical directive by counting up a variable in a parallelized loop within a critical section.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp critical</ompts:directive>
+<ompts:testcode>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "omp_testsuite.h"
+#include "omp_my_sleep.h"
+
+int <ompts:testcode:functionname>omp_critical</ompts:testcode:functionname> (FILE * logFile)
+{
+ <ompts:orphan:vars>
+ int sum;
+ </ompts:orphan:vars>
+ sum=0;
+ int known_sum;
+
+ <ompts:orphan>
+ #pragma omp parallel
+ {
+ int mysum=0;
+ int i;
+
+ #pragma omp for
+ for (i = 0; i < 1000; i++)
+ mysum = mysum + i;
+
+ <ompts:check>#pragma omp critical</ompts:check>
+ sum = mysum +sum;
+
+ } /* end of parallel */
+ </ompts:orphan>
+
+ printf("sum=%d\n",sum);
+ known_sum = 999 * 1000 / 2;
+ return (known_sum == sum);
+
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_flush.c b/final/testsuite/c/omp_flush.c
new file mode 100644
index 0000000..3fabf8e
--- /dev/null
+++ b/final/testsuite/c/omp_flush.c
@@ -0,0 +1,50 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp flush directive.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp flush</ompts:directive>
+<ompts:dependences>omp barrier</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "omp_testsuite.h"
+#include "omp_my_sleep.h"
+
+int <ompts:testcode:functionname>omp_flush</ompts:testcode:functionname> (FILE * logFile)
+{
+ <ompts:orphan:vars>
+ int result1;
+ int result2;
+ int dummy;
+ </ompts:orphan:vars>
+
+ result1 = 0;
+ result2 = 0;
+
+#pragma omp parallel
+ {
+ int rank;
+ rank = omp_get_thread_num ();
+
+#pragma omp barrier
+ if (rank == 1) {
+ result2 = 3;
+ <ompts:orphan>
+ <ompts:check>#pragma omp flush (result2)</ompts:check>
+ dummy = result2;
+ </ompts:orphan>
+ }
+
+ if (rank == 0) {
+ <ompts:check>my_sleep(SLEEPTIME_LONG);</ompts:check>
+ <ompts:orphan>
+ <ompts:check>#pragma omp flush (result2)</ompts:check>
+ result1 = result2;
+ </ompts:orphan>
+ }
+ } /* end of parallel */
+
+ return ((result1 == result2) && (result2 == dummy) && (result2 == 3));
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_for_collapse.c b/final/testsuite/c/omp_for_collapse.c
new file mode 100644
index 0000000..7216f40
--- /dev/null
+++ b/final/testsuite/c/omp_for_collapse.c
@@ -0,0 +1,56 @@
+<ompts:test>
+<ompts:testdescription>Test with omp for collapse clause. Bind with two loops. Without the collapse clause, the first loop will not be ordered</ompts:testdescription>
+<ompts:ompversion>3.0</ompts:ompversion>
+<ompts:directive>omp for collapse</ompts:directive>
+<ompts:dependences>omp critical,omp for schedule</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include <math.h>
+
+#include "omp_testsuite.h"
+
+
+/* Utility function to check that i is increasing monotonically
+ with each call */
+static int check_i_islarger (int i)
+{
+ static int last_i;
+ int islarger;
+ if (i==1)
+ last_i=0;
+ islarger = ((i >= last_i)&&(i - last_i<=1));
+ last_i = i;
+ return (islarger);
+}
+
+int <ompts:testcode:functionname>omp_for_collapse</ompts:testcode:functionname> (FILE * logFile)
+{
+ <ompts:orphan:vars>
+ int is_larger = 1;
+ </ompts:orphan:vars>
+
+ #pragma omp parallel
+ {
+ <ompts:orphan>
+ int i,j;
+ int my_islarger = 1;
+ #pragma omp for private(i,j) schedule(static,1) <ompts:check>collapse(2)</ompts:check> ordered
+ for (i = 1; i < 100; i++){
+ <ompts:crosscheck>my_islarger = check_i_islarger(i)&& my_islarger;</ompts:crosscheck>
+ for (j =1; j <100; j++)
+ {
+ <ompts:check>
+ #pragma omp ordered
+ my_islarger = check_i_islarger(i)&&my_islarger;
+ </ompts:check>
+ } /* end of for */
+ }
+ #pragma omp critical
+ is_larger = is_larger && my_islarger;
+ </ompts:orphan>
+ }
+
+ return (is_larger);
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_for_firstprivate.c b/final/testsuite/c/omp_for_firstprivate.c
new file mode 100644
index 0000000..2272014
--- /dev/null
+++ b/final/testsuite/c/omp_for_firstprivate.c
@@ -0,0 +1,55 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp for firstprivate clause by counting up a variable in a parallelized loop. Each thread has a firstprivate variable (1) and an variable (2) declared by for firstprivate. First it stores the result of its last iteration in variable (2). Then it stores the value of the variable (2) in its firstprivate variable (1). At the end all firstprivate variables (1) are added to a total sum in a critical section and compared with the correct result.</ompts:testdescription>
+<ompts:ompversion>3.0</ompts:ompversion>
+<ompts:directive>omp for firstprivate</ompts:directive>
+<ompts:dependences>omp critical,omp parallel firstprivate</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include <math.h>
+
+#include "omp_testsuite.h"
+
+int sum1;
+#pragma omp threadprivate(sum1)
+
+int <ompts:testcode:functionname>omp_for_firstprivate</ompts:testcode:functionname> (FILE * logFile)
+{
+ int sum;
+ <ompts:orphan:vars>
+ int sum0;
+ </ompts:orphan:vars>
+
+ int known_sum;
+ int threadsnum;
+
+ sum = 0;
+ sum0 = 12345;
+ sum1 = 0;
+
+#pragma omp parallel
+ {
+#pragma omp single
+ {
+ threadsnum=omp_get_num_threads();
+ }
+ /* sum0 = 0; */
+ <ompts:orphan>
+ int i;
+#pragma omp for <ompts:check>firstprivate(sum0)</ompts:check><ompts:crosscheck>private(sum0)</ompts:crosscheck>
+ for (i = 1; i <= LOOPCOUNT; i++)
+ {
+ sum0 = sum0 + i;
+ sum1 = sum0;
+ } /* end of for */
+ </ompts:orphan>
+#pragma omp critical
+ {
+ sum = sum + sum1;
+ } /* end of critical */
+ } /* end of parallel */
+
+ known_sum = 12345* threadsnum+ (LOOPCOUNT * (LOOPCOUNT + 1)) / 2;
+ return (known_sum == sum);
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_for_lastprivate.c b/final/testsuite/c/omp_for_lastprivate.c
new file mode 100644
index 0000000..c2080a2
--- /dev/null
+++ b/final/testsuite/c/omp_for_lastprivate.c
@@ -0,0 +1,52 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp for lastprivate clause by counting up a variable in a parallelized loop. Each thread saves the next summand in a lastprivate variable i0. At the end i0 is compared to the value of the expected last summand.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp for lastprivate</ompts:directive>
+<ompts:dependences>omp critical,omp parallel firstprivate,omp schedule</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include <math.h>
+
+#include "omp_testsuite.h"
+
+int sum0;
+#pragma omp threadprivate(sum0)
+
+int <ompts:testcode:functionname>omp_for_lastprivate</ompts:testcode:functionname> (FILE * logFile)
+{
+ int sum = 0;
+ int known_sum;
+ <ompts:orphan:vars>
+ int i0;
+ </ompts:orphan:vars>
+
+ i0 = -1;
+
+#pragma omp parallel
+ {
+ sum0 = 0;
+ { /* Begin of orphaned block */
+ <ompts:orphan>
+ int i;
+#pragma omp for schedule(static,7) <ompts:check>lastprivate(i0)</ompts:check>
+ for (i = 1; i <= LOOPCOUNT; i++)
+ {
+ sum0 = sum0 + i;
+ i0 = i;
+ } /* end of for */
+ </ompts:orphan>
+ } /* end of orphaned block */
+
+#pragma omp critical
+ {
+ sum = sum + sum0;
+ } /* end of critical */
+ } /* end of parallel */
+
+ known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2;
+ fprintf(logFile," known_sum = %d , sum = %d \n",known_sum,sum);
+ fprintf(logFile," LOOPCOUNT = %d , i0 = %d \n",LOOPCOUNT,i0);
+ return ((known_sum == sum) && (i0 == LOOPCOUNT) );
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_for_nowait.c b/final/testsuite/c/omp_for_nowait.c
new file mode 100644
index 0000000..a3ec40b
--- /dev/null
+++ b/final/testsuite/c/omp_for_nowait.c
@@ -0,0 +1,57 @@
+<ompts:test>
+<ompts:description>Test which checks the omp parallel for nowait directive. It fills an array with values and operates on these in the following.</ompts:description>
+<ompts:directive>omp parallel for nowait</ompts:directive>
+<ompts:version>1.0</ompts:version>
+<ompts:dependences>omp parallel for, omp flush</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+
+#include "omp_testsuite.h"
+#include "omp_my_sleep.h"
+
+int <ompts:testcode:functionname>omp_for_nowait</ompts:testcode:functionname> (FILE * logFile)
+{
+ <ompts:orphan:vars>
+ int result;
+ int count;
+ </ompts:orphan:vars>
+ int j;
+ int myarray[LOOPCOUNT];
+
+ result = 0;
+ count = 0;
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int rank;
+ int i;
+
+ rank = omp_get_thread_num();
+
+#pragma omp for <ompts:check>nowait</ompts:check>
+ for (i = 0; i < LOOPCOUNT; i++) {
+ if (i == 0) {
+ fprintf (logFile, "Thread nr %d entering for loop and going to sleep.\n", rank);
+ my_sleep(SLEEPTIME);
+ count = 1;
+#pragma omp flush(count)
+ fprintf (logFile, "Thread nr %d woke up and set count = 1.\n", rank);
+ }
+ }
+
+ fprintf (logFile, "Thread nr %d exited first for loop and enters the second.\n", rank);
+#pragma omp for
+ for (i = 0; i < LOOPCOUNT; i++)
+ {
+#pragma omp flush(count)
+ if (count == 0)
+ result = 1;
+ }
+ </ompts:orphan>
+ }
+
+ return result;
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_for_ordered.c b/final/testsuite/c/omp_for_ordered.c
new file mode 100644
index 0000000..6297d04
--- /dev/null
+++ b/final/testsuite/c/omp_for_ordered.c
@@ -0,0 +1,60 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp ordered directive by counting up an variable in an parallelized loop and watching each iteration if the sumand is larger as the last one.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp for ordered</ompts:directive>
+<ompts:dependences>omp critical,omp for schedule</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include <math.h>
+
+#include "omp_testsuite.h"
+
+static int last_i = 0;
+
+/* Utility function to check that i is increasing monotonically
+ with each call */
+static int check_i_islarger (int i)
+{
+ int islarger;
+ islarger = (i > last_i);
+ last_i = i;
+ return (islarger);
+}
+
+int <ompts:testcode:functionname>omp_for_ordered</ompts:testcode:functionname> (FILE * logFile)
+{
+ <ompts:orphan:vars>
+ int sum;
+ int is_larger = 1;
+ </ompts:orphan:vars>
+ int known_sum;
+
+ last_i = 0;
+ sum = 0;
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int i;
+ int my_islarger = 1;
+#pragma omp for schedule(static,1) ordered
+ for (i = 1; i < 100; i++)
+ {
+ <ompts:check>#pragma omp ordered</ompts:check>
+ {
+ my_islarger = check_i_islarger(i) && my_islarger;
+ sum = sum + i;
+ } /* end of ordered */
+ } /* end of for */
+#pragma omp critical
+ {
+ is_larger = is_larger && my_islarger;
+ } /* end of critical */
+ </ompts:orphan>
+ }
+
+ known_sum=(99 * 100) / 2;
+ return ((known_sum == sum) && is_larger);
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_for_private.c b/final/testsuite/c/omp_for_private.c
new file mode 100644
index 0000000..8a65110
--- /dev/null
+++ b/final/testsuite/c/omp_for_private.c
@@ -0,0 +1,64 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp for private clause by counting up a variable in a parallelized loop. Each thread has a private variable (1) and a variable (2) declared by for private. First it stores the result of its last iteration in variable (2). Then this thread waits some time before it stores the value of the variable (2) in its private variable (1). At the beginning of the next iteration the value of (1) is assigned to (2). At the end all private variables (1) are added to a total sum in a critical section and compared with the correct result.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp for private</ompts:directive>
+<ompts:dependences>omp parallel,omp flush,omp critical,omp threadprivate</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include <math.h>
+#include "omp_testsuite.h"
+
+/* Utility function do spend some time in a loop */
+static void do_some_work (){
+ int i;
+ double sum = 0;
+ for(i = 0; i < 1000; i++){
+ sum += sqrt ((double) i);
+ }
+}
+
+int sum1;
+#pragma omp threadprivate(sum1)
+
+int <ompts:testcode:functionname>omp_for_private</ompts:testcode:functionname> (FILE * logFile)
+{
+ int sum = 0;
+ <ompts:orphan:vars>
+ int sum0;
+ </ompts:orphan:vars>
+
+ int known_sum;
+
+ sum0 = 0; /* setting (global) sum0 = 0 */
+
+#pragma omp parallel
+ {
+ sum1 = 0; /* setting sum1 in each thread to 0 */
+
+ { /* begin of orphaned block */
+ <ompts:orphan>
+ int i;
+#pragma omp for <ompts:check>private(sum0)</ompts:check> schedule(static,1)
+ for (i = 1; i <= LOOPCOUNT; i++)
+ {
+ sum0 = sum1;
+#pragma omp flush
+ sum0 = sum0 + i;
+ do_some_work ();
+#pragma omp flush
+ sum1 = sum0;
+ } /* end of for */
+ </ompts:orphan>
+ } /* end of orphaned block */
+
+#pragma omp critical
+ {
+ sum = sum + sum1;
+ } /*end of critical*/
+ } /* end of parallel*/
+
+ known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2;
+ return (known_sum == sum);
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_for_reduction.c b/final/testsuite/c/omp_for_reduction.c
new file mode 100644
index 0000000..6dd1917
--- /dev/null
+++ b/final/testsuite/c/omp_for_reduction.c
@@ -0,0 +1,429 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp for reduction directive wich all its options.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp for reduction</ompts:directive>
+<ompts:testcode>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include "omp_testsuite.h"
+
+
+int <ompts:testcode:functionname>omp_for_reduction</ompts:testcode:functionname> (FILE * logFile)
+{
+ <ompts:orphan:vars>
+ double dt;
+ int sum;
+ int diff;
+ int product = 1;
+ double dsum;
+ double dknown_sum;
+ double ddiff;
+ int logic_and;
+ int logic_or;
+ int bit_and;
+ int bit_or;
+ int exclusiv_bit_or;
+ int *logics;
+ </ompts:orphan:vars>
+
+#define DOUBLE_DIGITS 20 /* dt^DOUBLE_DIGITS */
+#define MAX_FACTOR 10
+#define KNOWN_PRODUCT 3628800 /* 10! */
+
+ int i;
+ int known_sum;
+ int known_product;
+ double rounding_error = 1.E-9; /* over all rounding error to be ignored in the double tests */
+ double dpt;
+ int result = 0;
+ int logicsArray[LOOPCOUNT];
+
+ /* Variables for integer tests */
+ sum = 0;
+ product = 1;
+ known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2;
+ /* variabels for double tests */
+ dt = 1. / 3.; /* base of geometric row for + and - test*/
+ dsum = 0.;
+ /* Variabeles for logic tests */
+ logics = logicsArray;
+ logic_and = 1;
+ logic_or = 0;
+ /* Variabeles for bit operators tests */
+ bit_and = 1;
+ bit_or = 0;
+ /* Variables for exclusiv bit or */
+ exclusiv_bit_or = 0;
+
+
+/****************************************************************************/
+/** Tests for integers **/
+/****************************************************************************/
+
+
+/**** Testing integer addition ****/
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int j;
+#pragma omp for schedule(dynamic,1) <ompts:check>reduction(+:sum)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for (j = 1; j <= LOOPCOUNT; j++)
+ {
+ sum = sum + j;
+ }
+ </ompts:orphan>
+ }
+
+ if (known_sum != sum) {
+ result++;
+ fprintf (logFile, "Error in sum with integers: Result was %d instead of %d.\n", sum, known_sum);
+ }
+
+
+/**** Testing integer subtracton ****/
+
+ diff = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2;
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int j;
+#pragma omp for schedule(dynamic,1) <ompts:check>reduction(-:diff)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for (j = 1; j <= LOOPCOUNT; j++)
+ {
+ diff = diff - j;
+ }
+ </ompts:orphan>
+ }
+
+ if (diff != 0) {
+ result++;
+ fprintf (logFile, "Error in difference with integers: Result was %d instead of 0.\n", diff);
+ }
+
+
+/**** Testing integer multiplication ****/
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int j;
+#pragma omp for schedule(dynamic,1) <ompts:check>reduction(*:product)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for (j = 1; j <= MAX_FACTOR; j++)
+ {
+ product *= j;
+ }
+ </ompts:orphan>
+ }
+
+ known_product = KNOWN_PRODUCT;
+ if(known_product != product)
+ {
+ result++;
+ fprintf (logFile,"Error in Product with integers: Result was %d instead of %d\n",product,known_product);
+ }
+
+
+/****************************************************************************/
+/** Tests for doubles **/
+/****************************************************************************/
+
+
+/**** Testing double addition ****/
+
+ dsum = 0.;
+ dpt = 1.;
+
+ for (i = 0; i < DOUBLE_DIGITS; ++i)
+ {
+ dpt *= dt;
+ }
+ dknown_sum = (1 - dpt) / (1 - dt);
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int j;
+#pragma omp for schedule(dynamic,1) <ompts:check>reduction(+:dsum)</ompts:check>
+ for (j = 0; j < DOUBLE_DIGITS; j++)
+ {
+ dsum += pow (dt, j);
+ }
+ </ompts:orphan>
+ }
+
+ if (fabs (dsum - dknown_sum) > rounding_error) {
+ result++;
+ fprintf (logFile, "\nError in sum with doubles: Result was %f instead of: %f (Difference: %E)\n", dsum, dknown_sum, dsum-dknown_sum);
+ }
+
+#if 0
+ dpt = 1.;
+ for (i = 0; i < DOUBLE_DIGITS; ++i)
+ {
+ dpt *= dt;
+ }
+#endif
+
+
+/**** Testing double subtraction ****/
+
+ ddiff = (1 - dpt) / (1 - dt);
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int j;
+#pragma omp for schedule(dynamic,1) <ompts:check>reduction(-:ddiff)</ompts:check>
+ for (j = 0; j < DOUBLE_DIGITS; ++j)
+ {
+ ddiff -= pow (dt, j);
+ }
+ </ompts:orphan>
+ }
+
+ if (fabs (ddiff) > rounding_error) {
+ result++;
+ fprintf (logFile, "Error in Difference with doubles: Result was %E instead of 0.0\n", ddiff);
+ }
+
+
+/****************************************************************************/
+/** Tests for logical values **/
+/****************************************************************************/
+
+
+/**** Testing logic and ****/
+
+ for (i = 0; i < LOOPCOUNT; i++)
+ {
+ logics[i] = 1;
+ }
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int j;
+#pragma omp for schedule(dynamic,1) <ompts:check>reduction(&&:logic_and)</ompts:check>
+ for (j = 0; j < LOOPCOUNT; ++j)
+ {
+ logic_and = (logic_and && logics[j]);
+ }
+ </ompts:orphan>
+ }
+
+ if(!logic_and) {
+ result++;
+ fprintf (logFile, "Error in logic AND part 1\n");
+ }
+
+ logic_and = 1;
+ logics[LOOPCOUNT / 2] = 0;
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int j;
+#pragma omp for schedule(dynamic,1) <ompts:check>reduction(&&:logic_and)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for (j = 0; j < LOOPCOUNT; ++j)
+ {
+ logic_and = logic_and && logics[j];
+ }
+ </ompts:orphan>
+ }
+
+ if(logic_and) {
+ result++;
+ fprintf (logFile, "Error in logic AND part 2\n");
+ }
+
+
+/**** Testing logic or ****/
+
+ for (i = 0; i < LOOPCOUNT; i++)
+ {
+ logics[i] = 0;
+ }
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int j;
+#pragma omp for schedule(dynamic,1) <ompts:check>reduction(||:logic_or) </ompts:check>
+ for (j = 0; j < LOOPCOUNT; ++j)
+ {
+ logic_or = logic_or || logics[j];
+ }
+ </ompts:orphan>
+ }
+
+ if (logic_or) {
+ result++;
+ fprintf (logFile, "Error in logic OR part 1\n");
+ }
+
+ logic_or = 0;
+ logics[LOOPCOUNT / 2] = 1;
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int j;
+#pragma omp for schedule(dynamic,1) <ompts:check>reduction(||:logic_or)</ompts:check>
+ for (j = 0; j < LOOPCOUNT; ++j)
+ {
+ logic_or = logic_or || logics[j];
+ }
+ </ompts:orphan>
+ }
+
+ if(!logic_or) {
+ result++;
+ fprintf (logFile, "Error in logic OR part 2\n");
+ }
+
+
+/****************************************************************************/
+/** Tests for bit values **/
+/****************************************************************************/
+
+
+/**** Testing bit and ****/
+
+ for (i = 0; i < LOOPCOUNT; ++i)
+ {
+ logics[i] = 1;
+ }
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int j;
+#pragma omp for schedule(dynamic,1) <ompts:check>reduction(&:bit_and) </ompts:check>
+ for (j = 0; j < LOOPCOUNT; ++j)
+ {
+ bit_and = (bit_and & logics[j]);
+ }
+ </ompts:orphan>
+ }
+
+ if (!bit_and) {
+ result++;
+ fprintf (logFile, "Error in BIT AND part 1\n");
+ }
+
+ bit_and = 1;
+ logics[LOOPCOUNT / 2] = 0;
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int j;
+#pragma omp for schedule(dynamic,1) <ompts:check>reduction(&:bit_and)</ompts:check>
+ for (j = 0; j < LOOPCOUNT; ++j)
+ {
+ bit_and = bit_and & logics[j];
+ }
+ </ompts:orphan>
+ }
+ if (bit_and) {
+ result++;
+ fprintf (logFile, "Error in BIT AND part 2\n");
+ }
+
+
+/**** Testing bit or ****/
+
+ for (i = 0; i < LOOPCOUNT; i++)
+ {
+ logics[i] = 0;
+ }
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int j;
+#pragma omp for schedule(dynamic,1) <ompts:check>reduction(|:bit_or)</ompts:check>
+ for (j = 0; j < LOOPCOUNT; ++j)
+ {
+ bit_or = bit_or | logics[j];
+ }
+ </ompts:orphan>
+ }
+
+ if (bit_or) {
+ result++;
+ fprintf (logFile, "Error in BIT OR part 1\n");
+ }
+
+ bit_or = 0;
+ logics[LOOPCOUNT / 2] = 1;
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int j;
+#pragma omp for schedule(dynamic,1) <ompts:check>reduction(|:bit_or)</ompts:check>
+ for (j = 0; j < LOOPCOUNT; ++j)
+ {
+ bit_or = bit_or | logics[j];
+ }
+ </ompts:orphan>
+ }
+ if (!bit_or) {
+ result++;
+ fprintf (logFile, "Error in BIT OR part 2\n");
+ }
+
+
+/**** Testing exclusive bit or ****/
+
+ for (i = 0; i < LOOPCOUNT; i++)
+ {
+ logics[i] = 0;
+ }
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int j;
+#pragma omp for schedule(dynamic,1) <ompts:check>reduction(^:exclusiv_bit_or)</ompts:check>
+ for (j = 0; j < LOOPCOUNT; ++j)
+ {
+ exclusiv_bit_or = exclusiv_bit_or ^ logics[j];
+ }
+ </ompts:orphan>
+ }
+ if (exclusiv_bit_or) {
+ result++;
+ fprintf (logFile, "Error in EXCLUSIV BIT OR part 1\n");
+ }
+
+ exclusiv_bit_or = 0;
+ logics[LOOPCOUNT / 2] = 1;
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int j;
+#pragma omp for schedule(dynamic,1) <ompts:check>reduction(^:exclusiv_bit_or)</ompts:check>
+ for (j = 0; j < LOOPCOUNT; ++j)
+ {
+ exclusiv_bit_or = exclusiv_bit_or ^ logics[j];
+ }
+ </ompts:orphan>
+ }
+ if (!exclusiv_bit_or) {
+ result++;
+ fprintf (logFile, "Error in EXCLUSIV BIT OR part 2\n");
+ }
+
+ /*fprintf ("\nResult:%d\n", result);*/
+ return (result == 0);
+
+ free (logics);
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_for_schedule_auto.c b/final/testsuite/c/omp_for_schedule_auto.c
new file mode 100644
index 0000000..e61a1c4
--- /dev/null
+++ b/final/testsuite/c/omp_for_schedule_auto.c
@@ -0,0 +1,55 @@
+<ompts:test>
+<ompts:testdescription>Test with omp for schedule auto</ompts:testdescription>
+<ompts:ompversion>3.0</ompts:ompversion>
+<ompts:directive>omp for auto</ompts:directive>
+<ompts:dependences>omp critical,omp parallel firstprivate</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include <math.h>
+
+#include "omp_testsuite.h"
+
+int sum1;
+#pragma omp threadprivate(sum1)
+
+int <ompts:testcode:functionname>omp_for_auto</ompts:testcode:functionname> (FILE * logFile)
+{
+ int sum;
+ <ompts:orphan:vars>
+ int sum0;
+ </ompts:orphan:vars>
+
+ int known_sum;
+ int threadsnum;
+
+ sum = 0;
+ sum0 = 12345;
+ sum1 = 0;
+
+#pragma omp parallel
+ {
+#pragma omp single
+ {
+ threadsnum=omp_get_num_threads();
+ }
+ /* sum0 = 0; */
+ <ompts:orphan>
+ int i;
+#pragma omp for <ompts:check>firstprivate(sum0) schedule(auto)</ompts:check><ompts:crosscheck>private(sum0)</ompts:crosscheck>
+ for (i = 1; i <= LOOPCOUNT; i++)
+ {
+ sum0 = sum0 + i;
+ sum1 = sum0;
+ } /* end of for */
+ </ompts:orphan>
+#pragma omp critical
+ {
+ sum = sum + sum1;
+ } /* end of critical */
+ } /* end of parallel */
+
+ known_sum = 12345* threadsnum+ (LOOPCOUNT * (LOOPCOUNT + 1)) / 2;
+ return (known_sum == sum);
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_for_schedule_dynamic.c b/final/testsuite/c/omp_for_schedule_dynamic.c
new file mode 100644
index 0000000..d2cda56
--- /dev/null
+++ b/final/testsuite/c/omp_for_schedule_dynamic.c
@@ -0,0 +1,111 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the dynamic option of the omp for schedule directive</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp for schedule(dynamic)</ompts:directive>
+<ompts:dependences>omp flush,omp for nowait,omp critical,omp single</ompts:dependences>
+<ompts:testcode>
+
+/*
+* Test for dynamic scheduling with chunk size
+* Method: caculate how many times the iteration space is dispatched
+* and judge if each dispatch has the requested chunk size
+* unless it is the last one.
+* It is possible for two adjacent chunks are assigned to the same thread
+* Modifyied by Chunhua Liao
+*/
+#include <stdio.h>
+#include <omp.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include "omp_testsuite.h"
+#include "omp_my_sleep.h"
+
+#define CFDMAX_SIZE 100
+const int chunk_size = 7;
+
+int <ompts:testcode:functionname>omp_for_schedule_dynamic</ompts:testcode:functionname> (FILE * logFile)
+{
+ int tid;
+<ompts:orphan:vars>
+ int *tids;
+ int i;
+</ompts:orphan:vars>
+
+ int tidsArray[CFDMAX_SIZE];
+ int count = 0;
+ int tmp_count = 0; /*dispatch times*/
+ int *tmp; /*store chunk size for each dispatch*/
+ int result = 0;
+
+ tids = tidsArray;
+
+#pragma omp parallel private(tid) shared(tids)
+ { /* begin of parallel */
+ <ompts:orphan>
+ int tid;
+
+ tid = omp_get_thread_num ();
+#pragma omp for <ompts:check>schedule(dynamic,chunk_size)</ompts:check>
+ for (i = 0; i < CFDMAX_SIZE; i++)
+ {
+ tids[i] = tid;
+ }
+ </ompts:orphan>
+ } /* end of parallel */
+
+ for (i = 0; i < CFDMAX_SIZE - 1; ++i)
+ {
+ if (tids[i] != tids[i + 1])
+ {
+ count++;
+ }
+ }
+
+ tmp = (int *) malloc (sizeof (int) * (count + 1));
+ tmp[0] = 1;
+
+ for (i = 0; i < CFDMAX_SIZE - 1; ++i)
+ {
+ if (tmp_count > count)
+ {
+ printf ("--------------------\nTestinternal Error: List too small!!!\n--------------------\n"); /* Error handling */
+ break;
+ }
+ if (tids[i] != tids[i + 1])
+ {
+ tmp_count++;
+ tmp[tmp_count] = 1;
+ }
+ else
+ {
+ tmp[tmp_count]++;
+ }
+ }
+/*
+printf("debug----\n");
+ for (i = 0; i < CFDMAX_SIZE; ++i)
+ printf("%d ",tids[i]);
+printf("debug----\n");
+*/
+/* is dynamic statement working? */
+ for (i = 0; i < count; i++)
+ {
+ if ((tmp[i]%chunk_size)!=0)
+/*it is possible for 2 adjacent chunks assigned to a same thread*/
+ {
+ result++;
+ fprintf(logFile,"The intermediate dispatch has wrong chunksize.\n");
+ /*result += ((tmp[i] / chunk_size) - 1);*/
+ }
+ }
+ if ((tmp[count]%chunk_size)!=(CFDMAX_SIZE%chunk_size))
+ {
+ result++;
+ fprintf(logFile,"the last dispatch has wrong chunksize.\n");
+ }
+ /* for (int i=0;i<count+1;++i) printf("%d\t:=\t%d\n",i+1,tmp[i]); */
+ return (result==0);
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_for_schedule_guided.c b/final/testsuite/c/omp_for_schedule_guided.c
new file mode 100644
index 0000000..83564a5
--- /dev/null
+++ b/final/testsuite/c/omp_for_schedule_guided.c
@@ -0,0 +1,225 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the guided option of the omp for schedule directive.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp for schedule(guided)</ompts:directive>
+<ompts:dependences>omp flush,omp for nowait,omp critical,omp single</ompts:dependences>
+<ompts:testcode>
+/* Test for guided scheduling
+ * Ensure threads get chunks interleavely first
+ * Then judge the chunk sizes are decreasing to a stable value
+ * Modified by Chunhua Liao
+ * For example, 100 iteration on 2 threads, chunksize 7
+ * one line for each dispatch, 0/1 means thread id
+ * 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 24
+ * 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 18
+ * 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14
+ * 1 1 1 1 1 1 1 1 1 1 10
+ * 0 0 0 0 0 0 0 0 8
+ * 1 1 1 1 1 1 1 7
+ * 0 0 0 0 0 0 0 7
+ * 1 1 1 1 1 1 1 7
+ * 0 0 0 0 0 5
+*/
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include "omp_testsuite.h"
+#include "omp_my_sleep.h"
+
+#define NUMBER_OF_THREADS 10
+#define CFSMAX_SIZE 1000
+#define MAX_TIME 0.005
+
+#ifdef SLEEPTIME
+#undef SLEEPTIME
+#define SLEEPTIME 0.0001
+#endif
+
+int <ompts:testcode:functionname>omp_for_schedule_guided</ompts:testcode:functionname> (FILE * logFile)
+{
+ <ompts:orphan:vars>
+ int * tids;
+ int * chunksizes;
+ int notout;
+ int maxiter;
+ </ompts:orphan:vars>
+
+ int threads;
+ int i;
+ int result;
+
+ tids = (int *) malloc (sizeof (int) * (CFSMAX_SIZE + 1));
+ maxiter = 0;
+ result = 1;
+ notout = 1;
+
+/* Testing if enought threads are available for this check. */
+#pragma omp parallel
+ {
+#pragma omp single
+ {
+ threads = omp_get_num_threads ();
+ } /* end of single */
+ } /* end of parallel */
+
+ if (threads < 2) {
+ printf ("This test only works with at least two threads .\n");
+ fprintf (logFile, "This test only works with at least two threads. Available were only %d thread(s).\n", threads);
+ return (0);
+ } /* end if */
+
+
+ /* Now the real parallel work:
+ *
+ * Each thread will start immediately with the first chunk.
+ */
+#pragma omp parallel shared(tids,maxiter)
+ { /* begin of parallel */
+ <ompts:orphan>
+ double count;
+ int tid;
+ int j;
+
+ tid = omp_get_thread_num ();
+
+#pragma omp for nowait <ompts:check>schedule(guided)</ompts:check>
+ for(j = 0; j < CFSMAX_SIZE; ++j)
+ {
+ count = 0.;
+#pragma omp flush(maxiter)
+ if (j > maxiter)
+ {
+#pragma omp critical
+ {
+ maxiter = j;
+ } /* end of critical */
+ }
+ /*printf ("thread %d sleeping\n", tid);*/
+#pragma omp flush(maxiter,notout)
+ while (notout && (count < MAX_TIME) && (maxiter == j))
+ {
+#pragma omp flush(maxiter,notout)
+ my_sleep (SLEEPTIME);
+ count += SLEEPTIME;
+#ifdef VERBOSE
+ printf(".");
+#endif
+ }
+#ifdef VERBOSE
+ if (count > 0.) printf(" waited %lf s\n", count);
+#endif
+ /*printf ("thread %d awake\n", tid);*/
+ tids[j] = tid;
+#ifdef VERBOSE
+ printf("%d finished by %d\n",j,tid);
+#endif
+ } /* end of for */
+
+ notout = 0;
+#pragma omp flush(maxiter,notout)
+ </ompts:orphan>
+ } /* end of parallel */
+
+/*******************************************************
+ * evaluation of the values *
+ *******************************************************/
+ {
+ int determined_chunksize = 1;
+ int last_threadnr = tids[0];
+ int global_chunknr = 0;
+ int local_chunknr[NUMBER_OF_THREADS];
+ int openwork = CFSMAX_SIZE;
+ int expected_chunk_size;
+ double c = 1;
+
+ for (i = 0; i < NUMBER_OF_THREADS; i++)
+ local_chunknr[i] = 0;
+
+ tids[CFSMAX_SIZE] = -1;
+
+ /*
+ * determine the number of global chunks
+ */
+ /*fprintf(logFile,"# global_chunknr thread local_chunknr chunksize\n"); */
+ for(i = 1; i <= CFSMAX_SIZE; ++i)
+ {
+ if (last_threadnr==tids[i]) {
+ determined_chunksize++;
+ }
+ else
+ {
+ /* fprintf (logFile, "%d\t%d\t%d\t%d\n", global_chunknr,last_threadnr, local_chunknr[last_threadnr], m); */
+ global_chunknr++;
+ local_chunknr[last_threadnr]++;
+ last_threadnr = tids[i];
+ determined_chunksize = 1;
+ }
+ }
+ /* now allocate the memory for saving the sizes of the global chunks */
+ chunksizes = (int*)malloc(global_chunknr * sizeof(int));
+
+ /*
+ * Evaluate the sizes of the global chunks
+ */
+ global_chunknr = 0;
+ determined_chunksize = 1;
+ last_threadnr = tids[0];
+ for (i = 1; i <= CFSMAX_SIZE; ++i)
+ {
+ /* If the threadnumber was the same as before increase the detected chunksize for this chunk
+ * otherwise set the detected chunksize again to one and save the number of the next thread in last_threadnr.
+ */
+ if (last_threadnr == tids[i]) {
+ determined_chunksize++;
+ }
+ else {
+ chunksizes[global_chunknr] = determined_chunksize;
+ global_chunknr++;
+ local_chunknr[last_threadnr]++;
+ last_threadnr = tids[i];
+ determined_chunksize = 1;
+ }
+ }
+
+#ifdef VERBOSE
+ fprintf (logFile, "found\texpected\tconstant\n");
+#endif
+
+ /* identify the constant c for the exponential decrease of the chunksize */
+ expected_chunk_size = openwork / threads;
+ c = (double) chunksizes[0] / expected_chunk_size;
+
+ for (i = 0; i < global_chunknr; i++)
+ {
+ /* calculate the new expected chunksize */
+ if (expected_chunk_size > 1)
+ expected_chunk_size = c * openwork / threads;
+
+#ifdef VERBOSE
+ fprintf (logFile, "%8d\t%8d\t%lf\n", chunksizes[i], expected_chunk_size, c * chunksizes[i]/expected_chunk_size);
+#endif
+
+ /* check if chunksize is inside the rounding errors */
+ if (abs (chunksizes[i] - expected_chunk_size) >= 2) {
+ result = 0;
+#ifndef VERBOSE
+ fprintf (logFile, "Chunksize differed from expected value: %d instead of %d\n", chunksizes[i], expected_chunk_size);
+ return 0;
+#endif
+ } /* end if */
+
+#ifndef VERBOSE
+ if (expected_chunk_size - chunksizes[i] < 0 )
+ fprintf (logFile, "Chunksize did not decrease: %d instead of %d\n", chunksizes[i],expected_chunk_size);
+#endif
+
+ /* calculating the remaining amount of work */
+ openwork -= chunksizes[i];
+ }
+ }
+ return result;
+}
+</ompts:testcode>
+</ompts:test>
+
diff --git a/final/testsuite/c/omp_for_schedule_static.c b/final/testsuite/c/omp_for_schedule_static.c
new file mode 100644
index 0000000..d71d7d4
--- /dev/null
+++ b/final/testsuite/c/omp_for_schedule_static.c
@@ -0,0 +1,165 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the static option of the omp for schedule directive.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp for schedule(static)</ompts:directive>
+<ompts:dependences>omp for nowait,omp flush,omp critical,omp single</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include "omp_testsuite.h"
+#include "omp_my_sleep.h"
+
+#define NUMBER_OF_THREADS 10
+#define CFSMAX_SIZE 1000
+#define MAX_TIME 0.01
+
+#ifdef SLEEPTIME
+#undef SLEEPTIME
+#define SLEEPTIME 0.0005
+#endif
+
+
+int <ompts:testcode:functionname>omp_for_schedule_static</ompts:testcode:functionname> (FILE * logFile)
+{
+ int threads;
+ int i,lasttid;
+ <ompts:orphan:vars>
+ int * tids;
+ int notout;
+ int maxiter;
+ int chunk_size;
+ </ompts:orphan:vars>
+ int counter = 0;
+ int tmp_count=1;
+ int lastthreadsstarttid = -1;
+ int result = 1;
+ chunk_size = 7;
+
+ tids = (int *) malloc (sizeof (int) * (CFSMAX_SIZE + 1));
+ notout = 1;
+ maxiter = 0;
+
+#pragma omp parallel shared(tids,counter)
+ { /* begin of parallel*/
+#pragma omp single
+ {
+ threads = omp_get_num_threads ();
+ } /* end of single */
+ } /* end of parallel */
+
+ if (threads < 2)
+ {
+ printf ("This test only works with at least two threads");
+ fprintf (logFile,"This test only works with at least two threads");
+ return 0;
+ }
+ else
+ {
+ fprintf (logFile,"Using an internal count of %d\nUsing a specified chunksize of %d\n", CFSMAX_SIZE, chunk_size);
+ tids[CFSMAX_SIZE] = -1; /* setting endflag */
+#pragma omp parallel shared(tids)
+ { /* begin of parallel */
+ <ompts:orphan>
+ double count;
+ int tid;
+ int j;
+
+ tid = omp_get_thread_num ();
+
+#pragma omp for nowait <ompts:check>schedule(static,chunk_size)</ompts:check>
+ for(j = 0; j < CFSMAX_SIZE; ++j)
+ {
+ count = 0.;
+#pragma omp flush(maxiter)
+ if (j > maxiter)
+ {
+#pragma omp critical
+ {
+ maxiter = j;
+ } /* end of critical */
+ }
+ /*printf ("thread %d sleeping\n", tid);*/
+ while (notout && (count < MAX_TIME) && (maxiter == j))
+ {
+#pragma omp flush(maxiter,notout)
+ my_sleep (SLEEPTIME);
+ count += SLEEPTIME;
+ printf(".");
+ }
+#ifdef VERBOSE
+ if (count > 0.) printf(" waited %lf s\n", count);
+#endif
+ /*printf ("thread %d awake\n", tid);*/
+ tids[j] = tid;
+#ifdef VERBOSE
+ printf("%d finished by %d\n",j,tid);
+#endif
+ } /* end of for */
+
+ notout = 0;
+#pragma omp flush(maxiter,notout)
+ </ompts:orphan>
+ } /* end of parallel */
+
+ /**** analysing the data in array tids ****/
+
+ lasttid = tids[0];
+ tmp_count = 0;
+
+ for (i = 0; i < CFSMAX_SIZE + 1; ++i)
+ {
+ /* If the work was done by the same thread increase tmp_count by one. */
+ if (tids[i] == lasttid) {
+ tmp_count++;
+#ifdef VERBOSE
+ fprintf (logFile, "%d: %d \n", i, tids[i]);
+#endif
+ continue;
+ }
+
+ /* Check if the next thread had has the right thread number. When finding
+ * threadnumber -1 the end should be reached.
+ */
+ if (tids[i] == (lasttid + 1) % threads || tids[i] == -1) {
+ /* checking for the right chunk size */
+ if (tmp_count == chunk_size) {
+ tmp_count = 1;
+ lasttid = tids[i];
+#ifdef VERBOSE
+ fprintf (logFile, "OK\n");
+#endif
+ }
+ /* If the chunk size was wrong, check if the end was reached */
+ else {
+ if (tids[i] == -1) {
+ if (i == CFSMAX_SIZE) {
+ fprintf (logFile, "Last thread had chunk size %d\n", tmp_count);
+ break;
+ }
+ else {
+ fprintf (logFile, "ERROR: Last thread (thread with number -1) was found before the end.\n");
+ result = 0;
+ }
+ }
+ else {
+ fprintf (logFile, "ERROR: chunk size was %d. (assigned was %d)\n", tmp_count, chunk_size);
+ result = 0;
+ }
+ }
+ }
+ else {
+ fprintf(logFile, "ERROR: Found thread with number %d (should be inbetween 0 and %d).", tids[i], threads - 1);
+ result = 0;
+ }
+#ifdef VERBOSE
+ fprintf (logFile, "%d: %d \n", i, tids[i]);
+#endif
+ }
+ }
+
+ return result;
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_for_schedule_static_3.c b/final/testsuite/c/omp_for_schedule_static_3.c
new file mode 100644
index 0000000..928667f
--- /dev/null
+++ b/final/testsuite/c/omp_for_schedule_static_3.c
@@ -0,0 +1,212 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the static option of the omp for schedule directive considering the specifications for the chunk distribution of several loop regions is the same as specified in the Open MP standard version 3.0.</ompts:testdescription>
+<ompts:ompversion>3.0</ompts:ompversion>
+<ompts:directive>omp for schedule(static)</ompts:directive>
+<ompts:dependences>omp for nowait,omp flush,omp critical,omp single</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include "omp_testsuite.h"
+#include "omp_my_sleep.h"
+
+#define NUMBER_OF_THREADS 10
+#define CFSMAX_SIZE 1000
+#define MAX_TIME 0.01
+
+#ifdef SLEEPTIME
+#undef SLEEPTIME
+#define SLEEPTIME 0.0005
+#endif
+
+#define VERBOSE 0
+
+
+int <ompts:testcode:functionname>omp_for_schedule_static_3</ompts:testcode:functionname> (FILE * logFile)
+{
+ int threads;
+ int i,lasttid;
+ <ompts:orphan:vars>
+ int * tids;
+ int * tids2;
+ int notout;
+ int maxiter;
+ int chunk_size;
+ </ompts:orphan:vars>
+ int counter = 0;
+ int tmp_count=1;
+ int lastthreadsstarttid = -1;
+ int result = 1;
+ chunk_size = 7;
+
+ tids = (int *) malloc (sizeof (int) * (CFSMAX_SIZE + 1));
+ notout = 1;
+ maxiter = 0;
+
+#pragma omp parallel shared(tids,counter)
+ { /* begin of parallel*/
+#pragma omp single
+ {
+ threads = omp_get_num_threads ();
+ } /* end of single */
+ } /* end of parallel */
+
+ if (threads < 2)
+ {
+ printf ("This test only works with at least two threads");
+ fprintf (logFile,"This test only works with at least two threads");
+ return 0;
+ }
+ else
+ {
+ fprintf (logFile,"Using an internal count of %d\nUsing a specified chunksize of %d\n", CFSMAX_SIZE, chunk_size);
+ tids[CFSMAX_SIZE] = -1; /* setting endflag */
+#pragma omp parallel shared(tids)
+ { /* begin of parallel */
+ <ompts:orphan>
+ double count;
+ int tid;
+ int j;
+
+ tid = omp_get_thread_num ();
+
+#pragma omp for nowait <ompts:check>schedule(static,chunk_size)</ompts:check>
+ for(j = 0; j < CFSMAX_SIZE; ++j)
+ {
+ count = 0.;
+#pragma omp flush(maxiter)
+ if (j > maxiter)
+ {
+#pragma omp critical
+ {
+ maxiter = j;
+ } /* end of critical */
+ }
+ /*printf ("thread %d sleeping\n", tid);*/
+ while (notout && (count < MAX_TIME) && (maxiter == j))
+ {
+#pragma omp flush(maxiter,notout)
+ my_sleep (SLEEPTIME);
+ count += SLEEPTIME;
+ printf(".");
+ }
+#ifdef VERBOSE
+ if (count > 0.) printf(" waited %lf s\n", count);
+#endif
+ /*printf ("thread %d awake\n", tid);*/
+ tids[j] = tid;
+#ifdef VERBOSE
+ printf("%d finished by %d\n",j,tid);
+#endif
+ } /* end of for */
+
+ notout = 0;
+#pragma omp flush(maxiter,notout)
+ </ompts:orphan>
+ } /* end of parallel */
+
+ /**** analysing the data in array tids ****/
+
+ lasttid = tids[0];
+ tmp_count = 0;
+
+ for (i = 0; i < CFSMAX_SIZE + 1; ++i)
+ {
+ /* If the work was done by the same thread increase tmp_count by one. */
+ if (tids[i] == lasttid) {
+ tmp_count++;
+#ifdef VERBOSE
+ fprintf (logFile, "%d: %d \n", i, tids[i]);
+#endif
+ continue;
+ }
+
+ /* Check if the next thread had has the right thread number. When finding
+ * threadnumber -1 the end should be reached.
+ */
+ if (tids[i] == (lasttid + 1) % threads || tids[i] == -1) {
+ /* checking for the right chunk size */
+ if (tmp_count == chunk_size) {
+ tmp_count = 1;
+ lasttid = tids[i];
+#ifdef VERBOSE
+ fprintf (logFile, "OK\n");
+#endif
+ }
+ /* If the chunk size was wrong, check if the end was reached */
+ else {
+ if (tids[i] == -1) {
+ if (i == CFSMAX_SIZE) {
+ fprintf (logFile, "Last thread had chunk size %d\n", tmp_count);
+ break;
+ }
+ else {
+ fprintf (logFile, "ERROR: Last thread (thread with number -1) was found before the end.\n");
+ result = 0;
+ }
+ }
+ else {
+ fprintf (logFile, "ERROR: chunk size was %d. (assigned was %d)\n", tmp_count, chunk_size);
+ result = 0;
+ }
+ }
+ }
+ else {
+ fprintf(logFile, "ERROR: Found thread with number %d (should be inbetween 0 and %d).", tids[i], threads - 1);
+ result = 0;
+ }
+#ifdef VERBOSE
+ fprintf (logFile, "%d: %d \n", i, tids[i]);
+#endif
+ }
+ }
+
+ /* Now we check if several loop regions in one parallel region have the same
+ * logical assignement of chunks to threads.
+ * We use the nowait clause to increase the probability to get an error. */
+
+ /* First we allocate some more memmory */
+ free (tids);
+ tids = (int *) malloc (sizeof (int) * LOOPCOUNT);
+ tids2 = (int *) malloc (sizeof (int) * LOOPCOUNT);
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ {
+ int n;
+#pragma omp for <ompts:check>schedule(static)</ompts:check> nowait
+ for (n = 0; n < LOOPCOUNT; n++)
+ {
+ if (LOOPCOUNT == n + 1 )
+ my_sleep(SLEEPTIME);
+
+ tids[n] = omp_get_thread_num();
+ }
+ }
+ </ompts:orphan>
+ <ompts:orphan>
+ {
+ int m;
+#pragma omp for <ompts:check>schedule(static)</ompts:check> nowait
+ for (m = 1; m <= LOOPCOUNT; m++)
+ {
+ tids2[m-1] = omp_get_thread_num();
+ }
+ }
+ </ompts:orphan>
+ }
+
+ for (i = 0; i < LOOPCOUNT; i++)
+ if (tids[i] != tids2[i]) {
+ fprintf (logFile, "Chunk no. %d was assigned once to thread %d and later to thread %d.\n", i, tids[i],tids2[i]);
+ result = 0;
+ }
+
+ free (tids);
+ free (tids2);
+ return result;
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_get_num_threads.c b/final/testsuite/c/omp_get_num_threads.c
new file mode 100644
index 0000000..4b092ba
--- /dev/null
+++ b/final/testsuite/c/omp_get_num_threads.c
@@ -0,0 +1,39 @@
+<ompts:test>
+<ompts:testdescription>Test which checks that the omp_get_num_threads returns the correct number of threads. Therefor it counts up a variable in a parallelized section and compars this value with the result of the omp_get_num_threads function.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp_get_num_threads</ompts:directive>
+<ompts:testcode>
+#include <stdio.h>
+
+#include "omp_testsuite.h"
+
+int <ompts:testcode:functionname>omp_get_num_threads</ompts:testcode:functionname> (FILE * logFile)
+{
+ /* checks that omp_get_num_threads is equal to the number of
+ threads */
+ <ompts:orphan:vars>
+ int nthreads_lib;
+ </ompts:orphan:vars>
+ int nthreads = 0;
+
+ nthreads_lib = -1;
+
+#pragma omp parallel
+ {
+#pragma omp critical
+ {
+ nthreads++;
+ } /* end of critical */
+#pragma omp single
+ {
+<ompts:orphan>
+ <ompts:check>nthreads_lib = omp_get_num_threads ();</ompts:check>
+</ompts:orphan>
+ } /* end of single */
+ } /* end of parallel */
+
+ fprintf (logFile, "Counted %d threads. get_num_threads returned %d.\n", nthreads, nthreads_lib);
+ return (nthreads == nthreads_lib);
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_get_wtick.c b/final/testsuite/c/omp_get_wtick.c
new file mode 100644
index 0000000..e82b57f
--- /dev/null
+++ b/final/testsuite/c/omp_get_wtick.c
@@ -0,0 +1,24 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp_get_wtick function.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp_get_wtick</ompts:directive>
+<ompts:testcode>
+#include<stdio.h>
+
+#include "omp_testsuite.h"
+
+int <ompts:testcode:functionname>omp_get_wtick</ompts:testcode:functionname>(FILE * logFile)
+{
+ <ompts:orphan:vars>
+ double tick;
+ </ompts:orphan:vars>
+ tick = -1.;
+
+ <ompts:orphan>
+ <ompts:check>tick = omp_get_wtick ();</ompts:check>
+ </ompts:orphan>
+ fprintf (logFile, "Work took %lf sec. time.\n", tick);
+ return ((tick > 0.0) && (tick < 0.01));
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_get_wtime.c b/final/testsuite/c/omp_get_wtime.c
new file mode 100644
index 0000000..9f0226d
--- /dev/null
+++ b/final/testsuite/c/omp_get_wtime.c
@@ -0,0 +1,38 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp_get_wtime function. It compares the time with which is called a sleep function with the time it took by messuring the difference between the call of the sleep function and its end.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp_get_wtime</ompts:directive>
+<ompts:testcode>
+#include<stdio.h>
+#include<stdlib.h>
+#include<unistd.h>
+
+
+#include "omp_testsuite.h"
+#include "omp_my_sleep.h"
+
+int <ompts:testcode:functionname>omp_get_wtime</ompts:testcode:functionname>(FILE * logFile)
+{
+ <ompts:orphan:vars>
+ double start;
+ double end;
+ </ompts:orphan:vars>
+ double measured_time;
+ int wait_time = 1;
+
+ start = 0;
+ end = 0;
+
+ <ompts:orphan>
+ <ompts:check>start = omp_get_wtime ();</ompts:check>
+ </ompts:orphan>
+ my_sleep (wait_time);
+ <ompts:orphan>
+ <ompts:check>end = omp_get_wtime ();</ompts:check>
+ </ompts:orphan>
+ measured_time = end-start;
+ fprintf(logFile, "Work took %lf sec. time.\n", measured_time);
+ return ((measured_time > 0.99 * wait_time) && (measured_time < 1.01 * wait_time)) ;
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_in_parallel.c b/final/testsuite/c/omp_in_parallel.c
new file mode 100644
index 0000000..09b6111
--- /dev/null
+++ b/final/testsuite/c/omp_in_parallel.c
@@ -0,0 +1,51 @@
+<ompts:test>
+<ompts:testdescription>Test which checks that omp_in_parallel returns false when called from a serial region and true when called within a parallel region.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp_in_parallel</ompts:directive>
+<ompts:testcode>
+/*
+ * Checks that false is returned when called from serial region
+ * and true is returned when called within parallel region.
+ */
+#include <stdio.h>
+#include "omp_testsuite.h"
+
+int <ompts:testcode:functionname>omp_in_parallel</ompts:testcode:functionname>(FILE * logFile){
+ <ompts:orphan:vars>
+ int serial;
+ int isparallel;
+ </ompts:orphan:vars>
+
+ serial = 1;
+ isparallel = 0;
+
+ <ompts:check>
+ <ompts:orphan>
+ serial = omp_in_parallel ();
+ </ompts:orphan>
+
+#pragma omp parallel
+ {
+#pragma omp single
+ {
+ <ompts:orphan>
+ isparallel = omp_in_parallel ();
+ </ompts:orphan>
+ }
+ }
+ </ompts:check>
+
+ <ompts:crosscheck>
+#pragma omp parallel
+ {
+#pragma omp single
+ {
+
+ }
+ }
+ </ompts:crosscheck>
+
+ return (!(serial) && isparallel);
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_lock.c b/final/testsuite/c/omp_lock.c
new file mode 100644
index 0000000..a529c07
--- /dev/null
+++ b/final/testsuite/c/omp_lock.c
@@ -0,0 +1,45 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp_set_lock and the omp_unset_lock function by counting the threads entering and exiting a single region with locks.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp_lock</ompts:directive>
+<ompts:dependences>omp flush</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include "omp_testsuite.h"
+
+omp_lock_t lck;
+
+int <ompts:testcode:functionname>omp_lock</ompts:testcode:functionname>(FILE * logFile)
+{
+ int nr_threads_in_single = 0;
+ int result = 0;
+ int nr_iterations = 0;
+ int i;
+ omp_init_lock (&lck);
+
+#pragma omp parallel shared(lck)
+ {
+ #pragma omp for
+ for(i = 0; i < LOOPCOUNT; i++)
+ {
+ <ompts:orphan>
+ <ompts:check>omp_set_lock (&lck);</ompts:check>
+ </ompts:orphan>
+#pragma omp flush
+ nr_threads_in_single++;
+#pragma omp flush
+ nr_iterations++;
+ nr_threads_in_single--;
+ result = result + nr_threads_in_single;
+ <ompts:orphan>
+ <ompts:check>omp_unset_lock(&lck);</ompts:check>
+ </ompts:orphan>
+ }
+ }
+ omp_destroy_lock (&lck);
+
+ return ((result == 0) && (nr_iterations == LOOPCOUNT));
+
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_master.c b/final/testsuite/c/omp_master.c
new file mode 100644
index 0000000..cdb2f1e
--- /dev/null
+++ b/final/testsuite/c/omp_master.c
@@ -0,0 +1,37 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp master directive by counting up a variable in a omp master section.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp master</ompts:directive>
+<ompts:dependences>omp critical</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include "omp_testsuite.h"
+
+int <ompts:testcode:functionname>omp_master</ompts:testcode:functionname>(FILE * logFile)
+{
+ <ompts:orphan:vars>
+ int nthreads;
+ int executing_thread;
+ </ompts:orphan:vars>
+
+ nthreads = 0;
+ executing_thread = -1;
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ <ompts:check>#pragma omp master </ompts:check>
+ {
+#pragma omp critical
+ {
+ nthreads++;
+ }
+ executing_thread = omp_get_thread_num ();
+
+ } /* end of master*/
+ </ompts:orphan>
+ } /* end of parallel*/
+ return ((nthreads == 1) && (executing_thread == 0));
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_master_3.c b/final/testsuite/c/omp_master_3.c
new file mode 100644
index 0000000..8e98129
--- /dev/null
+++ b/final/testsuite/c/omp_master_3.c
@@ -0,0 +1,44 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp master directive by counting up a variable in a omp master section. It also checks that the master thread has the thread number 0 as specified in the Open MP standard version 3.0.</ompts:testdescription>
+<ompts:ompversion>3.0</ompts:ompversion>
+<ompts:directive>omp master</ompts:directive>
+<ompts:dependences>omp critical</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include "omp_testsuite.h"
+
+int <ompts:testcode:functionname>omp_master_3</ompts:testcode:functionname>(FILE * logFile)
+{
+ <ompts:orphan:vars>
+ int nthreads;
+ int executing_thread;
+ int tid_result = 0; /* counts up the number of wrong thread no. for
+ the master thread. (Must be 0) */
+ </ompts:orphan:vars>
+
+ nthreads = 0;
+ executing_thread = -1;
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ <ompts:check>#pragma omp master </ompts:check>
+ {
+ int tid = omp_get_thread_num();
+ if (tid != 0) {
+#pragma omp critical
+ { tid_result++; }
+ }
+#pragma omp critical
+ {
+ nthreads++;
+ }
+ executing_thread = omp_get_thread_num ();
+
+ } /* end of master*/
+ </ompts:orphan>
+ } /* end of parallel*/
+ return ((nthreads == 1) && (executing_thread == 0) && (tid_result == 0));
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_nest_lock.c b/final/testsuite/c/omp_nest_lock.c
new file mode 100644
index 0000000..3ade389
--- /dev/null
+++ b/final/testsuite/c/omp_nest_lock.c
@@ -0,0 +1,45 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp_set_nest_lock and the omp_unset_nest_lock function.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp_nest_lock</ompts:directive>
+<ompts:dependences>omp flush</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include "omp_testsuite.h"
+
+omp_nest_lock_t lck;
+
+int <ompts:testcode:functionname>omp_nest_lock</ompts:testcode:functionname>(FILE * logFile)
+{
+ int nr_threads_in_single = 0;
+ int result = 0;
+ int nr_iterations = 0;
+ int i;
+
+ omp_init_nest_lock (&lck);
+
+#pragma omp parallel shared(lck)
+ {
+#pragma omp for
+ for(i = 0; i < LOOPCOUNT; i++)
+ {
+ <ompts:orphan>
+ <ompts:check>omp_set_nest_lock (&lck);</ompts:check>
+ </ompts:orphan>
+#pragma omp flush
+ nr_threads_in_single++;
+#pragma omp flush
+ nr_iterations++;
+ nr_threads_in_single--;
+ result = result + nr_threads_in_single;
+ <ompts:orphan>
+ <ompts:check>omp_unset_nest_lock (&lck);</ompts:check>
+ </ompts:orphan>
+ }
+ }
+ omp_destroy_nest_lock (&lck);
+
+ return ((result == 0) && (nr_iterations == LOOPCOUNT));
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_nested.c b/final/testsuite/c/omp_nested.c
new file mode 100644
index 0000000..9657bc8
--- /dev/null
+++ b/final/testsuite/c/omp_nested.c
@@ -0,0 +1,42 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp_nested function.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp_nested</ompts:directive>
+<ompts:dependences>omp critical</ompts:dependences>
+<ompts:testcode>
+/*
+ * Test if the compiler supports nested parallelism
+ * By Chunhua Liao, University of Houston
+ * Oct. 2005
+ */
+#include <stdio.h>
+#include "omp_testsuite.h"
+
+int <ompts:testcode:functionname>omp_nested</ompts:testcode:functionname>(FILE * logFile)
+{
+
+ <ompts:orphan:vars>
+ int counter = 0;
+ </ompts:orphan:vars>
+
+#ifdef _OPENMP
+ <ompts:check>omp_set_nested(1);</ompts:check>
+ <ompts:crosscheck>omp_set_nested(0);</ompts:crosscheck>
+#endif
+
+#pragma omp parallel shared(counter)
+{
+<ompts:orphan>
+#pragma omp critical
+ counter ++;
+#pragma omp parallel
+ {
+#pragma omp critical
+ counter --;
+ }
+</ompts:orphan>
+}
+ return (counter != 0);
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_parallel_copyin.c b/final/testsuite/c/omp_parallel_copyin.c
new file mode 100644
index 0000000..382bfa2
--- /dev/null
+++ b/final/testsuite/c/omp_parallel_copyin.c
@@ -0,0 +1,47 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp parallel copyin directive.</ompts:testdescription>
+<ompts:ompversion>3.0</ompts:ompversion>
+<ompts:directive>omp parallel copyin</ompts:directive>
+<ompts:dependences>omp critical,omp threadprivate</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include <stdlib.h>
+#include "omp_testsuite.h"
+
+static int sum1 = 789;
+#pragma omp threadprivate(sum1)
+
+int <ompts:testcode:functionname>omp_parallel_copyin</ompts:testcode:functionname>(FILE * logFile)
+{
+ <ompts:orphan:vars>
+ int sum, num_threads;
+ </ompts:orphan:vars>
+ int known_sum;
+
+ sum = 0;
+ sum1 = 7;
+ num_threads = 0;
+
+#pragma omp parallel <ompts:check>copyin(sum1)</ompts:check>
+ {
+ /*printf("sum1=%d\n",sum1);*/
+ <ompts:orphan>
+ int i;
+#pragma omp for
+ for (i = 1; i < 1000; i++)
+ {
+ sum1 = sum1 + i;
+ } /*end of for*/
+#pragma omp critical
+ {
+ sum = sum + sum1;
+ num_threads++;
+ } /*end of critical*/
+ </ompts:orphan>
+ } /* end of parallel*/
+ known_sum = (999 * 1000) / 2 + 7 * num_threads;
+ return (known_sum == sum);
+
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_parallel_default.c b/final/testsuite/c/omp_parallel_default.c
new file mode 100644
index 0000000..6c87371
--- /dev/null
+++ b/final/testsuite/c/omp_parallel_default.c
@@ -0,0 +1,44 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the default option of the parallel construct.</ompts:testdescription>
+<ompts:ompversion>3.0</ompts:ompversion>
+<ompts:directive>omp parallel default</ompts:directive>
+<ompts:testcode>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "omp_testsuite.h"
+
+int <ompts:testcode:functionname>omp_parallel_default</ompts:testcode:functionname> (FILE * logFile)
+{
+ <ompts:orphan:vars>
+ int i;
+ int sum;
+ int mysum;
+ </ompts:orphan:vars>
+
+ int known_sum;
+ sum =0;
+ known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2 ;
+
+ <ompts:orphan>
+ #pragma omp parallel <ompts:check>default(shared)</ompts:check> private(i) private(mysum<ompts:crosscheck>,sum</ompts:crosscheck>)
+ {
+ mysum = 0;
+ #pragma omp for
+ for (i = 1; i <= LOOPCOUNT; i++)
+ {
+ mysum = mysum + i;
+ }
+#pragma omp critical
+ {
+ sum = sum + mysum;
+ } /* end of critical */
+ } /* end of parallel */
+ </ompts:orphan>
+ if (known_sum != sum) {
+ fprintf(logFile, "KNOWN_SUM = %d; SUM = %d\n", known_sum, sum);
+ }
+ return (known_sum == sum);
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_parallel_firstprivate.c b/final/testsuite/c/omp_parallel_firstprivate.c
new file mode 100644
index 0000000..2415b4c
--- /dev/null
+++ b/final/testsuite/c/omp_parallel_firstprivate.c
@@ -0,0 +1,48 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp parallel firstprivate directive.</ompts:testdescription>
+<ompts:ompversion>3.0</ompts:ompversion>
+<ompts:directive>omp parallel firstprivate</ompts:directive>
+<ompts:dependences>omp for omp critical</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include <stdlib.h>
+#include "omp_testsuite.h"
+
+//static int sum1 = 789;
+
+int <ompts:testcode:functionname>omp_parallel_firstprivate</ompts:testcode:functionname>(FILE * logFile)
+{
+ <ompts:orphan:vars>
+ int sum, num_threads,sum1;
+ </ompts:orphan:vars>
+ int known_sum;
+
+ sum = 0;
+ sum1=7;
+ num_threads = 0;
+
+
+#pragma omp parallel <ompts:check>firstprivate(sum1)</ompts:check><ompts:crosscheck>private(sum1)</ompts:crosscheck>
+ {
+
+ /*printf("sum1=%d\n",sum1);*/
+ <ompts:orphan>
+ int i;
+#pragma omp for
+ for (i = 1; i < 1000; i++)
+ {
+ sum1 = sum1 + i;
+ } /*end of for*/
+#pragma omp critical
+ {
+ sum = sum + sum1;
+ num_threads++;
+ } /*end of critical*/
+ </ompts:orphan>
+ } /* end of parallel*/
+ known_sum = (999 * 1000) / 2 + 7 * num_threads;
+ return (known_sum == sum);
+
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_parallel_for_firstprivate.c b/final/testsuite/c/omp_parallel_for_firstprivate.c
new file mode 100644
index 0000000..5cb4926
--- /dev/null
+++ b/final/testsuite/c/omp_parallel_for_firstprivate.c
@@ -0,0 +1,36 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp parallel for firstprivate directive.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp parallel for firstprivate</ompts:directive>
+<ompts:dependences>omp parallel for reduction,omp parallel for private</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include "omp_testsuite.h"
+
+int <ompts:testcode:functionname>omp_parallel_for_firstprivate</ompts:testcode:functionname>(FILE * logFile)
+{
+ <ompts:orphan:vars>
+ int sum ;
+ int i2;
+ int i;
+ </ompts:orphan:vars>
+
+ sum=0;
+ i2=3;
+ int known_sum;
+
+ #pragma omp parallel for reduction(+:sum) private(i) <ompts:check>firstprivate(i2)</ompts:check><ompts:crosscheck>private(i2)</ompts:crosscheck>
+ <ompts:orphan>
+ for (i = 1; i <= LOOPCOUNT; i++)
+ {
+ sum = sum + (i + i2);
+ } /*end of for*/
+ </ompts:orphan>
+
+ known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2 + i2 * LOOPCOUNT;
+
+ return (known_sum == sum);
+
+} /* end of check_parallel_for_fistprivate */
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_parallel_for_if.c b/final/testsuite/c/omp_parallel_for_if.c
new file mode 100644
index 0000000..52886ba
--- /dev/null
+++ b/final/testsuite/c/omp_parallel_for_if.c
@@ -0,0 +1,38 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp parallel for if directive. Needs at least two threads.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp parallel for if</ompts:directive>
+<ompts:dependences></ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include <math.h>
+#include "omp_testsuite.h"
+
+int <ompts:testcode:functionname>omp_parallel_for_if</ompts:testcode:functionname>(FILE * logFile){
+ int known_sum;
+ <ompts:orphan:vars>
+ int num_threads;
+ int sum, sum2;
+ int i;
+ int control;
+ </ompts:orphan:vars>
+ control = 0;
+ num_threads=0;
+ sum = 0;
+ sum2 = 0;
+
+#pragma omp parallel for private(i) <ompts:check>if (control==1)</ompts:check>
+ <ompts:orphan>
+ for (i=0; i <= LOOPCOUNT; i++)
+ {
+ num_threads = omp_get_num_threads();
+ sum = sum + i;
+ } /*end of for*/
+
+ </ompts:orphan>
+ known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2;
+ fprintf (logFile, "Number of threads determined by omp_get_num_threads: %d\n", num_threads);
+ return (known_sum == sum && num_threads == 1);
+} /* end of check_parallel_for_private */
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_parallel_for_lastprivate.c b/final/testsuite/c/omp_parallel_for_lastprivate.c
new file mode 100644
index 0000000..909deba
--- /dev/null
+++ b/final/testsuite/c/omp_parallel_for_lastprivate.c
@@ -0,0 +1,34 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp parallel for lastprivate directive.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp parallel for lastprivate</ompts:directive>
+<ompts:dependences>omp parallel for reduction,omp parallel for private</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include "omp_testsuite.h"
+
+int <ompts:testcode:functionname>omp_parallel_for_lastprivate</ompts:testcode:functionname>(FILE * logFile){
+ <ompts:orphan:vars>
+ int sum;
+ int i;
+ int i0;
+ </ompts:orphan:vars>
+
+ sum =0;
+ i0 = -1;
+ int known_sum;
+
+#pragma omp parallel for reduction(+:sum) schedule(static,7) private(i) <ompts:check>lastprivate(i0)</ompts:check><ompts:crosscheck>private(i0)</ompts:crosscheck>
+ <ompts:orphan>
+ for (i = 1; i <= LOOPCOUNT; i++)
+ {
+ sum = sum + i;
+ i0 = i;
+ } /*end of for*/
+ /* end of parallel*/
+ </ompts:orphan>
+ known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2;
+ return ((known_sum == sum) && (i0 == LOOPCOUNT));
+} /* end of check_parallel_for_lastprivate */
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_parallel_for_ordered.c b/final/testsuite/c/omp_parallel_for_ordered.c
new file mode 100644
index 0000000..b1a4bc9
--- /dev/null
+++ b/final/testsuite/c/omp_parallel_for_ordered.c
@@ -0,0 +1,62 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp parallel for ordered directive</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp parallel for ordered</ompts:directive>
+<ompts:dependences>omp parallel schedule(static)</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include "omp_testsuite.h"
+
+static int last_i = 0;
+int i;
+
+#pragma omp threadprivate(i)
+
+/* Variable ii is used to avoid problems with a threadprivate variable used as a loop
+ * index. See test omp_threadprivate_for.
+ */
+static int ii;
+#pragma omp threadprivate(ii)
+
+/*!
+ Utility function: returns true if the passed argument is larger than
+ the argument of the last call of this function.
+ */
+static int check_i_islarger2 (int i){
+ int islarger;
+ islarger = (i > last_i);
+ last_i = i;
+ return (islarger);
+}
+
+int <ompts:testcode:functionname>omp_parallel_for_ordered</ompts:testcode:functionname>(FILE * logFile){
+ <ompts:orphan:vars>
+ int sum;
+ int is_larger;
+ </ompts:orphan:vars>
+
+ int known_sum;
+ int i;
+
+ sum = 0;
+ is_larger = 1;
+ last_i = 0;
+#pragma omp parallel for schedule(static,1) private(i) <ompts:check>ordered</ompts:check>
+ for (i = 1; i < 100; i++)
+ {
+ ii = i;
+ <ompts:orphan>
+<ompts:check>#pragma omp ordered</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+ is_larger = check_i_islarger2 (ii) && is_larger;
+ sum = sum + ii;
+ }
+ </ompts:orphan>
+ }
+ known_sum = (99 * 100) / 2;
+ fprintf (logFile," known_sum = %d , sum = %d \n", known_sum, sum);
+ fprintf (logFile," is_larger = %d\n", is_larger);
+ return (known_sum == sum) && is_larger;
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_parallel_for_private.c b/final/testsuite/c/omp_parallel_for_private.c
new file mode 100644
index 0000000..40280cc
--- /dev/null
+++ b/final/testsuite/c/omp_parallel_for_private.c
@@ -0,0 +1,48 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp parallel for private directive.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp parallel for private</ompts:directive>
+<ompts:dependences>omp parallel for reduction,omp flush</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include <math.h>
+#include "omp_testsuite.h"
+
+/*! Utility function to spend some time in a loop */
+static void do_some_work (void){
+ int i;
+ double sum = 0;
+ for(i = 0; i < 1000; i++){
+ sum += sqrt (i);
+ }
+}
+
+int <ompts:testcode:functionname>omp_parallel_for_private</ompts:testcode:functionname>(FILE * logFile){
+ <ompts:orphan:vars>
+ int sum;
+ int i;
+ int i2;
+ </ompts:orphan:vars>
+
+ sum =0;
+ i2=0;
+ int known_sum;
+
+#pragma omp parallel for reduction(+:sum) schedule(static,1) private(i) <ompts:check>private(i2)</ompts:check>
+ <ompts:orphan>
+
+ for (i=1;i<=LOOPCOUNT;i++)
+ {
+ i2 = i;
+#pragma omp flush
+ do_some_work ();
+#pragma omp flush
+ sum = sum + i2;
+ } /*end of for*/
+ </ompts:orphan>
+
+ known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2;
+ return (known_sum == sum);
+} /* end of check_parallel_for_private */
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_parallel_for_reduction.c b/final/testsuite/c/omp_parallel_for_reduction.c
new file mode 100644
index 0000000..6c991f7
--- /dev/null
+++ b/final/testsuite/c/omp_parallel_for_reduction.c
@@ -0,0 +1,280 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp parallel for reduction directive with all its options.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp parallel for reduction</ompts:directive>
+<ompts:testcode>
+#include <stdio.h>
+#include <math.h>
+#include "omp_testsuite.h"
+
+
+int <ompts:testcode:functionname>omp_parallel_for_reduction</ompts:testcode:functionname>(FILE * logFile){
+ <ompts:orphan:vars>
+ int sum;
+ int known_sum;
+ double dsum;
+ double dknown_sum;
+ double dt=0.5; /* base of geometric row for + and - test*/
+ double rounding_error= 1.E-9;
+#define DOUBLE_DIGITS 20 /* dt^DOUBLE_DIGITS */
+ int diff;
+ double ddiff;
+ int product;
+ int known_product;
+#define MAX_FACTOR 10
+#define KNOWN_PRODUCT 3628800 /* 10! */
+ int logic_and;
+ int logic_or;
+ int bit_and;
+ int bit_or;
+ int exclusiv_bit_or;
+ int logics[LOOPCOUNT];
+ int i;
+ double dpt;
+ int result;
+ </ompts:orphan:vars>
+
+ sum =0;
+ dsum=0;
+ dt = 1./3.;
+ result = 0;
+ product = 1;
+ logic_and=1;
+ logic_or=0;
+ bit_and=1;
+ bit_or=0;
+ exclusiv_bit_or=0;
+
+ known_sum = (LOOPCOUNT*(LOOPCOUNT+1))/2;
+<ompts:orphan>
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(+:sum)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for (i=1;i<=LOOPCOUNT;i++)
+ {
+ sum=sum+i;
+ }
+
+ if(known_sum!=sum)
+ {
+ result++;
+ fprintf(logFile,"Error in sum with integers: Result was %d instead of %d\n",sum,known_sum);
+ }
+
+ diff = (LOOPCOUNT*(LOOPCOUNT+1))/2;
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(-:diff)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for (i=1;i<=LOOPCOUNT;++i)
+ {
+ diff=diff-i;
+ }
+
+ if(diff != 0)
+ {
+ result++;
+ fprintf(logFile,"Error in difference with integers: Result was %d instead of 0.\n",diff);
+ }
+
+ /* Tests for doubles */
+ dsum=0;
+ dpt=1;
+ for (i=0;i<DOUBLE_DIGITS;++i)
+ {
+ dpt*=dt;
+ }
+ dknown_sum = (1-dpt)/(1-dt);
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(+:dsum)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for (i=0;i<DOUBLE_DIGITS;++i)
+ {
+ dsum += pow(dt,i);
+ }
+
+ if( fabs(dsum-dknown_sum) > rounding_error )
+ {
+ result++;
+ fprintf(logFile,"Error in sum with doubles: Result was %f instead of %f (Difference: %E)\n",dsum,dknown_sum, dsum-dknown_sum);
+ }
+
+ dpt=1;
+
+ for (i=0;i<DOUBLE_DIGITS;++i)
+ {
+ dpt*=dt;
+ }
+ fprintf(logFile,"\n");
+ ddiff = (1-dpt)/(1-dt);
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(-:ddiff)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for (i=0;i<DOUBLE_DIGITS;++i)
+ {
+ ddiff -= pow(dt,i);
+ }
+ if( fabs(ddiff) > rounding_error)
+ {
+ result++;
+ fprintf(logFile,"Error in Difference with doubles: Result was %E instead of 0.0\n",ddiff);
+ }
+
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(*:product)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for(i=1;i<=MAX_FACTOR;i++)
+ {
+ product *= i;
+ }
+
+ known_product = KNOWN_PRODUCT;
+ if(known_product != product)
+ {
+ result++;
+ fprintf(logFile,"Error in Product with integers: Result was %d instead of %d\n\n",product,known_product);
+ }
+
+ for(i=0;i<LOOPCOUNT;i++)
+ {
+ logics[i]=1;
+ }
+
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(&&:logic_and)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for(i=0;i<LOOPCOUNT;++i)
+ {
+ logic_and = (logic_and && logics[i]);
+ }
+ if(!logic_and)
+ {
+ result++;
+ fprintf(logFile,"Error in logic AND part 1.\n");
+ }
+
+ logic_and = 1;
+ logics[LOOPCOUNT/2]=0;
+
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(&&:logic_and)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for(i=0;i<LOOPCOUNT;++i)
+ {
+ logic_and = logic_and && logics[i];
+ }
+ if(logic_and)
+ {
+ result++;
+ fprintf(logFile,"Error in logic AND part 2.\n");
+ }
+
+ for(i=0;i<LOOPCOUNT;i++)
+ {
+ logics[i]=0;
+ }
+
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(||:logic_or)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for(i=0;i<LOOPCOUNT;++i)
+ {
+ logic_or = logic_or || logics[i];
+ }
+ if(logic_or)
+ {
+ result++;
+ fprintf(logFile,"Error in logic OR part 1.\n");
+ }
+ logic_or = 0;
+ logics[LOOPCOUNT/2]=1;
+
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(||:logic_or)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for(i=0;i<LOOPCOUNT;++i)
+ {
+ logic_or = logic_or || logics[i];
+ }
+ if(!logic_or)
+ {
+ result++;
+ fprintf(logFile,"Error in logic OR part 2.\n");
+ }
+
+
+ for(i=0;i<LOOPCOUNT;++i)
+ {
+ logics[i]=1;
+ }
+
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(&:bit_and)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for(i=0;i<LOOPCOUNT;++i)
+ {
+ bit_and = (bit_and & logics[i]);
+ }
+ if(!bit_and)
+ {
+ result++;
+ fprintf(logFile,"Error in BIT AND part 1.\n");
+ }
+
+ bit_and = 1;
+ logics[LOOPCOUNT/2]=0;
+
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(&:bit_and)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for(i=0;i<LOOPCOUNT;++i)
+ {
+ bit_and = bit_and & logics[i];
+ }
+ if(bit_and)
+ {
+ result++;
+ fprintf(logFile,"Error in BIT AND part 2.\n");
+ }
+
+ for(i=0;i<LOOPCOUNT;i++)
+ {
+ logics[i]=0;
+ }
+
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(|:bit_or)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for(i=0;i<LOOPCOUNT;++i)
+ {
+ bit_or = bit_or | logics[i];
+ }
+ if(bit_or)
+ {
+ result++;
+ fprintf(logFile,"Error in BIT OR part 1\n");
+ }
+ bit_or = 0;
+ logics[LOOPCOUNT/2]=1;
+
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(|:bit_or)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for(i=0;i<LOOPCOUNT;++i)
+ {
+ bit_or = bit_or | logics[i];
+ }
+ if(!bit_or)
+ {
+ result++;
+ fprintf(logFile,"Error in BIT OR part 2\n");
+ }
+
+ for(i=0;i<LOOPCOUNT;i++)
+ {
+ logics[i]=0;
+ }
+
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(^:exclusiv_bit_or)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for(i=0;i<LOOPCOUNT;++i)
+ {
+ exclusiv_bit_or = exclusiv_bit_or ^ logics[i];
+ }
+ if(exclusiv_bit_or)
+ {
+ result++;
+ fprintf(logFile,"Error in EXCLUSIV BIT OR part 1\n");
+ }
+
+ exclusiv_bit_or = 0;
+ logics[LOOPCOUNT/2]=1;
+
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(^:exclusiv_bit_or)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for(i=0;i<LOOPCOUNT;++i)
+ {
+ exclusiv_bit_or = exclusiv_bit_or ^ logics[i];
+ }
+ if(!exclusiv_bit_or)
+ {
+ result++;
+ fprintf(logFile,"Error in EXCLUSIV BIT OR part 2\n");
+ }
+</ompts:orphan>
+ /*printf("\nResult:%d\n",result);*/
+ return (result==0);
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_parallel_if.c b/final/testsuite/c/omp_parallel_if.c
new file mode 100644
index 0000000..d3f45b1
--- /dev/null
+++ b/final/testsuite/c/omp_parallel_if.c
@@ -0,0 +1,40 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the if option of the parallel construct.</ompts:testdescription>
+<ompts:ompversion>3.0</ompts:ompversion>
+<ompts:directive>omp parallel if</ompts:directive>
+<ompts:testcode>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "omp_testsuite.h"
+
+int <ompts:testcode:functionname>omp_parallel_if</ompts:testcode:functionname> (FILE * logFile)
+{
+<ompts:orphan:vars>
+ int i;
+ int sum;
+ int known_sum;
+ int mysum;
+ int control=1;
+</ompts:orphan:vars>
+ sum =0;
+ known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2 ;
+#pragma omp parallel private(i) <ompts:check>if(control==0)</ompts:check>
+ {
+ <ompts:orphan>
+ mysum = 0;
+ for (i = 1; i <= LOOPCOUNT; i++)
+ {
+ mysum = mysum + i;
+ }
+#pragma omp critical
+ {
+ sum = sum + mysum;
+ } /* end of critical */
+ </ompts:orphan>
+ } /* end of parallel */
+
+ return (known_sum == sum);
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_parallel_num_threads.c b/final/testsuite/c/omp_parallel_num_threads.c
new file mode 100644
index 0000000..897fed2
--- /dev/null
+++ b/final/testsuite/c/omp_parallel_num_threads.c
@@ -0,0 +1,46 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp_parallel_num_threads directive by counting the threads in a parallel region which was started with an explicitly stated number of threads.</ompts:testdescription>
+<ompts:ompversion>3.0</ompts:ompversion>
+<ompts:directive>omp parellel num_threads</ompts:directive>
+<ompts:dependences>omp master,omp parallel reduction,omp atomic</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include "omp_testsuite.h"
+
+int <ompts:testcode:functionname>omp_parallel_num_threads</ompts:testcode:functionname>(FILE * logFile){
+ <ompts:orphan:vars>
+ int failed;
+ int threads;
+ int nthreads;
+ </ompts:orphan:vars>
+
+ int max_threads = 0;
+
+ failed = 0;
+
+ /* first we check how many threads are available */
+#pragma omp parallel
+ {
+#pragma omp master
+ max_threads = omp_get_num_threads ();
+ }
+
+ /* we increase the number of threads from one to maximum:*/
+ for (threads = 1; threads <= max_threads; threads++)
+ {
+ nthreads = 0;
+
+ <ompts:orphan>
+#pragma omp parallel reduction(+:failed) <ompts:check>num_threads(threads)</ompts:check>
+ {
+ failed = failed + !(threads == omp_get_num_threads ());
+#pragma omp atomic
+ nthreads += 1;
+ }
+ </ompts:orphan>
+ failed = failed + !(nthreads == threads);
+ }
+ return (!failed);
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_parallel_private.c b/final/testsuite/c/omp_parallel_private.c
new file mode 100644
index 0000000..fdccc09
--- /dev/null
+++ b/final/testsuite/c/omp_parallel_private.c
@@ -0,0 +1,50 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp parallel private directive.</ompts:testdescription>
+<ompts:ompversion>3.0</ompts:ompversion>
+<ompts:directive>omp parallel private</ompts:directive>
+<ompts:dependences>omp for omp critical</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include <stdlib.h>
+#include "omp_testsuite.h"
+
+//static int sum1 = 789;
+
+int <ompts:testcode:functionname>omp_parallel_private</ompts:testcode:functionname>(FILE * logFile)
+{
+ <ompts:orphan:vars>
+ int sum, num_threads,sum1;
+ </ompts:orphan:vars>
+ int known_sum;
+
+ sum = 0;
+ <ompts:crosscheck> sum1=0; </ompts:crosscheck>
+ num_threads = 0;
+
+
+#pragma omp parallel <ompts:check>private(sum1)</ompts:check>
+ {
+ <ompts:check>
+ sum1 = 7;
+ </ompts:check>
+ /*printf("sum1=%d\n",sum1);*/
+ <ompts:orphan>
+ int i;
+#pragma omp for
+ for (i = 1; i < 1000; i++)
+ {
+ sum1 = sum1 + i;
+ } /*end of for*/
+#pragma omp critical
+ {
+ sum = sum + sum1;
+ num_threads++;
+ } /*end of critical*/
+ </ompts:orphan>
+ } /* end of parallel*/
+ known_sum = (999 * 1000) / 2 + 7 * num_threads;
+ return (known_sum == sum);
+
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_parallel_reduction.c b/final/testsuite/c/omp_parallel_reduction.c
new file mode 100644
index 0000000..96f8394
--- /dev/null
+++ b/final/testsuite/c/omp_parallel_reduction.c
@@ -0,0 +1,278 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp parallel reduction directive with all its options.</ompts:testdescription>
+<ompts:ompversion>3.0</ompts:ompversion>
+<ompts:directive>omp parallel reduction</ompts:directive>
+<ompts:testcode>
+#include <stdio.h>
+#include <math.h>
+#include "omp_testsuite.h"
+
+
+int <ompts:testcode:functionname>omp_parallel_reduction</ompts:testcode:functionname>(FILE * logFile){
+ <ompts:orphan:vars>
+ int sum;
+ int known_sum;
+ double dsum;
+ double dknown_sum;
+ double dt=0.5; /* base of geometric row for + and - test*/
+ double rounding_error= 1.E-9;
+#define DOUBLE_DIGITS 20 /* dt^DOUBLE_DIGITS */
+ int diff;
+ double ddiff;
+ int product;
+ int known_product;
+#define MAX_FACTOR 10
+#define KNOWN_PRODUCT 3628800 /* 10! */
+ int logic_and;
+ int logic_or;
+ int bit_and;
+ int bit_or;
+ int exclusiv_bit_or;
+ int logics[LOOPCOUNT];
+ int i;
+ double dpt;
+ int result;
+</ompts:orphan:vars>
+ sum =0;
+ dsum=0;
+ product=1;
+ logic_and=1;
+ logic_or=0;
+ bit_and=1;
+ bit_or=0;
+ exclusiv_bit_or=0;
+ result=0;
+ dt = 1./3.;
+ known_sum = (LOOPCOUNT*(LOOPCOUNT+1))/2;
+<ompts:orphan>
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(+:sum)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for (i=1;i<=LOOPCOUNT;i++)
+ {
+ sum=sum+i;
+ }
+
+ if(known_sum!=sum)
+ {
+ result++;
+ fprintf(logFile,"Error in sum with integers: Result was %d instead of %d\n",sum,known_sum);
+ }
+
+ diff = (LOOPCOUNT*(LOOPCOUNT+1))/2;
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(-:diff)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for (i=1;i<=LOOPCOUNT;++i)
+ {
+ diff=diff-i;
+ }
+
+ if(diff != 0)
+ {
+ result++;
+ fprintf(logFile,"Error in difference with integers: Result was %d instead of 0.\n",diff);
+ }
+
+ /* Tests for doubles */
+ dsum=0;
+ dpt=1;
+ for (i=0;i<DOUBLE_DIGITS;++i)
+ {
+ dpt*=dt;
+ }
+ dknown_sum = (1-dpt)/(1-dt);
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(+:dsum)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for (i=0;i<DOUBLE_DIGITS;++i)
+ {
+ dsum += pow(dt,i);
+ }
+
+ if( fabs(dsum-dknown_sum) > rounding_error )
+ {
+ result++;
+ fprintf(logFile,"Error in sum with doubles: Result was %f instead of %f (Difference: %E)\n",dsum,dknown_sum, dsum-dknown_sum);
+ }
+
+ dpt=1;
+
+ for (i=0;i<DOUBLE_DIGITS;++i)
+ {
+ dpt*=dt;
+ }
+ fprintf(logFile,"\n");
+ ddiff = (1-dpt)/(1-dt);
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(-:ddiff)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for (i=0;i<DOUBLE_DIGITS;++i)
+ {
+ ddiff -= pow(dt,i);
+ }
+ if( fabs(ddiff) > rounding_error)
+ {
+ result++;
+ fprintf(logFile,"Error in Difference with doubles: Result was %E instead of 0.0\n",ddiff);
+ }
+
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(*:product)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for(i=1;i<=MAX_FACTOR;i++)
+ {
+ product *= i;
+ }
+
+ known_product = KNOWN_PRODUCT;
+ if(known_product != product)
+ {
+ result++;
+ fprintf(logFile,"Error in Product with integers: Result was %d instead of %d\n\n",product,known_product);
+ }
+
+ for(i=0;i<LOOPCOUNT;i++)
+ {
+ logics[i]=1;
+ }
+
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(&&:logic_and)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for(i=0;i<LOOPCOUNT;++i)
+ {
+ logic_and = (logic_and && logics[i]);
+ }
+ if(!logic_and)
+ {
+ result++;
+ fprintf(logFile,"Error in logic AND part 1.\n");
+ }
+
+ logic_and = 1;
+ logics[LOOPCOUNT/2]=0;
+
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(&&:logic_and)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for(i=0;i<LOOPCOUNT;++i)
+ {
+ logic_and = logic_and && logics[i];
+ }
+ if(logic_and)
+ {
+ result++;
+ fprintf(logFile,"Error in logic AND part 2.\n");
+ }
+
+ for(i=0;i<LOOPCOUNT;i++)
+ {
+ logics[i]=0;
+ }
+
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(||:logic_or)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for(i=0;i<LOOPCOUNT;++i)
+ {
+ logic_or = logic_or || logics[i];
+ }
+ if(logic_or)
+ {
+ result++;
+ fprintf(logFile,"Error in logic OR part 1.\n");
+ }
+ logic_or = 0;
+ logics[LOOPCOUNT/2]=1;
+
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(||:logic_or)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for(i=0;i<LOOPCOUNT;++i)
+ {
+ logic_or = logic_or || logics[i];
+ }
+ if(!logic_or)
+ {
+ result++;
+ fprintf(logFile,"Error in logic OR part 2.\n");
+ }
+
+
+ for(i=0;i<LOOPCOUNT;++i)
+ {
+ logics[i]=1;
+ }
+
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(&:bit_and)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for(i=0;i<LOOPCOUNT;++i)
+ {
+ bit_and = (bit_and & logics[i]);
+ }
+ if(!bit_and)
+ {
+ result++;
+ fprintf(logFile,"Error in BIT AND part 1.\n");
+ }
+
+ bit_and = 1;
+ logics[LOOPCOUNT/2]=0;
+
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(&:bit_and)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for(i=0;i<LOOPCOUNT;++i)
+ {
+ bit_and = bit_and & logics[i];
+ }
+ if(bit_and)
+ {
+ result++;
+ fprintf(logFile,"Error in BIT AND part 2.\n");
+ }
+
+ for(i=0;i<LOOPCOUNT;i++)
+ {
+ logics[i]=0;
+ }
+
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(|:bit_or)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for(i=0;i<LOOPCOUNT;++i)
+ {
+ bit_or = bit_or | logics[i];
+ }
+ if(bit_or)
+ {
+ result++;
+ fprintf(logFile,"Error in BIT OR part 1\n");
+ }
+ bit_or = 0;
+ logics[LOOPCOUNT/2]=1;
+
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(|:bit_or)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for(i=0;i<LOOPCOUNT;++i)
+ {
+ bit_or = bit_or | logics[i];
+ }
+ if(!bit_or)
+ {
+ result++;
+ fprintf(logFile,"Error in BIT OR part 2\n");
+ }
+
+ for(i=0;i<LOOPCOUNT;i++)
+ {
+ logics[i]=0;
+ }
+
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(^:exclusiv_bit_or)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for(i=0;i<LOOPCOUNT;++i)
+ {
+ exclusiv_bit_or = exclusiv_bit_or ^ logics[i];
+ }
+ if(exclusiv_bit_or)
+ {
+ result++;
+ fprintf(logFile,"Error in EXCLUSIV BIT OR part 1\n");
+ }
+
+ exclusiv_bit_or = 0;
+ logics[LOOPCOUNT/2]=1;
+
+#pragma omp parallel for schedule(dynamic,1) private(i) <ompts:check>reduction(^:exclusiv_bit_or)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ for(i=0;i<LOOPCOUNT;++i)
+ {
+ exclusiv_bit_or = exclusiv_bit_or ^ logics[i];
+ }
+ if(!exclusiv_bit_or)
+ {
+ result++;
+ fprintf(logFile,"Error in EXCLUSIV BIT OR part 2\n");
+ }
+ </ompts:orphan>
+ /*printf("\nResult:%d\n",result);*/
+ return (result==0);
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_parallel_sections_firstprivate.c b/final/testsuite/c/omp_parallel_sections_firstprivate.c
new file mode 100644
index 0000000..2933839
--- /dev/null
+++ b/final/testsuite/c/omp_parallel_sections_firstprivate.c
@@ -0,0 +1,49 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp parallel sections firstprivate directive.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp parallel sections firstprivate</ompts:directive>
+<ompts:dependences>omp critical</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include "omp_testsuite.h"
+
+int <ompts:testcode:functionname>omp_parallel_sections_firstprivate</ompts:testcode:functionname>(FILE * logFile){
+ <ompts:orphan:vars>
+ int sum;
+ int sum0;
+ </ompts:orphan:vars>
+ int known_sum;
+ sum =7;
+ sum0=11;
+
+<ompts:orphan>
+#pragma omp parallel sections <ompts:check>firstprivate(sum0)</ompts:check><ompts:crosscheck>private(sum0)</ompts:crosscheck>
+ {
+#pragma omp section
+ {
+#pragma omp critical
+ {
+ sum= sum+sum0;
+ } /*end of critical */
+ }
+#pragma omp section
+ {
+#pragma omp critical
+ {
+ sum= sum+sum0;
+ } /*end of critical */
+ }
+#pragma omp section
+ {
+#pragma omp critical
+ {
+ sum= sum+sum0;
+ } /*end of critical */
+ }
+ } /*end of parallel sections*/
+</ompts:orphan>
+known_sum=11*3+7;
+return (known_sum==sum);
+} /* end of check_section_firstprivate*/
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_parallel_sections_lastprivate.c b/final/testsuite/c/omp_parallel_sections_lastprivate.c
new file mode 100644
index 0000000..55ae5f0
--- /dev/null
+++ b/final/testsuite/c/omp_parallel_sections_lastprivate.c
@@ -0,0 +1,70 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp parallel sections lastprivate directive.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp parallel sections lastprivate</ompts:directive>
+<ompts:dependences>omp critical,omp parallel sections private</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include "omp_testsuite.h"
+
+int <ompts:testcode:functionname>omp_parallel_sections_lastprivate</ompts:testcode:functionname>(FILE * logFile){
+ <ompts:orphan:vars>
+ int sum;
+ int sum0;
+ int i;
+ int i0;
+ </ompts:orphan:vars>
+ int known_sum;
+ sum =0;
+ sum0 = 0;
+ i0 = -1;
+
+ <ompts:orphan>
+#pragma omp parallel sections private(i,sum0) <ompts:check>lastprivate(i0)</ompts:check><ompts:crosscheck>private(i0)</ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ sum0=0;
+ for (i=1;i<400;i++)
+ {
+ sum0=sum0+i;
+ i0=i;
+ }
+#pragma omp critical
+ {
+ sum= sum+sum0;
+ } /*end of critical*/
+ }/* end of section */
+#pragma omp section
+ {
+ sum0=0;
+ for(i=400;i<700;i++)
+ {
+ sum0=sum0+i; /*end of for*/
+ i0=i;
+ }
+#pragma omp critical
+ {
+ sum= sum+sum0;
+ } /*end of critical*/
+ }
+#pragma omp section
+ {
+ sum0=0;
+ for(i=700;i<1000;i++)
+ {
+ sum0=sum0+i;
+ i0=i;
+ }
+#pragma omp critical
+ {
+ sum= sum+sum0;
+ } /*end of critical*/
+ }
+ }/* end of parallel sections*/
+ </ompts:orphan>
+ known_sum=(999*1000)/2;
+ return ((known_sum==sum) && (i0==999) );
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_parallel_sections_private.c b/final/testsuite/c/omp_parallel_sections_private.c
new file mode 100644
index 0000000..c5fe414
--- /dev/null
+++ b/final/testsuite/c/omp_parallel_sections_private.c
@@ -0,0 +1,65 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp parallel sections private directive.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp parallel sections private</ompts:directive>
+<ompts:dependences>omp critical</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include "omp_testsuite.h"
+
+int <ompts:testcode:functionname>omp_parallel_sections_private</ompts:testcode:functionname>(FILE * logFile){
+ <ompts:orphan:vars>
+ int sum;
+ int sum0;
+ int i;
+ </ompts:orphan:vars>
+ int known_sum;
+ sum = 7;
+ sum0=0;
+
+<ompts:orphan>
+#pragma omp parallel sections private(<ompts:check>sum0,</ompts:check> i)
+ {
+#pragma omp section
+ {
+ <ompts:check>
+ sum0=0;
+ </ompts:check>
+ for (i=1;i<400;i++)
+ sum0=sum0+i;
+#pragma omp critical
+ {
+ sum= sum+sum0;
+ } /*end of critical */
+ }
+#pragma omp section
+ {
+ <ompts:check>
+ sum0=0;
+ </ompts:check>
+ for(i=400;i<700;i++)
+ sum0=sum0+i;
+#pragma omp critical
+ {
+ sum= sum+sum0;
+ } /*end of critical */
+ }
+#pragma omp section
+ {
+ <ompts:check>
+ sum0=0;
+ </ompts:check>
+ for(i=700;i<1000;i++)
+ sum0=sum0+i;
+#pragma omp critical
+ {
+ sum= sum+sum0;
+ } /*end of critical */
+ }
+ } /*end of parallel sections*/
+</ompts:orphan>
+known_sum=(999*1000)/2+7;
+return (known_sum==sum);
+} /* end of check_section_private*/
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_parallel_sections_reduction.c b/final/testsuite/c/omp_parallel_sections_reduction.c
new file mode 100644
index 0000000..cadea6a
--- /dev/null
+++ b/final/testsuite/c/omp_parallel_sections_reduction.c
@@ -0,0 +1,568 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp parallel sections reduction directive with all its option.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp parallel sections reduction</ompts:directive>
+<ompts:testcode>
+#include <stdio.h>
+#include <math.h>
+#include "omp_testsuite.h"
+
+
+int <ompts:testcode:functionname>omp_parallel_sections_reduction</ompts:testcode:functionname>(FILE * logFile){
+ <ompts:orphan:vars>
+ int sum;
+ int known_sum;
+ double dpt;
+ double dsum;
+ double dknown_sum;
+ double dt=0.5; /* base of geometric row for + and - test*/
+ double rounding_error= 1.E-5;
+ int diff;
+ double ddiff;
+ int product;
+ int known_product;
+ int logic_and;
+ int bit_and;
+ int logic_or;
+ int bit_or;
+ int exclusiv_bit_or;
+ int logics[1000];
+ int i;
+ int result;
+ </ompts:orphan:vars>
+
+ sum = 7;
+ dsum=0;
+ product =1;
+ dpt = 1;
+ logic_and=1;
+ bit_and=1;
+ logic_or=0;
+ bit_or=0;
+ exclusiv_bit_or=0;
+ result =0;
+ /* int my_islarger;*/
+ /*int is_larger=1;*/
+ known_sum = (999*1000)/2+7;
+
+ <ompts:orphan>
+#pragma omp parallel sections private(i) <ompts:check>reduction(+:sum)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for (i=1;i<300;i++)
+ {
+ sum=sum+i;
+ }
+ }
+#pragma omp section
+ {
+ for (i=300;i<700;i++)
+ {
+ sum=sum+i;
+ }
+ }
+#pragma omp section
+ {
+ for (i=700;i<1000;i++)
+ {
+ sum=sum+i;
+ }
+ }
+ }
+
+ if(known_sum!=sum)
+ {
+ result++;
+ fprintf(logFile,"Error in sum with integers: Result was %d instead of %d.\n",sum, known_sum);
+ }
+
+ diff = (999*1000)/2;
+#pragma omp parallel sections private(i) <ompts:check>reduction(-:diff)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for (i=1;i<300;i++)
+ {
+ diff=diff-i;
+ }
+ }
+#pragma omp section
+ {
+ for (i=300;i<700;i++)
+ {
+ diff=diff-i;
+ }
+ }
+#pragma omp section
+ {
+ for (i=700;i<1000;i++)
+ {
+ diff=diff-i;
+ }
+ }
+ }
+
+
+ if(diff != 0)
+ {
+ result++;
+ fprintf(logFile,"Error in Difference with integers: Result was %d instead of 0.\n",diff);
+ }
+ for (i=0;i<20;++i)
+ {
+ dpt*=dt;
+ }
+ dknown_sum = (1-dpt)/(1-dt);
+#pragma omp parallel sections private(i) <ompts:check>reduction(+:dsum)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for (i=0;i<6;++i)
+ {
+ dsum += pow(dt,i);
+ }
+ }
+#pragma omp section
+ {
+ for (i=6;i<12;++i)
+ {
+ dsum += pow(dt,i);
+ }
+ }
+#pragma omp section
+ {
+ for (i=12;i<20;++i)
+ {
+ dsum += pow(dt,i);
+ }
+ }
+ }
+
+
+ if( fabs(dsum-dknown_sum) > rounding_error )
+ {
+ result++;
+ fprintf(logFile,"Error in sum with doubles: Result was %f instead of %f (Difference: %E)\n",dsum,dknown_sum, dsum-dknown_sum);
+ }
+
+ dpt=1;
+
+ for (i=0;i<20;++i)
+ {
+ dpt*=dt;
+ }
+ fprintf(logFile,"\n");
+ ddiff = (1-dpt)/(1-dt);
+#pragma omp parallel sections private(i) <ompts:check>reduction(-:ddiff)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for (i=0;i<6;++i)
+ {
+ ddiff -= pow(dt,i);
+ }
+ }
+#pragma omp section
+ {
+ for (i=6;i<12;++i)
+ {
+ ddiff -= pow(dt,i);
+ }
+ }
+#pragma omp section
+ {
+ for (i=12;i<20;++i)
+ {
+ ddiff -= pow(dt,i);
+ }
+ }
+ }
+
+ if( fabs(ddiff) > rounding_error)
+ {
+ result++;
+ fprintf(logFile,"Error in Difference with doubles: Result was %E instead of 0.0\n",ddiff);
+ }
+
+ known_product = 3628800;
+#pragma omp parallel sections private(i) <ompts:check>reduction(*:product)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for(i=1;i<3;i++)
+ {
+ product *= i;
+ }
+ }
+#pragma omp section
+ {
+ for(i=3;i<7;i++)
+ {
+ product *= i;
+ }
+ }
+#pragma omp section
+ {
+ for(i=7;i<11;i++)
+ {
+ product *= i;
+ }
+ }
+ }
+
+
+ if(known_product != product)
+ {
+ result++;
+ fprintf(logFile,"Error in Product with integers: Result was %d instead of %d\n",product,known_product);
+ }
+
+ for(i=0;i<1000;i++)
+ {
+ logics[i]=1;
+ }
+
+#pragma omp parallel sections private(i) <ompts:check>reduction(&&:logic_and)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for (i=1;i<300;i++)
+ {
+ logic_and = (logic_and && logics[i]);
+ }
+ }
+#pragma omp section
+ {
+ for (i=300;i<700;i++)
+ {
+ logic_and = (logic_and && logics[i]);
+ }
+ }
+#pragma omp section
+ {
+ for (i=700;i<1000;i++)
+ {
+ logic_and = (logic_and && logics[i]);
+ }
+ }
+ }
+
+ if(!logic_and)
+ {
+ result++;
+ fprintf(logFile,"Error in logic AND part 1\n");
+ }
+
+ logic_and = 1;
+ logics[501] = 0;
+
+#pragma omp parallel sections private(i) <ompts:check>reduction(&&:logic_and)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for (i=1;i<300;i++)
+ {
+ logic_and = (logic_and && logics[i]);
+ }
+ }
+#pragma omp section
+ {
+ for (i=300;i<700;i++)
+ {
+ logic_and = (logic_and && logics[i]);
+ }
+ }
+#pragma omp section
+ {
+ for (i=700;i<1000;i++)
+ {
+ logic_and = (logic_and && logics[i]);
+ }
+ }
+ }
+
+ if(logic_and)
+ {
+ result++;
+ fprintf(logFile,"Error in logic AND part 2");
+ }
+
+ for(i=0;i<1000;i++)
+ {
+ logics[i]=0;
+ }
+
+#pragma omp parallel sections private(i) <ompts:check>reduction(||:logic_or)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for (i=1;i<300;i++)
+ {
+ logic_or = (logic_or || logics[i]);
+ }
+ }
+#pragma omp section
+ {
+ for (i=300;i<700;i++)
+ {
+ logic_or = (logic_or || logics[i]);
+ }
+ }
+#pragma omp section
+ {
+ for (i=700;i<1000;i++)
+ {
+ logic_or = (logic_or || logics[i]);
+ }
+ }
+ }
+
+ if(logic_or)
+ {
+ result++;
+ fprintf(logFile,"Error in logic OR part 1\n");
+ }
+
+ logic_or = 0;
+ logics[501]=1;
+
+#pragma omp parallel sections private(i) <ompts:check>reduction(||:logic_or)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for (i=1;i<300;i++)
+ {
+ logic_or = (logic_or || logics[i]);
+ }
+ }
+#pragma omp section
+ {
+ for (i=300;i<700;i++)
+ {
+ logic_or = (logic_or || logics[i]);
+ }
+ }
+#pragma omp section
+ {
+ for (i=700;i<1000;i++)
+ {
+ logic_or = (logic_or || logics[i]);
+ }
+ }
+ }
+
+ if(!logic_or)
+ {
+ result++;
+ fprintf(logFile,"Error in logic OR part 2\n");
+ }
+
+ for(i=0;i<1000;++i)
+ {
+ logics[i]=1;
+ }
+
+#pragma omp parallel sections private(i) <ompts:check>reduction(&:bit_and)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for(i=0;i<300;++i)
+ {
+ bit_and = (bit_and & logics[i]);
+ }
+ }
+#pragma omp section
+ {
+ for(i=300;i<700;++i)
+ {
+ bit_and = (bit_and & logics[i]);
+ }
+ }
+#pragma omp section
+ {
+ for(i=700;i<1000;++i)
+ {
+ bit_and = (bit_and & logics[i]);
+ }
+ }
+ }
+ if(!bit_and)
+ {
+ result++;
+ fprintf(logFile,"Error in BIT AND part 1\n");
+ }
+
+ bit_and = 1;
+ logics[501]=0;
+
+#pragma omp parallel sections private(i) <ompts:check>reduction(&:bit_and)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for(i=0;i<300;++i)
+ {
+ bit_and = bit_and & logics[i];
+ }
+ }
+#pragma omp section
+ {
+ for(i=300;i<700;++i)
+ {
+ bit_and = bit_and & logics[i];
+ }
+ }
+#pragma omp section
+ {
+ for(i=700;i<1000;++i)
+ {
+ bit_and = bit_and & logics[i];
+ }
+ }
+ }
+ if(bit_and)
+ {
+ result++;
+ fprintf(logFile,"Error in BIT AND part 2");
+ }
+
+ for(i=0;i<1000;i++)
+ {
+ logics[i]=0;
+ }
+
+#pragma omp parallel sections private(i) <ompts:check>reduction(|:bit_or)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for(i=0;i<300;++i)
+ {
+ bit_or = bit_or | logics[i];
+ }
+ }
+#pragma omp section
+ {
+ for(i=300;i<700;++i)
+ {
+ bit_or = bit_or | logics[i];
+ }
+ }
+#pragma omp section
+ {
+ for(i=700;i<1000;++i)
+ {
+ bit_or = bit_or | logics[i];
+ }
+ }
+ }
+ if(bit_or)
+ {
+ result++;
+ fprintf(logFile,"Error in BIT OR part 1\n");
+ }
+ bit_or = 0;
+ logics[501]=1;
+
+#pragma omp parallel sections private(i) <ompts:check>reduction(|:bit_or)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for(i=0;i<300;++i)
+ {
+ bit_or = bit_or | logics[i];
+ }
+ }
+#pragma omp section
+ {
+ for(i=300;i<700;++i)
+ {
+ bit_or = bit_or | logics[i];
+ }
+ }
+#pragma omp section
+ {
+ for(i=700;i<1000;++i)
+ {
+ bit_or = bit_or | logics[i];
+ }
+ }
+ }
+ if(!bit_or)
+ {
+ result++;
+ fprintf(logFile,"Error in BIT OR part 2\n");
+ }
+
+ for(i=0;i<1000;i++)
+ {
+ logics[i]=0;
+ }
+
+#pragma omp parallel sections private(i) <ompts:check>reduction(^:exclusiv_bit_or)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for(i=0;i<300;++i)
+ {
+ exclusiv_bit_or = exclusiv_bit_or ^ logics[i];
+ }
+ }
+#pragma omp section
+ {
+ for(i=300;i<700;++i)
+ {
+ exclusiv_bit_or = exclusiv_bit_or ^ logics[i];
+ }
+ }
+#pragma omp section
+ {
+ for(i=700;i<1000;++i)
+ {
+ exclusiv_bit_or = exclusiv_bit_or ^ logics[i];
+ }
+ }
+ }
+ if(exclusiv_bit_or)
+ {
+ result++;
+ fprintf(logFile,"Error in EXCLUSIV BIT OR part 1\n");
+ }
+
+ exclusiv_bit_or = 0;
+ logics[501]=1;
+
+#pragma omp parallel sections private(i) <ompts:check>reduction(^:exclusiv_bit_or)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for(i=0;i<300;++i)
+ {
+ exclusiv_bit_or = exclusiv_bit_or ^ logics[i];
+ }
+ }
+#pragma omp section
+ {
+ for(i=300;i<700;++i)
+ {
+ exclusiv_bit_or = exclusiv_bit_or ^ logics[i];
+ }
+ }
+#pragma omp section
+ {
+ for(i=700;i<1000;++i)
+ {
+ exclusiv_bit_or = exclusiv_bit_or ^ logics[i];
+ }
+ }
+ }
+ if(!exclusiv_bit_or)
+ {
+ result++;
+ fprintf(logFile,"Error in EXCLUSIV BIT OR part 2\n");
+ }
+</ompts:orphan>
+ /*printf("\nResult:%d\n",result);*/
+ return (result==0);
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_parallel_shared.c b/final/testsuite/c/omp_parallel_shared.c
new file mode 100644
index 0000000..1f28e38
--- /dev/null
+++ b/final/testsuite/c/omp_parallel_shared.c
@@ -0,0 +1,43 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the shared option of the parallel construct.</ompts:testdescription>
+<ompts:ompversion>3.0</ompts:ompversion>
+<ompts:directive>omp parallel shared</ompts:directive>
+<ompts:testcode>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "omp_testsuite.h"
+
+int <ompts:testcode:functionname>omp_parallel_shared</ompts:testcode:functionname> (FILE * logFile)
+{
+ <ompts:orphan:vars>
+ int i;
+ int sum;
+ </ompts:orphan:vars>
+ sum = 0;
+ int known_sum;
+ known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2 ;
+
+#pragma omp parallel private(i) <ompts:check>shared(sum)</ompts:check> <ompts:crosscheck>firstprivate(sum)</ompts:crosscheck>
+ {
+ <ompts:orphan>
+ int mysum = 0;
+#pragma omp for
+ for (i = 1; i <= LOOPCOUNT; i++)
+ {
+ mysum = mysum + i;
+ }
+#pragma omp critical
+ {
+ sum = sum + mysum;
+ } /* end of critical */
+</ompts:orphan>
+
+ } /* end of parallel */
+ if (known_sum != sum) {
+ fprintf(logFile, "KNOWN_SUM = %d; SUM = %d\n", known_sum, sum);
+ }
+ return (known_sum == sum);
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_section_firstprivate.c b/final/testsuite/c/omp_section_firstprivate.c
new file mode 100644
index 0000000..a035d10
--- /dev/null
+++ b/final/testsuite/c/omp_section_firstprivate.c
@@ -0,0 +1,52 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp section firstprivate directive by adding a variable which is defined before the parallel region.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp firstprivate</ompts:directive>
+<ompts:testcode>
+#include <stdio.h>
+#include "omp_testsuite.h"
+
+
+int <ompts:testcode:functionname>omp_section_firstprivate</ompts:testcode:functionname>(FILE * logFile){
+ <ompts:orphan:vars>
+ int sum;
+ int sum0;
+ </ompts:orphan:vars>
+ int known_sum;
+
+ sum0 = 11;
+ sum = 7;
+#pragma omp parallel
+ {
+<ompts:orphan>
+#pragma omp sections <ompts:check>firstprivate(sum0)</ompts:check><ompts:crosscheck>private(sum0)</ompts:crosscheck>
+ {
+#pragma omp section
+ {
+#pragma omp critical
+ {
+ sum = sum + sum0;
+ } /*end of critical */
+ }
+#pragma omp section
+ {
+#pragma omp critical
+ {
+ sum = sum + sum0;
+ } /*end of critical */
+ }
+#pragma omp section
+ {
+#pragma omp critical
+ {
+ sum = sum + sum0;
+ } /*end of critical */
+ }
+ } /*end of sections*/
+</ompts:orphan>
+ } /* end of parallel */
+ known_sum = 11 * 3 + 7;
+ return (known_sum == sum);
+} /* end of check_section_firstprivate*/
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_section_lastprivate.c b/final/testsuite/c/omp_section_lastprivate.c
new file mode 100644
index 0000000..56ae0df
--- /dev/null
+++ b/final/testsuite/c/omp_section_lastprivate.c
@@ -0,0 +1,73 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp section lastprivate directive.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp section lastprivate</ompts:directive>
+<ompts:testcode>
+#include <stdio.h>
+#include "omp_testsuite.h"
+
+
+int <ompts:testcode:functionname>omp_section_lastprivate</ompts:testcode:functionname>(FILE * logFile){
+ <ompts:orphan:vars>
+ int i0 = -1;
+ int sum = 0;
+ int i;
+ int sum0 = 0;
+ </ompts:orphan:vars>
+ int known_sum;
+
+ i0 = -1;
+ sum = 0;
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+#pragma omp sections <ompts:check>lastprivate(i0)</ompts:check><ompts:crosscheck>private(i0)</ompts:crosscheck> private(i,sum0)
+ {
+#pragma omp section
+ {
+ sum0 = 0;
+ for (i = 1; i < 400; i++)
+ {
+ sum0 = sum0 + i;
+ i0 = i;
+ }
+#pragma omp critical
+ {
+ sum = sum + sum0;
+ } /*end of critical*/
+ } /* end of section */
+#pragma omp section
+ {
+ sum0 = 0;
+ for(i = 400; i < 700; i++)
+ {
+ sum0 = sum0 + i;
+ i0 = i;
+ }
+#pragma omp critical
+ {
+ sum = sum + sum0;
+ } /*end of critical*/
+ }
+#pragma omp section
+ {
+ sum0 = 0;
+ for(i = 700; i < 1000; i++)
+ {
+ sum0 = sum0 + i;
+ i0 = i;
+ }
+#pragma omp critical
+ {
+ sum = sum + sum0;
+ } /*end of critical*/
+ }
+ } /* end of sections*/
+ </ompts:orphan>
+ } /* end of parallel*/
+ known_sum = (999 * 1000) / 2;
+ return ((known_sum == sum) && (i0 == 999) );
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_section_private.c b/final/testsuite/c/omp_section_private.c
new file mode 100644
index 0000000..399a2f8
--- /dev/null
+++ b/final/testsuite/c/omp_section_private.c
@@ -0,0 +1,69 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp section private directive by upcounting a variable in a to several sections splitted loop.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp section private</ompts:directive>
+<ompts:dependences>omp critical</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include "omp_testsuite.h"
+
+int <ompts:testcode:functionname>omp_section_private</ompts:testcode:functionname>(FILE * logFile){
+ <ompts:orphan:vars>
+ int sum;
+ int sum0;
+ int i;
+ </ompts:orphan:vars>
+ int known_sum;
+
+ sum = 7;
+ sum0 = 0;
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+#pragma omp sections <ompts:check>private(sum0,i)</ompts:check><ompts:crosscheck>private(i)</ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ <ompts:check>
+ sum0 = 0;
+ </ompts:check>
+ for (i = 1; i < 400; i++)
+ sum0 = sum0 + i;
+#pragma omp critical
+ {
+ sum = sum + sum0;
+ } /*end of critical */
+ }
+#pragma omp section
+ {
+ <ompts:check>
+ sum0 = 0;
+ </ompts:check>
+ for (i = 400; i < 700; i++)
+ sum0 = sum0 + i;
+#pragma omp critical
+ {
+ sum = sum + sum0;
+ } /*end of critical */
+ }
+#pragma omp section
+ {
+ <ompts:check>
+ sum0 = 0;
+ </ompts:check>
+ for (i = 700; i < 1000; i++)
+ sum0 = sum0 + i;
+#pragma omp critical
+ {
+ sum = sum + sum0;
+ } /*end of critical */
+ }
+ } /*end of sections*/
+ </ompts:orphan>
+ } /* end of parallel */
+ known_sum = (999 * 1000) / 2 + 7;
+ return (known_sum == sum);
+} /* end of check_section_private*/
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_sections_nowait.c b/final/testsuite/c/omp_sections_nowait.c
new file mode 100644
index 0000000..b91a375
--- /dev/null
+++ b/final/testsuite/c/omp_sections_nowait.c
@@ -0,0 +1,66 @@
+<ompts:test>
+<ompts:description>Test which checks the omp parallel for nowait directive. It fills an array with values and operates on these in the following.</ompts:description>
+<ompts:directive>omp parallel sections nowait</ompts:directive>
+<ompts:version>1.0</ompts:version>
+<ompts:dependences>omp parallel sections, omp flush</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+
+#include "omp_testsuite.h"
+#include "omp_my_sleep.h"
+
+int <ompts:testcode:functionname>omp_sections_nowait</ompts:testcode:functionname> (FILE * logFile)
+{
+ <ompts:orphan:vars>
+ int result;
+ int count;
+ </ompts:orphan:vars>
+ int j;
+
+ result = 0;
+ count = 0;
+
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int rank;
+
+ rank = omp_get_thread_num ();
+
+#pragma omp sections <ompts:check>nowait</ompts:check>
+ {
+#pragma omp section
+ {
+ fprintf (logFile, "Thread nr %d enters first section and gets sleeping.\n", rank);
+ my_sleep(SLEEPTIME);
+ count = 1;
+ fprintf (logFile, "Thread nr %d woke up an set count to 1.\n", rank);
+#pragma omp flush(count)
+ }
+#pragma omp section
+ {
+ fprintf (logFile, "Thread nr %d executed work in the first section.\n", rank);
+ }
+ }
+/* Begin of second sections environment */
+#pragma omp sections
+ {
+#pragma omp section
+ {
+ fprintf (logFile, "Thread nr %d executed work in the second section.\n", rank);
+ }
+#pragma omp section
+ {
+ fprintf (logFile, "Thread nr %d executed work in the second section and controls the value of count\n", rank);
+ if (count == 0)
+ result = 1;
+ fprintf (logFile, "cout was %d", count);
+ }
+ }
+ </ompts:orphan>
+ }
+
+ return result;
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_sections_reduction.c b/final/testsuite/c/omp_sections_reduction.c
new file mode 100644
index 0000000..7e7829a
--- /dev/null
+++ b/final/testsuite/c/omp_sections_reduction.c
@@ -0,0 +1,613 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp sections reduction directive with all its options.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp sections reduction</ompts:directive>
+<ompts:testcode>
+#include <stdio.h>
+#include <math.h>
+#include "omp_testsuite.h"
+
+
+int <ompts:testcode:functionname>omp_sections_reduction</ompts:testcode:functionname>(FILE * logFile){
+ <ompts:orphan:vars>
+ int sum;
+ int known_sum;
+ double dpt,dsum;
+ double dknown_sum;
+ double dt=0.5; /* base of geometric row for + and - test*/
+ double rounding_error= 1.E-9;
+ int diff;
+ double ddiff;
+ int product;
+ int known_product;
+ int logic_and;
+ int bit_and;
+ int logic_or;
+ int bit_or;
+ int exclusiv_bit_or;
+ int logics[1000];
+ int i;
+ int result;
+ </ompts:orphan:vars>
+ /* int my_islarger;*/
+ /*int is_larger=1;*/
+
+ sum =7;
+ dpt =1;
+ dsum=0;
+ product =1;
+ logic_and=1;
+ bit_and=1;
+ logic_or=0;
+ bit_or=0;
+ exclusiv_bit_or=0;
+ result = 0;
+ dt = 1./3.;
+ known_sum = (999*1000)/2+7;
+<ompts:orphan>
+#pragma omp parallel
+ {
+
+#pragma omp sections private(i) <ompts:check>reduction(+:sum)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for (i=1;i<300;i++)
+ {
+ sum=sum+i;
+ }
+ }
+#pragma omp section
+ {
+ for (i=300;i<700;i++)
+ {
+ sum=sum+i;
+ }
+ }
+#pragma omp section
+ {
+ for (i=700;i<1000;i++)
+ {
+ sum=sum+i;
+ }
+ }
+ }
+ }
+
+ if(known_sum!=sum)
+ {
+ ++result;
+ fprintf(logFile,"Error in sum with integers: Result was %d instead of %d\n", sum,known_sum);
+ }
+
+ diff = (999*1000)/2;
+#pragma omp parallel
+ {
+#pragma omp sections private(i) <ompts:check>reduction(-:diff)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for (i=1;i<300;i++)
+ {
+ diff=diff-i;
+ }
+ }
+#pragma omp section
+ {
+ for (i=300;i<700;i++)
+ {
+ diff=diff-i;
+ }
+ }
+#pragma omp section
+ {
+ for (i=700;i<1000;i++)
+ {
+ diff=diff-i;
+ }
+ }
+ }
+ }
+
+ if(diff != 0)
+ {
+ result++;
+ fprintf(logFile,"Error in Difference with integers: Result was %d instead of 0.\n",diff);
+ }
+
+ for (i=0;i<20;++i)
+ {
+ dpt*=dt;
+ }
+ dknown_sum = (1-dpt)/(1-dt);
+#pragma omp parallel
+ {
+#pragma omp sections private(i) <ompts:check>reduction(+:dsum)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for (i=0;i<6;++i)
+ {
+ dsum += pow(dt,i);
+ }
+ }
+#pragma omp section
+ {
+ for (i=6;i<12;++i)
+ {
+ dsum += pow(dt,i);
+ }
+ }
+#pragma omp section
+ {
+ for (i=12;i<20;++i)
+ {
+ dsum += pow(dt,i);
+ }
+ }
+ }
+ }
+
+ if( fabs(dsum-dknown_sum) > rounding_error )
+ {
+ result++;
+ fprintf(logFile,"Error in sum with doubles: Result was %f instead of %f (Difference: %E)\n",dsum,dknown_sum, dsum-dknown_sum);
+ }
+
+ dpt=1;
+
+ for (i=0;i<20;++i)
+ {
+ dpt*=dt;
+ }
+ fprintf(logFile,"\n");
+ ddiff = (1-dpt)/(1-dt);
+#pragma omp parallel
+ {
+#pragma omp sections private(i) <ompts:check>reduction(-:ddiff)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for (i=0;i<6;++i)
+ {
+ ddiff -= pow(dt,i);
+ }
+ }
+#pragma omp section
+ {
+ for (i=6;i<12;++i)
+ {
+ ddiff -= pow(dt,i);
+ }
+ }
+#pragma omp section
+ {
+ for (i=12;i<20;++i)
+ {
+ ddiff -= pow(dt,i);
+ }
+ }
+ }
+ }
+
+ if( fabs(ddiff) > rounding_error)
+ {
+ result++;
+ fprintf(logFile,"Error in Difference with doubles: Result was %E instead of 0.0\n",ddiff);
+ }
+
+
+ known_product = 3628800;
+#pragma omp parallel
+ {
+#pragma omp sections private(i) <ompts:check>reduction(*:product)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for(i=1;i<3;i++)
+ {
+ product *= i;
+ }
+ }
+#pragma omp section
+ {
+ for(i=3;i<7;i++)
+ {
+ product *= i;
+ }
+ }
+#pragma omp section
+ {
+ for(i=7;i<11;i++)
+ {
+ product *= i;
+ }
+ }
+ }
+ }
+
+ if(known_product != product)
+ {
+ result++;
+ fprintf(logFile,"Error in Product with integers: Result was %d instead of %d\n",product,known_product);
+ }
+
+ for(i=0;i<1000;i++)
+ {
+ logics[i]=1;
+ }
+
+#pragma omp parallel
+ {
+#pragma omp sections private(i) <ompts:check>reduction(&&:logic_and)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for (i=1;i<300;i++)
+ {
+ logic_and = (logic_and && logics[i]);
+ }
+ }
+#pragma omp section
+ {
+ for (i=300;i<700;i++)
+ {
+ logic_and = (logic_and && logics[i]);
+ }
+ }
+#pragma omp section
+ {
+ for (i=700;i<1000;i++)
+ {
+ logic_and = (logic_and && logics[i]);
+ }
+ }
+ }
+ }
+
+ if(!logic_and)
+ {
+ result++;
+ fprintf(logFile,"Error in logic AND part 1\n");
+ }
+
+ logic_and = 1;
+ logics[501] = 0;
+
+#pragma omp parallel
+ {
+#pragma omp sections private(i) <ompts:check>reduction(&&:logic_and)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for (i=1;i<300;i++)
+ {
+ logic_and = (logic_and && logics[i]);
+ }
+ }
+#pragma omp section
+ {
+ for (i=300;i<700;i++)
+ {
+ logic_and = (logic_and && logics[i]);
+ }
+ }
+#pragma omp section
+ {
+ for (i=700;i<1000;i++)
+ {
+ logic_and = (logic_and && logics[i]);
+ }
+ }
+ }
+ }
+
+ if(logic_and)
+ {
+ result++;
+ fprintf(logFile,"Error in logic AND part 2\n");
+ }
+
+ for(i=0;i<1000;i++)
+ {
+ logics[i]=0;
+ }
+
+#pragma omp parallel
+ {
+#pragma omp sections private(i) <ompts:check>reduction(||:logic_or)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for (i=1;i<300;i++)
+ {
+ logic_or = (logic_or || logics[i]);
+ }
+ }
+#pragma omp section
+ {
+ for (i=300;i<700;i++)
+ {
+ logic_or = (logic_or || logics[i]);
+ }
+ }
+#pragma omp section
+ {
+ for (i=700;i<1000;i++)
+ {
+ logic_or = (logic_or || logics[i]);
+ }
+ }
+ }
+ }
+
+ if(logic_or)
+ {
+ result++;
+ fprintf(logFile,"\nError in logic OR part 1\n");
+ }
+
+ logic_or = 0;
+ logics[501]=1;
+
+#pragma omp parallel
+ {
+#pragma omp sections private(i) <ompts:check>reduction(||:logic_or)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for (i=1;i<300;i++)
+ {
+ logic_or = (logic_or || logics[i]);
+ }
+ }
+#pragma omp section
+ {
+ for (i=300;i<700;i++)
+ {
+ logic_or = (logic_or || logics[i]);
+ }
+ }
+#pragma omp section
+ {
+ for (i=700;i<1000;i++)
+ {
+ logic_or = (logic_or || logics[i]);
+ }
+ }
+ }
+ }
+
+ if(!logic_or)
+ {
+ result++;
+ fprintf(logFile,"Error in logic OR part 2\n");
+ }
+
+
+ for(i=0;i<1000;++i)
+ {
+ logics[i]=1;
+ }
+
+#pragma omp parallel
+ {
+#pragma omp sections private(i) <ompts:check>reduction(&:bit_and)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for(i=0;i<300;++i)
+ {
+ bit_and = (bit_and & logics[i]);
+ }
+ }
+#pragma omp section
+ {
+ for(i=300;i<700;++i)
+ {
+ bit_and = (bit_and & logics[i]);
+ }
+ }
+#pragma omp section
+ {
+ for(i=700;i<1000;++i)
+ {
+ bit_and = (bit_and & logics[i]);
+ }
+ }
+ }
+ }
+ if(!bit_and)
+ {
+ result++;
+ fprintf(logFile,"Error in BIT AND part 1\n");
+ }
+
+ bit_and = 1;
+ logics[501]=0;
+
+#pragma omp parallel
+ {
+#pragma omp sections private(i) <ompts:check>reduction(&:bit_and)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for(i=0;i<300;++i)
+ {
+ bit_and = bit_and & logics[i];
+ }
+ }
+#pragma omp section
+ {
+ for(i=300;i<700;++i)
+ {
+ bit_and = bit_and & logics[i];
+ }
+ }
+#pragma omp section
+ {
+ for(i=700;i<1000;++i)
+ {
+ bit_and = bit_and & logics[i];
+ }
+ }
+ }
+ }
+ if(bit_and)
+ {
+ result++;
+ fprintf(logFile,"Error in BIT AND part 2\n");
+ }
+
+ for(i=0;i<1000;i++)
+ {
+ logics[i]=0;
+ }
+
+#pragma omp parallel
+ {
+#pragma omp sections private(i) <ompts:check>reduction(|:bit_or)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for(i=0;i<300;++i)
+ {
+ bit_or = bit_or | logics[i];
+ }
+ }
+#pragma omp section
+ {
+ for(i=300;i<700;++i)
+ {
+ bit_or = bit_or | logics[i];
+ }
+ }
+#pragma omp section
+ {
+ for(i=700;i<1000;++i)
+ {
+ bit_or = bit_or | logics[i];
+ }
+ }
+ }
+ }
+ if(bit_or)
+ {
+ result++;
+ fprintf(logFile,"Error in BIT OR part 1\n");
+ }
+ bit_or = 0;
+ logics[501]=1;
+
+#pragma omp parallel
+ {
+#pragma omp sections private(i) <ompts:check>reduction(|:bit_or)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for(i=0;i<300;++i)
+ {
+ bit_or = bit_or | logics[i];
+ }
+ }
+#pragma omp section
+ {
+ for(i=300;i<700;++i)
+ {
+ bit_or = bit_or | logics[i];
+ }
+ }
+#pragma omp section
+ {
+ for(i=700;i<1000;++i)
+ {
+ bit_or = bit_or | logics[i];
+ }
+ }
+ }
+ }
+ if(!bit_or)
+ {
+ result++;
+ fprintf(logFile,"Error in BIT OR part 2\n");
+ }
+
+ for(i=0;i<1000;i++)
+ {
+ logics[i]=0;
+ }
+
+#pragma omp parallel
+ {
+#pragma omp sections private(i) <ompts:check>reduction(^:exclusiv_bit_or)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for(i=0;i<300;++i)
+ {
+ exclusiv_bit_or = exclusiv_bit_or ^ logics[i];
+ }
+ }
+#pragma omp section
+ {
+ for(i=300;i<700;++i)
+ {
+ exclusiv_bit_or = exclusiv_bit_or ^ logics[i];
+ }
+ }
+#pragma omp section
+ {
+ for(i=700;i<1000;++i)
+ {
+ exclusiv_bit_or = exclusiv_bit_or ^ logics[i];
+ }
+ }
+ }
+ }
+ if(exclusiv_bit_or)
+ {
+ result++;
+ fprintf(logFile,"Error in EXCLUSIV BIT OR part 1\n");
+ }
+
+ exclusiv_bit_or = 0;
+ logics[501]=1;
+
+#pragma omp parallel
+ {
+#pragma omp sections private(i) <ompts:check>reduction(^:exclusiv_bit_or)</ompts:check><ompts:crosscheck></ompts:crosscheck>
+ {
+#pragma omp section
+ {
+ for(i=0;i<300;++i)
+ {
+ exclusiv_bit_or = exclusiv_bit_or ^ logics[i];
+ }
+ }
+#pragma omp section
+ {
+ for(i=300;i<700;++i)
+ {
+ exclusiv_bit_or = exclusiv_bit_or ^ logics[i];
+ }
+ }
+#pragma omp section
+ {
+ for(i=700;i<1000;++i)
+ {
+ exclusiv_bit_or = exclusiv_bit_or ^ logics[i];
+ }
+ }
+ }
+ }
+ if(!exclusiv_bit_or)
+ {
+ result++;
+ fprintf(logFile,"Error in EXCLUSIV BIT OR part 2\n");
+ }
+</ompts:orphan>
+ /*printf("\nResult:%d\n",result);*/
+ return (result==0);
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_single.c b/final/testsuite/c/omp_single.c
new file mode 100644
index 0000000..032b0d2
--- /dev/null
+++ b/final/testsuite/c/omp_single.c
@@ -0,0 +1,43 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp single directive by controlling how often a directive is called in an omp single region.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp single</ompts:directive>
+<ompts:dependences>omp parallel private,omp flush</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include "omp_testsuite.h"
+
+int <ompts:testcode:functionname>omp_single</ompts:testcode:functionname>(FILE * logFile)
+{
+ <ompts:orphan:vars>
+ int nr_threads_in_single;
+ int result;
+ int nr_iterations;
+ int i;
+ </ompts:orphan:vars>
+
+ nr_threads_in_single = 0;
+ result = 0;
+ nr_iterations = 0;
+
+#pragma omp parallel private(i)
+ {
+ for (i = 0; i < LOOPCOUNT; i++)
+ {
+ <ompts:orphan>
+ <ompts:check>#pragma omp single </ompts:check>
+ {
+#pragma omp flush
+ nr_threads_in_single++;
+#pragma omp flush
+ nr_iterations++;
+ nr_threads_in_single--;
+ result = result + nr_threads_in_single;
+ } /* end of single */
+ </ompts:orphan>
+ } /* end of for */
+ } /* end of parallel */
+ return ((result == 0) && (nr_iterations == LOOPCOUNT));
+} /* end of check_single*/
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_single_copyprivate.c b/final/testsuite/c/omp_single_copyprivate.c
new file mode 100644
index 0000000..bc7cd54
--- /dev/null
+++ b/final/testsuite/c/omp_single_copyprivate.c
@@ -0,0 +1,50 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp single copyprivate directive.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp single copyprivate</ompts:directive>
+<ompts:dependences>omp parllel,omp critical</ompts:dependences>
+<ompts:testcode>
+#include "omp_testsuite.h"
+
+int j;
+#pragma omp threadprivate(j)
+
+int <ompts:testcode:functionname>omp_single_copyprivate</ompts:testcode:functionname>(FILE * logFile)
+{
+ <ompts:orphan:vars>
+ int result;
+ int nr_iterations;
+ </ompts:orphan:vars>
+
+ result = 0;
+ nr_iterations = 0;
+#pragma omp parallel
+ {
+ <ompts:orphan>
+ int i;
+ for (i = 0; i < LOOPCOUNT; i++)
+ {
+ /*
+ int thread;
+ thread = omp_get_thread_num ();
+ */
+#pragma omp single <ompts:check>copyprivate(j)</ompts:check>
+ {
+ nr_iterations++;
+ j = i;
+ /*printf ("thread %d assigns, j = %d, i = %d\n", thread, j, i);*/
+ }
+ /* #pragma omp barrier*/
+#pragma omp critical
+ {
+ /*printf ("thread = %d, j = %d, i = %d\n", thread, j, i);*/
+ result = result + j - i;
+ }
+#pragma omp barrier
+ } /* end of for */
+ </ompts:orphan>
+ } /* end of parallel */
+ return ((result == 0) && (nr_iterations == LOOPCOUNT));
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_single_nowait.c b/final/testsuite/c/omp_single_nowait.c
new file mode 100644
index 0000000..9b7a250
--- /dev/null
+++ b/final/testsuite/c/omp_single_nowait.c
@@ -0,0 +1,60 @@
+<ompts:test>
+<ompts:testdescription></ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp single nowait</ompts:directive>
+<ompts:dependences>omp critical,omp atomic</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include "omp_testsuite.h"
+
+int my_iterations;
+#pragma omp threadprivate(my_iterations)
+
+int <ompts:testcode:functionname>omp_single_nowait</ompts:testcode:functionname>(FILE * logFile)
+{
+ <ompts:orphan:vars>
+ int nr_iterations;
+ </ompts:orphan:vars>
+
+ int total_iterations = 0;
+ int i;
+
+ nr_iterations = 0;
+ my_iterations = 0;
+
+#pragma omp parallel private(i)
+ {
+ for (i = 0; i < LOOPCOUNT; i++)
+ {
+ <ompts:orphan>
+ <ompts:check>#pragma omp single nowait</ompts:check>
+ {
+#pragma omp atomic
+ nr_iterations++;
+ } /* end of single*/
+ </ompts:orphan>
+ } /* end of for */
+ } /* end of parallel */
+
+#pragma omp parallel private(i)
+ {
+ my_iterations = 0;
+ for (i = 0; i < LOOPCOUNT; i++)
+ {
+ <ompts:orphan>
+ <ompts:check>#pragma omp single nowait</ompts:check>
+ {
+ my_iterations++;
+ } /* end of single*/
+ </ompts:orphan>
+ } /* end of for */
+#pragma omp critical
+ {
+ total_iterations += my_iterations;
+ }
+
+ } /* end of parallel */
+ return ((nr_iterations == LOOPCOUNT) && (total_iterations == LOOPCOUNT));
+} /* end of check_single_nowait*/
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_single_private.c b/final/testsuite/c/omp_single_private.c
new file mode 100644
index 0000000..a7502c7
--- /dev/null
+++ b/final/testsuite/c/omp_single_private.c
@@ -0,0 +1,56 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp single private directive.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp singel private</ompts:directive>
+<ompts:dependences>omp critical,omp flush,omp single nowait</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include "omp_testsuite.h"
+
+int myit = 0;
+#pragma omp threadprivate(myit)
+int myresult = 0;
+#pragma omp threadprivate(myresult)
+
+int <ompts:testcode:functionname>omp_single_private</ompts:testcode:functionname>(FILE * logFile)
+{
+ <ompts:orphan:vars>
+ int nr_threads_in_single;
+ int result;
+ int nr_iterations;
+ </ompts:orphan:vars>
+ int i;
+
+ myit = 0;
+ nr_threads_in_single = 0;
+ nr_iterations = 0;
+ result = 0;
+
+#pragma omp parallel private(i)
+ {
+ myresult = 0;
+ myit = 0;
+ for (i = 0; i < LOOPCOUNT; i++)
+ {
+ <ompts:orphan>
+#pragma omp single <ompts:check>private(nr_threads_in_single) </ompts:check>nowait
+ {
+ nr_threads_in_single = 0;
+#pragma omp flush
+ nr_threads_in_single++;
+#pragma omp flush
+ myit++;
+ myresult = myresult + nr_threads_in_single;
+ } /* end of single */
+ </ompts:orphan>
+ } /* end of for */
+#pragma omp critical
+ {
+ result += nr_threads_in_single;
+ nr_iterations += myit;
+ }
+ } /* end of parallel */
+ return ((result == 0) && (nr_iterations == LOOPCOUNT));
+} /* end of check_single private */
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_task.c b/final/testsuite/c/omp_task.c
new file mode 100644
index 0000000..ae89790
--- /dev/null
+++ b/final/testsuite/c/omp_task.c
@@ -0,0 +1,52 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp task directive. The idea of the tests is to generate a set of tasks in a single region. We let pause the tasks generated so that other threads get sheduled to the newly opened tasks.</ompts:testdescription>
+<ompts:ompversion>3.0</ompts:ompversion>
+<ompts:directive>omp task</ompts:directive>
+<ompts:dependences>omp single</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include <math.h>
+#include "omp_testsuite.h"
+#include "omp_my_sleep.h"
+
+
+int <ompts:testcode:functionname>omp_task</ompts:testcode:functionname>(FILE * logFile){
+ <ompts:orphan:vars>
+ int tids[NUM_TASKS];
+ int i;
+ </ompts:orphan:vars>
+
+#pragma omp parallel
+{
+#pragma omp single
+ {
+ for (i = 0; i < NUM_TASKS; i++) {
+ <ompts:orphan>
+ /* First we have to store the value of the loop index in a new variable
+ * which will be private for each task because otherwise it will be overwritten
+ * if the execution of the task takes longer than the time which is needed to
+ * enter the next step of the loop!
+ */
+ int myi;
+ myi = i;
+
+<ompts:check>#pragma omp task</ompts:check>
+ {
+ my_sleep (SLEEPTIME);
+
+ tids[myi] = omp_get_thread_num();
+ } /* end of omp task */
+ </ompts:orphan>
+ } /* end of for */
+ } /* end of single */
+} /*end of parallel */
+
+/* Now we ckeck if more than one thread executed the tasks. */
+ for (i = 1; i < NUM_TASKS; i++) {
+ if (tids[0] != tids[i])
+ return 1;
+ }
+ return 0;
+} /* end of check_parallel_for_private */
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_task_final.c b/final/testsuite/c/omp_task_final.c
new file mode 100644
index 0000000..4e00c5f
--- /dev/null
+++ b/final/testsuite/c/omp_task_final.c
@@ -0,0 +1,52 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp task directive. The idea of the tests is to generate a set of tasks in a single region. We let pause the tasks generated so that other threads get sheduled to the newly opened tasks.</ompts:testdescription>
+<ompts:ompversion>3.0</ompts:ompversion>
+<ompts:directive>omp task final</ompts:directive>
+<ompts:dependences>omp single</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include <math.h>
+#include "omp_testsuite.h"
+#include "omp_my_sleep.h"
+
+
+int <ompts:testcode:functionname>omp_task_final</ompts:testcode:functionname>(FILE * logFile){
+ <ompts:orphan:vars>
+ int tids[NUM_TASKS];
+ int i;
+ </ompts:orphan:vars>
+ int error;
+#pragma omp parallel
+{
+#pragma omp single
+ {
+ for (i = 0; i < NUM_TASKS; i++) {
+ <ompts:orphan>
+ /* First we have to store the value of the loop index in a new variable
+ * which will be private for each task because otherwise it will be overwritten
+ * if the execution of the task takes longer than the time which is needed to
+ * enter the next step of the loop!
+ */
+ int myi;
+ myi = i;
+
+ #pragma omp task <ompts:check>final(i>=10)</ompts:check>
+ {
+ my_sleep (SLEEPTIME);
+
+ tids[myi] = omp_get_thread_num();
+ } /* end of omp task */
+ </ompts:orphan>
+ } /* end of for */
+ } /* end of single */
+} /*end of parallel */
+
+/* Now we ckeck if more than one thread executed the tasks. */
+ for (i = 10; i < NUM_TASKS; i++) {
+ if (tids[10] != tids[i])
+ error++;
+ }
+ return (error==0);
+} /* end of check_parallel_for_private */
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_task_firstprivate.c b/final/testsuite/c/omp_task_firstprivate.c
new file mode 100644
index 0000000..7aa0746
--- /dev/null
+++ b/final/testsuite/c/omp_task_firstprivate.c
@@ -0,0 +1,51 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the firstprivate clause of the task directive. We create a set of tasks in a single region. We defines a variable named sum unequal zero which gets declared firstprivate for each task. Now each task calcualtes a sum using this private variable. Before each calcualation step we introduce a flush command so that maybe the private variabel gets bad. At the end we check if the calculated sum was right.</ompts:testdescription>
+<ompts:ompversion>3.0</ompts:ompversion>
+<ompts:directive>omp task firstprivate</ompts:directive>
+<ompts:dependences>omp single,omp flush,omp critical</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include <math.h>
+#include "omp_testsuite.h"
+
+int <ompts:testcode:functionname>omp_task_firstprivate</ompts:testcode:functionname> (FILE * logFile)
+{
+ int i;
+ <ompts:orphan:vars>
+ int sum = 1234;
+ int known_sum;
+ int result = 0; /* counts the wrong sums from tasks */
+ </ompts:orphan:vars>
+
+ known_sum = 1234 + (LOOPCOUNT * (LOOPCOUNT + 1)) / 2;
+
+#pragma omp parallel
+ {
+#pragma omp single
+ {
+ for (i = 0; i < NUM_TASKS; i++)
+ {
+ <ompts:orphan>
+#pragma omp task <ompts:check>firstprivate(sum)</ompts:check>
+ {
+ int j;
+ for (j = 0; j <= LOOPCOUNT; j++) {
+#pragma omp flush
+ sum += j;
+ }
+
+ /* check if calculated sum was right */
+ if (sum != known_sum) {
+#pragma omp critical
+ { result++; }
+ }
+ } /* end of omp task */
+ </ompts:orphan>
+ } /* end of for */
+ } /* end of single */
+ } /* end of parallel*/
+
+ return (result == 0);
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_task_if.c b/final/testsuite/c/omp_task_if.c
new file mode 100644
index 0000000..c07ab2f
--- /dev/null
+++ b/final/testsuite/c/omp_task_if.c
@@ -0,0 +1,43 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the if clause of the omp task directive. The idear of the tests is to generate a tasks in a single region and pause it immediately. The parent thread now shall set a counter variable which the paused task shall evaluate when woke up.</ompts:testdescription>
+<ompts:ompversion>3.0</ompts:ompversion>
+<ompts:directive>omp task if</ompts:directive>
+<ompts:dependences>omp single,omp flush</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include <math.h>
+#include "omp_testsuite.h"
+#include "omp_my_sleep.h"
+
+
+int <ompts:testcode:functionname>omp_task_if</ompts:testcode:functionname>(FILE * logFile){
+ <ompts:orphan:vars>
+ int condition_false;
+ int count;
+ int result;
+ </ompts:orphan:vars>
+ count=0;
+ condition_false = (logFile == NULL);
+#pragma omp parallel
+{
+#pragma omp single
+ {
+ <ompts:orphan>
+#pragma omp task <ompts:check>if (condition_false)</ompts:check> shared(count, result)
+ {
+ my_sleep (SLEEPTIME_LONG);
+//#pragma omp flush (count)
+ result = (0 == count);
+ } /* end of omp task */
+ </ompts:orphan>
+
+ count = 1;
+//#pragma omp flush (count)
+
+ } /* end of single */
+} /*end of parallel */
+
+ return result;
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_task_imp_firstprivate.c b/final/testsuite/c/omp_task_imp_firstprivate.c
new file mode 100644
index 0000000..bb8f0ef
--- /dev/null
+++ b/final/testsuite/c/omp_task_imp_firstprivate.c
@@ -0,0 +1,51 @@
+<ompts:test>
+<ompts:testdescription> Test to see if implied private works properly</ompts:testdescription>
+<ompts:ompversion>3.0</ompts:ompversion>
+<ompts:directive>omp task</ompts:directive>
+<ompts:dependences>omp single</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include <math.h>
+#include "omp_testsuite.h"
+
+
+
+
+/* Utility function do spend some time in a loop */
+int <ompts:testcode:functionname>omp_task_imp_firstprivate</ompts:testcode:functionname> (FILE * logFile)
+{
+ int i=5;
+ int k = 0;
+ int result = 0;
+ int task_result = 1;
+ #pragma omp parallel firstprivate(i)
+ {
+ #pragma omp single
+ {
+
+
+ for (k = 0; k < NUM_TASKS; k++)
+ {
+ #pragma omp task shared(result , task_result<ompts:crosscheck>, i</ompts:crosscheck>)
+ {
+ int j;
+ //check if i is private
+ if(i != 5)
+ task_result = 0;
+
+ for(j = 0; j < NUM_TASKS; j++)
+ i++;
+ //this should be firstprivate implicitly
+ }
+ }
+
+ #pragma omp taskwait
+ result = (task_result && i==5);
+ }
+
+ }
+
+ return result;
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_task_private.c b/final/testsuite/c/omp_task_private.c
new file mode 100644
index 0000000..59e26dd
--- /dev/null
+++ b/final/testsuite/c/omp_task_private.c
@@ -0,0 +1,53 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the private clause of the task directive. We create a set of tasks in a single region. We defines a variable named sum which gets declared private for each task. Now each task calcualtes a sum using this private variable. Before each calcualation step we introduce a flush command so that maybe the private variabel gets bad. At the end we check if the calculated sum was right.</ompts:testdescription>
+<ompts:ompversion>3.0</ompts:ompversion>
+<ompts:directive>omp task private</ompts:directive>
+<ompts:dependences>omp single,omp flush,omp critical</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include <math.h>
+#include "omp_testsuite.h"
+
+/* Utility function do spend some time in a loop */
+int <ompts:testcode:functionname>omp_task_private</ompts:testcode:functionname> (FILE * logFile)
+{
+ int i;
+ <ompts:orphan:vars>
+ int known_sum;
+ int sum = 0;
+ int result = 0; /* counts the wrong sums from tasks */
+ </ompts:orphan:vars>
+
+ known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2;
+
+#pragma omp parallel
+ {
+#pragma omp single
+ {
+ for (i = 0; i < NUM_TASKS; i++)
+ {
+ <ompts:orphan>
+#pragma omp task <ompts:check>private(sum)</ompts:check> shared(result, known_sum)
+ {
+ int j;
+ //if sum is private, initialize to 0
+ <ompts:check>sum = 0;</ompts:check>
+ for (j = 0; j <= LOOPCOUNT; j++) {
+#pragma omp flush
+ sum += j;
+ }
+ /* check if calculated sum was right */
+ if (sum != known_sum) {
+#pragma omp critical
+ result++;
+ }
+ } /* end of omp task */
+ </ompts:orphan>
+ } /* end of for */
+ } /* end of single */
+ } /* end of parallel*/
+
+ return (result == 0);
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_task_shared.c b/final/testsuite/c/omp_task_shared.c
new file mode 100644
index 0000000..74c2109
--- /dev/null
+++ b/final/testsuite/c/omp_task_shared.c
@@ -0,0 +1,47 @@
+<ompts:test>
+<ompts:testdescription> Test to see if implied shared works correctly</ompts:testdescription>
+<ompts:ompversion>3.0</ompts:ompversion>
+<ompts:directive>omp task</ompts:directive>
+<ompts:dependences>omp single, omp task firstprivate</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include <math.h>
+#include "omp_testsuite.h"
+
+
+
+
+/* Utility function do spend some time in a loop */
+int <ompts:testcode:functionname>omp_task_imp_shared</ompts:testcode:functionname> (FILE * logFile)
+{
+ <ompts:orphan:vars>
+ int i;
+ </ompts:orphan:vars>
+ i=0;
+ int k = 0;
+ int result = 0;
+
+ #pragma omp parallel
+ {
+ #pragma omp single
+ for (k = 0; k < NUM_TASKS; k++)
+ {
+ <ompts:orphan>
+ #pragma omp task <ompts:crosscheck> firstprivate(i) </ompts:crosscheck> <ompts:check> shared(i)</ompts:check>
+ {
+ #pragma omp atomic
+ i++;
+ //this should be shared implicitly
+
+ }
+ </ompts:orphan>
+ }
+
+ }
+
+result = i;
+return ((result == NUM_TASKS));
+
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_task_untied.c b/final/testsuite/c/omp_task_untied.c
new file mode 100644
index 0000000..3d6ebe2
--- /dev/null
+++ b/final/testsuite/c/omp_task_untied.c
@@ -0,0 +1,69 @@
+<ompts:test>
+<ompts:testdescription>Test for untied clause. First generate a set of tasks and pause it immediately. Then we resume half of them and check whether they are scheduled by different threads</ompts:testdescription>
+<ompts:ompversion>3.0</ompts:ompversion>
+<ompts:directive>omp task untied</ompts:directive>
+<ompts:dependences>omp taskwait</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include <math.h>
+#include "omp_testsuite.h"
+#include "omp_my_sleep.h"
+
+int <ompts:testcode:functionname>omp_task_untied</ompts:testcode:functionname>(FILE * logFile){
+
+ <ompts:orphan:vars>
+ int i;
+ int count;
+ int start_tid[NUM_TASKS];
+ int current_tid[NUM_TASKS];
+ </ompts:orphan:vars>
+ count = 0;
+
+ /*initialization*/
+ for (i=0; i< NUM_TASKS; i++){
+ start_tid[i]=0;
+ current_tid[i]=0;
+ }
+
+ #pragma omp parallel firstprivate(i)
+ {
+ #pragma omp single
+ {
+ for (i = 0; i < NUM_TASKS; i++) {
+ <ompts:orphan>
+ int myi = i;
+ #pragma omp task <ompts:check>untied</ompts:check>
+ {
+ my_sleep(SLEEPTIME);
+ start_tid[myi] = omp_get_thread_num();
+ current_tid[myi] = omp_get_thread_num();
+
+ #pragma omp taskwait
+
+ <ompts:check>if((start_tid[myi] %2) !=0){</ompts:check>
+ my_sleep(SLEEPTIME);
+ current_tid[myi] = omp_get_thread_num();
+ <ompts:check>
+ } /* end of if */
+ else {
+ current_tid[myi] = omp_get_thread_num();
+ }
+ </ompts:check>
+
+ } /*end of omp task */
+ </ompts:orphan>
+ } /* end of for */
+ } /* end of single */
+ } /* end of parallel */
+
+ for (i=0;i<NUM_TASKS; i++)
+ {
+ printf("start_tid[%d]=%d, current_tid[%d]=%d\n",i, start_tid[i], i , current_tid[i]);
+ if (current_tid[i] == start_tid[i])
+ count++;
+ }
+ return (count<NUM_TASKS);
+}
+</ompts:testcode>
+
+</ompts:test>
diff --git a/final/testsuite/c/omp_taskwait.c b/final/testsuite/c/omp_taskwait.c
new file mode 100644
index 0000000..88761f2
--- /dev/null
+++ b/final/testsuite/c/omp_taskwait.c
@@ -0,0 +1,75 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp taskwait directive. First we generate a set of tasks, which set the elements of an array to a specific value. Then we do a taskwait and check if all tasks finished meaning all array elements contain the right value. Then we generate a second set setting the array elements to another value. After the parallel region we check if all tasks of the second set finished and were executed after the tasks of the first set.</ompts:testdescription>
+<ompts:ompversion>3.0</ompts:ompversion>
+<ompts:directive>omp taskwait</ompts:directive>
+<ompts:dependences>omp single,omp task</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include <math.h>
+#include "omp_testsuite.h"
+#include "omp_my_sleep.h"
+
+
+int <ompts:testcode:functionname>omp_taskwait</ompts:testcode:functionname>(FILE * logFile){
+ int result1 = 0; /* Stores number of not finished tasks after the taskwait */
+ int result2 = 0; /* Stores number of wrong array elements at the end */
+
+ int array[NUM_TASKS];
+ int i;
+
+ /* fill array */
+ for (i = 0; i < NUM_TASKS; i++)
+ array[i] = 0;
+
+#pragma omp parallel
+ {
+#pragma omp single
+ {
+ for (i = 0; i < NUM_TASKS; i++) {
+ /* First we have to store the value of the loop index in a new variable
+ * which will be private for each task because otherwise it will be overwritten
+ * if the execution of the task takes longer than the time which is needed to
+ * enter the next step of the loop!
+ */
+ int myi;
+ myi = i;
+#pragma omp task
+ {
+ my_sleep (SLEEPTIME);
+ array[myi] = 1;
+ } /* end of omp task */
+ } /* end of for */
+
+<ompts:orphan>
+<ompts:check>#pragma omp taskwait</ompts:check>
+</ompts:orphan>
+
+ /* check if all tasks were finished */
+ for (i = 0; i < NUM_TASKS; i++)
+ if (array[i] != 1)
+ result1++;
+
+ /* generate some more tasks which now shall overwrite
+ * the values in the tids array */
+ for (i = 0; i < NUM_TASKS; i++) {
+ int myi;
+ myi = i;
+#pragma omp task
+ {
+ array[myi] = 2;
+ } /* end of omp task */
+ } /* end of for */
+
+ } /* end of single */
+ } /*end of parallel */
+
+ /* final check, if all array elements contain the right values: */
+ for (i = 0; i < NUM_TASKS; i++) {
+ if (array[i] != 2)
+ result2++;
+ }
+
+ return ((result1 == 0) && (result2 == 0));
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_taskyield.c b/final/testsuite/c/omp_taskyield.c
new file mode 100644
index 0000000..1d1271e
--- /dev/null
+++ b/final/testsuite/c/omp_taskyield.c
@@ -0,0 +1,59 @@
+<ompts:test>
+<ompts:testdescription>Test taskyield directive. First generate a set of tasks and pause it immediately. Then we resume half of them and check whether they are scheduled by different threads</ompts:testdescription>
+<ompts:ompversion>3.0</ompts:ompversion>
+<ompts:directive>omp taskyield</ompts:directive>
+<ompts:dependences>omp taskwait</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include <math.h>
+#include "omp_testsuite.h"
+#include "omp_my_sleep.h"
+
+int <ompts:testcode:functionname>omp_taskyield</ompts:testcode:functionname>(FILE * logFile){
+
+ <ompts:orphan:vars>
+ int i;
+ int count = 0;
+ int start_tid[NUM_TASKS];
+ int current_tid[NUM_TASKS];
+ </ompts:orphan:vars>
+ for (i=0; i< NUM_TASKS; i++){
+ start_tid[i]=0;
+ current_tid[i]=0;
+ }
+
+ #pragma omp parallel
+ {
+ #pragma omp single
+ {
+ for (i = 0; i < NUM_TASKS; i++) {
+ <ompts:orphan>
+ int myi = i;
+ <ompts:check>#pragma omp task untied</ompts:check>
+ {
+ my_sleep(SLEEPTIME);
+ start_tid[myi] = omp_get_thread_num();
+
+ #pragma omp taskyield
+
+ if((start_tid[myi] %2) ==0){
+ my_sleep(SLEEPTIME);
+ current_tid[myi] = omp_get_thread_num();
+ } /*end of if*/
+ } /* end of omp task */
+ </ompts:orphan>
+ } /* end of for */
+ } /* end of single */
+ } /* end of parallel */
+
+ for (i=0;i<NUM_TASKS; i++)
+ {
+ //printf("start_tid[%d]=%d, current_tid[%d]=%d\n",i, start_tid[i], i , current_tid[i]);
+ if (current_tid[i] == start_tid[i])
+ count++;
+ }
+ return (count<NUM_TASKS);
+}
+</ompts:testcode>
+
+</ompts:test>
diff --git a/final/testsuite/c/omp_test_lock.c b/final/testsuite/c/omp_test_lock.c
new file mode 100644
index 0000000..e889dfb
--- /dev/null
+++ b/final/testsuite/c/omp_test_lock.c
@@ -0,0 +1,47 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp_testlock function. The test counts the threads entering and exiting a single region which is build with a test_lock in an endless loop.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp_test_lock</ompts:directive>
+<ompts:dependences>omp flush</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include "omp_testsuite.h"
+
+omp_lock_t lck;
+
+int <ompts:testcode:functionname>omp_test_lock</ompts:testcode:functionname>(FILE * logFile)
+{
+ int nr_threads_in_single = 0;
+ int result = 0;
+ int nr_iterations = 0;
+ int i;
+
+ omp_init_lock (&lck);
+
+#pragma omp parallel shared(lck)
+ {
+
+#pragma omp for
+ for (i = 0; i < LOOPCOUNT; i++)
+ {
+ /*omp_set_lock(&lck);*/
+ <ompts:orphan>
+ <ompts:check>while (!omp_test_lock (&lck))
+ {};</ompts:check>
+ </ompts:orphan>
+#pragma omp flush
+ nr_threads_in_single++;
+#pragma omp flush
+ nr_iterations++;
+ nr_threads_in_single--;
+ result = result + nr_threads_in_single;
+ <ompts:check>omp_unset_lock (&lck);</ompts:check>
+ }
+ }
+ omp_destroy_lock(&lck);
+
+ return ((result == 0) && (nr_iterations == LOOPCOUNT));
+
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_test_nest_lock.c b/final/testsuite/c/omp_test_nest_lock.c
new file mode 100644
index 0000000..a8d6a45
--- /dev/null
+++ b/final/testsuite/c/omp_test_nest_lock.c
@@ -0,0 +1,48 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp_test_nest_lock function.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp_test_nest_lock</ompts:directive>
+<ompts:dependences>omp flush</ompts:dependences>
+<ompts:testcode>
+#include <stdio.h>
+#include "omp_testsuite.h"
+
+
+static omp_nest_lock_t lck;
+
+int <ompts:testcode:functionname>omp_test_nest_lock</ompts:testcode:functionname>(FILE * logFile)
+{
+
+ int nr_threads_in_single = 0;
+ int result = 0;
+ int nr_iterations = 0;
+ int i;
+
+ omp_init_nest_lock (&lck);
+
+#pragma omp parallel shared(lck)
+ {
+
+#pragma omp for
+ for (i = 0; i < LOOPCOUNT; i++)
+ {
+ /*omp_set_lock(&lck);*/
+<ompts:orphan>
+ <ompts:check>while(!omp_test_nest_lock (&lck))
+ {};</ompts:check>
+</ompts:orphan>
+#pragma omp flush
+ nr_threads_in_single++;
+#pragma omp flush
+ nr_iterations++;
+ nr_threads_in_single--;
+ result = result + nr_threads_in_single;
+ <ompts:check>omp_unset_nest_lock (&lck);</ompts:check>
+ }
+ }
+ omp_destroy_nest_lock (&lck);
+
+ return ((result == 0) && (nr_iterations == LOOPCOUNT));
+}
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_threadprivate.c b/final/testsuite/c/omp_threadprivate.c
new file mode 100644
index 0000000..8e4d7aa
--- /dev/null
+++ b/final/testsuite/c/omp_threadprivate.c
@@ -0,0 +1,97 @@
+<ompts:test>
+<ompts:testdescription>Test which checks the omp threadprivate directive by filling an array with random numbers in an parallelised region. Each thread generates one number of the array and saves this in a temporary threadprivate variable. In a second parallelised region the test controls, that the temporary variable contains still the former value by comparing it with the one in the array.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp threadprivate</ompts:directive>
+<ompts:dependences>omp critical,omp_set_dynamic,omp_get_num_threads</ompts:dependences>
+<ompts:testcode>
+/*
+ * Threadprivate is tested in 2 ways:
+ * 1. The global variable declared as threadprivate should have
+ * local copy for each thread. Otherwise race condition and
+ * wrong result.
+ * 2. If the value of local copy is retained for the two adjacent
+ * parallel regions
+ */
+#include "omp_testsuite.h"
+#include <stdlib.h>
+#include <stdio.h>
+
+static int sum0=0;
+static int myvalue = 0;
+
+<ompts:check>#pragma omp threadprivate(sum0)</ompts:check>
+<ompts:check>#pragma omp threadprivate(myvalue)</ompts:check>
+
+
+int <ompts:testcode:functionname>omp_threadprivate</ompts:testcode:functionname>(FILE * logFile)
+{
+ int sum = 0;
+ int known_sum;
+ int i;
+ int iter;
+ int *data;
+ int size;
+ int failed = 0;
+ int my_random;
+ omp_set_dynamic(0);
+
+ #pragma omp parallel private(i)
+ {
+ sum0 = 0;
+ #pragma omp for
+ for (i = 1; i <= LOOPCOUNT; i++)
+ {
+ sum0 = sum0 + i;
+ } /*end of for*/
+ #pragma omp critical
+ {
+ sum = sum + sum0;
+ } /*end of critical */
+ } /* end of parallel */
+ known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2;
+ if (known_sum != sum ) {
+ fprintf (logFile, " known_sum = %d, sum = %d\n", known_sum, sum);
+ }
+
+ /* the next parallel region is just used to get the number of threads*/
+ omp_set_dynamic(0);
+ #pragma omp parallel
+ {
+ #pragma omp master
+ {
+ size=omp_get_num_threads();
+ data=(int*) malloc(size*sizeof(int));
+ }
+ }/* end parallel*/
+
+
+ srand(45);
+ for (iter = 0; iter < 100; iter++){
+ my_random = rand(); /* random number generator is called inside serial region*/
+
+ /* the first parallel region is used to initialiye myvalue and the array with my_random+rank*/
+ #pragma omp parallel
+ {
+ int rank;
+ rank = omp_get_thread_num ();
+ myvalue = data[rank] = my_random + rank;
+ }
+
+ /* the second parallel region verifies that the value of "myvalue" is retained */
+ #pragma omp parallel reduction(+:failed)
+ {
+ int rank;
+ rank = omp_get_thread_num ();
+ failed = failed + (myvalue != data[rank]);
+ if(myvalue != data[rank]){
+ fprintf (logFile, " myvalue = %d, data[rank]= %d\n", myvalue, data[rank]);
+ }
+ }
+ }
+ free (data);
+
+ return (known_sum == sum) && !failed;
+
+} /* end of check_threadprivate*/
+</ompts:testcode>
+</ompts:test>
diff --git a/final/testsuite/c/omp_threadprivate_for.c b/final/testsuite/c/omp_threadprivate_for.c
new file mode 100644
index 0000000..034359d
--- /dev/null
+++ b/final/testsuite/c/omp_threadprivate_for.c
@@ -0,0 +1,44 @@
+<ompts:test>
+<ompts:testdescription>Test which checks if a variable declared as threadprivate can be used as a loopindex.</ompts:testdescription>
+<ompts:ompversion>2.0</ompts:ompversion>
+<ompts:directive>omp threadprivate</ompts:directive>
+<ompts:dependences>omp critical</ompts:dependences>
+<ompts:testcode>
+#include "omp_testsuite.h"
+#include <stdlib.h>
+#include <stdio.h>
+
+static int i;
+<ompts:check>#pragma omp threadprivate(i)</ompts:check>
+
+int <ompts:testcode:functionname>omp_threadprivate_for</ompts:testcode:functionname>(FILE * logFile)
+{
+ int known_sum;
+ int sum;
+ known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2;
+ sum = 0;
+
+#pragma omp parallel
+ {
+ int sum0 = 0;
+#pragma omp for
+ for (i = 1; i <= LOOPCOUNT; i++)
+ {
+ sum0 = sum0 + i;
+ } /*end of for*/
+#pragma omp critical
+ {
+ sum = sum + sum0;
+ } /*end of critical */
+ } /* end of parallel */
+
+ if (known_sum != sum ) {
+ fprintf (logFile, " known_sum = %d, sum = %d\n", known_sum, sum);
+ }
+
+ return (known_sum == sum);
+
+} /* end of check_threadprivate*/
+</ompts:testcode>
+</ompts:test>
+