testsuite/libgomp.c/omp_workshare3.c

Go to the documentation of this file.
00001 /* { dg-do compile } */
00002 
00003 /******************************************************************************
00004 * OpenMP Example - Combined Parallel Loop Work-sharing - C/C++ Version
00005 * FILE: omp_workshare3.c
00006 * DESCRIPTION:
00007 *   This example attempts to show use of the parallel for construct.  However
00008 *   it will generate errors at compile time.  Try to determine what is causing
00009 *   the error.  See omp_workshare4.c for a corrected version.
00010 * SOURCE: Blaise Barney  5/99
00011 * LAST REVISED: 03/03/2002
00012 ******************************************************************************/
00013 
00014 #include <omp.h>
00015 #include <stdio.h>
00016 #define N       50
00017 #define CHUNKSIZE   5
00018 
00019 main ()  {
00020 
00021 int i, chunk, tid;
00022 float a[N], b[N], c[N];
00023 
00024 /* Some initializations */
00025 for (i=0; i < N; i++)
00026   a[i] = b[i] = i * 1.0;
00027 chunk = CHUNKSIZE;
00028 
00029 #pragma omp parallel for     \
00030   shared(a,b,c,chunk)            \
00031   private(i,tid)             \
00032   schedule(static,chunk)
00033   {             /* { dg-error "expected" } */
00034   tid = omp_get_thread_num();
00035   for (i=0; i < N; i++)
00036     {
00037     c[i] = a[i] + b[i];
00038     printf("tid= %d i= %d c[i]= %f\n", tid, i, c[i]);
00039     }
00040   }  /* end of parallel for construct */
00041 
00042   return 0;
00043 }

Generated on Fri Apr 5 05:38:10 2013 for Libgomp by  doxygen 1.4.7