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