diff --git a/micro-benchmarks/DRB013-nowait-orig-yes.c b/micro-benchmarks/DRB013-nowait-orig-yes.c index b9a959f..e948774 100644 --- a/micro-benchmarks/DRB013-nowait-orig-yes.c +++ b/micro-benchmarks/DRB013-nowait-orig-yes.c @@ -72,7 +72,7 @@ int main() a[i] = b + a[i]*5; #pragma omp single - error = a[9] + 1; + error = a[9] + a[len/2] + a[len-1] + 1; } printf ("error = %d\n", error); diff --git a/micro-benchmarks/DRB114-if-orig-yes.c b/micro-benchmarks/DRB114-if-orig-yes.c index c527e41..cca79fa 100644 --- a/micro-benchmarks/DRB114-if-orig-yes.c +++ b/micro-benchmarks/DRB114-if-orig-yes.c @@ -60,8 +60,7 @@ int main(int argc, char* argv[]) for (i=0;i +#include +#include +int main(int argc, char* argv[]) +{ + int i; + int len=100; + int a[100]; + + for (i=0;i #include #include +#include "signaling.h" omp_lock_t l; -int x = 1; +int x = 1, sem = 0; int main() { @@ -32,11 +33,13 @@ int main() if (tid == 0) { omp_set_lock(&l); + SIGNAL(sem); x = 0; omp_unset_lock(&l); } else if (tid == 1) { + WAIT(sem, 1); omp_set_lock(&l); omp_unset_lock(&l); x = 1; @@ -45,4 +48,4 @@ int main() } // end of parallel construct omp_destroy_lock(&l); printf("Done: x=%d\n", x); -} \ No newline at end of file +} diff --git a/micro-benchmarks/DRB201b-sync1-yes.c b/micro-benchmarks/DRB201b-sync1-yes.c new file mode 100644 index 0000000..9448a88 --- /dev/null +++ b/micro-benchmarks/DRB201b-sync1-yes.c @@ -0,0 +1,51 @@ +/* +!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! +!!! Copyright (c) 2017-20, Lawrence Livermore National Security, LLC +!!! and DataRaceBench project contributors. See the DataRaceBench/COPYRIGHT file for details. +!!! +!!! SPDX-License-Identifier: (BSD-3-Clause) +!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! + */ + +/* + * This is a program based on a dataset contributed by + * Wenhao Wu and Stephen F. Siegel @Univ. of Delaware. + + * Thread with id 1 acquires and releases the lock, but then it modifies x without holding it. + * Data race pair: size@35:7:W vs. size@42:7:W + */ + +#include +#include +#include +#include "signaling.h" + +omp_lock_t l; +int x = 1, sem = 0; + +int main() +{ + omp_init_lock(&l); +#pragma omp parallel num_threads(2) + { + int tid = omp_get_thread_num(); +#pragma omp barrier + if (tid == 0) + { + WAIT(sem, 1); + omp_set_lock(&l); + x = 0; + omp_unset_lock(&l); + } + else if (tid == 1) + { + omp_set_lock(&l); + SIGNAL(sem); + omp_unset_lock(&l); + x = 1; + } +#pragma omp barrier + } // end of parallel construct + omp_destroy_lock(&l); + printf("Done: x=%d\n", x); +}