1 | /******************************************************************************* |
2 | * Copyright 2022 Intel Corporation |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | *******************************************************************************/ |
16 | |
17 | #ifndef GPU_JIT_PASS_HOIST_HPP |
18 | #define GPU_JIT_PASS_HOIST_HPP |
19 | |
20 | #include "gpu/jit/ir/ir.hpp" |
21 | |
22 | namespace dnnl { |
23 | namespace impl { |
24 | namespace gpu { |
25 | namespace jit { |
26 | |
27 | // Moves invariant expressions out of loops. |
28 | stmt_t hoist_exprs(const stmt_t &s, ir_context_t &ir_ctx, int reserved_regs); |
29 | |
30 | // Moves boolean mask computation from send calls to the top of the statement |
31 | // group corresponding to `label`. This is done to reduce GRF consumption and |
32 | // to reuse masks between calls. A vector boolean mask is stored as u16 type |
33 | // and converted to bool type right before the call. Transformation is limited |
34 | // to the statement group corresponding to `label`. |
35 | // If `split_by_and` is true then any ((A & B) & C) mask is split into A, B, C |
36 | // sub-masks which are initialized independently. This allows reusing those |
37 | // sub-masks for other masks. |
38 | stmt_t hoist_send_masks(const stmt_t &s, ir_context_t &ir_ctx, |
39 | const stmt_label_t &label, bool split_by_and); |
40 | |
41 | } // namespace jit |
42 | } // namespace gpu |
43 | } // namespace impl |
44 | } // namespace dnnl |
45 | |
46 | #endif |
47 | |