(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.oacc-c-c++-common/
reduction-3.c
       1  /* { dg-do run } */
       2  
       3  /* double reductions.  */
       4  
       5  #include <stdlib.h>
       6  #include "reduction.h"
       7  
       8  #define ng 8
       9  #define nw 4
      10  #define vl 32
      11  
      12  static void
      13  test_reductions (void)
      14  {
      15    const int n = 10;
      16    int i;
      17    double array[n];
      18  
      19    for (i = 0; i < n; i++)
      20      array[i] = i+1;
      21  
      22    /* Gang reductions.  */
      23    check_reduction_op (double, +, 0, array[i], num_gangs (ng), gang);
      24    check_reduction_op (double, *, 1, array[i], num_gangs (ng), gang);
      25  
      26    /* Worker reductions.  */
      27    check_reduction_op (double, +, 0, array[i], num_workers (nw), worker);
      28    check_reduction_op (double, *, 1, array[i], num_workers (nw), worker);
      29  
      30    /* Vector reductions.  */
      31    check_reduction_op (double, +, 0, array[i], vector_length (vl), vector);
      32    check_reduction_op (double, *, 1, array[i], vector_length (vl), vector);
      33  
      34    /* Combined reductions.  */
      35    check_reduction_op (double, +, 0, array[i], num_gangs (ng)  num_workers (nw)
      36  		      vector_length (vl), gang worker vector);
      37    check_reduction_op (double, *, 1, array[i], num_gangs (ng)  num_workers (nw)
      38  		      vector_length (vl), gang worker vector);
      39  }
      40  
      41  static void
      42  test_reductions_minmax (void)
      43  {
      44    const int n = 1000;
      45    int i;
      46    double array[n];
      47  
      48    for (i = 0; i < n; i++)
      49      array[i] = i;
      50  
      51    /* Gang reductions.  */
      52    check_reduction_macro (double, min, n + 1, array[i], num_gangs (ng), gang);
      53    check_reduction_macro (double, max, -1, array[i], num_gangs (ng), gang);
      54  
      55    /* Worker reductions.  */
      56    check_reduction_macro (double, min, n + 1, array[i], num_workers (nw),
      57  			 worker);
      58    check_reduction_macro (double, max, -1, array[i], num_workers (nw), worker);
      59  
      60    /* Vector reductions.  */
      61    check_reduction_macro (double, min, n + 1, array[i], vector_length (vl),
      62  			 vector);
      63    check_reduction_macro (double, max, -1, array[i], vector_length (vl),
      64  			 vector);
      65  
      66    /* Combined reductions.  */
      67    check_reduction_macro (double, min, n + 1, array[i], num_gangs (ng)
      68  			 num_workers (nw) vector_length (vl), gang worker
      69  			 vector);
      70    check_reduction_macro (double, max, -1, array[i], num_gangs (ng)
      71  			 num_workers (nw) vector_length (vl), gang worker
      72  			 vector);
      73  }
      74  
      75  int
      76  main (void)
      77  {
      78    test_reductions ();
      79    test_reductions_minmax ();
      80    return 0;
      81  }