1 | /******************************************************************************* |
2 | * Copyright 2021-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 | // Proxy classes for selected nGEN functionality to minimize dependency on |
18 | // template-heavy nGEN headers, and reduce compilation time. |
19 | |
20 | #ifndef GPU_JIT_UTILS_NGEN_PROXY_HPP |
21 | #define GPU_JIT_UTILS_NGEN_PROXY_HPP |
22 | |
23 | #include "gpu/jit/utils/utils.hpp" |
24 | |
25 | namespace dnnl { |
26 | namespace impl { |
27 | namespace gpu { |
28 | namespace jit { |
29 | namespace ngen_proxy { |
30 | |
31 | enum class Access { Read, Write }; |
32 | |
33 | enum AddressModel { |
34 | ModelInvalid, |
35 | ModelBTS, |
36 | ModelA64, |
37 | ModelSLM, |
38 | }; |
39 | |
40 | enum AtomicOp { undef, fadd }; |
41 | |
42 | class Bundle { |
43 | public: |
44 | Bundle() : bundle_id(any), bank_id(any) {} |
45 | |
46 | Bundle(int8_t bank_id_, int8_t bundle_id_) |
47 | : bundle_id(bundle_id_), bank_id(bank_id_) {} |
48 | |
49 | bool operator==(const Bundle &other) const { |
50 | return (bundle_id == other.bundle_id) && (bank_id == other.bank_id); |
51 | } |
52 | |
53 | static const int8_t any = -1; |
54 | |
55 | int8_t bundle_id; |
56 | int8_t bank_id; |
57 | }; |
58 | |
59 | class SBID { |
60 | public: |
61 | SBID(int token = -1) : token(token) {} |
62 | |
63 | bool is_empty() const { return token == -1; } |
64 | |
65 | int token; |
66 | }; |
67 | |
68 | class InstructionModifier { |
69 | public: |
70 | bool operator==(const InstructionModifier &other) const { |
71 | return (is_atomic == other.is_atomic); |
72 | } |
73 | |
74 | size_t get_hash() const { return ir_utils::get_hash(is_atomic); } |
75 | |
76 | InstructionModifier with_atomic() const { |
77 | auto ret = *this; |
78 | ret.is_atomic = true; |
79 | return ret; |
80 | } |
81 | |
82 | InstructionModifier with_sbid(const SBID &sbid) const { |
83 | auto ret = *this; |
84 | ret.sbid = sbid; |
85 | return ret; |
86 | } |
87 | |
88 | bool is_atomic = false; |
89 | SBID sbid; |
90 | }; |
91 | |
92 | } // namespace ngen_proxy |
93 | } // namespace jit |
94 | } // namespace gpu |
95 | } // namespace impl |
96 | } // namespace dnnl |
97 | |
98 | #endif |
99 | |