1// RUN: mlir-opt %s | mlir-opt | FileCheck %s 2 3func @omp_barrier() -> () { 4 // CHECK: omp.barrier 5 omp.barrier 6 return 7} 8 9func @omp_master() -> () { 10 // CHECK: omp.master 11 omp.master { 12 // CHECK: omp.terminator 13 omp.terminator 14 } 15 16 return 17} 18 19func @omp_taskwait() -> () { 20 // CHECK: omp.taskwait 21 omp.taskwait 22 return 23} 24 25func @omp_taskyield() -> () { 26 // CHECK: omp.taskyield 27 omp.taskyield 28 return 29} 30 31// CHECK-LABEL: func @omp_flush 32// CHECK-SAME: ([[ARG0:%.*]]: !llvm.i32) { 33func @omp_flush(%arg0 : !llvm.i32) -> () { 34 // Test without data var 35 // CHECK: omp.flush 36 omp.flush 37 38 // Test with one data var 39 // CHECK: omp.flush([[ARG0]] : !llvm.i32) 40 omp.flush(%arg0 : !llvm.i32) 41 42 // Test with two data var 43 // CHECK: omp.flush([[ARG0]], [[ARG0]] : !llvm.i32, !llvm.i32) 44 omp.flush(%arg0, %arg0: !llvm.i32, !llvm.i32) 45 46 return 47} 48 49func @omp_terminator() -> () { 50 // CHECK: omp.terminator 51 omp.terminator 52} 53 54func @omp_parallel(%data_var : memref<i32>, %if_cond : i1, %num_threads : si32) -> () { 55 // CHECK: omp.parallel if(%{{.*}}) num_threads(%{{.*}} : si32) private(%{{.*}} : memref<i32>) firstprivate(%{{.*}} : memref<i32>) shared(%{{.*}} : memref<i32>) copyin(%{{.*}} : memref<i32>) allocate(%{{.*}} : memref<i32> -> %{{.*}} : memref<i32>) 56 "omp.parallel" (%if_cond, %num_threads, %data_var, %data_var, %data_var, %data_var, %data_var, %data_var) ({ 57 58 // test without if condition 59 // CHECK: omp.parallel num_threads(%{{.*}} : si32) private(%{{.*}} : memref<i32>) firstprivate(%{{.*}} : memref<i32>) shared(%{{.*}} : memref<i32>) copyin(%{{.*}} : memref<i32>) allocate(%{{.*}} : memref<i32> -> %{{.*}} : memref<i32>) 60 "omp.parallel"(%num_threads, %data_var, %data_var, %data_var, %data_var, %data_var, %data_var) ({ 61 omp.terminator 62 }) {operand_segment_sizes = dense<[0,1,1,1,1,1,1,1]>: vector<8xi32>, default_val = "defshared"} : (si32, memref<i32>, memref<i32>, memref<i32>, memref<i32>, memref<i32>, memref<i32>) -> () 63 64 // CHECK: omp.barrier 65 omp.barrier 66 67 // test without num_threads 68 // CHECK: omp.parallel if(%{{.*}}) private(%{{.*}} : memref<i32>) firstprivate(%{{.*}} : memref<i32>) shared(%{{.*}} : memref<i32>) copyin(%{{.*}} : memref<i32>) allocate(%{{.*}} : memref<i32> -> %{{.*}} : memref<i32>) 69 "omp.parallel"(%if_cond, %data_var, %data_var, %data_var, %data_var, %data_var, %data_var) ({ 70 omp.terminator 71 }) {operand_segment_sizes = dense<[1,0,1,1,1,1,1,1]> : vector<8xi32>} : (i1, memref<i32>, memref<i32>, memref<i32>, memref<i32>, memref<i32>, memref<i32>) -> () 72 73 // test without allocate 74 // CHECK: omp.parallel if(%{{.*}}) num_threads(%{{.*}} : si32) private(%{{.*}} : memref<i32>) firstprivate(%{{.*}} : memref<i32>) shared(%{{.*}} : memref<i32>) copyin(%{{.*}} : memref<i32>) 75 "omp.parallel"(%if_cond, %num_threads, %data_var, %data_var, %data_var, %data_var) ({ 76 omp.terminator 77 }) {operand_segment_sizes = dense<[1,1,1,1,1,1,0,0]> : vector<8xi32>} : (i1, si32, memref<i32>, memref<i32>, memref<i32>, memref<i32>) -> () 78 79 omp.terminator 80 }) {operand_segment_sizes = dense<[1,1,1,1,1,1,1,1]> : vector<8xi32>, proc_bind_val = "spread"} : (i1, si32, memref<i32>, memref<i32>, memref<i32>, memref<i32>, memref<i32>, memref<i32>) -> () 81 82 // test with multiple parameters for single variadic argument 83 // CHECK: omp.parallel private(%{{.*}} : memref<i32>) firstprivate(%{{.*}} : memref<i32>, %{{.*}} : memref<i32>) shared(%{{.*}} : memref<i32>) copyin(%{{.*}} : memref<i32>) allocate(%{{.*}} : memref<i32> -> %{{.*}} : memref<i32>) 84 "omp.parallel" (%data_var, %data_var, %data_var, %data_var, %data_var, %data_var, %data_var) ({ 85 omp.terminator 86 }) {operand_segment_sizes = dense<[0,0,1,2,1,1,1,1]> : vector<8xi32>} : (memref<i32>, memref<i32>, memref<i32>, memref<i32>, memref<i32>, memref<i32>, memref<i32>) -> () 87 88 return 89} 90 91func @omp_parallel_pretty(%data_var : memref<i32>, %if_cond : i1, %num_threads : si32, %allocator : si32) -> () { 92 // CHECK: omp.parallel 93 omp.parallel { 94 omp.terminator 95 } 96 97 // CHECK: omp.parallel num_threads(%{{.*}} : si32) 98 omp.parallel num_threads(%num_threads : si32) { 99 omp.terminator 100 } 101 102 // CHECK: omp.parallel allocate(%{{.*}} : memref<i32> -> %{{.*}} : memref<i32>) 103 omp.parallel allocate(%data_var : memref<i32> -> %data_var : memref<i32>) { 104 omp.terminator 105 } 106 107 // CHECK: omp.parallel private(%{{.*}} : memref<i32>, %{{.*}} : memref<i32>) firstprivate(%{{.*}} : memref<i32>) 108 omp.parallel private(%data_var : memref<i32>, %data_var : memref<i32>) firstprivate(%data_var : memref<i32>) { 109 omp.terminator 110 } 111 112 // CHECK omp.parallel shared(%{{.*}} : memref<i32>) copyin(%{{.*}} : memref<i32>, %{{.*}} : memref<i32>) 113 omp.parallel shared(%data_var : memref<i32>) copyin(%data_var : memref<i32>, %data_var : memref<i32>) { 114 omp.parallel if(%if_cond: i1) { 115 omp.terminator 116 } 117 omp.terminator 118 } 119 120 // CHECK omp.parallel if(%{{.*}}) num_threads(%{{.*}} : si32) private(%{{.*}} : memref<i32>) proc_bind(close) 121 omp.parallel num_threads(%num_threads : si32) if(%if_cond: i1) 122 private(%data_var : memref<i32>) proc_bind(close) { 123 omp.terminator 124 } 125 126 return 127} 128 129func @omp_wsloop(%lb : index, %ub : index, %step : index, 130 %data_var : memref<i32>, %linear_var : si32, %chunk_var : si32) -> () { 131 132 // CHECK: "omp.wsloop"(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) 133 "omp.wsloop" (%lb, %ub, %step, %data_var) ({ 134 omp.yield 135 }) {operand_segment_sizes = dense<[1,1,1,1,0,0,0,0,0]> : vector<9xi32>, collapse_val = 2, ordered_val = 1} : 136 (index, index, index, memref<i32>) -> () 137 138 // CHECK: "omp.wsloop"(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) 139 "omp.wsloop" (%lb, %lb, %ub, %ub, %step, %step, %data_var) ({ 140 omp.yield 141 }) {operand_segment_sizes = dense<[2,2,2,1,0,0,0,0,0]> : vector<9xi32>, collapse_val = 2, ordered_val = 1} : 142 (index, index, index, index, index, index, memref<i32>) -> () 143 144 145 // CHECK: "omp.wsloop"(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) 146 "omp.wsloop" (%lb, %ub, %step, %data_var, %linear_var) ({ 147 omp.yield 148 }) {operand_segment_sizes = dense<[1,1,1,0,0,0,1,1,0]> : vector<9xi32>, schedule_val = "Static"} : 149 (index, index, index, memref<i32>, si32) -> () 150 151 // CHECK: "omp.wsloop"(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) 152 "omp.wsloop" (%lb, %ub, %step, %data_var, %data_var, %data_var, %data_var, %linear_var, %chunk_var) ({ 153 omp.yield 154 }) {operand_segment_sizes = dense<[1,1,1,1,1,1,1,1,1]> : vector<9xi32>, schedule_val = "Dynamic", collapse_val = 3, ordered_val = 2} : 155 (index, index, index, memref<i32>, memref<i32>, memref<i32>, memref<i32>, si32, si32) -> () 156 157 // CHECK: "omp.wsloop"(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) 158 "omp.wsloop" (%lb, %ub, %step, %data_var) ({ 159 omp.yield 160 }) {operand_segment_sizes = dense<[1,1,1,1,0,0,0,0,0]> : vector<9xi32>, nowait, schedule_val = "Auto"} : 161 (index, index, index, memref<i32>) -> () 162 163 164 return 165} 166