1 /******************************************************************************
2 * OpenMP Example - Combined Parallel Loop Work-sharing - C/C++ Version
3 * FILE: omp_workshare4.c
5 * This is a corrected version of the omp_workshare3.c example. Corrections
6 * include removing all statements between the parallel for construct and
7 * the actual for loop, and introducing logic to preserve the ability to
8 * query a thread's id and print it from inside the for loop.
9 * SOURCE: Blaise Barney 5/99
10 * LAST REVISED: 03/03/2002
11 ******************************************************************************/
21 float a
[N
], b
[N
], c
[N
];
24 /* Some initializations */
26 a
[i
] = b
[i
] = i
* 1.0;
30 #pragma omp parallel for \
33 schedule(static,chunk) \
34 firstprivate(first_time)
38 if (first_time
== 'y')
40 tid
= omp_get_thread_num();
44 printf("tid= %d i= %d c[i]= %f\n", tid
, i
, c
[i
]);