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

Several fixes for existing kernels #144

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
6 changes: 4 additions & 2 deletions micro-benchmarks/DRB013-nowait-orig-yes.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ Some threads may finish the for loop early and execute errors = dt[9]+1
while another thread may still be simultaneously executing
the for worksharing region by writing to d[9], causing data races.

Data race pair: a[i]@72:7:W vs. a[9]@75:13:R
Data race pair: a[i]@74:7:W vs. a[9]@77:13:R
Data race pair: a[i]@74:7:W vs. a[9]@77:20:R
Data race pair: a[i]@74:7:W vs. a[9]@77:31:R
*/

#include <stdio.h>
Expand All @@ -72,7 +74,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: 2 additions & 1 deletion micro-benchmarks/DRB020-privatemissing-var-yes.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
tmp should be put as private to avoid race condition
Data race pair: tmp@65:5:W vs. tmp@66:12:R
Data race pair: tmp@66:5:W vs. tmp@67:12:R
tmp@66:5:W vs. tmp@66:5:W
*/
#include <stdlib.h>
int main(int argc, char* argv[])
Expand Down
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@64:5:W vs. i@70: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@66:5:W vs. i@71: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;
}
3 changes: 2 additions & 1 deletion micro-benchmarks/DRB035-truedepscalar-orig-yes.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ THE POSSIBILITY OF SUCH DAMAGE.

/*
Loop carried true dep between tmp =.. and ..= tmp.
Data race pair: tmp@66:12:R vs. tmp@67:5:W
Data race pair: tmp@67:12:R vs. tmp@68:5:W
tmp@68:5:W vs. tmp@68:5:W
*/
#include <stdlib.h>
#include <stdio.h>
Expand Down
4 changes: 2 additions & 2 deletions micro-benchmarks/DRB036-truedepscalar-var-yes.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ THE POSSIBILITY OF SUCH DAMAGE.

/*
Loop carried true dep between tmp =.. and ..= tmp.
Data race pairs: tmp@66:12:R vs. tmp@67:5:W
tmp@67:5:W vs. tmp@67:5:W
Data race pairs: tmp@67:12:R vs. tmp@68:5:W
tmp@68:5:W vs. tmp@68:5:W
*/
#include <stdlib.h>
int main(int argc, char* argv[])
Expand Down
2 changes: 1 addition & 1 deletion micro-benchmarks/DRB065-pireduction-orig-no.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
Classic PI calculation using reduction
*/

#define num_steps 2000000000
#define num_steps 200000000

#include <stdio.h>
int main(int argc, char** argv)
Expand Down
3 changes: 2 additions & 1 deletion micro-benchmarks/DRB078-taskdep2-orig-no.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ i is shared for two tasks based on implicit data-sharing attribute rules.
*/
#include <assert.h>
#include <unistd.h>
#include "signaling.h"
int main()
{
int i=0;
Expand All @@ -58,7 +59,7 @@ int main()
{
#pragma omp task depend (out:i)
{
sleep(3);
delay(10000);
i = 1;
}
#pragma omp task depend (out:i)
Expand Down
3 changes: 2 additions & 1 deletion micro-benchmarks/DRB079-taskdep3-orig-no.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ tasks with depend clauses to ensure execution order, no data races.
#include <stdio.h>
#include <assert.h>
#include <unistd.h>
#include "signaling.h"
int main()
{
int i=0, j, k;
Expand All @@ -58,7 +59,7 @@ int main()
{
#pragma omp task depend (out:i)
{
sleep(3);
delay(10000);
i = 1;
}
#pragma omp task depend (in:i)
Expand Down
3 changes: 2 additions & 1 deletion micro-benchmarks/DRB107-taskgroup-orig-no.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
#include <stdio.h>
#include <assert.h>
#include <unistd.h>
#include "signaling.h"

int main()
{
Expand All @@ -62,7 +63,7 @@ int main()
{
#pragma omp task
{
sleep(3);
delay(10000);
result = 1;
}
}
Expand Down
5 changes: 2 additions & 3 deletions micro-benchmarks/DRB114-if-orig-yes.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ THE POSSIBILITY OF SUCH DAMAGE.

/*
When if() evaluates to true, this program has data races due to true dependence within the loop at 65.
Data race pair: a[i+1]@66:5:W vs. a[i]@66:12:R
Data race pair: a[i+1]@65:5:W vs. a[i]@65:12:R
*/
#include <stdlib.h>
#include <stdio.h>
Expand All @@ -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;
}
2 changes: 1 addition & 1 deletion micro-benchmarks/DRB116-target-teams-orig-yes.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
/*
use of omp target + teams
Without protection, master threads from two teams cause data races.
Data race pair: a@66:5:W vs. a@66:5:W
Data race pair: a[50]*@66:5:W vs. a[50]*@66:5:W
*/
int main(int argc, char* argv[])
{
Expand Down
2 changes: 1 addition & 1 deletion micro-benchmarks/DRB117-taskwait-waitonlychild-orig-yes.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
The thread encountering the taskwait directive at line 46 only waits for
its child task (line 37-44) to complete. It does not wait for its
descendant tasks (line 39-42).
Data Race Pairs, sum@47:7:W vs. sum@47:7:W
Data Race Pairs, psum[1]@41:10:W vs. psum[1]@47:13:R
*/

#include <stdio.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* The created task will access different instances of the variable x if the task is not merged,
* as x is firstprivate, but it will access the same variable x if the task is merged. It can
* print two different values for x depending on the decisions taken by the implementation.
* Data Race Pairs, x@27:5:W vs. x@27:5:W
* No data race, but implementation-specific behavior for data scoping of x, x@27:5:W
*/

#include <omp.h>
Expand Down
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
Loading