Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix non-deteminism in classification results #153

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion micro-benchmarks/DRB013-nowait-orig-yes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions micro-benchmarks/DRB114-if-orig-yes.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ int main(int argc, char* argv[])
for (i=0;i<len;i++)
a[i]=i;

srand(time(NULL));
#pragma omp parallel for if (rand()%2)
#pragma omp parallel for if (argc%2)
for (i=0;i<len-1;i++)
a[i+1]=a[i]+1;

Expand Down
70 changes: 70 additions & 0 deletions micro-benchmarks/DRB114b-if-orig-no.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
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: [email protected], [email protected], [email protected],
[email protected], [email protected])
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.
*/

/*
When if() evaluates to true, this program has data races due to true dependence within the loop at 65.
Without argument, (argc+1)%2 will be 0.
No data race.
*/
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main(int argc, char* argv[])
{
int i;
int len=100;
int a[100];

for (i=0;i<len;i++)
a[i]=i;

#pragma omp parallel for if ((argc+1)%2)
for (i=0;i<len-1;i++)
a[i+1]=a[i]+1;

printf("a[50]=%d\n", a[50]);
return 0;
}
7 changes: 5 additions & 2 deletions micro-benchmarks/DRB201-sync1-yes.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
#include <stdio.h>
#include <omp.h>
#include <assert.h>
#include "signaling.h"

omp_lock_t l;
int x = 1;
int x = 1, sem = 0;

int main()
{
Expand All @@ -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;
Expand All @@ -45,4 +48,4 @@ int main()
} // end of parallel construct
omp_destroy_lock(&l);
printf("Done: x=%d\n", x);
}
}
51 changes: 51 additions & 0 deletions micro-benchmarks/DRB201b-sync1-yes.c
Original file line number Diff line number Diff line change
@@ -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 <stdio.h>
#include <omp.h>
#include <assert.h>
#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);
}