Home | History | Annotate | Download | only in OpenMP
      1 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
      2 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
      3 // RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
      4 // expected-no-diagnostics
      5 
      6 #ifndef HEADER
      7 #define HEADER
      8 
      9 void foo() {}
     10 
     11 template <class T>
     12 T tmain (T argc) {
     13   T b = argc, c, d, e, f, g;
     14   static T a;
     15   #pragma omp for ordered
     16   for (int i =0 ; i < argc; ++i)
     17   #pragma omp ordered
     18   {
     19     a=2;
     20   }
     21   #pragma omp for ordered
     22   for (int i =0 ; i < argc; ++i)
     23   #pragma omp ordered threads
     24   {
     25     a=2;
     26   }
     27   #pragma omp simd
     28   for (int i =0 ; i < argc; ++i)
     29   #pragma omp ordered simd
     30   {
     31     a=2;
     32   }
     33   #pragma omp for simd
     34   for (int i =0 ; i < argc; ++i)
     35   #pragma omp ordered simd
     36   {
     37     a=2;
     38   }
     39   #pragma omp parallel for simd
     40   for (int i =0 ; i < argc; ++i)
     41   #pragma omp ordered simd
     42   {
     43     a=2;
     44   }
     45   #pragma omp parallel for ordered(1)
     46   for (int i =0 ; i < argc; ++i) {
     47   #pragma omp ordered depend(source)
     48     a = 2;
     49   }
     50   return (0);
     51 }
     52 
     53 // CHECK: static int a;
     54 // CHECK-NEXT: #pragma omp for ordered
     55 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
     56 // CHECK-NEXT: #pragma omp ordered
     57 // CHECK-NEXT: {
     58 // CHECK-NEXT: a = 2;
     59 // CHECK-NEXT: }
     60 // CHECK-NEXT: #pragma omp for ordered
     61 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
     62 // CHECK-NEXT: #pragma omp ordered threads
     63 // CHECK-NEXT: {
     64 // CHECK-NEXT: a = 2;
     65 // CHECK-NEXT: }
     66 // CHECK-NEXT: #pragma omp simd
     67 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
     68 // CHECK-NEXT: #pragma omp ordered simd
     69 // CHECK-NEXT: {
     70 // CHECK-NEXT: a = 2;
     71 // CHECK-NEXT: }
     72 // CHECK-NEXT: #pragma omp for simd
     73 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
     74 // CHECK-NEXT: #pragma omp ordered simd
     75 // CHECK-NEXT: {
     76 // CHECK-NEXT: a = 2;
     77 // CHECK-NEXT: }
     78 // CHECK-NEXT: #pragma omp parallel for simd
     79 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
     80 // CHECK-NEXT: #pragma omp ordered simd
     81 // CHECK-NEXT: {
     82 // CHECK-NEXT: a = 2;
     83 // CHECK-NEXT: }
     84 // CHECK-NEXT: #pragma omp parallel for ordered(1)
     85 // CHECK-NEXT: for (int i = 0; i < argc; ++i) {
     86 // CHECK-NEXT: #pragma omp ordered depend(source)
     87 // CHECK-NEXT: a = 2;
     88 // CHECK-NEXT: }
     89 // CHECK: static T a;
     90 // CHECK-NEXT: #pragma omp for ordered
     91 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
     92 // CHECK-NEXT: #pragma omp ordered
     93 // CHECK-NEXT: {
     94 // CHECK-NEXT: a = 2;
     95 // CHECK-NEXT: }
     96 // CHECK-NEXT: #pragma omp for ordered
     97 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
     98 // CHECK-NEXT: #pragma omp ordered threads
     99 // CHECK-NEXT: {
    100 // CHECK-NEXT: a = 2;
    101 // CHECK-NEXT: }
    102 // CHECK-NEXT: #pragma omp simd
    103 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
    104 // CHECK-NEXT: #pragma omp ordered simd
    105 // CHECK-NEXT: {
    106 // CHECK-NEXT: a = 2;
    107 // CHECK-NEXT: }
    108 // CHECK-NEXT: #pragma omp for simd
    109 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
    110 // CHECK-NEXT: #pragma omp ordered simd
    111 // CHECK-NEXT: {
    112 // CHECK-NEXT: a = 2;
    113 // CHECK-NEXT: }
    114 // CHECK-NEXT: #pragma omp parallel for simd
    115 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
    116 // CHECK-NEXT: #pragma omp ordered simd
    117 // CHECK-NEXT: {
    118 // CHECK-NEXT: a = 2;
    119 // CHECK-NEXT: }
    120 // CHECK-NEXT: #pragma omp parallel for ordered(1)
    121 // CHECK-NEXT: for (int i = 0; i < argc; ++i) {
    122 // CHECK-NEXT: #pragma omp ordered depend(source)
    123 // CHECK-NEXT: a = 2;
    124 // CHECK-NEXT: }
    125 
    126 // CHECK-LABEL: int main(
    127 int main (int argc, char **argv) {
    128   int b = argc, c, d, e, f, g;
    129   static int a;
    130 // CHECK: static int a;
    131   #pragma omp for ordered
    132   for (int i =0 ; i < argc; ++i)
    133   #pragma omp ordered
    134   {
    135     a=2;
    136   }
    137   #pragma omp for ordered
    138   for (int i =0 ; i < argc; ++i)
    139   #pragma omp ordered threads
    140   {
    141     a=2;
    142   }
    143   #pragma omp simd
    144   for (int i =0 ; i < argc; ++i)
    145   #pragma omp ordered simd
    146   {
    147     a=2;
    148   }
    149   #pragma omp for simd
    150   for (int i =0 ; i < argc; ++i)
    151   #pragma omp ordered simd
    152   {
    153     a=2;
    154   }
    155   #pragma omp parallel for simd
    156   for (int i =0 ; i < argc; ++i)
    157   #pragma omp ordered simd
    158   {
    159     a=2;
    160   }
    161   #pragma omp parallel for ordered(1)
    162   for (int i =0 ; i < argc; ++i) {
    163   #pragma omp ordered depend(source)
    164     a = 2;
    165   }
    166 // CHECK-NEXT: #pragma omp for ordered
    167 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
    168 // CHECK-NEXT: #pragma omp ordered
    169 // CHECK-NEXT: {
    170 // CHECK-NEXT: a = 2;
    171 // CHECK-NEXT: }
    172 // CHECK-NEXT: #pragma omp for ordered
    173 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
    174 // CHECK-NEXT: #pragma omp ordered threads
    175 // CHECK-NEXT: {
    176 // CHECK-NEXT: a = 2;
    177 // CHECK-NEXT: }
    178 // CHECK-NEXT: #pragma omp simd
    179 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
    180 // CHECK-NEXT: #pragma omp ordered simd
    181 // CHECK-NEXT: {
    182 // CHECK-NEXT: a = 2;
    183 // CHECK-NEXT: }
    184 // CHECK-NEXT: #pragma omp for simd
    185 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
    186 // CHECK-NEXT: #pragma omp ordered simd
    187 // CHECK-NEXT: {
    188 // CHECK-NEXT: a = 2;
    189 // CHECK-NEXT: }
    190 // CHECK-NEXT: #pragma omp parallel for simd
    191 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
    192 // CHECK-NEXT: #pragma omp ordered simd
    193 // CHECK-NEXT: {
    194 // CHECK-NEXT: a = 2;
    195 // CHECK-NEXT: }
    196 // CHECK-NEXT: #pragma omp parallel for ordered(1)
    197 // CHECK-NEXT: for (int i = 0; i < argc; ++i) {
    198 // CHECK-NEXT: #pragma omp ordered depend(source)
    199 // CHECK-NEXT: a = 2;
    200 // CHECK-NEXT: }
    201   return tmain(argc);
    202 }
    203 
    204 #endif
    205