-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from jprotze/simd
- Loading branch information
Showing
8 changed files
with
276 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! | ||
!!! 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) | ||
!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! | ||
*/ | ||
|
||
/* | ||
Data race in vectorizable code | ||
Adding a fixed array element to the whole array. Data race present. | ||
Data Race Pairs, a[i]@30:5:W vs. a[64]@30:19:R | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <math.h> | ||
int main(int argc, char *argv[]) { | ||
int len = 20000; | ||
if (argc > 1) | ||
len = atoi(argv[1]); | ||
double a[len]; | ||
for (int i = 0; i < len; i++) | ||
a[i] = i; | ||
double c = M_PI; | ||
|
||
#pragma omp parallel for simd schedule(dynamic, 64) | ||
for (int i = 0; i < len; i++) | ||
a[i] = a[i] + a[64]; | ||
|
||
printf("a[0]=%f, a[%i]=%f, a[%i]=%f\n", a[0], len / 2, a[len / 2], len - 1, | ||
a[len - 1]); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! | ||
!!! Copyright (c) 17-20, Lawrence Livermore National Security, LLC | ||
!!! and DataRaceBench project contributors. See the DataRaceBench/COPYRIGHT file for details. | ||
!!! | ||
!!! SPDX-License-Identifier: (BSD-3-Clause) | ||
!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! | ||
*/ | ||
|
||
/* | ||
No data race present. | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <math.h> | ||
int main(int argc, char *argv[]) { | ||
int len = 20000; | ||
if (argc > 1) | ||
len = atoi(argv[1]); | ||
double a[len]; | ||
for (int i = 0; i < len; i++) | ||
a[i] = i; | ||
double c = M_PI; | ||
|
||
#pragma omp parallel for simd schedule(dynamic, 64) | ||
for (int i = 0; i < len; i++) | ||
a[i] = a[i] + c; | ||
|
||
printf("a[0]=%f, a[%i]=%f, a[%i]=%f\n", a[0], len / 2, a[len / 2], len - 1, | ||
a[len - 1]); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! | ||
!!! 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) | ||
!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! | ||
*/ | ||
|
||
/* | ||
Data race in vectorizable code | ||
Loop depencency with 64 element offset. Data race present. | ||
Data Race Pairs, a[i + 64]@33:5:W vs. a[i * 2]@33:17:R | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
int main(int argc, char *argv[]) { | ||
int len = 20000; | ||
|
||
if (argc > 1) | ||
len = atoi(argv[1]); | ||
double a[2 * len], b[len]; | ||
|
||
for (int i = 0; i < 2 * len; i++) | ||
a[i] = i; | ||
for (int i = 0; i < len; i++) | ||
b[i] = i + 1; | ||
|
||
#pragma omp parallel for simd schedule(dynamic, 64) | ||
for (int i = 0; i < len; i++) | ||
a[i + 64] = a[i * 2] + b[i]; | ||
|
||
printf("a[0]=%f, a[%i]=%f, a[%i]=%f\n", a[0], len / 2, a[len / 2], len - 1, | ||
a[len - 1]); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! | ||
!!! Copyright (c) 17-20, Lawrence Livermore National Security, LLC | ||
!!! and DataRaceBench project contributors. See the DataRaceBench/COPYRIGHT file for details. | ||
!!! | ||
!!! SPDX-License-Identifier: (BSD-3-Clause) | ||
!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! | ||
*/ | ||
|
||
/* | ||
No data race present. | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
int main(int argc, char *argv[]) { | ||
int len = 20000; | ||
|
||
if (argc > 1) | ||
len = atoi(argv[1]); | ||
double a[2 * len], b[len]; | ||
|
||
for (int i = 0; i < 2 * len; i++) | ||
a[i] = i; | ||
for (int i = 0; i < len; i++) | ||
b[i] = i + 1; | ||
|
||
#pragma omp parallel for simd schedule(dynamic, 64) | ||
for (int i = 0; i < len; i++) | ||
a[i * 2] = a[i * 2] + b[i]; | ||
|
||
printf("a[0]=%f, a[%i]=%f, a[%i]=%f\n", a[0], len / 2, a[len / 2], len - 1, | ||
a[len - 1]); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! | ||
!!! 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) | ||
!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! | ||
*/ | ||
|
||
/* | ||
Data race in vectorizable code | ||
Loop depencency with 64 element offset. Data race present. | ||
Data Race Pairs, a[i * 2]@33:5:W vs. a[i + 64]@33:17:R | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
int main(int argc, char *argv[]) { | ||
int len = 20000; | ||
|
||
if (argc > 1) | ||
len = atoi(argv[1]); | ||
double a[2 * len], b[len]; | ||
|
||
for (int i = 0; i < 2 * len; i++) | ||
a[i] = i; | ||
for (int i = 0; i < len; i++) | ||
b[i] = i + 1; | ||
|
||
#pragma omp parallel for simd schedule(dynamic, 64) | ||
for (int i = 0; i < len; i++) | ||
a[i * 2] = a[i + 64] + b[i]; | ||
|
||
printf("a[0]=%f, a[%i]=%f, a[%i]=%f\n", a[0], len / 2, a[len / 2], len - 1, | ||
a[len - 1]); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! | ||
!!! 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) | ||
!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! | ||
*/ | ||
|
||
/* | ||
Data race in vectorizable code | ||
Loop depencency with 64 element offset. Data race present. | ||
Data Race Pairs, a[i + 64]@34:5:W vs. a[i]@34:17:R | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
int main(int argc, char *argv[]) { | ||
int len = 20000; | ||
|
||
if (argc > 1) | ||
len = atoi(argv[1]); | ||
double a[len], b[len]; | ||
|
||
for (int i = 0; i < len; i++) { | ||
a[i] = i; | ||
b[i] = i + 1; | ||
} | ||
|
||
#pragma omp parallel for simd schedule(dynamic, 64) | ||
for (int i = 0; i < len - 64; i++) | ||
a[i + 64] = a[i] + b[i]; | ||
|
||
printf("a[0]=%f, a[%i]=%f, a[%i]=%f\n", a[0], len / 2, a[len / 2], len - 1, | ||
a[len - 1]); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! | ||
!!! Copyright (c) 17-20, Lawrence Livermore National Security, LLC | ||
!!! and DataRaceBench project contributors. See the DataRaceBench/COPYRIGHT file for details. | ||
!!! | ||
!!! SPDX-License-Identifier: (BSD-3-Clause) | ||
!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! | ||
*/ | ||
|
||
/* | ||
No data race present. | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
int main(int argc, char *argv[]) { | ||
int len = 20000; | ||
|
||
if (argc > 1) | ||
len = atoi(argv[1]); | ||
double a[len], b[len]; | ||
|
||
for (int i = 0; i < len; i++) { | ||
a[i] = i; | ||
b[i] = i + 1; | ||
} | ||
|
||
#pragma omp parallel for simd schedule(dynamic, 64) | ||
for (int i = 0; i < len; i++) | ||
a[i] = a[i] + b[i]; | ||
|
||
printf("a[0]=%f, a[%i]=%f, a[%i]=%f\n", a[0], len / 2, a[len / 2], len - 1, | ||
a[len - 1]); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters