1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
// RUN: mlir-translate -mlir-to-llvmir %s -split-input-file -verify-diagnostics
// Checking translation when the update is carried out by using more than one op
// in the region.
llvm.func @omp_atomic_update_multiple_step_update(%x: !llvm.ptr<i32>, %expr: i32) {
// expected-error @+2 {{exactly two operations are allowed inside an atomic update region while lowering to LLVM IR}}
// expected-error @+1 {{LLVM Translation failed for operation: omp.atomic.update}}
omp.atomic.update %x : !llvm.ptr<i32> {
^bb0(%xval: i32):
%t1 = llvm.mul %xval, %expr : i32
%t2 = llvm.sdiv %t1, %expr : i32
%newval = llvm.add %xval, %t2 : i32
omp.yield(%newval : i32)
}
llvm.return
}
// -----
// Checking translation when the captured variable is not used in the inner
// update operation
llvm.func @omp_atomic_update_multiple_step_update(%x: !llvm.ptr<i32>, %expr: i32) {
// expected-error @+2 {{the update operation inside the region must be a binary operation and that update operation must have the region argument as an operand}}
// expected-error @+1 {{LLVM Translation failed for operation: omp.atomic.update}}
omp.atomic.update %x : !llvm.ptr<i32> {
^bb0(%xval: i32):
%newval = llvm.mul %expr, %expr : i32
omp.yield(%newval : i32)
}
llvm.return
}
// -----
// Checking translation when the update is carried out by using more than one
// operations in the atomic capture region.
llvm.func @omp_atomic_update_multiple_step_update(%x: !llvm.ptr<i32>, %v: !llvm.ptr<i32>, %expr: i32) {
// expected-error @+1 {{LLVM Translation failed for operation: omp.atomic.capture}}
omp.atomic.capture memory_order(seq_cst) {
omp.atomic.read %v = %x : !llvm.ptr<i32>, i32
// expected-error @+1 {{the update operation inside the region must be a binary operation and that update operation must have the region argument as an operand}}
omp.atomic.update %x : !llvm.ptr<i32> {
^bb0(%xval: i32):
%newval = llvm.mul %expr, %expr : i32
omp.yield(%newval : i32)
}
}
llvm.return
}
// -----
// Checking translation when the captured variable is not used in the inner
// update operation
llvm.func @omp_atomic_update_multiple_step_update(%x: !llvm.ptr<i32>, %v: !llvm.ptr<i32>, %expr: i32) {
// expected-error @+1 {{LLVM Translation failed for operation: omp.atomic.capture}}
omp.atomic.capture memory_order(seq_cst) {
omp.atomic.read %v = %x : !llvm.ptr<i32>, i32
// expected-error @+1 {{exactly two operations are allowed inside an atomic update region while lowering to LLVM IR}}
omp.atomic.update %x : !llvm.ptr<i32> {
^bb0(%xval: i32):
%t1 = llvm.mul %xval, %expr : i32
%t2 = llvm.sdiv %t1, %expr : i32
%newval = llvm.add %xval, %t2 : i32
omp.yield(%newval : i32)
}
}
llvm.return
}
// -----
llvm.func @omp_threadprivate() {
%0 = llvm.mlir.constant(1 : i64) : i64
%1 = llvm.mlir.constant(1 : i32) : i32
%2 = llvm.mlir.constant(2 : i32) : i32
%3 = llvm.mlir.constant(3 : i32) : i32
%4 = llvm.alloca %0 x i32 {in_type = i32, name = "a"} : (i64) -> !llvm.ptr<i32>
// expected-error @below {{Addressing symbol not found}}
// expected-error @below {{LLVM Translation failed for operation: omp.threadprivate}}
%5 = omp.threadprivate %4 : !llvm.ptr<i32> -> !llvm.ptr<i32>
llvm.store %1, %5 : !llvm.ptr<i32>
omp.parallel {
%6 = omp.threadprivate %4 : !llvm.ptr<i32> -> !llvm.ptr<i32>
llvm.store %2, %6 : !llvm.ptr<i32>
omp.terminator
}
llvm.store %3, %5 : !llvm.ptr<i32>
llvm.return
}
|