1 | #ifndef TDL_INCLUDE_CODEGEN_BARRIERS_H |
2 | #define TDL_INCLUDE_CODEGEN_BARRIERS_H |
3 | |
4 | #include <vector> |
5 | #include <map> |
6 | #include <list> |
7 | #include <set> |
8 | #include "triton/codegen/target.h" |
9 | |
10 | namespace triton { |
11 | |
12 | namespace ir { |
13 | class module; |
14 | class basic_block; |
15 | class instruction; |
16 | class masked_load_async_inst; |
17 | class value; |
18 | class builder; |
19 | } |
20 | |
21 | namespace codegen{ |
22 | |
23 | namespace analysis{ |
24 | |
25 | class allocation; |
26 | class liveness; |
27 | class layouts; |
28 | class cts; |
29 | class shared_layout; |
30 | |
31 | } |
32 | |
33 | namespace transform{ |
34 | |
35 | class prefetch; |
36 | |
37 | class membar { |
38 | private: |
39 | typedef std::pair<unsigned, unsigned> interval_t; |
40 | typedef std::set<ir::value*> val_set_t; |
41 | typedef std::vector<ir::value*> val_vec_t; |
42 | |
43 | private: |
44 | bool intersect(const val_set_t &X, const val_set_t &Y); |
45 | bool check_safe_war(ir::instruction* i); |
46 | int group_of(triton::ir::value *i, std::vector<triton::ir::value *> &async_write); |
47 | bool intersect_with(analysis::shared_layout* a_layout, analysis::shared_layout* b_layout); |
48 | val_set_t intersect_with(const val_set_t& as, const val_set_t& bs); |
49 | void transfer(ir::basic_block *block, val_vec_t &async_write, val_set_t &sync_write, val_set_t &sync_read, |
50 | std::set<triton::ir::value *> &safe_war, bool &inserted, ir::builder &builder); |
51 | |
52 | public: |
53 | membar(analysis::liveness *liveness, analysis::layouts *layouts, analysis::allocation *alloc, |
54 | transform::prefetch *prefetch, target* tgt): |
55 | liveness_(liveness), layouts_(layouts), alloc_(alloc), prefetch_(prefetch), tgt_(tgt) {} |
56 | void run(ir::module &mod); |
57 | |
58 | private: |
59 | analysis::liveness *liveness_; |
60 | analysis::layouts *layouts_; |
61 | analysis::allocation *alloc_; |
62 | transform::prefetch *prefetch_; |
63 | |
64 | target* tgt_; |
65 | }; |
66 | |
67 | |
68 | } |
69 | } |
70 | } |
71 | |
72 | #endif |
73 | |