omp_workshare3.c 1.1 KB

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