gcc/
[official-gcc.git] / libgomp / testsuite / libgomp.c / omp_workshare3.c
blob4c55f13d58d1e59fabcb260aec6dff6bde2c55a4
1 /* { dg-do compile } */
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 ******************************************************************************/
14 #include <omp.h>
15 #include <stdio.h>
16 #define N 50
17 #define CHUNKSIZE 5
19 int
20 main () {
22 int i, chunk, tid;
23 float a[N], b[N], c[N];
25 /* Some initializations */
26 for (i=0; i < N; i++)
27 a[i] = b[i] = i * 1.0;
28 chunk = CHUNKSIZE;
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++)
38 c[i] = a[i] + b[i];
39 printf("tid= %d i= %d c[i]= %f\n", tid, i, c[i]);
41 } /* end of parallel for construct */
43 return 0;