// RUN: mlir-opt %s | mlir-opt | FileCheck %s func @omp_barrier() -> () { // CHECK: omp.barrier omp.barrier return } func @omp_master() -> () { // CHECK: omp.master omp.master { // CHECK: omp.terminator omp.terminator } return } func @omp_taskwait() -> () { // CHECK: omp.taskwait omp.taskwait return } func @omp_taskyield() -> () { // CHECK: omp.taskyield omp.taskyield return } // CHECK-LABEL: func @omp_flush // CHECK-SAME: ([[ARG0:%.*]]: !llvm.i32) { func @omp_flush(%arg0 : !llvm.i32) -> () { // Test without data var // CHECK: omp.flush omp.flush // Test with one data var // CHECK: omp.flush([[ARG0]] : !llvm.i32) omp.flush(%arg0 : !llvm.i32) // Test with two data var // CHECK: omp.flush([[ARG0]], [[ARG0]] : !llvm.i32, !llvm.i32) omp.flush(%arg0, %arg0: !llvm.i32, !llvm.i32) return } func @omp_terminator() -> () { // CHECK: omp.terminator omp.terminator } func @omp_parallel(%data_var : memref, %if_cond : i1, %num_threads : si32) -> () { // CHECK: omp.parallel if(%{{.*}}) num_threads(%{{.*}} : si32) private(%{{.*}} : memref) firstprivate(%{{.*}} : memref) shared(%{{.*}} : memref) copyin(%{{.*}} : memref) allocate(%{{.*}} : memref -> %{{.*}} : memref) "omp.parallel" (%if_cond, %num_threads, %data_var, %data_var, %data_var, %data_var, %data_var, %data_var) ({ // test without if condition // CHECK: omp.parallel num_threads(%{{.*}} : si32) private(%{{.*}} : memref) firstprivate(%{{.*}} : memref) shared(%{{.*}} : memref) copyin(%{{.*}} : memref) allocate(%{{.*}} : memref -> %{{.*}} : memref) "omp.parallel"(%num_threads, %data_var, %data_var, %data_var, %data_var, %data_var, %data_var) ({ omp.terminator }) {operand_segment_sizes = dense<[0,1,1,1,1,1,1,1]>: vector<8xi32>, default_val = "defshared"} : (si32, memref, memref, memref, memref, memref, memref) -> () // CHECK: omp.barrier omp.barrier // test without num_threads // CHECK: omp.parallel if(%{{.*}}) private(%{{.*}} : memref) firstprivate(%{{.*}} : memref) shared(%{{.*}} : memref) copyin(%{{.*}} : memref) allocate(%{{.*}} : memref -> %{{.*}} : memref) "omp.parallel"(%if_cond, %data_var, %data_var, %data_var, %data_var, %data_var, %data_var) ({ omp.terminator }) {operand_segment_sizes = dense<[1,0,1,1,1,1,1,1]> : vector<8xi32>} : (i1, memref, memref, memref, memref, memref, memref) -> () // test without allocate // CHECK: omp.parallel if(%{{.*}}) num_threads(%{{.*}} : si32) private(%{{.*}} : memref) firstprivate(%{{.*}} : memref) shared(%{{.*}} : memref) copyin(%{{.*}} : memref) "omp.parallel"(%if_cond, %num_threads, %data_var, %data_var, %data_var, %data_var) ({ omp.terminator }) {operand_segment_sizes = dense<[1,1,1,1,1,1,0,0]> : vector<8xi32>} : (i1, si32, memref, memref, memref, memref) -> () omp.terminator }) {operand_segment_sizes = dense<[1,1,1,1,1,1,1,1]> : vector<8xi32>, proc_bind_val = "spread"} : (i1, si32, memref, memref, memref, memref, memref, memref) -> () // test with multiple parameters for single variadic argument // CHECK: omp.parallel private(%{{.*}} : memref) firstprivate(%{{.*}} : memref, %{{.*}} : memref) shared(%{{.*}} : memref) copyin(%{{.*}} : memref) allocate(%{{.*}} : memref -> %{{.*}} : memref) "omp.parallel" (%data_var, %data_var, %data_var, %data_var, %data_var, %data_var, %data_var) ({ omp.terminator }) {operand_segment_sizes = dense<[0,0,1,2,1,1,1,1]> : vector<8xi32>} : (memref, memref, memref, memref, memref, memref, memref) -> () return } func @omp_parallel_pretty(%data_var : memref, %if_cond : i1, %num_threads : si32, %allocator : si32) -> () { // CHECK: omp.parallel omp.parallel { omp.terminator } // CHECK: omp.parallel num_threads(%{{.*}} : si32) omp.parallel num_threads(%num_threads : si32) { omp.terminator } // CHECK: omp.parallel allocate(%{{.*}} : memref -> %{{.*}} : memref) omp.parallel allocate(%data_var : memref -> %data_var : memref) { omp.terminator } // CHECK: omp.parallel private(%{{.*}} : memref, %{{.*}} : memref) firstprivate(%{{.*}} : memref) omp.parallel private(%data_var : memref, %data_var : memref) firstprivate(%data_var : memref) { omp.terminator } // CHECK omp.parallel shared(%{{.*}} : memref) copyin(%{{.*}} : memref, %{{.*}} : memref) omp.parallel shared(%data_var : memref) copyin(%data_var : memref, %data_var : memref) { omp.parallel if(%if_cond: i1) { omp.terminator } omp.terminator } // CHECK omp.parallel if(%{{.*}}) num_threads(%{{.*}} : si32) private(%{{.*}} : memref) proc_bind(close) omp.parallel num_threads(%num_threads : si32) if(%if_cond: i1) private(%data_var : memref) proc_bind(close) { omp.terminator } return } func @omp_wsloop(%lb : index, %ub : index, %step : index, %data_var : memref, %linear_var : si32, %chunk_var : si32) -> () { // CHECK: "omp.wsloop"(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) "omp.wsloop" (%lb, %ub, %step, %data_var) ({ omp.yield }) {operand_segment_sizes = dense<[1,1,1,1,0,0,0,0,0]> : vector<9xi32>, collapse_val = 2, ordered_val = 1} : (index, index, index, memref) -> () // CHECK: "omp.wsloop"(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) "omp.wsloop" (%lb, %lb, %ub, %ub, %step, %step, %data_var) ({ omp.yield }) {operand_segment_sizes = dense<[2,2,2,1,0,0,0,0,0]> : vector<9xi32>, collapse_val = 2, ordered_val = 1} : (index, index, index, index, index, index, memref) -> () // CHECK: "omp.wsloop"(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) "omp.wsloop" (%lb, %ub, %step, %data_var, %linear_var) ({ omp.yield }) {operand_segment_sizes = dense<[1,1,1,0,0,0,1,1,0]> : vector<9xi32>, schedule_val = "Static"} : (index, index, index, memref, si32) -> () // CHECK: "omp.wsloop"(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) "omp.wsloop" (%lb, %ub, %step, %data_var, %data_var, %data_var, %data_var, %linear_var, %chunk_var) ({ omp.yield }) {operand_segment_sizes = dense<[1,1,1,1,1,1,1,1,1]> : vector<9xi32>, schedule_val = "Dynamic", collapse_val = 3, ordered_val = 2} : (index, index, index, memref, memref, memref, memref, si32, si32) -> () // CHECK: "omp.wsloop"(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) "omp.wsloop" (%lb, %ub, %step, %data_var) ({ omp.yield }) {operand_segment_sizes = dense<[1,1,1,1,0,0,0,0,0]> : vector<9xi32>, nowait, schedule_val = "Auto"} : (index, index, index, memref) -> () return }