1.23
2.0
acw/focus-triggers
main
test-branch
| Line | |
|---|
| 1 | // using variable-length array in C99
|
|---|
| 2 | // Avoid dynamic allocated arrays, which introduces pointers , bad for static analysis tools
|
|---|
| 3 | #include <stdlib.h>
|
|---|
| 4 | int main(int argc,char *argv[])
|
|---|
| 5 | {
|
|---|
| 6 | int i, j;
|
|---|
| 7 | int len = 20;
|
|---|
| 8 |
|
|---|
| 9 | if (argc>1)
|
|---|
| 10 | len = atoi(argv[1]);
|
|---|
| 11 |
|
|---|
| 12 | double a[len][len];
|
|---|
| 13 |
|
|---|
| 14 | for (i=0; i< len; i++)
|
|---|
| 15 | for (j=0; j<len; j++)
|
|---|
| 16 | a[i][j] = 0.5;
|
|---|
| 17 |
|
|---|
| 18 | #pragma omp parallel for
|
|---|
| 19 | for (i = 0; i < len - 1; i += 1) {
|
|---|
| 20 | for (j = 0; j < len ; j += 1) {
|
|---|
| 21 | a[i][j] += a[i + 1][j];
|
|---|
| 22 | }
|
|---|
| 23 | }
|
|---|
| 24 | return 0;
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.