(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.oacc-c-c++-common/
lib-9.c
       1  /* { dg-do run } */
       2  
       3  #include <stdlib.h>
       4  #include <openacc.h>
       5  
       6  int
       7  main (int argc, char **argv)
       8  {
       9    int i;
      10    int num_devices;
      11    int devnum;
      12    acc_device_t devtype = acc_device_default;
      13  
      14    num_devices = acc_get_num_devices (devtype);
      15    if (num_devices == 0)
      16      abort ();
      17  
      18    acc_init (devtype);
      19  
      20    if (num_devices != acc_get_num_devices (devtype))
      21      abort ();
      22  
      23    for (i = 0; i < num_devices; i++)
      24      {
      25        acc_set_device_num (i, devtype);
      26        devnum = acc_get_device_num (devtype);
      27        if (devnum != i)
      28  	abort ();
      29      }
      30  
      31    acc_shutdown (devtype);
      32  
      33    if (num_devices != acc_get_num_devices (devtype))
      34      abort ();
      35  
      36    for (i = 0; i < num_devices; i++)
      37      {
      38        acc_set_device_num (i, devtype);
      39        devnum = acc_get_device_num (devtype);
      40        if (devnum != i)
      41  	abort ();
      42      }
      43  
      44    acc_shutdown (devtype);
      45  
      46    acc_init (devtype);
      47  
      48    acc_set_device_num (0, devtype);
      49  
      50    devnum = acc_get_device_num (devtype);
      51    if (devnum != 0)
      52      abort ();
      53  
      54    if (num_devices > 1)
      55      {
      56        acc_set_device_num (1, (acc_device_t) 0);
      57  
      58        devnum = acc_get_device_num (devtype);
      59        if (devnum != 1)
      60  	abort ();
      61    }
      62  
      63    acc_shutdown (devtype);
      64  
      65    return 0;
      66  }
      67  
      68  /* { dg-output "" } */