target-44.c 476 B

123456789101112131415161718192021222324252627
  1. /* { dg-additional-options "-foffload-options=nvptx-none=-latomic" { target { offload_target_nvptx } } } */
  2. #include <stdlib.h>
  3. struct s
  4. {
  5. int i;
  6. };
  7. #pragma omp declare reduction(+: struct s: omp_out.i += omp_in.i)
  8. int
  9. main (void)
  10. {
  11. const int N0 = 32768;
  12. struct s counter_N0 = { 0 };
  13. #pragma omp target
  14. #pragma omp for simd reduction(+: counter_N0)
  15. for (int i0 = 0 ; i0 < N0 ; i0++ )
  16. counter_N0.i += 1;
  17. if (counter_N0.i != N0)
  18. abort ();
  19. return 0;
  20. }