diff --git a/README.md b/README.md index a6a93f6..b814250 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# DataRaceBench 1.1.1 +# DataRaceBench 1.2.0 DataRaceBench is a benchmark suite designed to systematically and quantitatively evaluate the effectiveness of data race detection @@ -6,9 +6,13 @@ tools. It includes a set of microbenchmarks with and without data races. Parallelism is represented by OpenMP directives. OpenMP is a popular parallel programming model for multi-threaded applications. -Note that if you are using gcc for compiling the microbenchmarks, at -least version 4.9 is required to have support for all used OpenMP -directives. +Note that some microbenchmarks use OpenMP 4.5 features. Those are: + DRB094-doall2-ordered-orig-no.c + DRB095-doall2-taskloop-orig-yes.c (requires gcc 7.x) + DRB096-doall2-taskloop-collapse-orig-no.c (requires gcc 7.x) + DRB100-task-reference-orig-no.cpp + DRB112-linear-orig-no.c +You need a recent OpenMP compiler (e.g. gcc 7.x or later) to compile them. DataRaceBench also comes with an evaluation script (check-data-races.sh). The script can be used to evaluate the tools @@ -22,7 +26,7 @@ some pre-defined values. P-Label | Meaning (microbenchmarks with data races) | P-Label | Meaning (microbenchmarks without data races) ------|-----------------------------------|------|------------------------------ - Y1 | Unresolvable dependences | N1 | Embarrassingly parallel + Y1 | Unresolvable dependences | N1 | Embarrassingly parallel or single thread execution Y2 | Missing data sharing clauses | N2 | Use of data sharing clauses Y3 | Missing synchronization | N3 | Use of synchronization Y4 | SIMD data races | N4 | Use of SIMD directives @@ -30,80 +34,131 @@ P-Label | Meaning (microbenchmarks with data races) | P-Label | Meaning (microb Y6 | Undefined behavior | N6 | Use of special language features Y7 | Numerical kernel data races | N7 | Numerical kernels - ## Microbenchmarks with known data races (some have a varying length version) -ID | Microbenchmark |P-Label| Description | Source -----------|-----------------------------------------------|-------|------------------------------------------------------------------------------|---------- -1|2 | antidep1-(orig|var)-yes.c |Y1 | Anti-dependence within a single loop | AutoPar -3|4 | antidep2-(orig|var)-yes.c |Y1 | Anti-dependence within a two-level loop nest | AutoPar -5 | indirectaccess1-orig-yes.c |Y7 | Indirect access with overlapped index array elements | LLNL App -6 | indirectaccess2-orig-yes.c |Y7 | Overlapping index array elements when 36 or more threads are used | LLNL App -7 | indirectaccess3-orig-yes.c |Y7 | Overlapping index array elements when 60 or more threads are used | LLNL App -8 | indirectaccess4-orig-yes.c |Y7 | Overlapping index array elements when 180 or more threads are used | LLNL App -9|10 | lastprivatemissing-(orig|var)-yes.c |Y2 | Data race due to a missing `lastprivate()` clause | AutoPar -11|12| minusminus-(orig|var)-yes.c |Y3 | Unprotected decrement operation `--` | AutoPar -13 | nowait-orig-yes.c |Y3 | Missing barrier due to a wrongfully used nowait | AutoPar -14|15| outofbounds-(orig|var)-yes.c |Y6 | Out of bound access of the 2nd dimension of array | AutoPar -16|17| outputdep-(orig|var)-yes.c |Y1 | Output dependence and true dependence within a loop | AutoPar -18|19| plusplus-(orig|var)-yes.c |Y1 | increment operation `++` on array index variable | AutoPar -20|21| privatemissing-(orig|var)-yes.c |Y2 | Missing `private()` for a temp variable | AutoPar -22|23| reductionmissing-(orig|var)-yes.c |Y2 | Missing `reduction()` for a variable | AutoPar -24 | sections1-orig-yes.c |Y3 | Unprotected data writes in parallel sections | New -25|26| simdtruedep-(orig|var)-yes.c |Y1,Y4 | SIMD instruction level data races | New -27 | targetparallelfor-orig-yes.c |Y1,Y5 | Data races in loops offloaded to accelerators | New -28 | taskdependmissing-orig-yes.c |Y3 | Unprotected data writes in two tasks | New -29|30| truedep1-(orig|var)-yes.c |Y1 | True data dependence among multiple array elements within a single level loop| AutoPar -31|32| truedepfirstdimension-(orig|var)-yes.c |Y1 | True data dependence of first dimension for a 2-D array accesses | AutoPar -33|34| truedeplinear-(orig|var)-yes.c |Y1 | Linear equation as array subscript | AutoPar -35|36| truedepscalar-(orig|var)-yes.c |Y1 | True data dependence due to scalar | AutoPar -37|38| truedepseconddimension-(orig|var)-yes.c |Y1 | True data dependence on 2nd dimension of a 2-D array accesses | AutoPar -39|40| truedepsingleelement-(orig|var)-yes.c |Y1 | True data dependence due to a single array element | AutoPar -73 | doall2-orig-yes.c |Y2 | Missing `private()` for inner loop nest's loop index variable | New -74 | flush-orig-yes.c |Y2 | Reduction using a shared variable, extracted from an official OpenMP example | New -75 | getthreadnum-orig-yes.c |Y1 | Work sharing within one branch of a `if` statement | New - +Microbenchmark |P-Label| Description | Source +----------------------------------------------------|-------|------------------------------------------------------------------------------|---------- +DRB001-antidep1-orig-yes.c |Y1 | Anti-dependence within a single loop | AutoPar +DRB002-antidep1-var-yes.c |Y1 | Anti-dependence within a single loop | AutoPar +DRB003-antidep2-orig-yes.c |Y1 | Anti-dependence within a two-level loop nest | AutoPar +DRB004-antidep2-var-yes.c |Y1 | Anti-dependence within a two-level loop nest | AutoPar +DRB005-indirectaccess1-orig-yes.c |Y7 | Indirect access with overlapped index array elements | LLNL App +DRB006-indirectaccess2-orig-yes.c |Y7 | Overlapping index array elements when 36 or more threads are used | LLNL App +DRB007-indirectaccess3-orig-yes.c |Y7 | Overlapping index array elements when 60 or more threads are used | LLNL App +DRB008-indirectaccess4-orig-yes.c |Y7 | Overlapping index array elements when 180 or more threads are used | LLNL App +DRB009-lastprivatemissing-orig-yes.c |Y2 | Data race due to a missing `lastprivate()` clause | AutoPar +DRB010-lastprivatemissing-var-yes.c |Y2 | Data race due to a missing `lastprivate()` clause | AutoPar +DRB011-minusminus-orig-yes.c |Y3 | Unprotected decrement operation `--` | AutoPar +DRB012-minusminus-var-yes.c |Y3 | Unprotected decrement operation `--` | AutoPar +DRB013-nowait-orig-yes.c |Y3 | Missing barrier due to a wrongfully used nowait | AutoPar +DRB014-outofbounds-orig-yes.c |Y6 | Out of bound access of the 2nd dimension of array | AutoPar +DRB015-outofbounds-var-yes.c |Y6 | Out of bound access of the 2nd dimension of array | AutoPar +DRB016-outputdep-orig-yes.c |Y1 | Output dependence and true dependence within a loop | AutoPar +DRB017-outputdep-var-yes.c |Y1 | Output dependence and true dependence within a loop | AutoPar +DRB018-plusplus-orig-yes.c |Y1 | increment operation `++` on array index variable | AutoPar +DRB019-plusplus-var-yes.c |Y1 | increment operation `++` on array index variable | AutoPar +DRB020-privatemissing-orig-yes.c |Y2 | Missing `private()` for a temp variable | AutoPar +DRB021-privatemissing-var-yes.c |Y2 | Missing `private()` for a temp variable | AutoPar +DRB022-reductionmissing-orig-yes.c |Y2 | Missing `reduction()` for a variable | AutoPar +DRB023-reductionmissing-var-yes.c |Y2 | Missing `reduction()` for a variable | AutoPar +DRB024-sections1-orig-yes.c |Y3 | Unprotected data writes in parallel sections | New +DRB025-simdtruedep-orig-yes.c |Y1,Y4 | SIMD instruction level data races | New +DRB026-simdtruedep-var-yes.c |Y1,Y4 | SIMD instruction level data races | New +DRB027-targetparallelfor-orig-yes.c |Y1,Y5 | Data races in loops offloaded to accelerators | New +DRB028-taskdependmissing-orig-yes.c |Y3 | Unprotected data writes in two tasks | New +DRB029-truedep1-orig-yes.c |Y1 | True data dependence among multiple array elements within a single level loop| AutoPar +DRB030-truedep1-var-yes.c |Y1 | True data dependence among multiple array elements within a single level loop| AutoPar +DRB031-truedepfirstdimension-(orig|var)-yes.c |Y1 | True data dependence of first dimension for a 2-D array accesses | AutoPar +DRB032-truedepfirstdimension-(orig|var)-yes.c |Y1 | True data dependence of first dimension for a 2-D array accesses | AutoPar +DRB033-truedeplinear-orig-yes.c |Y1 | Linear equation as array subscript | AutoPar +DRB034-truedeplinear-var-yes.c |Y1 | Linear equation as array subscript | AutoPar +DRB035-truedepscalar-orig-yes.c |Y1 | True data dependence due to scalar | AutoPar +DRB036-truedepscalar-var-yes.c |Y1 | True data dependence due to scalar | AutoPar +DRB037-truedepseconddimension-(orig|var)-yes.c |Y1 | True data dependence on 2nd dimension of a 2-D array accesses | AutoPar +DRB038-truedepseconddimension-(orig|var)-yes.c |Y1 | True data dependence on 2nd dimension of a 2-D array accesses | AutoPar +DRB039-truedepsingleelement-(orig|var)-yes.c |Y1 | True data dependence due to a single array element | AutoPar +DRB040-truedepsingleelement-(orig|var)-yes.c |Y1 | True data dependence due to a single array element | AutoPar +DRB073-doall2-orig-yes.c |Y2 | Missing `private()` for inner loop nest's loop index variable | New +DRB074-flush-orig-yes.c |Y2 | Reduction using a shared variable, extracted from an official OpenMP example | New +DRB075-getthreadnum-orig-yes.c |Y1 | Work sharing within one branch of a `if` statement | New +DRB080-func-arg-orig-yes.c |Y6 | Function arguments passed by reference, inheriting shared attribute | New +DRB082-declared-in-func-orig-yes.c |Y6 | A variable declared within a function called by a parallel region | New +DRB084-threadprivatemissing-orig-yes.c |Y2 | Missing threadprivate for a global var, not referenced within a construct | New +DRB086-static-data-member-orig-yes.cpp |Y2 | Missing threadprivate for a static member, not referenced within a construct | New +DRB087-static-data-member2-orig-yes.cpp |Y2 | Missing threadprivate for a static member, referenced within a construct | New +DRB088-dynamic-storage-orig-yes.c |Y2 | Data race for a dynamica storage variable, not referenced within a construct | New +DRB089-dynamic-storage2-orig-yes.c |Y2 | Data race for a dynamica storage variable, referenced within a construct | New +DRB090-static-local-orig-yes.c |Y2 | Data race for a locally declared static variable | New +DRB092-threadprivatemissing2-orig-yes.c |Y2 | Missing threadprivate for a variable referenced within a construct | New +DRB095-doall2-taskloop-orig-yes.c |Y2 | Missing protection for inner loop's loop variable | New +DRB106-taskwaitmissing-orig-yes.c |Y3 | Missing taskwait to ensure correct order of calculations | New +DRB109-orderedmissing-orig-yes.c |Y3 | Missing the ordered clause, causing data races | New +DRB111-linearmissing-orig-yes.c |Y2 | Missing linear for a shared variable, causing data races | New +DRB114-if-orig-yes.c |Y1 | True data dependence within a single level loop, with if() clause | New +DRB115-forsimd-orig-yes.c |Y1,Y4 | Both thread and instruction level data races due to omp loop simd | New +DRB116-target-teams-orig-yes.c |Y3 | Master threads of two teams do not have synchronization, causing data races | New ## Microbenchmarks without known data races -ID| Microbenchmark |P-Label| Description | Source ---|-----------------------------------|-------|--------------------------------------------------------------------------------------|------------ -41| 3mm-parallel-no.c |N2 | 3-step matrix-matrix multiplication, non-optimized version | Polyhedral -42| 3mm-tile-no.c |N2,N4 | 3-step matrix-matrix multiplication, with tiling and nested SIMD | Polyhedral -43| adi-parallel-no.c |N2 | Alternating Direction Implicit solver, non-optimized version | Polyhedral -44| adi-tile-no.c |N2,N4 | Alternating Direction Implicit solver, with tiling and nested SIMD | Polyhedral -45| doall1-orig-no.c |N1 | Classic DOAll loop operating on a one dimensional array | AutoPar -46| doall2-orig-no.c |N1 | Classic DOAll loop operating on a two dimensional array | AutoPar -47| doallchar-orig-no.c |N1 | Classic DOALL loop operating on a character array | New -48| firstprivate-orig-no.c |N2 | Example use of firstprivate | AutoPar -49| fprintf-orig-no.c |N6 | Use of `fprintf()` | New -50| functionparameter-orig-no.c |N6 | Arrays passed as function parameters | LLNL App -51| getthreadnum-orig-no.c |N2 | single thread execution using `if (omp_get_thread_num()==0)` | New -52| indirectaccesssharebase-orig-no.c |N7 | Indirect array accesses using index arrays without overlapping | LLNL App -53| inneronly1-orig-no.c |N1 | Two-level nested loops, inner level is parallelizable. True dependence on outer level| AutoPar -54| inneronly2-orig-no.c |N1 | Two-level nested loops, inner level is parallelizable. Anti dependence on outer level| AutoPar -55| jacobi2d-parallel-no.c |N7 | Jacobi with array copying, no reduction, non-optimized version | Polyhedral -56| jacobi2d-tile-no.c |N4,N7 | Jacobi with array copying, no reduction, with tiling and nested SIMD | Polyhedral -57| jacobiinitialize-orig-no.c |N7 | The array initialization parallel loop in Jacobi | AutoPar -58| jacobikernel-orig-no.c |N7 | Parallel Jacobi stencil computation kernel with array copying and reduction | AutoPar -59| lastprivate-orig-no.c |N2 | Example use of lastprivate | AutoPar -60| matrixmultiply-orig-no.c |N7 | Classic i-k-j order matrix multiplication using OpenMP | AutoPar -61| matrixvector1-orig-no.c |N7 | Matrix-vector multiplication parallelized at the outer level loop | AutoPar -62| matrixvector2-orig-no.c |N7 | Matrix-vector multiplication parallelized at the inner level loop with reduction | AutoPar -63| outeronly1-orig-no.c |N2 | Two-level nested loops, outer level is parallelizable. True dependence on inner level| AutoPar -64| outeronly2-orig-no.c |N2 | Two-level nested loops, outer level is parallelizable. Anti dependence on inner level| AutoPar -65| pireduction-orig-no.c |N7 | PI calculation using reduction | AutoPar -66| pointernoaliasing-orig-no.c |N6 | Pointers assigned by different malloc calls, without aliasing | LLNL App -67| restrictpointer1-orig-no.c |N6 | C99 restrict pointers used for array initialization, no aliasing | LLNL App -68| restrictpointer2-orig-no.c |N6 | C99 restrict pointers used for array computation, no aliasing | LLNL App -69| sectionslock1-orig-no.c |N3 | OpenMP parallel sections with a lock to protect shared data writes | New -70| simd1-orig-no.c |N1,N4 | OpenMP SIMD directive to indicate vectorization of a loop | New -71| targetparallelfor-orig-no.c |N1,N5 | data races in loops offloaded to accelerators | New -72| taskdep1-orig-no.c |N3 | OpenMP task with depend clauses to avoid data races | New -76| flush-orig-no.c |N2 | OpenMP private clause to avoid data races | New -77| single-orig-no.c |N2 | OpenMP single directive to avoid data races | New -78| taskdep2-orig-no.c |N3 | OpenMP task depend clause to avoid data races | New -79| taskdep3-orig-no.c |N3 | OpenMP task depend clause to avoid data races | New +Microbenchmark |P-Label| Description | Source +-----------------------------------------|-------|--------------------------------------------------------------------------------------|------------ +DRB041-3mm-parallel-no.c |N2 | 3-step matrix-matrix multiplication, non-optimized version | Polyhedral +DRB042-3mm-tile-no.c |N2,N4 | 3-step matrix-matrix multiplication, with tiling and nested SIMD | Polyhedral +DRB043-adi-parallel-no.c |N2 | Alternating Direction Implicit solver, non-optimized version | Polyhedral +DRB044-adi-tile-no.c |N2,N4 | Alternating Direction Implicit solver, with tiling and nested SIMD | Polyhedral +DRB045-doall1-orig-no.c |N1 | Classic DOAll loop operating on a one dimensional array | AutoPar +DRB046-doall2-orig-no.c |N1 | Classic DOAll loop operating on a two dimensional array | AutoPar +DRB047-doallchar-orig-no.c |N1 | Classic DOALL loop operating on a character array | New +DRB048-firstprivate-orig-no.c |N2 | Example use of firstprivate | AutoPar +DRB049-fprintf-orig-no.c |N6 | Use of `fprintf()` | New +DRB050-functionparameter-orig-no.c |N6 | Arrays passed as function parameters | LLNL App +DRB051-getthreadnum-orig-no.c |N2 | single thread execution using `if (omp_get_thread_num()==0)` | New +DRB052-indirectaccesssharebase-orig-no.c |N7 | Indirect array accesses using index arrays without overlapping | LLNL App +DRB053-inneronly1-orig-no.c |N1 | Two-level nested loops, inner level is parallelizable. Anti dependence on outer level| AutoPar +DRB054-inneronly2-orig-no.c |N1 | Two-level nested loops, inner level is parallelizable. True dependence on outer level| AutoPar +DRB055-jacobi2d-parallel-no.c |N7 | Jacobi with array copying, no reduction, non-optimized version | Polyhedral +DRB056-jacobi2d-tile-no.c |N4,N7 | Jacobi with array copying, no reduction, with tiling and nested SIMD | Polyhedral +DRB057-jacobiinitialize-orig-no.c |N7 | The array initialization parallel loop in Jacobi | AutoPar +DRB058-jacobikernel-orig-no.c |N7 | Parallel Jacobi stencil computation kernel with array copying and reduction | AutoPar +DRB059-lastprivate-orig-no.c |N2 | Example use of lastprivate | AutoPar +DRB060-matrixmultiply-orig-no.c |N7 | Classic i-k-j order matrix multiplication using OpenMP | AutoPar +DRB061-matrixvector1-orig-no.c |N7 | Matrix-vector multiplication parallelized at the outer level loop | AutoPar +DRB062-matrixvector2-orig-no.c |N7 | Matrix-vector multiplication parallelized at the inner level loop with reduction | AutoPar +DRB063-outeronly1-orig-no.c |N2 | Two-level nested loops, outer level is parallelizable. Anti dependence on inner level| AutoPar +DRB064-outeronly2-orig-no.c |N2 | Two-level nested loops, outer level is parallelizable. True dependence on inner level| AutoPar +DRB065-pireduction-orig-no.c |N7 | PI calculation using reduction | AutoPar +DRB066-pointernoaliasing-orig-no.c |N6 | Pointers assigned by different malloc calls, without aliasing | LLNL App +DRB067-restrictpointer1-orig-no.c |N6 | C99 restrict pointers used for array initialization, no aliasing | LLNL App +DRB068-restrictpointer2-orig-no.c |N6 | C99 restrict pointers used for array computation, no aliasing | LLNL App +DRB069-sectionslock1-orig-no.c |N3 | OpenMP parallel sections with a lock to protect shared data writes | New +DRB070-simd1-orig-no.c |N1,N4 | OpenMP SIMD directive to indicate vectorization of a loop | New +DRB071-targetparallelfor-orig-no.c |N1,N5 | No data races in loops offloaded to accelerators | New +DRB072-taskdep1-orig-no.c |N3 | OpenMP task with depend clauses to avoid data races | New +DRB076-flush-orig-no.c |N2 | OpenMP private clause to avoid data races | New +DRB077-single-orig-no.c |N1 | OpenMP single directive to use only one thread for execution | New +DRB078-taskdep2-orig-no.c |N3 | OpenMP task depend clause to avoid data races | New +DRB079-taskdep3-orig-no.c |N3 | OpenMP task depend clause to avoid data races | New +DRB081-func-arg-orig-no.c |N6 | Function arguments passed by value, private | New +DRB083-declared-in-func-orig-no.c |N6 | A variable declared within a function called by a parallel region | New +DRB085-threadprivate-orig-no.c |N2 | Use threadprivate to protect a file scope variable, not referenced within a construct| New +DRB091-threadprivate2-orig-no.c |N2 | Use threadprivate to protect a file scope variable, referenced within a construct | New +DRB093-doall2-collapse-orig-no.c |N2 | Use collapse(n) to control the number of associated loops of omp for | New +DRB094-doall2-ordered-orig-no.c |N2 | Use ordered(n) to control the number of associated loops of omp for | New +DRB096-doall2-taskloop-collapse-orig-no.c|N2 | Use ordered(n) to control the number of associated loops of taskloop | New +DRB097-target-teams-distribute-orig-no.c |N2 | Predetermined attribute rule for loop variable associated with distribute | New +DRB098-simd2-orig-no.c |N1,N2 | OpenMP SIMD directive to indicate vectorization of two nested loops | New +DRB099-targetparallelfor2-orig-no.c |N1,N5 | Loops offloaded to accelerators: array sections derived from pointer | New +DRB100-task-reference-orig-no.cpp |N1 | OpenMP 4.5 feature: orphaned task generating construct using pass-by-reference | New +DRB101-task-value-orig-no.cpp |N1 | In a task generating construct, a variable without applicable rules is firstprivate | New +DRB102-copyprivate-orig-no.c |N2 | threadprivate+copyprivate, a variable without applicable rules is firstprivate | New +DRB103-master-orig-no.c |N1 | master directive to ensure only one thread will execute data accesses | New +DRB104-nowait-barrier-orig-no.c |N3 | Use barrier to ensure correct order of initialization and assignment phases | New +DRB105-taskwait-orig-no.c |N3 | Use taskwait to ensure correct order of tasks | New +DRB107-taskgroup-orig-no.c |N3 | Use taskgroup to ensure correct order of tasks | New +DRB108-atomic-orig-no.c |N3 | Use atomic to protect shared accesses to a variable | New +DRB110-ordered-orig-no.c |N3 | Proper use of the ordered clause to avoid data races | New +DRB112-linear-orig-no.c |N2 | Use linear to privatize a variable | New +DRB113-default-orig-no.c |N1 | default(none) to enforce explicitly listing variables in data-sharing clauses | New ## Authors diff --git a/check-data-races.sh b/check-data-races.sh index 1eff399..2ad7ec7 100755 --- a/check-data-races.sh +++ b/check-data-races.sh @@ -46,6 +46,7 @@ OPTION=$1 TESTS=$(grep -l main micro-benchmarks/*.c) +CPPTESTS=$(grep -l main micro-benchmarks/*.cpp) POLYFLAG="micro-benchmarks/utilities/polybench.c -I micro-benchmarks -I micro-benchmarks/utilities -DPOLYBENCH_NO_FLUSH_CACHE -DPOLYBENCH_TIME -D_POSIX_C_SOURCE=200112L" if [[ -z "$OPTION" || "$OPTION" == "--help" ]]; then @@ -55,6 +56,7 @@ if [[ -z "$OPTION" || "$OPTION" == "--help" ]]; then echo "--help : this option" echo "--small : compile and test all benchmarks using small parameters with Helgrind, ThreadSanitizer, Archer, Intel inspector." echo "--run : compile and run all benchmarks with gcc (no evaluation)" + echo "--run-intel: compile and run all benchmarks with Intel compilers (no evaluation)" echo "--helgrind : compile and test all benchmarks with Helgrind" echo "--tsan : compile and test all benchmarks with clang ThreadSanitizer" echo "--archer : compile and test all benchmarks with Archer" @@ -80,9 +82,43 @@ if [[ "$OPTION" == "--run" ]]; then ./a.out > /dev/null done rm -f ./a.out +# test for cpp files + for test in $CPPTESTS; do + echo "------------------------------------------" + echo "RUNNING: $test" + CFLAGS="-g -Wall -fopenmp" + if grep -q 'PolyBench' "$test"; then CFLAGS+=" $POLYFLAG"; fi + g++ $CFLAGS "$test" -lm + ./a.out > /dev/null + done + rm -f ./a.out + exit +fi + +if [[ "$OPTION" == "--run-intel" ]]; then + for test in $TESTS; do + echo "------------------------------------------" + echo "RUNNING: $test" + CFLAGS="-g -Wall -std=c99 -fopenmp" + if grep -q 'PolyBench' "$test"; then CFLAGS+=" $POLYFLAG"; fi + icc $CFLAGS "$test" -lm + ./a.out > /dev/null + done + rm -f ./a.out +# test for cpp files + for test in $CPPTESTS; do + echo "------------------------------------------" + echo "RUNNING: $test" + CFLAGS="-g -Wall -fopenmp" + if grep -q 'PolyBench' "$test"; then CFLAGS+=" $POLYFLAG"; fi + icpc $CFLAGS "$test" -lm + ./a.out > /dev/null + done + rm -f ./a.out exit fi + if [[ "$OPTION" == "--helgrind" ]]; then scripts/test-harness.sh -x helgrind fi diff --git a/micro-benchmarks/antidep1-orig-yes.c b/micro-benchmarks/DRB001-antidep1-orig-yes.c similarity index 100% rename from micro-benchmarks/antidep1-orig-yes.c rename to micro-benchmarks/DRB001-antidep1-orig-yes.c diff --git a/micro-benchmarks/antidep1-var-yes.c b/micro-benchmarks/DRB002-antidep1-var-yes.c similarity index 100% rename from micro-benchmarks/antidep1-var-yes.c rename to micro-benchmarks/DRB002-antidep1-var-yes.c diff --git a/micro-benchmarks/antidep2-orig-yes.c b/micro-benchmarks/DRB003-antidep2-orig-yes.c similarity index 100% rename from micro-benchmarks/antidep2-orig-yes.c rename to micro-benchmarks/DRB003-antidep2-orig-yes.c diff --git a/micro-benchmarks/antidep2-var-yes.c b/micro-benchmarks/DRB004-antidep2-var-yes.c similarity index 100% rename from micro-benchmarks/antidep2-var-yes.c rename to micro-benchmarks/DRB004-antidep2-var-yes.c diff --git a/micro-benchmarks/indirectaccess1-orig-yes.c b/micro-benchmarks/DRB005-indirectaccess1-orig-yes.c similarity index 100% rename from micro-benchmarks/indirectaccess1-orig-yes.c rename to micro-benchmarks/DRB005-indirectaccess1-orig-yes.c diff --git a/micro-benchmarks/indirectaccess2-orig-yes.c b/micro-benchmarks/DRB006-indirectaccess2-orig-yes.c similarity index 100% rename from micro-benchmarks/indirectaccess2-orig-yes.c rename to micro-benchmarks/DRB006-indirectaccess2-orig-yes.c diff --git a/micro-benchmarks/indirectaccess3-orig-yes.c b/micro-benchmarks/DRB007-indirectaccess3-orig-yes.c similarity index 100% rename from micro-benchmarks/indirectaccess3-orig-yes.c rename to micro-benchmarks/DRB007-indirectaccess3-orig-yes.c diff --git a/micro-benchmarks/indirectaccess4-orig-yes.c b/micro-benchmarks/DRB008-indirectaccess4-orig-yes.c similarity index 100% rename from micro-benchmarks/indirectaccess4-orig-yes.c rename to micro-benchmarks/DRB008-indirectaccess4-orig-yes.c diff --git a/micro-benchmarks/lastprivatemissing-orig-yes.c b/micro-benchmarks/DRB009-lastprivatemissing-orig-yes.c similarity index 100% rename from micro-benchmarks/lastprivatemissing-orig-yes.c rename to micro-benchmarks/DRB009-lastprivatemissing-orig-yes.c diff --git a/micro-benchmarks/lastprivatemissing-var-yes.c b/micro-benchmarks/DRB010-lastprivatemissing-var-yes.c similarity index 100% rename from micro-benchmarks/lastprivatemissing-var-yes.c rename to micro-benchmarks/DRB010-lastprivatemissing-var-yes.c diff --git a/micro-benchmarks/minusminus-orig-yes.c b/micro-benchmarks/DRB011-minusminus-orig-yes.c similarity index 100% rename from micro-benchmarks/minusminus-orig-yes.c rename to micro-benchmarks/DRB011-minusminus-orig-yes.c diff --git a/micro-benchmarks/minusminus-var-yes.c b/micro-benchmarks/DRB012-minusminus-var-yes.c similarity index 100% rename from micro-benchmarks/minusminus-var-yes.c rename to micro-benchmarks/DRB012-minusminus-var-yes.c diff --git a/micro-benchmarks/nowait-orig-yes.c b/micro-benchmarks/DRB013-nowait-orig-yes.c similarity index 99% rename from micro-benchmarks/nowait-orig-yes.c rename to micro-benchmarks/DRB013-nowait-orig-yes.c index 2ba19c3..4e25e0e 100644 --- a/micro-benchmarks/nowait-orig-yes.c +++ b/micro-benchmarks/DRB013-nowait-orig-yes.c @@ -60,7 +60,7 @@ int main() { int i,error; int len = 1000; - int a[1000], b=5; + int a[len], b=5; for (i=0; i #include /* Include polybench common header. */ -#include +#include "polybench/polybench.h" /* Include benchmark-specific header. */ /* Default data type is double, default size is 4000. */ -#include "3mm.h" +#include "polybench/3mm.h" /* Array initialization. */ static void init_array(int ni,int nj,int nk,int nl,int nm,double A[128 + 0][128 + 0],double B[128 + 0][128 + 0],double C[128 + 0][128 + 0],double D[128 + 0][128 + 0]) diff --git a/micro-benchmarks/3mm-tile-no.c b/micro-benchmarks/DRB042-3mm-tile-no.c similarity index 99% rename from micro-benchmarks/3mm-tile-no.c rename to micro-benchmarks/DRB042-3mm-tile-no.c index 1d17791..dd7a3d8 100644 --- a/micro-benchmarks/3mm-tile-no.c +++ b/micro-benchmarks/DRB042-3mm-tile-no.c @@ -11,10 +11,10 @@ #include #include /* Include polybench common header. */ -#include +#include "polybench/polybench.h" /* Include benchmark-specific header. */ /* Default data type is double, default size is 4000. */ -#include "3mm.h" +#include "polybench/3mm.h" /* Array initialization. */ static void init_array(int ni,int nj,int nk,int nl,int nm,double A[128 + 0][128 + 0],double B[128 + 0][128 + 0],double C[128 + 0][128 + 0],double D[128 + 0][128 + 0]) diff --git a/micro-benchmarks/adi-parallel-no.c b/micro-benchmarks/DRB043-adi-parallel-no.c similarity index 98% rename from micro-benchmarks/adi-parallel-no.c rename to micro-benchmarks/DRB043-adi-parallel-no.c index ebc05e2..403a8b7 100644 --- a/micro-benchmarks/adi-parallel-no.c +++ b/micro-benchmarks/DRB043-adi-parallel-no.c @@ -12,10 +12,10 @@ #include #include /* Include polybench common header. */ -#include +#include "polybench/polybench.h" /* Include benchmark-specific header. */ /* Default data type is double, default size is 10x1024x1024. */ -#include "adi.h" +#include "polybench/adi.h" /* Array initialization. */ static void init_array(int n,double X[500 + 0][500 + 0],double A[500 + 0][500 + 0],double B[500 + 0][500 + 0]) diff --git a/micro-benchmarks/adi-tile-no.c b/micro-benchmarks/DRB044-adi-tile-no.c similarity index 99% rename from micro-benchmarks/adi-tile-no.c rename to micro-benchmarks/DRB044-adi-tile-no.c index 3401b43..3f6d40a 100644 --- a/micro-benchmarks/adi-tile-no.c +++ b/micro-benchmarks/DRB044-adi-tile-no.c @@ -11,10 +11,10 @@ #include #include /* Include polybench common header. */ -#include +#include "polybench/polybench.h" /* Include benchmark-specific header. */ /* Default data type is double, default size is 10x1024x1024. */ -#include "adi.h" +#include "polybench/adi.h" /* Array initialization. */ static void init_array(int n,double X[500 + 0][500 + 0],double A[500 + 0][500 + 0],double B[500 + 0][500 + 0]) diff --git a/micro-benchmarks/doall1-orig-no.c b/micro-benchmarks/DRB045-doall1-orig-no.c similarity index 100% rename from micro-benchmarks/doall1-orig-no.c rename to micro-benchmarks/DRB045-doall1-orig-no.c diff --git a/micro-benchmarks/DRB046-doall2-orig-no.c b/micro-benchmarks/DRB046-doall2-orig-no.c new file mode 100644 index 0000000..6bed558 --- /dev/null +++ b/micro-benchmarks/DRB046-doall2-orig-no.c @@ -0,0 +1,64 @@ +/* +Copyright (c) 2017, Lawrence Livermore National Security, LLC. +Produced at the Lawrence Livermore National Laboratory +Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund, +Markus Schordan, and Ian Karlin +(email: liao6@llnl.gov, lin32@llnl.gov, asplund1@llnl.gov, +schordan1@llnl.gov, karlin1@llnl.gov) +LLNL-CODE-732144 +All rights reserved. + +This file is part of DataRaceBench. For details, see +https://github.com/LLNL/dataracebench. Please also see the LICENSE file +for our additional BSD notice. + +Redistribution and use in source and binary forms, with +or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the disclaimer below. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the disclaimer (as noted below) + in the documentation and/or other materials provided with the + distribution. + +* Neither the name of the LLNS/LLNL nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL +SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* +Two-dimensional array computation: +Only one loop is associated with the omp for construct. +The inner loop's loop iteration variable needs an explicit private() clause, +otherwise it will be shared by default. +*/ + +int a[100][100]; +int main() +{ + int i,j; +#pragma omp parallel for private(j) + for (i=0;i<100;i++) + for (j=0;j<100;j++) + a[i][j]=a[i][j]+1; + return 0; +} + diff --git a/micro-benchmarks/doallchar-orig-no.c b/micro-benchmarks/DRB047-doallchar-orig-no.c similarity index 100% rename from micro-benchmarks/doallchar-orig-no.c rename to micro-benchmarks/DRB047-doallchar-orig-no.c diff --git a/micro-benchmarks/firstprivate-orig-no.c b/micro-benchmarks/DRB048-firstprivate-orig-no.c similarity index 100% rename from micro-benchmarks/firstprivate-orig-no.c rename to micro-benchmarks/DRB048-firstprivate-orig-no.c diff --git a/micro-benchmarks/fprintf-orig-no.c b/micro-benchmarks/DRB049-fprintf-orig-no.c similarity index 100% rename from micro-benchmarks/fprintf-orig-no.c rename to micro-benchmarks/DRB049-fprintf-orig-no.c diff --git a/micro-benchmarks/functionparameter-orig-no.c b/micro-benchmarks/DRB050-functionparameter-orig-no.c similarity index 100% rename from micro-benchmarks/functionparameter-orig-no.c rename to micro-benchmarks/DRB050-functionparameter-orig-no.c diff --git a/micro-benchmarks/getthreadnum-orig-no.c b/micro-benchmarks/DRB051-getthreadnum-orig-no.c similarity index 100% rename from micro-benchmarks/getthreadnum-orig-no.c rename to micro-benchmarks/DRB051-getthreadnum-orig-no.c diff --git a/micro-benchmarks/indirectaccesssharebase-orig-no.c b/micro-benchmarks/DRB052-indirectaccesssharebase-orig-no.c similarity index 100% rename from micro-benchmarks/indirectaccesssharebase-orig-no.c rename to micro-benchmarks/DRB052-indirectaccesssharebase-orig-no.c diff --git a/micro-benchmarks/inneronly1-orig-no.c b/micro-benchmarks/DRB053-inneronly1-orig-no.c similarity index 100% rename from micro-benchmarks/inneronly1-orig-no.c rename to micro-benchmarks/DRB053-inneronly1-orig-no.c diff --git a/micro-benchmarks/inneronly2-orig-no.c b/micro-benchmarks/DRB054-inneronly2-orig-no.c similarity index 100% rename from micro-benchmarks/inneronly2-orig-no.c rename to micro-benchmarks/DRB054-inneronly2-orig-no.c diff --git a/micro-benchmarks/jacobi2d-parallel-no.c b/micro-benchmarks/DRB055-jacobi2d-parallel-no.c similarity index 98% rename from micro-benchmarks/jacobi2d-parallel-no.c rename to micro-benchmarks/DRB055-jacobi2d-parallel-no.c index 9b7bba3..3735d65 100644 --- a/micro-benchmarks/jacobi2d-parallel-no.c +++ b/micro-benchmarks/DRB055-jacobi2d-parallel-no.c @@ -11,10 +11,10 @@ #include #include /* Include polybench common header. */ -#include +#include "polybench/polybench.h" /* Include benchmark-specific header. */ /* Default data type is double, default size is 20x1000. */ -#include "jacobi-2d-imper.h" +#include "polybench/jacobi-2d-imper.h" /* Array initialization. */ static void init_array(int n,double A[500 + 0][500 + 0],double B[500 + 0][500 + 0]) diff --git a/micro-benchmarks/jacobi2d-tile-no.c b/micro-benchmarks/DRB056-jacobi2d-tile-no.c similarity index 99% rename from micro-benchmarks/jacobi2d-tile-no.c rename to micro-benchmarks/DRB056-jacobi2d-tile-no.c index be176e5..478b5ee 100644 --- a/micro-benchmarks/jacobi2d-tile-no.c +++ b/micro-benchmarks/DRB056-jacobi2d-tile-no.c @@ -11,10 +11,10 @@ #include #include /* Include polybench common header. */ -#include +#include "polybench/polybench.h" /* Include benchmark-specific header. */ /* Default data type is double, default size is 20x1000. */ -#include "jacobi-2d-imper.h" +#include "polybench/jacobi-2d-imper.h" /* Array initialization. */ static void init_array(int n,double A[500 + 0][500 + 0],double B[500 + 0][500 + 0]) diff --git a/micro-benchmarks/jacobiinitialize-orig-no.c b/micro-benchmarks/DRB057-jacobiinitialize-orig-no.c similarity index 100% rename from micro-benchmarks/jacobiinitialize-orig-no.c rename to micro-benchmarks/DRB057-jacobiinitialize-orig-no.c diff --git a/micro-benchmarks/jacobikernel-orig-no.c b/micro-benchmarks/DRB058-jacobikernel-orig-no.c similarity index 100% rename from micro-benchmarks/jacobikernel-orig-no.c rename to micro-benchmarks/DRB058-jacobikernel-orig-no.c diff --git a/micro-benchmarks/lastprivate-orig-no.c b/micro-benchmarks/DRB059-lastprivate-orig-no.c similarity index 100% rename from micro-benchmarks/lastprivate-orig-no.c rename to micro-benchmarks/DRB059-lastprivate-orig-no.c diff --git a/micro-benchmarks/matrixmultiply-orig-no.c b/micro-benchmarks/DRB060-matrixmultiply-orig-no.c similarity index 100% rename from micro-benchmarks/matrixmultiply-orig-no.c rename to micro-benchmarks/DRB060-matrixmultiply-orig-no.c diff --git a/micro-benchmarks/matrixvector1-orig-no.c b/micro-benchmarks/DRB061-matrixvector1-orig-no.c similarity index 100% rename from micro-benchmarks/matrixvector1-orig-no.c rename to micro-benchmarks/DRB061-matrixvector1-orig-no.c diff --git a/micro-benchmarks/matrixvector2-orig-no.c b/micro-benchmarks/DRB062-matrixvector2-orig-no.c similarity index 100% rename from micro-benchmarks/matrixvector2-orig-no.c rename to micro-benchmarks/DRB062-matrixvector2-orig-no.c diff --git a/micro-benchmarks/outeronly1-orig-no.c b/micro-benchmarks/DRB063-outeronly1-orig-no.c similarity index 100% rename from micro-benchmarks/outeronly1-orig-no.c rename to micro-benchmarks/DRB063-outeronly1-orig-no.c diff --git a/micro-benchmarks/outeronly2-orig-no.c b/micro-benchmarks/DRB064-outeronly2-orig-no.c similarity index 97% rename from micro-benchmarks/outeronly2-orig-no.c rename to micro-benchmarks/DRB064-outeronly2-orig-no.c index fd256eb..8680ec8 100644 --- a/micro-benchmarks/outeronly2-orig-no.c +++ b/micro-benchmarks/DRB064-outeronly2-orig-no.c @@ -47,7 +47,7 @@ THE POSSIBILITY OF SUCH DAMAGE. /* Only the outmost loop can be parallelized. -The inner loop has loop carried anti data dependence. +The inner loop has loop carried true data dependence. However, the loop is not parallelized so no race condition. */ int n=100, m=100; diff --git a/micro-benchmarks/pireduction-orig-no.c b/micro-benchmarks/DRB065-pireduction-orig-no.c similarity index 99% rename from micro-benchmarks/pireduction-orig-no.c rename to micro-benchmarks/DRB065-pireduction-orig-no.c index 235b5fd..62fc44f 100644 --- a/micro-benchmarks/pireduction-orig-no.c +++ b/micro-benchmarks/DRB065-pireduction-orig-no.c @@ -54,7 +54,7 @@ Classic PI calculation using reduction int main(int argc, char** argv) { double pi = 0.0; - int i; + long int i; double x, interval_width; interval_width = 1.0/(double)num_steps; diff --git a/micro-benchmarks/pointernoaliasing-orig-no.c b/micro-benchmarks/DRB066-pointernoaliasing-orig-no.c similarity index 100% rename from micro-benchmarks/pointernoaliasing-orig-no.c rename to micro-benchmarks/DRB066-pointernoaliasing-orig-no.c diff --git a/micro-benchmarks/restrictpointer1-orig-no.c b/micro-benchmarks/DRB067-restrictpointer1-orig-no.c similarity index 100% rename from micro-benchmarks/restrictpointer1-orig-no.c rename to micro-benchmarks/DRB067-restrictpointer1-orig-no.c diff --git a/micro-benchmarks/restrictpointer2-orig-no.c b/micro-benchmarks/DRB068-restrictpointer2-orig-no.c similarity index 100% rename from micro-benchmarks/restrictpointer2-orig-no.c rename to micro-benchmarks/DRB068-restrictpointer2-orig-no.c diff --git a/micro-benchmarks/sectionslock1-orig-no.c b/micro-benchmarks/DRB069-sectionslock1-orig-no.c similarity index 100% rename from micro-benchmarks/sectionslock1-orig-no.c rename to micro-benchmarks/DRB069-sectionslock1-orig-no.c diff --git a/micro-benchmarks/simd1-orig-no.c b/micro-benchmarks/DRB070-simd1-orig-no.c similarity index 100% rename from micro-benchmarks/simd1-orig-no.c rename to micro-benchmarks/DRB070-simd1-orig-no.c diff --git a/micro-benchmarks/targetparallelfor-orig-no.c b/micro-benchmarks/DRB071-targetparallelfor-orig-no.c similarity index 93% rename from micro-benchmarks/targetparallelfor-orig-no.c rename to micro-benchmarks/DRB071-targetparallelfor-orig-no.c index aa8a7f8..f59c663 100644 --- a/micro-benchmarks/targetparallelfor-orig-no.c +++ b/micro-benchmarks/DRB071-targetparallelfor-orig-no.c @@ -45,21 +45,20 @@ THE POSSIBILITY OF SUCH DAMAGE. */ /* -use of omp target +use of omp target: len is not mapped. It should be firstprivate within target. */ int main(int argc, char* argv[]) { int i; int len = 1000; - - int a[1000]; + int a[len]; for (i=0; i /* Two-dimensional array computation using loops: missing private(j). References to j in the loop cause data races. Data race pairs (we allow multiple ones to preserve the pattern): Write_set = {j@61:10, j@61:20} - Read_set = {j@62:20, j@62:12, j62@:14, j61@:20} + Read_set = {j@62:20, j@62:12, j61@:14, j61@:20} Any pair from Write_set vs. Write_set and Write_set vs. Read_set is a data race pair. */ int a[100][100]; diff --git a/micro-benchmarks/flush-orig-yes.c b/micro-benchmarks/DRB074-flush-orig-yes.c similarity index 100% rename from micro-benchmarks/flush-orig-yes.c rename to micro-benchmarks/DRB074-flush-orig-yes.c diff --git a/micro-benchmarks/getthreadnum-orig-yes.c b/micro-benchmarks/DRB075-getthreadnum-orig-yes.c similarity index 100% rename from micro-benchmarks/getthreadnum-orig-yes.c rename to micro-benchmarks/DRB075-getthreadnum-orig-yes.c diff --git a/micro-benchmarks/flush-orig-no.c b/micro-benchmarks/DRB076-flush-orig-no.c similarity index 100% rename from micro-benchmarks/flush-orig-no.c rename to micro-benchmarks/DRB076-flush-orig-no.c diff --git a/micro-benchmarks/single-orig-no.c b/micro-benchmarks/DRB077-single-orig-no.c similarity index 100% rename from micro-benchmarks/single-orig-no.c rename to micro-benchmarks/DRB077-single-orig-no.c diff --git a/micro-benchmarks/taskdep2-orig-no.c b/micro-benchmarks/DRB078-taskdep2-orig-no.c similarity index 97% rename from micro-benchmarks/taskdep2-orig-no.c rename to micro-benchmarks/DRB078-taskdep2-orig-no.c index dbb3124..9d170c4 100644 --- a/micro-benchmarks/taskdep2-orig-no.c +++ b/micro-benchmarks/DRB078-taskdep2-orig-no.c @@ -49,6 +49,7 @@ Two tasks with depend clause to ensure execution order, no data races. i is shared for two tasks based on implicit data-sharing attribute rules. */ #include +#include int main() { int i=0; @@ -56,7 +57,10 @@ int main() #pragma omp single { #pragma omp task depend (out:i) - i = 1; + { + sleep(3); + i = 1; + } #pragma omp task depend (out:i) i = 2; } diff --git a/micro-benchmarks/taskdep3-orig-no.c b/micro-benchmarks/DRB079-taskdep3-orig-no.c similarity index 92% rename from micro-benchmarks/taskdep3-orig-no.c rename to micro-benchmarks/DRB079-taskdep3-orig-no.c index f77fc3f..cd07937 100644 --- a/micro-benchmarks/taskdep3-orig-no.c +++ b/micro-benchmarks/DRB079-taskdep3-orig-no.c @@ -48,19 +48,25 @@ THE POSSIBILITY OF SUCH DAMAGE. tasks with depend clauses to ensure execution order, no data races. */ #include +#include +#include int main() { - int i=0; + int i=0, j, k; #pragma omp parallel #pragma omp single { #pragma omp task depend (out:i) - i = 1; + { + sleep(3); + i = 1; + } #pragma omp task depend (in:i) - printf ("x=%d\n", i); + j =i; #pragma omp task depend (in:i) - printf ("x=%d\n", i); + k =i; } - + printf ("j=%d k=%d\n", j, k); + assert (j==1 && k==1); return 0; } diff --git a/micro-benchmarks/DRB080-func-arg-orig-yes.c b/micro-benchmarks/DRB080-func-arg-orig-yes.c new file mode 100644 index 0000000..9bfb483 --- /dev/null +++ b/micro-benchmarks/DRB080-func-arg-orig-yes.c @@ -0,0 +1,71 @@ +/* +Copyright (c) 2017, Lawrence Livermore National Security, LLC. +Produced at the Lawrence Livermore National Laboratory +Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund, +Markus Schordan, and Ian Karlin +(email: liao6@llnl.gov, lin32@llnl.gov, asplund1@llnl.gov, +schordan1@llnl.gov, karlin1@llnl.gov) +LLNL-CODE-732144 +All rights reserved. + +This file is part of DataRaceBench. For details, see +https://github.com/LLNL/dataracebench. Please also see the LICENSE file +for our additional BSD notice. + +Redistribution and use in source and binary forms, with +or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the disclaimer below. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the disclaimer (as noted below) + in the documentation and/or other materials provided with the + distribution. + +* Neither the name of the LLNS/LLNL nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL +SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* +A function arguments is passed by reference: +its data-sharing attribute is the same as its actual argument's. +i is shared. *q is shared. +Data race pair: *q(i)@59:4 vs. *q(i)@59:4 +*/ + +#include + +/* argument pass-by-reference */ +void f1(int* q) +{ + *q += 1; +} + +int main() +{ + int i=0; + #pragma omp parallel + { + f1(&i); + } + printf ("i=%d\n",i); + return 0; +} diff --git a/micro-benchmarks/DRB081-func-arg-orig-no.c b/micro-benchmarks/DRB081-func-arg-orig-no.c new file mode 100644 index 0000000..95bee3c --- /dev/null +++ b/micro-benchmarks/DRB081-func-arg-orig-no.c @@ -0,0 +1,71 @@ +/* +Copyright (c) 2017, Lawrence Livermore National Security, LLC. +Produced at the Lawrence Livermore National Laboratory +Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund, +Markus Schordan, and Ian Karlin +(email: liao6@llnl.gov, lin32@llnl.gov, asplund1@llnl.gov, +schordan1@llnl.gov, karlin1@llnl.gov) +LLNL-CODE-732144 +All rights reserved. + +This file is part of DataRaceBench. For details, see +https://github.com/LLNL/dataracebench. Please also see the LICENSE file +for our additional BSD notice. + +Redistribution and use in source and binary forms, with +or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the disclaimer below. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the disclaimer (as noted below) + in the documentation and/or other materials provided with the + distribution. + +* Neither the name of the LLNS/LLNL nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL +SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* +A function argument passed by value should be private inside the function. +Variable i is read only. +*/ + +#include +#include +/* argument pass-by-value */ +void f1(int q) +{ + q += 1; +} + +int main() +{ + int i=0; + #pragma omp parallel + { + f1(i); + } + assert (i==0); + printf ("i=%d\n",i); + return 0; +} + diff --git a/micro-benchmarks/DRB082-declared-in-func-orig-yes.c b/micro-benchmarks/DRB082-declared-in-func-orig-yes.c new file mode 100644 index 0000000..19b6c22 --- /dev/null +++ b/micro-benchmarks/DRB082-declared-in-func-orig-yes.c @@ -0,0 +1,68 @@ +/* +Copyright (c) 2017, Lawrence Livermore National Security, LLC. +Produced at the Lawrence Livermore National Laboratory +Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund, +Markus Schordan, and Ian Karlin +(email: liao6@llnl.gov, lin32@llnl.gov, asplund1@llnl.gov, +schordan1@llnl.gov, karlin1@llnl.gov) +LLNL-CODE-732144 +All rights reserved. + +This file is part of DataRaceBench. For details, see +https://github.com/LLNL/dataracebench. Please also see the LICENSE file +for our additional BSD notice. + +Redistribution and use in source and binary forms, with +or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the disclaimer below. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the disclaimer (as noted below) + in the documentation and/or other materials provided with the + distribution. + +* Neither the name of the LLNS/LLNL nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL +SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* +A variable is declared inside a function called within a parallel region. +The variable should be shared if it uses static storage. + +Data race pair: q@57:3 vs. q@57:3 +*/ + +void foo() +{ + static int q; + q += 1; +} + +int main() +{ + #pragma omp parallel + { + foo(); + } + return 0; +} + diff --git a/micro-benchmarks/DRB083-declared-in-func-orig-no.c b/micro-benchmarks/DRB083-declared-in-func-orig-no.c new file mode 100644 index 0000000..26ea248 --- /dev/null +++ b/micro-benchmarks/DRB083-declared-in-func-orig-no.c @@ -0,0 +1,67 @@ +/* +Copyright (c) 2017, Lawrence Livermore National Security, LLC. +Produced at the Lawrence Livermore National Laboratory +Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund, +Markus Schordan, and Ian Karlin +(email: liao6@llnl.gov, lin32@llnl.gov, asplund1@llnl.gov, +schordan1@llnl.gov, karlin1@llnl.gov) +LLNL-CODE-732144 +All rights reserved. + +This file is part of DataRaceBench. For details, see +https://github.com/LLNL/dataracebench. Please also see the LICENSE file +for our additional BSD notice. + +Redistribution and use in source and binary forms, with +or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the disclaimer below. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the disclaimer (as noted below) + in the documentation and/or other materials provided with the + distribution. + +* Neither the name of the LLNS/LLNL nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL +SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* +A variable is declared inside a function called within a parallel region. +The variable should be private if it does not use static storage. + +*/ + +void foo() +{ + int q=0; + q += 1; +} + +int main() +{ + #pragma omp parallel + { + foo(); + } + return 0; +} + diff --git a/micro-benchmarks/DRB084-threadprivatemissing-orig-yes.c b/micro-benchmarks/DRB084-threadprivatemissing-orig-yes.c new file mode 100644 index 0000000..5de9e2a --- /dev/null +++ b/micro-benchmarks/DRB084-threadprivatemissing-orig-yes.c @@ -0,0 +1,88 @@ +/* +Copyright (c) 2017, Lawrence Livermore National Security, LLC. +Produced at the Lawrence Livermore National Laboratory +Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund, +Markus Schordan, and Ian Karlin +(email: liao6@llnl.gov, lin32@llnl.gov, asplund1@llnl.gov, +schordan1@llnl.gov, karlin1@llnl.gov) +LLNL-CODE-732144 +All rights reserved. + +This file is part of DataRaceBench. For details, see +https://github.com/LLNL/dataracebench. Please also see the LICENSE file +for our additional BSD notice. + +Redistribution and use in source and binary forms, with +or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the disclaimer below. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the disclaimer (as noted below) + in the documentation and/or other materials provided with the + distribution. + +* Neither the name of the LLNS/LLNL nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL +SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* +A file-scope variable used within a function called by a parallel region. +No threadprivate is used to avoid data races. + +Data race pairs sum0@61:3 vs. sum0@61:8 + sum0@61:3 vs. sum0@61:3 +*/ +#include +#include +int sum0=0, sum1=0; +//#pragma omp threadprivate(sum0) + +void foo (int i) +{ + sum0=sum0+i; +} + +int main() +{ + int i, sum=0; +#pragma omp parallel + { +#pragma omp for + for (i=1;i<=1000;i++) + { + foo (i); + } +#pragma omp critical + { + sum= sum+sum0; + } + } +/* reference calculation */ + for (i=1;i<=1000;i++) + { + sum1=sum1+i; + } + printf("sum=%d; sum1=%d\n",sum,sum1); +// assert(sum==sum1); + return 0; +} + diff --git a/micro-benchmarks/DRB085-threadprivate-orig-no.c b/micro-benchmarks/DRB085-threadprivate-orig-no.c new file mode 100644 index 0000000..3144627 --- /dev/null +++ b/micro-benchmarks/DRB085-threadprivate-orig-no.c @@ -0,0 +1,87 @@ +/* +Copyright (c) 2017, Lawrence Livermore National Security, LLC. +Produced at the Lawrence Livermore National Laboratory +Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund, +Markus Schordan, and Ian Karlin +(email: liao6@llnl.gov, lin32@llnl.gov, asplund1@llnl.gov, +schordan1@llnl.gov, karlin1@llnl.gov) +LLNL-CODE-732144 +All rights reserved. + +This file is part of DataRaceBench. For details, see +https://github.com/LLNL/dataracebench. Please also see the LICENSE file +for our additional BSD notice. + +Redistribution and use in source and binary forms, with +or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the disclaimer below. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the disclaimer (as noted below) + in the documentation and/or other materials provided with the + distribution. + +* Neither the name of the LLNS/LLNL nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL +SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* +A file-scope variable used within a function called by a parallel region. +Use threadprivate to avoid data races. +*/ +#include +#include + +int sum0=0, sum1=0; +#pragma omp threadprivate(sum0) + +void foo (int i) +{ + sum0=sum0+i; +} + +int main() +{ + int len=1000; + int i, sum=0; +#pragma omp parallel copyin(sum0) + { +#pragma omp for + for (i=0;i +#include +using namespace std; + +class A { +public: + static int counter; + static int pcounter; +#pragma omp threadprivate(pcounter) +}; + +int A::counter=0; +int A::pcounter=0; + +A a; + +void foo() +{ + a.counter++; + a.pcounter++; +} + +int main() +{ + #pragma omp parallel + { + foo(); + } + assert (A::pcounter == 1); + cout< +#include +using namespace std; + +class A { +public: + static int counter; + static int pcounter; +#pragma omp threadprivate(pcounter) +}; + +int A::counter=0; +int A::pcounter=0; + +A a; + +int main() +{ + #pragma omp parallel + { + a.counter++; + a.pcounter++; + } + assert (A::pcounter == 1); + cout< +#include + +int* counter; + +void foo() +{ + (*counter)++; +} + +int main() +{ + counter = (int*) malloc(sizeof(int)); + if (counter== NULL) + { + fprintf(stderr, "malloc() failes\n"); + exit(1); + } + *counter = 0; + #pragma omp parallel + { + foo(); + } + printf("%d \n", *counter); + free (counter); + return 0; +} + diff --git a/micro-benchmarks/DRB089-dynamic-storage2-orig-yes.c b/micro-benchmarks/DRB089-dynamic-storage2-orig-yes.c new file mode 100644 index 0000000..fa9652f --- /dev/null +++ b/micro-benchmarks/DRB089-dynamic-storage2-orig-yes.c @@ -0,0 +1,79 @@ +/* +Copyright (c) 2017, Lawrence Livermore National Security, LLC. +Produced at the Lawrence Livermore National Laboratory +Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund, +Markus Schordan, and Ian Karlin +(email: liao6@llnl.gov, lin32@llnl.gov, asplund1@llnl.gov, +schordan1@llnl.gov, karlin1@llnl.gov) +LLNL-CODE-732144 +All rights reserved. + +This file is part of DataRaceBench. For details, see +https://github.com/LLNL/dataracebench. Please also see the LICENSE file +for our additional BSD notice. + +Redistribution and use in source and binary forms, with +or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the disclaimer below. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the disclaimer (as noted below) + in the documentation and/or other materials provided with the + distribution. + +* Neither the name of the LLNS/LLNL nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL +SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* +For the case of a variable which is referenced within a construct: +objects with dynamic storage duration should be shared. +Putting it within a threadprivate directive may cause seg fault +since threadprivate copies are not allocated. + +Dependence pair: *counter@73:7 vs. *counter@73:7 +*/ + +#include +#include + +int* counter; +//#pragma omp threadprivate(counter) + +int main() +{ + counter = (int*) malloc(sizeof(int)); + if (counter== NULL) + { + fprintf(stderr, "malloc() failes\n"); + exit(1); + } + *counter = 0; + #pragma omp parallel + { + (*counter)++; + } + printf("%d \n", *counter); + free (counter); + return 0; +} + diff --git a/micro-benchmarks/DRB090-static-local-orig-yes.c b/micro-benchmarks/DRB090-static-local-orig-yes.c new file mode 100644 index 0000000..e1d827d --- /dev/null +++ b/micro-benchmarks/DRB090-static-local-orig-yes.c @@ -0,0 +1,93 @@ +/* +Copyright (c) 2017, Lawrence Livermore National Security, LLC. +Produced at the Lawrence Livermore National Laboratory +Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund, +Markus Schordan, and Ian Karlin +(email: liao6@llnl.gov, lin32@llnl.gov, asplund1@llnl.gov, +schordan1@llnl.gov, karlin1@llnl.gov) +LLNL-CODE-732144 +All rights reserved. + +This file is part of DataRaceBench. For details, see +https://github.com/LLNL/dataracebench. Please also see the LICENSE file +for our additional BSD notice. + +Redistribution and use in source and binary forms, with +or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the disclaimer below. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the disclaimer (as noted below) + in the documentation and/or other materials provided with the + distribution. + +* Neither the name of the LLNS/LLNL nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL +SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* +For a variable declared in a scope inside an OpenMP construct: +* private if the variable has an automatic storage duration +* shared if the variable has a static storage duration. + +Dependence pairs: + tmp@73:5 vs. tmp@73:5 + tmp@73:5 vs. tmp@74:12 +*/ +#include + +int main(int argc, char* argv[]) +{ + int i; + int len=100; + int a[len], b[len]; + + for (i=0;i +#include + +int sum0=0, sum1=0; +#pragma omp threadprivate(sum0) + +int main() +{ + int len=1000; + int i, sum=0; +#pragma omp parallel copyin(sum0) + { +#pragma omp for + for (i=0;i +#include +int sum0=0, sum1=0; +//#pragma omp threadprivate(sum0) + +int main() +{ + int i, sum=0; +#pragma omp parallel + { +#pragma omp for + for (i=1;i<=1000;i++) + { + sum0=sum0+i; + } +#pragma omp critical + { + sum= sum+sum0; + } + } +/* reference calculation */ + for (i=1;i<=1000;i++) + { + sum1=sum1+i; + } + printf("sum=%d; sum1=%d\n",sum,sum1); +// assert(sum==sum1); + return 0; +} + diff --git a/micro-benchmarks/doall2-orig-no.c b/micro-benchmarks/DRB093-doall2-collapse-orig-no.c similarity index 91% rename from micro-benchmarks/doall2-orig-no.c rename to micro-benchmarks/DRB093-doall2-collapse-orig-no.c index 1175259..e134d4a 100644 --- a/micro-benchmarks/doall2-orig-no.c +++ b/micro-benchmarks/DRB093-doall2-collapse-orig-no.c @@ -45,13 +45,15 @@ THE POSSIBILITY OF SUCH DAMAGE. */ /* -Two-dimensional array computation +Two-dimensional array computation: +collapse(2) is used to associate two loops with omp for. +The corresponding loop iteration variables are private. */ int a[100][100]; int main() { int i,j; -#pragma omp parallel for private(j) +#pragma omp parallel for collapse(2) for (i=0;i<100;i++) for (j=0;j<100;j++) a[i][j]=a[i][j]+1; diff --git a/micro-benchmarks/DRB094-doall2-ordered-orig-no.c b/micro-benchmarks/DRB094-doall2-ordered-orig-no.c new file mode 100644 index 0000000..5942334 --- /dev/null +++ b/micro-benchmarks/DRB094-doall2-ordered-orig-no.c @@ -0,0 +1,73 @@ +/* +Copyright (c) 2017, Lawrence Livermore National Security, LLC. +Produced at the Lawrence Livermore National Laboratory +Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund, +Markus Schordan, and Ian Karlin +(email: liao6@llnl.gov, lin32@llnl.gov, asplund1@llnl.gov, +schordan1@llnl.gov, karlin1@llnl.gov) +LLNL-CODE-732144 +All rights reserved. + +This file is part of DataRaceBench. For details, see +https://github.com/LLNL/dataracebench. Please also see the LICENSE file +for our additional BSD notice. + +Redistribution and use in source and binary forms, with +or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the disclaimer below. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the disclaimer (as noted below) + in the documentation and/or other materials provided with the + distribution. + +* Neither the name of the LLNS/LLNL nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL +SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* +Two-dimensional array computation: +ordered(2) is used to associate two loops with omp for. +The corresponding loop iteration variables are private. + +ordered(n) is an OpenMP 4.5 addition. +*/ +#if (_OPENMP<201511) +#error "An OpenMP 4.5 compiler is needed to compile this test." +#endif +#include +int a[100][100]; +int main() +{ + int i, j; +#pragma omp parallel for ordered(2) + for (i = 0; i < 100; i++) + for (j = 0; j < 100; j++) + { + a[i][j] = a[i][j] + 1; +#pragma omp ordered depend(sink:i-1,j) depend (sink:i,j-1) + printf ("test i=%d j=%d\n",i,j); +#pragma omp ordered depend(source) + } + return 0; +} + diff --git a/micro-benchmarks/DRB095-doall2-taskloop-orig-yes.c b/micro-benchmarks/DRB095-doall2-taskloop-orig-yes.c new file mode 100644 index 0000000..f51947a --- /dev/null +++ b/micro-benchmarks/DRB095-doall2-taskloop-orig-yes.c @@ -0,0 +1,75 @@ +/* +Copyright (c) 2017, Lawrence Livermore National Security, LLC. +Produced at the Lawrence Livermore National Laboratory +Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund, +Markus Schordan, and Ian Karlin +(email: liao6@llnl.gov, lin32@llnl.gov, asplund1@llnl.gov, +schordan1@llnl.gov, karlin1@llnl.gov) +LLNL-CODE-732144 +All rights reserved. + +This file is part of DataRaceBench. For details, see +https://github.com/LLNL/dataracebench. Please also see the LICENSE file +for our additional BSD notice. + +Redistribution and use in source and binary forms, with +or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the disclaimer below. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the disclaimer (as noted below) + in the documentation and/or other materials provided with the + distribution. + +* Neither the name of the LLNS/LLNL nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL +SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ +/* +Two-dimensional array computation: +Only one loop is associated with omp taskloop. +The inner loop's loop iteration variable will be shared if it is shared in the enclosing context. +Data race pairs (we allow multiple ones to preserve the pattern): + Write_set = {j@69:14, j@69:30} + Read_set = {j@69:21, j@69:30, j@70:16} + Any pair from Write_set vs. Write_set and Write_set vs. Read_set is a data race pair. +*/ +#if (_OPENMP<201511) +#error "An OpenMP 4.5 compiler is needed to compile this test." +#endif +#include +int a[100][100]; +int main() +{ + int i, j; +#pragma omp parallel + { +#pragma omp single + { +#pragma omp taskloop + for (i = 0; i < 100; i++) + for (j = 0; j < 100; j++) + a[i][j]+=1; + } + } + printf ("a[50][50]=%d\n", a[50][50]); + return 0; +} diff --git a/micro-benchmarks/DRB096-doall2-taskloop-collapse-orig-no.c b/micro-benchmarks/DRB096-doall2-taskloop-collapse-orig-no.c new file mode 100644 index 0000000..cb3efcf --- /dev/null +++ b/micro-benchmarks/DRB096-doall2-taskloop-collapse-orig-no.c @@ -0,0 +1,73 @@ +/* +Copyright (c) 2017, Lawrence Livermore National Security, LLC. +Produced at the Lawrence Livermore National Laboratory +Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund, +Markus Schordan, and Ian Karlin +(email: liao6@llnl.gov, lin32@llnl.gov, asplund1@llnl.gov, +schordan1@llnl.gov, karlin1@llnl.gov) +LLNL-CODE-732144 +All rights reserved. + +This file is part of DataRaceBench. For details, see +https://github.com/LLNL/dataracebench. Please also see the LICENSE file +for our additional BSD notice. + +Redistribution and use in source and binary forms, with +or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the disclaimer below. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the disclaimer (as noted below) + in the documentation and/or other materials provided with the + distribution. + +* Neither the name of the LLNS/LLNL nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL +SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ +/* +Two-dimensional array computation: +Two loops are associated with omp taskloop due to collapse(2). +Both loop index variables are private. +taskloop requires OpenMP 4.5 compilers. +*/ +#if (_OPENMP<201511) +#error "An OpenMP 4.5 compiler is needed to compile this test." +#endif + +#include +int a[100][100]; +int main() +{ + int i, j; +#pragma omp parallel + { +#pragma omp single + { +#pragma omp taskloop collapse(2) + for (i = 0; i < 100; i++) + for (j = 0; j < 100; j++) + a[i][j]+=1; + } + } + printf ("a[50][50]=%d\n", a[50][50]); + return 0; +} diff --git a/micro-benchmarks/DRB097-target-teams-distribute-orig-no.c b/micro-benchmarks/DRB097-target-teams-distribute-orig-no.c new file mode 100644 index 0000000..a0e27ae --- /dev/null +++ b/micro-benchmarks/DRB097-target-teams-distribute-orig-no.c @@ -0,0 +1,79 @@ +/* +Copyright (c) 2017, Lawrence Livermore National Security, LLC. +Produced at the Lawrence Livermore National Laboratory +Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund, +Markus Schordan, and Ian Karlin +(email: liao6@llnl.gov, lin32@llnl.gov, asplund1@llnl.gov, +schordan1@llnl.gov, karlin1@llnl.gov) +LLNL-CODE-732144 +All rights reserved. + +This file is part of DataRaceBench. For details, see +https://github.com/LLNL/dataracebench. Please also see the LICENSE file +for our additional BSD notice. + +Redistribution and use in source and binary forms, with +or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the disclaimer below. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the disclaimer (as noted below) + in the documentation and/or other materials provided with the + distribution. + +* Neither the name of the LLNS/LLNL nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL +SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include +#define min(x, y) (((x) < (y)) ? (x) : (y)) + +/* +use of omp target + teams + distribute + parallel for +*/ +int main(int argc, char* argv[]) +{ + int i, i2; + int len = 2560; + double sum =0.0, sum2=0.0; + double a[len], b[len]; + /*Initialize with some values*/ + for (i=0; i +/* +Two-dimension array computation with a vetorization directive +collapse(2) makes simd associate with 2 loops. +Loop iteration variables should be predetermined as lastprivate. +*/ +int main() +{ + int len=100; + double a[len][len], b[len][len], c[len][len]; + int i,j; + + for (i=0;i +/* +use of omp target + map + array sections derived from pointers +*/ +void foo (double* a, double* b, int N) +{ + int i; +#pragma omp target map(to:a[0:N]) map(from:b[0:N]) +#pragma omp parallel for + for (i=0;i< N ;i++) + b[i]=a[i]*(double)i; +} + +int main(int argc, char* argv[]) +{ + int i; + int len = 1000; + double a[len], b[len]; + for (i=0; i +#define MYLEN 100 +int a[MYLEN]; + +void gen_task(int& i) +{ +#pragma omp task + { + a[i]= i+1; + } +} + +int main() +{ + int i=0; +#pragma omp parallel + { +#pragma omp single + { + for (i=0; i + +#define MYLEN 100 +int a[MYLEN]; + +void gen_task(int i) +{ +#pragma omp task + { + a[i]= i+1; + } +} + +int main() +{ + int i=0; +#pragma omp parallel + { +#pragma omp single + { + for (i=0; i + +float x=0.0; +int y=0; +#pragma omp threadprivate(x,y) + +int main (int argc, char * argv[]) +{ +#pragma omp parallel + { +#pragma omp single copyprivate(x,y) + { + x=1.0; + y=1; + } + } + printf ("x=%f y=%d\n", x, y); + return 0; +} diff --git a/micro-benchmarks/DRB103-master-orig-no.c b/micro-benchmarks/DRB103-master-orig-no.c new file mode 100644 index 0000000..0bd8204 --- /dev/null +++ b/micro-benchmarks/DRB103-master-orig-no.c @@ -0,0 +1,60 @@ +/* +Copyright (c) 2017, Lawrence Livermore National Security, LLC. +Produced at the Lawrence Livermore National Laboratory +Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund, +Markus Schordan, and Ian Karlin +(email: liao6@llnl.gov, lin32@llnl.gov, asplund1@llnl.gov, +schordan1@llnl.gov, karlin1@llnl.gov) +LLNL-CODE-732144 +All rights reserved. +This file is part of DataRaceBench. For details, see +https://github.com/LLNL/dataracebench. Please also see the LICENSE file +for our additional BSD notice. +Redistribution and use in source and binary forms, with +or without modification, are permitted provided that the following +conditions are met: +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the disclaimer below. +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the disclaimer (as noted below) + in the documentation and/or other materials provided with the + distribution. +* Neither the name of the LLNS/LLNL nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL +SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* +A master directive is used to protect memory accesses. +*/ +#include +#include + +int main() +{ + int k; + +#pragma omp parallel + { +#pragma omp master + { + k = omp_get_num_threads(); + printf ("Number of Threads requested = %i\n",k); + } + } + return 0; +} diff --git a/micro-benchmarks/DRB104-nowait-barrier-orig-no.c b/micro-benchmarks/DRB104-nowait-barrier-orig-no.c new file mode 100644 index 0000000..577f81e --- /dev/null +++ b/micro-benchmarks/DRB104-nowait-barrier-orig-no.c @@ -0,0 +1,78 @@ +/* +Copyright (c) 2017, Lawrence Livermore National Security, LLC. +Produced at the Lawrence Livermore National Laboratory +Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund, +Markus Schordan, and Ian Karlin +(email: liao6@llnl.gov, lin32@llnl.gov, asplund1@llnl.gov, +schordan1@llnl.gov, karlin1@llnl.gov) +LLNL-CODE-732144 +All rights reserved. + +This file is part of DataRaceBench. For details, see +https://github.com/LLNL/dataracebench. Please also see the LICENSE file +for our additional BSD notice. + +Redistribution and use in source and binary forms, with +or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the disclaimer below. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the disclaimer (as noted below) + in the documentation and/or other materials provided with the + distribution. + +* Neither the name of the LLNS/LLNL nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL +SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* +This example is based on one code snippet extracted from a paper: +Ma etc. Symbolic Analysis of Concurrency Errors in OpenMP Programs, ICPP 2013 + +Explicit barrier to counteract nowait +*/ +#include +#include +int main() +{ + int i,error; + int len = 1000; + int a[len], b=5; + + for (i=0; i +#include +unsigned int input = 30; +int fib(unsigned int n) +{ + if (n<2) + return n; + else + { + int i, j; +#pragma omp task shared(i) + i=fib(n-1); +#pragma omp task shared(j) + j=fib(n-2); +#pragma omp taskwait + return i+j; + } +} +int main() +{ + int result = 0; +#pragma omp parallel + { + #pragma omp single + { + result = fib(input); + } + } + printf ("Fib(%d)=%d\n", input, result); + assert (result==832040); + return 0; +} diff --git a/micro-benchmarks/DRB106-taskwaitmissing-orig-yes.c b/micro-benchmarks/DRB106-taskwaitmissing-orig-yes.c new file mode 100644 index 0000000..b46abbb --- /dev/null +++ b/micro-benchmarks/DRB106-taskwaitmissing-orig-yes.c @@ -0,0 +1,88 @@ +/* +Copyright (c) 2017, Lawrence Livermore National Security, LLC. +Produced at the Lawrence Livermore National Laboratory +Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund, +Markus Schordan, and Ian Karlin +(email: liao6@llnl.gov, lin32@llnl.gov, asplund1@llnl.gov, +schordan1@llnl.gov, karlin1@llnl.gov) +LLNL-CODE-732144 +All rights reserved. + +This file is part of DataRaceBench. For details, see +https://github.com/LLNL/dataracebench. Please also see the LICENSE file +for our additional BSD notice. + +Redistribution and use in source and binary forms, with +or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the disclaimer below. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the disclaimer (as noted below) + in the documentation and/or other materials provided with the + distribution. + +* Neither the name of the LLNS/LLNL nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL +SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include +/* This is a program based on a test contributed by Yizi Gu@Rice Univ. + * Classic Fibonacci calculation using task but missing taskwait. + * Data races pairs: i@61:5 vs i@65:12 + * j@63:5 vs j@65:14 + * */ +unsigned int input = 10; +int fib(unsigned int n) +{ + if (n<2) + return n; + else + { + int i, j; +#pragma omp task shared(i) + i=fib(n-1); +#pragma omp task shared(j) + j=fib(n-2); + + int res= i+j; +/* We move the original taskwait to a location after i+j to + * simulate the missing taskwait mistake. + * Directly removing the taskwait may cause a child task to write to i or j + * within the stack of a parent task which may already be gone, causing seg fault. + * This change is suggested by Joachim Protze @RWTH-Aachen. + * */ +#pragma omp taskwait + return res; + } +} +int main() +{ + int result = 0; +#pragma omp parallel + { + #pragma omp single + { + result = fib(input); + } + } + printf ("Fib(%d)=%d (correct answer should be 55)\n", input, result); + return 0; +} diff --git a/micro-benchmarks/DRB107-taskgroup-orig-no.c b/micro-benchmarks/DRB107-taskgroup-orig-no.c new file mode 100644 index 0000000..6c62b00 --- /dev/null +++ b/micro-benchmarks/DRB107-taskgroup-orig-no.c @@ -0,0 +1,78 @@ +/* +Copyright (c) 2017, Lawrence Livermore National Security, LLC. +Produced at the Lawrence Livermore National Laboratory +Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund, +Markus Schordan, and Ian Karlin +(email: liao6@llnl.gov, lin32@llnl.gov, asplund1@llnl.gov, +schordan1@llnl.gov, karlin1@llnl.gov) +LLNL-CODE-732144 +All rights reserved. + +This file is part of DataRaceBench. For details, see +https://github.com/LLNL/dataracebench. Please also see the LICENSE file +for our additional BSD notice. + +Redistribution and use in source and binary forms, with +or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the disclaimer below. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the disclaimer (as noted below) + in the documentation and/or other materials provided with the + distribution. + +* Neither the name of the LLNS/LLNL nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL +SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* This is a program based on a test contributed by Yizi Gu@Rice Univ. + * Use taskgroup to synchronize two tasks: + * */ +#include +#include +#include + +int main() +{ + int result = 0; +#pragma omp parallel + { +#pragma omp single + { +#pragma omp taskgroup + { +#pragma omp task + { + sleep(3); + result = 1; + } + } +#pragma omp task + { + result = 2; + } + } + } + printf ("result=%d\n", result); + assert (result==2); + return 0; +} diff --git a/micro-benchmarks/DRB108-atomic-orig-no.c b/micro-benchmarks/DRB108-atomic-orig-no.c new file mode 100644 index 0000000..ca341f7 --- /dev/null +++ b/micro-benchmarks/DRB108-atomic-orig-no.c @@ -0,0 +1,61 @@ +/* +Copyright (c) 2017, Lawrence Livermore National Security, LLC. +Produced at the Lawrence Livermore National Laboratory +Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund, +Markus Schordan, and Ian Karlin +(email: liao6@llnl.gov, lin32@llnl.gov, asplund1@llnl.gov, +schordan1@llnl.gov, karlin1@llnl.gov) +LLNL-CODE-732144 +All rights reserved. + +This file is part of DataRaceBench. For details, see +https://github.com/LLNL/dataracebench. Please also see the LICENSE file +for our additional BSD notice. + +Redistribution and use in source and binary forms, with +or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the disclaimer below. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the disclaimer (as noted below) + in the documentation and/or other materials provided with the + distribution. + +* Neither the name of the LLNS/LLNL nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL +SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include +/* + * Test if atomic can be recognized properly. No data races. + * */ +int main (void) +{ + int a=0; +#pragma omp parallel + { +#pragma omp atomic + a+=1; + } + printf ("a=%d\n",a); + return 0; +} + diff --git a/micro-benchmarks/DRB109-orderedmissing-orig-yes.c b/micro-benchmarks/DRB109-orderedmissing-orig-yes.c new file mode 100644 index 0000000..833ecce --- /dev/null +++ b/micro-benchmarks/DRB109-orderedmissing-orig-yes.c @@ -0,0 +1,60 @@ +/* +Copyright (c) 2017, Lawrence Livermore National Security, LLC. +Produced at the Lawrence Livermore National Laboratory +Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund, +Markus Schordan, and Ian Karlin +(email: liao6@llnl.gov, lin32@llnl.gov, asplund1@llnl.gov, +schordan1@llnl.gov, karlin1@llnl.gov) +LLNL-CODE-732144 +All rights reserved. + +This file is part of DataRaceBench. For details, see +https://github.com/LLNL/dataracebench. Please also see the LICENSE file +for our additional BSD notice. + +Redistribution and use in source and binary forms, with +or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the disclaimer below. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the disclaimer (as noted below) + in the documentation and/or other materials provided with the + distribution. + +* Neither the name of the LLNS/LLNL nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL +SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include +/* This is a program based on a test contributed by Yizi Gu@Rice Univ. + * Missing the ordered clause + * Data race pair: x@56:5 vs. x@56:5 + * */ +int main() +{ + int x =0; +#pragma omp parallel for ordered + for (int i = 0; i < 100; ++i) { + x++; + } + printf ("x=%d\n",x); + return 0; +} diff --git a/micro-benchmarks/DRB110-ordered-orig-no.c b/micro-benchmarks/DRB110-ordered-orig-no.c new file mode 100644 index 0000000..62397b8 --- /dev/null +++ b/micro-benchmarks/DRB110-ordered-orig-no.c @@ -0,0 +1,64 @@ +/* +Copyright (c) 2017, Lawrence Livermore National Security, LLC. +Produced at the Lawrence Livermore National Laboratory +Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund, +Markus Schordan, and Ian Karlin +(email: liao6@llnl.gov, lin32@llnl.gov, asplund1@llnl.gov, +schordan1@llnl.gov, karlin1@llnl.gov) +LLNL-CODE-732144 +All rights reserved. + +This file is part of DataRaceBench. For details, see +https://github.com/LLNL/dataracebench. Please also see the LICENSE file +for our additional BSD notice. + +Redistribution and use in source and binary forms, with +or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the disclaimer below. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the disclaimer (as noted below) + in the documentation and/or other materials provided with the + distribution. + +* Neither the name of the LLNS/LLNL nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL +SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include +#include +/* This is a program based on a test contributed by Yizi Gu@Rice Univ. + * Proper user of ordered directive and clause, no data races + * */ +int main() +{ + int x =0; +#pragma omp parallel for ordered + for (int i = 0; i < 100; ++i) { +#pragma omp ordered + { + x++; + } + } + assert (x==100); + printf ("x=%d\n",x); + return 0; +} diff --git a/micro-benchmarks/DRB111-linearmissing-orig-yes.c b/micro-benchmarks/DRB111-linearmissing-orig-yes.c new file mode 100644 index 0000000..03d2647 --- /dev/null +++ b/micro-benchmarks/DRB111-linearmissing-orig-yes.c @@ -0,0 +1,73 @@ +/* +Copyright (c) 2017, Lawrence Livermore National Security, LLC. +Produced at the Lawrence Livermore National Laboratory +Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund, +Markus Schordan, and Ian Karlin +(email: liao6@llnl.gov, lin32@llnl.gov, asplund1@llnl.gov, +schordan1@llnl.gov, karlin1@llnl.gov) +LLNL-CODE-732144 +All rights reserved. + +This file is part of DataRaceBench. For details, see +https://github.com/LLNL/dataracebench. Please also see the LICENSE file +for our additional BSD notice. + +Redistribution and use in source and binary forms, with +or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the disclaimer below. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the disclaimer (as noted below) + in the documentation and/or other materials provided with the + distribution. + +* Neither the name of the LLNS/LLNL nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL +SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include +/* + * loop missing the linear clause + * Data race pair: j@67:7 vs. j@68:5 +*/ +int main() +{ + int len=100; + double a[len], b[len], c[len]; + int i,j=0; + + for (i=0;i +int main() +{ + int len=100; + double a[len], b[len], c[len]; + int i,j=0; + + for (i=0;i +#include +#include +int main(int argc, char* argv[]) +{ + int i; + int len=100; + int a[100]; + + for (i=0;i +int main(int argc, char* argv[]) +{ + int i; + int len=100; + int a[100], b[100]; + + for (i=0;i + +/* +use of omp target + teams +Without protection, master threads from two teams cause data races. +Data race pair: a@66:5 vs. a@66:5 +*/ +int main(int argc, char* argv[]) +{ + int i; + int len = 100; + double a[len]; + + /*Initialize with some values*/ + for (i=0; i> "$file" @@ -221,19 +254,41 @@ for tool in "${TOOLS[@]}"; do additional_compile_flags='' if [[ "$test" =~ $RACES_PATTERN ]]; then haverace=true; else haverace=false; fi if [[ "$test" =~ $VARLEN_PATTERN ]]; then SIZES=("${DATASET_SIZES[@]}"); else SIZES=(''); fi - + testname=$(basename $test) + id=${testname#DRB} + id=${id%%-*} + echo "$test has $testname and ID=$id" + # Compile - exname="$(basename "$test").$tool.out" + exname="$EXEC_DIR/$(basename "$test").$tool.out" logname="$(basename "$test").$tool.log" if [[ -e "$LOG_DIR/$logname" ]]; then rm "$LOG_DIR/$logname"; fi if grep -q 'PolyBench' "$test"; then additional_compile_flags+=" $POLYFLAG"; fi - case "$tool" in - helgrind) gcc $VALGRIND_COMPILE_FLAGS $additional_compile_flags $test -o $exname -lm ;; - archer) clang-archer $ARCHER_COMPILE_FLAGS $additional_compile_flags $test -o $exname -lm ;; - tsan) clang $TSAN_COMPILE_FLAGS $additional_compile_flags $test -o $exname -lm ;; - inspector) icc $ICC_COMPILE_FLAGS $additional_compile_flags $test -o $exname -lm ;; - esac + if [[ "$test" =~ $CPP_PATTERN ]]; then + echo "testing C++ code:$test" + case "$tool" in + gnu) g++ -g -fopenmp $additional_compile_flags $test -o $exname -lm ;; + clang) clang++ -fopenmp -g $additional_compile_flags $test -o $exname -lm ;; + intel) icpc $ICPC_COMPILE_FLAGS $additional_compile_flags $test -o $exname -lm ;; + helgrind) g++ $VALGRIND_COMPILE_CPP_FLAGS $additional_compile_flags $test -o $exname -lm ;; + archer) clang-archer++ $ARCHER_COMPILE_FLAGS $additional_compile_flags $test -o $exname -lm ;; + tsan) clang++ $TSAN_COMPILE_FLAGS $additional_compile_flags $test -o $exname -lm ;; + inspector) icpc $ICPC_COMPILE_FLAGS $additional_compile_flags $test -o $exname -lm ;; + esac + else + case "$tool" in + gnu) gcc -g -std=c99 -fopenmp $additional_compile_flags $test -o $exname -lm ;; + clang) clang -fopenmp -g $additional_compile_flags $test -o $exname -lm ;; + intel) icc $ICC_COMPILE_FLAGS $additional_compile_flags $test -o $exname -lm ;; + helgrind) gcc $VALGRIND_COMPILE_C_FLAGS $additional_compile_flags $test -o $exname -lm ;; + archer) clang-archer $ARCHER_COMPILE_FLAGS $additional_compile_flags $test -o $exname -lm ;; + tsan) clang $TSAN_COMPILE_FLAGS $additional_compile_flags $test -o $exname -lm ;; + inspector) icc $ICC_COMPILE_FLAGS $additional_compile_flags $test -o $exname -lm ;; + esac + fi + compilereturn=$?; + echo "compile return code: $compilereturn"; THREAD_INDEX=0 for thread in "${THREADLIST[@]}"; do @@ -243,29 +298,52 @@ for tool in "${TOOLS[@]}"; do for size in "${SIZES[@]}"; do # Sanity check if [[ ! -e "$exname" ]]; then - echo "$tool,\"$test\",$haverace,$thread,${size:-"N/A"},Error,N/A" >> "$file"; - echo "Executable for $test with $thread threads and input size $size is not available" >> "$LOGFILE"; + echo "$tool,$id,\"$testname\",$haverace,$thread,${size:-"N/A"},,,,$compilereturn," >> "$file"; + echo "Executable for $testname with $thread threads and input size $size is not available" >> "$LOGFILE"; elif { "./$exname $size"; } 2>&1 | grep -Eq 'Segmentation fault'; then - echo "$tool,\"$test\",$haverace,$thread,${size:-"N/A"},Error,N/A" >> "$file"; - echo "Seg fault found in $test with $thread threads and input size $size" >> "$LOGFILE"; + echo "$tool,$id,\"$testname\",$haverace,$thread,${size:-"N/A"},,,,$compilereturn," >> "$file"; + echo "Seg fault found in $testname with $thread threads and input size $size" >> "$LOGFILE"; else ITER_INDEX=1 for ITER in $(seq 1 "$ITERATIONS"); do - echo -e "***** Log $ITER_INDEX for $test with $thread threads and input size $size *****" >> "$LOG_DIR/$logname" + echo -e "***** Log $ITER_INDEX for $testname with $thread threads and input size $size *****" >> "$LOG_DIR/$logname" start=$(date +%s%6N) case "$tool" in + gnu) + #races=$($TIMEOUTCMD $TIMEOUTMIN"m" $MEMCHECK -f "%M" -o "$MEMLOG" "./$exname" $size 2>&1 | tee -a "$LOG_DIR/$logname" | grep -ce 'Possible data race') ;; + ;& + clang) + #races=$($MEMCHECK -f "%M" -o "$MEMLOG" "./$exname" $size 2>&1 | tee -a "$LOG_DIR/$logname" | grep -ce 'Possible data race') ;; + ;& + intel) + #races=$($MEMCHECK -f "%M" -o "$MEMLOG" "./$exname" $size 2>&1 | tee -a "$LOG_DIR/$logname" | grep -ce 'Possible data race') ;; + $TIMEOUTCMD $TIMEOUTMIN"m" $MEMCHECK -f "%M" -o "$MEMLOG" "./$exname" $size &> tmp.log; + check_return_code $?; + echo "testname return $testreturn"; + races="", + cat tmp.log >> "$LOG_DIR/$logname" || >tmp.log ;; helgrind) - races=$($VALGRIND --tool=helgrind "./$exname" $size 2>&1 | tee -a "$LOG_DIR/$logname" | grep -ce 'Possible data race') ;; + races=$($MEMCHECK -f "%M" -o "$MEMLOG" $VALGRIND --tool=helgrind "./$exname" $size 2>&1 | tee -a "$LOG_DIR/$logname" | grep -ce 'Possible data race') ;; archer) - races=$("./$exname" $size 2>&1 | tee -a "$LOG_DIR/$logname" | grep -ce 'WARNING: ThreadSanitizer: data race') ;; + $TIMEOUTCMD $TIMEOUTMIN"m" $MEMCHECK -f "%M" -o "$MEMLOG" "./$exname" $size &> tmp.log; + check_return_code $?; + echo "testname return $testreturn" + races=$(grep -ce 'WARNING: ThreadSanitizer: data race' tmp.log) + cat tmp.log >> "$LOG_DIR/$logname" || >tmp.log ;; tsan) - races=$("./$exname" $size 2>&1 | tee -a "$LOG_DIR/$logname" | grep -ce 'WARNING: ThreadSanitizer: data race') ;; + races=$($MEMCHECK -f "%M" -o "$MEMLOG" "./$exname" $size 2>&1 | tee -a "$LOG_DIR/$logname" | grep -ce 'WARNING: ThreadSanitizer: data race') ;; inspector) - races=$($INSPECTOR $runtime_flags -- "./$exname" $size 2>&1 | tee -a "$LOG_DIR/$logname" | grep 'Data race' | sed -E 's/[[:space:]]*([[:digit:]]+).*/\1/') ;; +# races=$($MEMCHECK -f "%M" -o "$MEMLOG" $INSPECTOR $runtime_flags -- "./$exname" $size 2>&1 | tee -a "$LOG_DIR/$logname" | grep 'Data race' | sed -E 's/[[:space:]]*([[:digit:]]+).*/\1/') ;; + $TIMEOUTCMD $TIMEOUTMIN"m" $MEMCHECK -f "%M" -o "$MEMLOG" $INSPECTOR $runtime_flags -- "./$exname" $size &> tmp.log; + check_return_code $?; + echo "testname return $testreturn"; + races=$(grep 'Data race' tmp.log | sed -E 's/[[:space:]]*([[:digit:]]+).*/\1/'); + cat tmp.log >> "$LOG_DIR/$logname" || >tmp.log ;; esac end=$(date +%s%6N) elapsedtime=$(echo "scale=3; ($end-$start)/1000000"|bc) - echo "$tool,\"$test\",$haverace,$thread,${size:-"N/A"},${races:-0},$elapsedtime" >> "$file" + mem=$(cat $MEMLOG) + echo "$tool,$id,\"$testname\",$haverace,$thread,${size:-"N/A"},${races:-0},$elapsedtime,$mem,$compilereturn,$testreturn" >> "$file" ITER_INDEX=$((ITER_INDEX+1)) done fi @@ -274,7 +352,7 @@ for tool in "${TOOLS[@]}"; do THREAD_INDEX=$((THREAD_INDEX+1)) done TEST_INDEX=$((TEST_INDEX+1)) - if [[ -e $exname ]]; then rm "$exname"; fi + #if [[ -e $exname ]]; then rm "$exname"; fi done TOOL_INDEX=$((TOOL_INDEX+1)) done