summaryrefslogtreecommitdiff
path: root/mlir/test
diff options
context:
space:
mode:
authorValentin Clement <clementval@gmail.com>2023-05-17 11:11:42 -0700
committerValentin Clement <clementval@gmail.com>2023-05-17 11:18:30 -0700
commit8497dfdf5f35cc9c2f0e74762b34873eb3b1022d (patch)
tree8c85238b5ce69a332a0a7c167629badeca6d65b4 /mlir/test
parent0457f506fddf47cfe842b398c7f522057cef8163 (diff)
downloadllvm-8497dfdf5f35cc9c2f0e74762b34873eb3b1022d.tar.gz
[mlir][openacc] Add firstprivate representation
Add a representation for firstprivate clause modeled on the private representation added in D150622. The firstprivate recipe operation has an additional mandatory region representing a sequences of operations needed to copy the initial value to the created private copy. Depends on D150622 Reviewed By: razvanlupusoru Differential Revision: https://reviews.llvm.org/D150729
Diffstat (limited to 'mlir/test')
-rw-r--r--mlir/test/Dialect/OpenACC/invalid.mlir91
1 files changed, 91 insertions, 0 deletions
diff --git a/mlir/test/Dialect/OpenACC/invalid.mlir b/mlir/test/Dialect/OpenACC/invalid.mlir
index 257435c9c4c7..02ddae197b46 100644
--- a/mlir/test/Dialect/OpenACC/invalid.mlir
+++ b/mlir/test/Dialect/OpenACC/invalid.mlir
@@ -303,3 +303,94 @@ acc.private.recipe @privatization_i32 : !llvm.ptr<i32> init {
^bb0(%arg0 : f32):
"test.openacc_dummy_op"(%arg0) : (f32) -> ()
}
+
+// -----
+
+// expected-error@+1 {{expects non-empty init region}}
+acc.firstprivate.recipe @privatization_i32 : !llvm.ptr<i32> init {
+} copy {}
+
+// -----
+
+// expected-error@+1 {{expects init region with one argument of the privatization type}}
+acc.firstprivate.recipe @privatization_i32 : !llvm.ptr<i32> init {
+^bb0(%arg0 : !llvm.ptr<f32>):
+ %c1 = arith.constant 1 : i32
+ %c0 = arith.constant 0 : i32
+ %0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr<i32>
+ llvm.store %c0, %0 : !llvm.ptr<i32>
+ acc.yield %0 : !llvm.ptr<i32>
+} copy {}
+
+// -----
+
+// expected-error@+1 {{expects init region to yield a value of the privatization type}}
+acc.firstprivate.recipe @privatization_i32 : !llvm.ptr<f32> init {
+^bb0(%arg0 : !llvm.ptr<f32>):
+ %c1 = arith.constant 1 : i32
+ %c0 = arith.constant 0 : i32
+ %0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr<i32>
+ llvm.store %c0, %0 : !llvm.ptr<i32>
+ acc.yield %0 : !llvm.ptr<i32>
+} copy {}
+
+// -----
+
+// expected-error@+1 {{expects non-empty copy region}}
+acc.firstprivate.recipe @privatization_i32 : !llvm.ptr<i32> init {
+^bb0(%arg0 : !llvm.ptr<i32>):
+ %c1 = arith.constant 1 : i32
+ %c0 = arith.constant 0 : i32
+ %0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr<i32>
+ llvm.store %c0, %0 : !llvm.ptr<i32>
+ acc.yield %0 : !llvm.ptr<i32>
+} copy {
+}
+
+// -----
+
+// expected-error@+1 {{expects copy region with two arguments of the privatization type}}
+acc.firstprivate.recipe @privatization_i32 : !llvm.ptr<i32> init {
+^bb0(%arg0 : !llvm.ptr<i32>):
+ %c1 = arith.constant 1 : i32
+ %c0 = arith.constant 0 : i32
+ %0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr<i32>
+ llvm.store %c0, %0 : !llvm.ptr<i32>
+ acc.yield %0 : !llvm.ptr<i32>
+} copy {
+^bb0(%arg0 : f32):
+ "test.openacc_dummy_op"(%arg0) : (f32) -> ()
+}
+
+// -----
+
+// expected-error@+1 {{expects copy region with two arguments of the privatization type}}
+acc.firstprivate.recipe @privatization_i32 : !llvm.ptr<i32> init {
+^bb0(%arg0 : !llvm.ptr<i32>):
+ %c1 = arith.constant 1 : i32
+ %c0 = arith.constant 0 : i32
+ %0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr<i32>
+ llvm.store %c0, %0 : !llvm.ptr<i32>
+ acc.yield %0 : !llvm.ptr<i32>
+} copy {
+^bb0(%arg0 : f32, %arg1 : i32):
+ "test.openacc_dummy_op"(%arg0) : (f32) -> ()
+}
+
+// -----
+
+// expected-error@+1 {{destroy region with one argument of the privatization type}}
+acc.firstprivate.recipe @privatization_i32 : i32 init {
+^bb0(%arg0 : i32):
+ %0 = arith.constant 1 : i32
+ acc.yield %0 : i32
+} copy {
+^bb0(%arg0 : i32, %arg1 : !llvm.ptr<i32>):
+ llvm.store %arg0, %arg1 : !llvm.ptr<i32>
+ acc.yield
+} destroy {
+^bb0(%arg0 : f32):
+ acc.yield
+}
+
+