0
|
1 /* { dg-do compile } */
|
|
2
|
|
3 /******************************************************************************
|
|
4 * OpenMP Example - Combined Parallel Loop Work-sharing - C/C++ Version
|
|
5 * FILE: omp_workshare3.c
|
|
6 * DESCRIPTION:
|
|
7 * This example attempts to show use of the parallel for construct. However
|
|
8 * it will generate errors at compile time. Try to determine what is causing
|
|
9 * the error. See omp_workshare4.c for a corrected version.
|
|
10 * SOURCE: Blaise Barney 5/99
|
|
11 * LAST REVISED: 03/03/2002
|
|
12 ******************************************************************************/
|
|
13
|
|
14 #include <omp.h>
|
|
15 #include <stdio.h>
|
|
16 #define N 50
|
|
17 #define CHUNKSIZE 5
|
|
18
|
111
|
19 int
|
0
|
20 main () {
|
|
21
|
|
22 int i, chunk, tid;
|
|
23 float a[N], b[N], c[N];
|
|
24
|
|
25 /* Some initializations */
|
|
26 for (i=0; i < N; i++)
|
|
27 a[i] = b[i] = i * 1.0;
|
|
28 chunk = CHUNKSIZE;
|
|
29
|
|
30 #pragma omp parallel for \
|
|
31 shared(a,b,c,chunk) \
|
|
32 private(i,tid) \
|
|
33 schedule(static,chunk)
|
|
34 { /* { dg-error "expected" } */
|
|
35 tid = omp_get_thread_num();
|
|
36 for (i=0; i < N; i++)
|
|
37 {
|
|
38 c[i] = a[i] + b[i];
|
|
39 printf("tid= %d i= %d c[i]= %f\n", tid, i, c[i]);
|
|
40 }
|
|
41 } /* end of parallel for construct */
|
|
42
|
|
43 return 0;
|
|
44 }
|