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

Encourage specific task schedules to reduce non-deterministic results #154

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
18 changes: 14 additions & 4 deletions micro-benchmarks/DRB027-taskdependmissing-orig-yes.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,30 @@ THE POSSIBILITY OF SUCH DAMAGE.
/*
Two tasks without depend clause to protect data writes.
i is shared for two tasks based on implicit data-sharing attribute rules.
Data race pair: i@61:5:W vs. i@63:5:W
Data race pair: i@63:5:W vs. i@67:5:W
*/
#include <assert.h>
#include <stdio.h>
#include "signaling.h"

int main()
{
int i=0;
#pragma omp parallel
int i=0, sem=0;
#pragma omp parallel shared(sem) num_threads(2)
#pragma omp single
{
#pragma omp task
i = 1;
{
i = 1;
SIGNAL(sem);
WAIT(sem,2);
}
#pragma omp task
{
i = 2;
SIGNAL(sem);
WAIT(sem,2);
}
}

printf ("i=%d\n",i);
Expand Down
79 changes: 79 additions & 0 deletions micro-benchmarks/DRB027b-taskdependmissing-orig-yes.c
Original file line number Diff line number Diff line change
@@ -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: [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.
*/

/*
Two tasks without depend clause to protect data writes.
i is shared for two tasks based on implicit data-sharing attribute rules.
Data race pair: i@63:5:W vs. i@67:5:W
*/
#include <assert.h>
#include <stdio.h>
#include "signaling.h"

int main()
{
int i=0, sem=0;
#pragma omp parallel shared(sem) num_threads(2)
{
#pragma omp masked
{
#pragma omp task
{
SIGNAL(sem);
i = 1;
}
#pragma omp task
{
SIGNAL(sem);
i = 2;
}
#pragma omp taskwait
}
WAIT(sem, 2);
}
printf ("i=%d\n",i);
return 0;
}
22 changes: 15 additions & 7 deletions micro-benchmarks/DRB131-taskdep4-orig-omp45-yes.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,30 @@
* There is no completion restraint on the second child task. Hence, immediately after the first
* taskwait it is unsafe to access the y variable since the second child task may still be
* executing.
* Data Race at y@28:2:W vs. y@34:19:R
* Data Race at y@34:4:W vs. y@42:19:R
*/

#include <stdio.h>
#include <omp.h>
#include "signaling.h"

void foo(){

int x = 0, y = 2;
int x = 0, y = 2, sem = 0;

#pragma omp task depend(inout: x) shared(x)
x++; //1st Child Task
#pragma omp task depend(inout: x) shared(x, sem)
{
SIGNAL(sem);
x++; //1st Child Task
}

#pragma omp task shared(y)
y--; // 2nd child task
#pragma omp task shared(y, sem)
{
SIGNAL(sem);
y--; // 2nd child task
}

WAIT(sem, 2);
#pragma omp task depend(in: x) if(0) // 1st taskwait
{}

Expand All @@ -37,7 +45,7 @@ void foo(){


int main(){
#pragma omp parallel
#pragma omp parallel num_threads(2)
#pragma omp single
foo();

Expand Down
57 changes: 57 additions & 0 deletions micro-benchmarks/DRB131b-taskdep4-orig-omp45-yes.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!!
!!! 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)
!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!!
*/

/*
* There is no completion restraint on the second child task. Hence, immediately after the first
* taskwait it is unsafe to access the y variable since the second child task may still be
* executing.
* Data Race at y@36:4:W vs. y@43:19:R
*/

#include <stdio.h>
#include <omp.h>
#include "signaling.h"

int sem = 0;

void foo(){

int x = 0, y = 2;

#pragma omp task depend(inout: x) shared(x, sem)
{
SIGNAL(sem);
x++; //1st Child Task
}

#pragma omp task shared(y, sem)
{
SIGNAL(sem);
y--; // 2nd child task
}

#pragma omp task depend(in: x) if(0) // 1st taskwait
{}

printf("x=%d\n",x);
printf("y=%d\n",y);
#pragma omp taskwait // 2nd taskwait
}


int main(){
#pragma omp parallel
{
#pragma omp masked
foo();
WAIT(sem, 2);
}

return 0;
}
20 changes: 14 additions & 6 deletions micro-benchmarks/DRB132-taskdep4-orig-omp45-no.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,25 @@

#include <stdio.h>
#include <omp.h>
#include "signaling.h"

void foo(){

int x = 0, y = 2;
int x = 0, y = 2, sem = 0;

#pragma omp task depend(inout: x) shared(x)
x++; //1st Child Task
#pragma omp task depend(inout: x) shared(x, sem)
{
SIGNAL(sem);
x++; //1st Child Task
}

#pragma omp task shared(y)
y--; // 2nd child task
#pragma omp task shared(y, sem)
{
SIGNAL(sem);
y--; // 2nd child task
}

WAIT(sem, 2);
#pragma omp task depend(in: x) if(0) // 1st taskwait
{}

Expand All @@ -37,7 +45,7 @@ void foo(){


int main(){
#pragma omp parallel
#pragma omp parallel num_threads(2)
#pragma omp single
foo();

Expand Down
58 changes: 58 additions & 0 deletions micro-benchmarks/DRB132b-taskdep4-orig-omp45-no.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!!
!!! 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)
!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!!
*/

/* The second taskwait ensures that the second child task has completed; hence it is safe to access
* the y variable in the following print statement.
* */


#include <stdio.h>
#include <omp.h>
#include "signaling.h"

int sem = 0;

void foo(){

int x = 0, y = 2;

#pragma omp task depend(inout: x) shared(x, sem)
{
SIGNAL(sem);
x++; //1st Child Task
}

#pragma omp task shared(y, sem)
{
SIGNAL(sem);
y--; // 2nd child task
}

#pragma omp task depend(in: x) if(0) // 1st taskwait
{}

printf("x=%d\n",x);

#pragma omp taskwait // 2nd taskwait

printf("y=%d\n",y);
}


int main(){
#pragma omp parallel
{
#pragma omp masked
foo();
WAIT(sem, 2);
}

return 0;
}

18 changes: 14 additions & 4 deletions micro-benchmarks/DRB133-taskdep5-orig-omp45-no.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,26 @@

#include <stdio.h>
#include <omp.h>
#include "signaling.h"

int sem=0;

void foo(){
int x = 0, y = 2;

#pragma omp task depend(inout: x) shared(x)
#pragma omp task depend(inout: x) shared(x, sem)
{
SIGNAL(sem);
x++; // 1st child task
}

#pragma omp task depend(in: x) depend(inout: y) shared(x, y)
y = y-x; //2nd child task
#pragma omp task depend(in: x) depend(inout: y) shared(x, y, sem)
{
SIGNAL(sem);
y -= x; //2nd child task
}

WAIT(sem, 2);
#pragma omp task depend(in: x) if(0) // 1st taskwait
{}

Expand All @@ -38,7 +48,7 @@ void foo(){
}

int main(){
#pragma omp parallel
#pragma omp parallel num_threads(2)
#pragma omp single
foo();

Expand Down
Loading