(root)/
gcc-13.2.0/
gcc/
testsuite/
c-c++-common/
gomp/
target-device-ancestor-2.c
       1  /* { dg-do compile } */
       2  
       3  #pragma omp requires reverse_offload
       4  
       5  void
       6  foo (int n)
       7  {
       8    #pragma omp target device (ancestor: 1)
       9    ;
      10  
      11  
      12    /* Ensure that the integer expression in the 'device' clause for
      13       device-modifier 'ancestor' evaluates to '1' in case of a constant.  */
      14  
      15    #pragma omp target device (ancestor : 1)
      16    ;
      17    #pragma omp target device (ancestor : 42) /* { dg-error "the 'device' clause expression must evaluate to '1'" } */
      18    ;
      19  
      20    #pragma omp target device (ancestor : n)
      21    ;
      22    #pragma omp target device (ancestor : n + 1)
      23    ;
      24  
      25  
      26    /* Ensure that only one 'device' clause appears on the construct.  */
      27  
      28    #pragma omp target device (17) device (42) /* { dg-error "too many 'device' clauses" } */
      29    ;
      30  
      31  
      32    /* Ensure that with 'ancestor' only the 'device', 'firstprivate', 'private',
      33       'defaultmap', and 'map' clauses appear on the construct.  */
      34  
      35    #pragma omp target nowait device (ancestor: 1) /* { dg-error "with 'ancestor', only the 'device', 'firstprivate', 'private', 'defaultmap', and 'map' clauses may appear on the construct" } */
      36    ;
      37    #pragma omp target device (ancestor: 1) nowait /* { dg-error "with 'ancestor', only the 'device', 'firstprivate', 'private', 'defaultmap', and 'map' clauses may appear on the construct" } */
      38    ;
      39    #pragma omp target nowait device (42)
      40    ;
      41    #pragma omp target nowait device (device_num: 42)
      42    ;
      43  
      44    int a = 0, b = 0, c = 0;
      45    #pragma omp target device (ancestor: 1) firstprivate (a) private (b) defaultmap (none) map (c)
      46    ;
      47  
      48  
      49    /* Ensure that 'ancestor' is only used with 'target' constructs (not with
      50       'target data', 'target update' etc.).  */
      51  
      52    #pragma omp target data map (a) device (ancestor: 1) /* { dg-error "'device' clause with 'ancestor' is only allowed on 'target' construct" } */
      53    ;
      54    #pragma omp target enter data map (to: a) device (ancestor: 1) /* { dg-error "'device' clause with 'ancestor' is only allowed on 'target' construct" } */
      55    #pragma omp target exit data map (from: a) device (ancestor: 1) /* { dg-error "'device' clause with 'ancestor' is only allowed on 'target' construct" } */
      56    #pragma omp target update to (a) device (ancestor: 1) /* { dg-error "'device' clause with 'ancestor' is only allowed on 'target' construct" "" { target *-*-* } } */
      57  
      58  
      59    /* Ensure that no OpenMP constructs appear inside target regions with 
      60       'ancestor'.  */
      61  
      62    #pragma omp target device (ancestor: 1)
      63      {
      64        #pragma omp teams /* { dg-error "OpenMP constructs are not allowed in target region with 'ancestor'" } */
      65        ;
      66      }
      67  
      68    #pragma omp target device (device_num: 1) 
      69      {
      70        #pragma omp teams
      71        ;
      72      }
      73  
      74    #pragma omp target device (1) 
      75      {
      76        #pragma omp teams
      77        ;
      78      }
      79  
      80  }