1.23
2.0
main
test-branch
| Rev | Line | |
|---|
| [36a61f3] | 1 | /* A kernel for two level parallelizable loop with reduction
|
|---|
| 2 | if reduction(error) is missing, there is race condition.
|
|---|
| 3 | */
|
|---|
| 4 | #include <stdio.h>
|
|---|
| 5 | int main(int argc, char* argv[])
|
|---|
| 6 | {
|
|---|
| 7 | int i,j;
|
|---|
| 8 | float temp, error;
|
|---|
| 9 | int len=100;
|
|---|
| 10 |
|
|---|
| 11 | float u[100][100];
|
|---|
| 12 | #pragma omp parallel for private (temp,i,j)
|
|---|
| 13 | for (i = 0; i < len; i++)
|
|---|
| 14 | for (j = 0; j < len; j++)
|
|---|
| 15 | {
|
|---|
| 16 | temp = u[i][j];
|
|---|
| 17 | error = error + temp * temp;
|
|---|
| 18 | }
|
|---|
| 19 | printf ("error = %f\n", error);
|
|---|
| 20 | return 0;
|
|---|
| 21 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.