@@ -22,23 +22,48 @@ class ParallelOp;
22
22
} // namespace mlir
23
23
24
24
namespace mlir {
25
+
26
+ // / Loop vectorization info
25
27
struct SCFVectorizeInfo {
28
+ // / Loop dimension on which to vectorize.
26
29
unsigned dim = 0 ;
30
+
31
+ // / Biggest vector width, in elements.
27
32
unsigned factor = 0 ;
33
+
34
+ // / Number of ops, which will be vectorized.
28
35
unsigned count = 0 ;
36
+
37
+ // / Can use masked vector ops for our of bounds memory accesses.
29
38
bool masked = false ;
30
39
};
31
40
41
+ // / Collect vectorization statistics on specified `scf.parallel` dimension.
42
+ // / Return `SCFVectorizeInfo` or `std::nullopt` if loop cannot be vectorized on
43
+ // / specified dimension.
44
+ // /
45
+ // / `vectorBitwidth` - maximum vector size, in bits.
32
46
std::optional<SCFVectorizeInfo> getLoopVectorizeInfo (mlir::scf::ParallelOp loop,
33
47
unsigned dim,
34
- unsigned vectorBitWidth );
48
+ unsigned vectorBitwidth );
35
49
50
+ // / Vectorization params
36
51
struct SCFVectorizeParams {
52
+ // / Loop dimension on which to vectorize.
37
53
unsigned dim = 0 ;
54
+
55
+ // / Desired vector length, in elements
38
56
unsigned factor = 0 ;
57
+
58
+ // / Use masked vector ops for memory access outside loop bounds.
39
59
bool masked = false ;
40
60
};
41
61
62
+ // / Vectorize loop on specified dimension with specified factor.
63
+ // /
64
+ // / If `masked` is `true` and loop bound is not divisible by `factor`, instead
65
+ // / of generating second loop to process remainig iterations, extend loop count
66
+ // / and generate masked vector ops to handle out-of bounds memory accesses.
42
67
mlir::LogicalResult vectorizeLoop (mlir::OpBuilder &builder,
43
68
mlir::scf::ParallelOp loop,
44
69
const SCFVectorizeParams ¶ms);
0 commit comments