forked from tinygrad/tinygrad
Compare commits
515
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5844883e59 | ||
|
|
a51c688f39 | ||
|
|
bb5ded85cc | ||
|
|
666b6149bc | ||
|
|
48349efdc1 | ||
|
|
4c28235bd1 | ||
|
|
057c70b05f | ||
|
|
89eebd4bfb | ||
|
|
7a9e3247c2 | ||
|
|
b4e8878e01 | ||
|
|
6a0da51ed0 | ||
|
|
c7c279a6bd | ||
|
|
61de654efa | ||
|
|
6ec7f1b00f | ||
|
|
c26b06eaeb | ||
|
|
acf0baefee | ||
|
|
dcf104ee68 | ||
|
|
b92f36179d | ||
|
|
56fa5c1191 | ||
|
|
836cf42c2e | ||
|
|
746d899dbd | ||
|
|
fa90079370 | ||
|
|
ec447a31e7 | ||
|
|
cce26009f0 | ||
|
|
d1aa9f30bc | ||
|
|
73c75d6ee1 | ||
|
|
b6c617272a | ||
|
|
b075aefc12 | ||
|
|
a5753095dc | ||
|
|
f484db0e63 | ||
|
|
af2c2837f6 | ||
|
|
565c37c681 | ||
|
|
d64af3c884 | ||
|
|
83a904aaad | ||
|
|
6dadb60c93 | ||
|
|
66306b5321 | ||
|
|
6e523e4d17 | ||
|
|
7841852870 | ||
|
|
dc34a4146f | ||
|
|
5b1fc4dcb2 | ||
|
|
73ee2d74c0 | ||
|
|
72e1f41f8e | ||
|
|
b3fa76419a | ||
|
|
42d7c800a1 | ||
|
|
431a86615d | ||
|
|
07d3676019 | ||
|
|
741bbc900d | ||
|
|
7bbb568dec | ||
|
|
1f730ae8f8 | ||
|
|
0a59db936a | ||
|
|
af4f9d1aa9 | ||
|
|
643c09a6c6 | ||
|
|
a78f0f85d3 | ||
|
|
2a33750e4c | ||
|
|
e63d160376 | ||
|
|
1fce864a6d | ||
|
|
7647cd8428 | ||
|
|
0513b0c17d | ||
|
|
f0924e0857 | ||
|
|
f5da275f46 | ||
|
|
c8d878a5c1 | ||
|
|
530961f7d5 | ||
|
|
7cdc607544 | ||
|
|
5643429c17 | ||
|
|
5527f86a8f | ||
|
|
a2faa5e49b | ||
|
|
9df8e34160 | ||
|
|
78c0455c7a | ||
|
|
cac2b4e8b6 | ||
|
|
a2d55fb644 | ||
|
|
7f606fbde4 | ||
|
|
260df1a17f | ||
|
|
ec120ce6b9 | ||
|
|
50ba2bb642 | ||
|
|
c7ca7959e6 | ||
|
|
199a36d079 | ||
|
|
ba17786068 | ||
|
|
3417bc1814 | ||
|
|
801ec9e697 | ||
|
|
e724af74d7 | ||
|
|
da464d039f | ||
|
|
e8be8a5835 | ||
|
|
80089536e5 | ||
|
|
5d62aa28dc | ||
|
|
af0452f116 | ||
|
|
d66680b17e | ||
|
|
a65d2917cb | ||
|
|
aefbc2637f | ||
|
|
ed672881b0 | ||
|
|
2c71c60719 | ||
|
|
62655e4999 | ||
|
|
299fa8f37b | ||
|
|
c99ae81f63 | ||
|
|
1c608ae34f | ||
|
|
b240f12593 | ||
|
|
9760688e7f | ||
|
|
ed1b573868 | ||
|
|
3ed146a5ff | ||
|
|
bf041659a5 | ||
|
|
96bff0b4f7 | ||
|
|
efc7971090 | ||
|
|
a9d9f98d05 | ||
|
|
2454bf01c3 | ||
|
|
d488bbb1ec | ||
|
|
bbb2dd8141 | ||
|
|
a6e496b195 | ||
|
|
ac70f63d4b | ||
|
|
b53fe7c2fc | ||
|
|
06b58aa7ec | ||
|
|
1b4618e257 | ||
|
|
b4bf6a7dea | ||
|
|
0ffd572e1e | ||
|
|
0e42befc6e | ||
|
|
c74c5901a8 | ||
|
|
a037201168 | ||
|
|
e2b380b743 | ||
|
|
cb0978b377 | ||
|
|
2f06eccf1d | ||
|
|
0c759e1ff6 | ||
|
|
e0e176efbc | ||
|
|
dc10187fc0 | ||
|
|
7a2223a6c6 | ||
|
|
0814a79cb4 | ||
|
|
07069b9988 | ||
|
|
e82ba1454b | ||
|
|
eb77488f85 | ||
|
|
3e987fc856 | ||
|
|
04846b91aa | ||
|
|
8e5bd0cd7a | ||
|
|
e4512baea4 | ||
|
|
07ec99001a | ||
|
|
6cb74bb630 | ||
|
|
af65331b76 | ||
|
|
907dfa0e82 | ||
|
|
49b914ee69 | ||
|
|
93fb50ce77 | ||
|
|
891436853d | ||
|
|
2dae467b75 | ||
|
|
e3d1464ba4 | ||
|
|
9a9079118e | ||
|
|
9f6d545a16 | ||
|
|
c5e46c5eee | ||
|
|
1e283c33d3 | ||
|
|
018edd934b | ||
|
|
d6bf1feaab | ||
|
|
3628f89929 | ||
|
|
6733a3a96b | ||
|
|
f0d424ecdf | ||
|
|
e2008c98c3 | ||
|
|
2b239db5d2 | ||
|
|
66ac0087e8 | ||
|
|
08eb1f1f56 | ||
|
|
02ad450e22 | ||
|
|
b14c9848cc | ||
|
|
1a15c0e89d | ||
|
|
dd82b4c913 | ||
|
|
46a8c5e1e5 | ||
|
|
679b1ad058 | ||
|
|
08ca871d77 | ||
|
|
9d3c40601f | ||
|
|
9e55495b4d | ||
|
|
ed63ff2372 | ||
|
|
3499a2c72d | ||
|
|
b1847d561f | ||
|
|
689bf68cfc | ||
|
|
4198bce150 | ||
|
|
98d01a059d | ||
|
|
f532c78889 | ||
|
|
2d0842386d | ||
|
|
168c16646a | ||
|
|
beba490ba8 | ||
|
|
5842ee56c6 | ||
|
|
2faf8774fe | ||
|
|
d957a4f108 | ||
|
|
bd0fb14d70 | ||
|
|
0ef85b52e6 | ||
|
|
5267a411e7 | ||
|
|
b49a04145e | ||
|
|
c49e0fca60 | ||
|
|
d2234e308a | ||
|
|
5afb0a4a81 | ||
|
|
0d7bd4f389 | ||
|
|
8609b880bd | ||
|
|
f8cc971c3b | ||
|
|
3506a7585f | ||
|
|
23f0ff0ed8 | ||
|
|
2b7db9b45d | ||
|
|
4f0d1b4759 | ||
|
|
0289fbb1c2 | ||
|
|
f91ca508cf | ||
|
|
f671da6755 | ||
|
|
81a84aa85a | ||
|
|
00e5979897 | ||
|
|
611208cd8a | ||
|
|
82ef956cb8 | ||
|
|
d5c90da286 | ||
|
|
b3efeeb717 | ||
|
|
7ecced7f6d | ||
|
|
a1f70ce7d0 | ||
|
|
bae20e5043 | ||
|
|
6193e279d4 | ||
|
|
e1f7c90459 | ||
|
|
7fb1c7af61 | ||
|
|
504ad08e73 | ||
|
|
f29d6f54b8 | ||
|
|
4ee3243c93 | ||
|
|
7860a80801 | ||
|
|
930728c069 | ||
|
|
0790d8059f | ||
|
|
c85737c200 | ||
|
|
fdd46c9f28 | ||
|
|
dddd4e5f9f | ||
|
|
c5782e85d2 | ||
|
|
bfbe81df71 | ||
|
|
393eec3201 | ||
|
|
d5a646d492 | ||
|
|
cbfd51f5a5 | ||
|
|
52e7003414 | ||
|
|
76a03e950a | ||
|
|
4057b98f7f | ||
|
|
1ff6862a3d | ||
|
|
97ec564b03 | ||
|
|
5aab2806f0 | ||
|
|
863abc7140 | ||
|
|
05e54f00d3 | ||
|
|
d443e91d82 | ||
|
|
227d96d7a3 | ||
|
|
c4e33048c6 | ||
|
|
ae2229d727 | ||
|
|
c2504357af | ||
|
|
4abe631b56 | ||
|
|
d19c1c7f03 | ||
|
|
c25d5d3101 | ||
|
|
74b83c4c41 | ||
|
|
d224d0ed7f | ||
|
|
586e730d32 | ||
|
|
7562cc0399 | ||
|
|
df59b072db | ||
|
|
994944920b | ||
|
|
05e5de6a91 | ||
|
|
4ac4c1415a | ||
|
|
d817dc10db | ||
|
|
2f71a00236 | ||
|
|
cde18fddce | ||
|
|
867004fbeb | ||
|
|
38b5ac4d4a | ||
|
|
def90b22f6 | ||
|
|
ae241e96db | ||
|
|
cff1ee9038 | ||
|
|
87cbff3ac0 | ||
|
|
98c9e23560 | ||
|
|
815c505e1d | ||
|
|
79738d768c | ||
|
|
a70d1bf439 | ||
|
|
2f0856c1e2 | ||
|
|
60503c8621 | ||
|
|
61665a63c9 | ||
|
|
c7acd40574 | ||
|
|
8891495996 | ||
|
|
d09897c2aa | ||
|
|
70fa65cd95 | ||
|
|
f457cb64d6 | ||
|
|
337328e409 | ||
|
|
6a7f971fa0 | ||
|
|
cd4edc5206 | ||
|
|
92b59c9b7a | ||
|
|
9833fe83d8 | ||
|
|
e172b759f0 | ||
|
|
2cbb34535c | ||
|
|
23c56817d8 | ||
|
|
5720871903 | ||
|
|
88661cd96f | ||
|
|
62447c253d | ||
|
|
299d333806 | ||
|
|
2fd068ffc0 | ||
|
|
f6eb0574f2 | ||
|
|
83a8217cbf | ||
|
|
1efb1188d8 | ||
|
|
7595352dfc | ||
|
|
4c5c32ff5f | ||
|
|
aa3d612df2 | ||
|
|
31fcfe764d | ||
|
|
49abe6d3a6 | ||
|
|
21c7d7c71a | ||
|
|
2f530adb04 | ||
|
|
947de23cac | ||
|
|
b22494b710 | ||
|
|
afef69a37d | ||
|
|
ab3ac2b58d | ||
|
|
0e97f807e0 | ||
|
|
85a4397f27 | ||
|
|
0061dc7447 | ||
|
|
c69f459c96 | ||
|
|
5cb9443ebb | ||
|
|
ed618a72e7 | ||
|
|
280143467b | ||
|
|
547fd5078f | ||
|
|
ed121d235c | ||
|
|
eb7df92136 | ||
|
|
76a138cdb6 | ||
|
|
b6be407bc6 | ||
|
|
9229867fec | ||
|
|
c9c7f1be46 | ||
|
|
b4f4a3ac12 | ||
|
|
0e0cba2cfc | ||
|
|
4143f6a7d9 | ||
|
|
9bc317d5d2 | ||
|
|
ddad4d55da | ||
|
|
036efa9157 | ||
|
|
615d5276b1 | ||
|
|
5df213d51e | ||
|
|
3dfc8e1706 | ||
|
|
6c639dee5c | ||
|
|
5ffc50d58c | ||
|
|
12fa4340b3 | ||
|
|
bd4d7dc4eb | ||
|
|
c163b2c5f0 | ||
|
|
0d33391038 | ||
|
|
5d37d33fc5 | ||
|
|
048643e7f9 | ||
|
|
de306c615b | ||
|
|
08c9d980dc | ||
|
|
6fa38367bf | ||
|
|
e7c6282dd6 | ||
|
|
241db29ede | ||
|
|
c4b13e2f6d | ||
|
|
f2bee34197 | ||
|
|
dc9af4e2fc | ||
|
|
e5c85ec684 | ||
|
|
e3c9cfad80 | ||
|
|
c18307e749 | ||
|
|
d4a1d5211e | ||
|
|
24de25b52f | ||
|
|
f3fdec940d | ||
|
|
ae00fa3b28 | ||
|
|
4c94726bac | ||
|
|
e276b6eecd | ||
|
|
19a54ae0b4 | ||
|
|
12cccd8bc5 | ||
|
|
c7ec0ab674 | ||
|
|
803a47494e | ||
|
|
b6266c8e41 | ||
|
|
d157b20027 | ||
|
|
866dfa1f23 | ||
|
|
0addbad36d | ||
|
|
180916257d | ||
|
|
29c14f1cbf | ||
|
|
96f2a83a62 | ||
|
|
7499139239 | ||
|
|
a3c359b28b | ||
|
|
0d2400fc7c | ||
|
|
b71c51191b | ||
|
|
b7511cc390 | ||
|
|
34987a03af | ||
|
|
a44cd1e6f7 | ||
|
|
98b2854f14 | ||
|
|
0fd6d7482b | ||
|
|
da2fa0b37f | ||
|
|
90ce2c6029 | ||
|
|
f69ad7506a | ||
|
|
ba59b0528f | ||
|
|
0a139b1436 | ||
|
|
5755ac1f72 | ||
|
|
90f1f0c9d5 | ||
|
|
d8b08790b9 | ||
|
|
b5820a5209 | ||
|
|
22abd9dc03 | ||
|
|
9defbc7d54 | ||
|
|
6bb54eb532 | ||
|
|
a562ee2c6e | ||
|
|
9ed064710a | ||
|
|
4712847766 | ||
|
|
c1cd94baf6 | ||
|
|
8aa68e8d5c | ||
|
|
393d39da58 | ||
|
|
313bdfa43f | ||
|
|
4cbe5919d6 | ||
|
|
6422936b62 | ||
|
|
3f46425f1e | ||
|
|
a35eef8d58 | ||
|
|
de3705168e | ||
|
|
a647f3dd2c | ||
|
|
2c93f27652 | ||
|
|
5c2fe04bb6 | ||
|
|
3273972f44 | ||
|
|
3a556a7e8b | ||
|
|
b589dec06e | ||
|
|
0d6fe6200c | ||
|
|
c587b3b08c | ||
|
|
239d2a7214 | ||
|
|
78cb47dfc5 | ||
|
|
a556adf028 | ||
|
|
572ebd9f27 | ||
|
|
8d4439282b | ||
|
|
e6f4c24619 | ||
|
|
b7397c1322 | ||
|
|
afcd70af97 | ||
|
|
8fdcb60461 | ||
|
|
7ea633f94f | ||
|
|
e934f987c6 | ||
|
|
514a6740e4 | ||
|
|
83284985f0 | ||
|
|
88bc51385c | ||
|
|
991b91d4d6 | ||
|
|
ba0c844a83 | ||
|
|
3f83748661 | ||
|
|
72aa38aa3b | ||
|
|
4e8812db37 | ||
|
|
1ce9851ba6 | ||
|
|
18dca3c3d7 | ||
|
|
9f62c80f68 | ||
|
|
2649e87546 | ||
|
|
b7499764f5 | ||
|
|
cd79a904c5 | ||
|
|
074315ec08 | ||
|
|
20eebbc61a | ||
|
|
59f4b8da95 | ||
|
|
5776ea9386 | ||
|
|
e63c7818dc | ||
|
|
82833f1b3c | ||
|
|
62e5d96446 | ||
|
|
9c77e9f9b7 | ||
|
|
adcdc583a2 | ||
|
|
9f306e12ac | ||
|
|
aa9462c29b | ||
|
|
7059459648 | ||
|
|
7153f7709f | ||
|
|
2bf47b75da | ||
|
|
791a80a1c7 | ||
|
|
8e266091fb | ||
|
|
0ad264ed2d | ||
|
|
2aa39d03cd | ||
|
|
3a9ca62b9e | ||
|
|
423d823c50 | ||
|
|
accc186c8b | ||
|
|
8a8eaa1ed9 | ||
|
|
6608ba316d | ||
|
|
52243b258c | ||
|
|
d2ee304337 | ||
|
|
b4bb8de7f4 | ||
|
|
8f95b578f6 | ||
|
|
63f195729d | ||
|
|
bd9c015b09 | ||
|
|
6a1987f9f9 | ||
|
|
fddaeb6344 | ||
|
|
c5ae66215a | ||
|
|
69eb55a529 | ||
|
|
32df46cd73 | ||
|
|
45f2fb82d5 | ||
|
|
801e199196 | ||
|
|
4e2d98638d | ||
|
|
a9f46ebf70 | ||
|
|
66b92b6061 | ||
|
|
513d765c9e | ||
|
|
673a76398a | ||
|
|
5977a3d8a6 | ||
|
|
777d2aec05 | ||
|
|
32c995a5da | ||
|
|
21b085b8ed | ||
|
|
af87e4b53c | ||
|
|
0794af97db | ||
|
|
4764a4c172 | ||
|
|
c0d4346b5a | ||
|
|
f16188b8c0 | ||
|
|
fd23738d9d | ||
|
|
856c068172 | ||
|
|
775746fa08 | ||
|
|
df7ba102c3 | ||
|
|
e3731766c9 | ||
|
|
3195bd0d12 | ||
|
|
6e2e56c0ff | ||
|
|
cda34ccadf | ||
|
|
2bb298f38d | ||
|
|
befa8641c8 | ||
|
|
a2a4ff30dc | ||
|
|
f05fd118a2 | ||
|
|
9789a83064 | ||
|
|
da2245a458 | ||
|
|
1d21651823 | ||
|
|
53603c4ec1 | ||
|
|
e1518f1e38 | ||
|
|
67e66ac1ab | ||
|
|
58b224a40f | ||
|
|
ef1346ab39 | ||
|
|
d05e21cb69 | ||
|
|
e0aeb2e9f4 | ||
|
|
ace654a7e4 | ||
|
|
d78e75f710 | ||
|
|
16c1b2379d | ||
|
|
4c1733440d | ||
|
|
3eb952f537 | ||
|
|
bcd7ea60f0 | ||
|
|
734f2c5344 | ||
|
|
0708a169dd | ||
|
|
8396d90f91 | ||
|
|
37fa38d272 | ||
|
|
e9ee39df22 | ||
|
|
e0956c518c | ||
|
|
e2f87ecf36 | ||
|
|
e371a23c45 | ||
|
|
6d83a96440 | ||
|
|
4679f9fb44 | ||
|
|
62e19649c0 | ||
|
|
da19c37f0a | ||
|
|
0d26c970ba | ||
|
|
eb0e5a14fd | ||
|
|
c1b79c118f | ||
|
|
8a50868264 | ||
|
|
aff112f8ab | ||
|
|
dbe549e462 | ||
|
|
0a00187dce | ||
|
|
70f6183f34 | ||
|
|
eebb3a1bb9 | ||
|
|
1824cbd72c | ||
|
|
6d6c34eb1e |
@@ -2,7 +2,7 @@ name: Benchmarks
|
||||
env:
|
||||
# TODO: this rescheduling makes gpt2, mixtral and llama unjitted slower
|
||||
# TODO: very slow for llama 70B and resnet training 6 GPU
|
||||
RUN_PROCESS_REPLAY: "1"
|
||||
CAPTURE_PROCESS_REPLAY: "1"
|
||||
ASSERT_PROCESS_REPLAY: "0"
|
||||
PYTHONPATH: .
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -62,6 +62,8 @@ jobs:
|
||||
run: BIG=2 MPS=1 python3.11 test/test_speed_v_torch.py | tee torch_speed.txt
|
||||
- name: Test tensor cores
|
||||
run: METAL=1 python3.11 test/test_linearizer.py TestLinearizer.test_tensor_cores TestLinearizer.test_tensor_cores_padded
|
||||
- name: Test AMX tensor cores
|
||||
run: DEBUG=2 CLANG=1 AMX=1 python3.11 test/test_linearizer.py TestLinearizer.test_tensor_cores TestLinearizer.test_tensor_cores_padded
|
||||
- name: Run Tensor Core GEMM (float)
|
||||
run: DEBUG=2 python3.11 extra/gemm/simple_matmul.py | tee matmul.txt
|
||||
- name: Run Tensor Core GEMM (half)
|
||||
@@ -89,7 +91,7 @@ jobs:
|
||||
- name: Run GPT2 w HALF
|
||||
run: HALF=1 python3.11 examples/gpt2.py --count 10 --temperature 0 --timing | tee gpt2_half.txt
|
||||
- name: Run GPT2 w HALF/BEAM
|
||||
run: HALF=1 JITBEAM=2 IGNORE_BEAM_CACHE=1 CAST_BEFORE_VIEW=0 python3.11 examples/gpt2.py --count 10 --temperature 0 --timing | tee gpt2_half_beam.txt
|
||||
run: HALF=1 JITBEAM=2 IGNORE_BEAM_CACHE=1 python3.11 examples/gpt2.py --count 10 --temperature 0 --timing | tee gpt2_half_beam.txt
|
||||
- name: Train MNIST
|
||||
run: time PYTHONPATH=. TARGET_EVAL_ACC_PCT=96.0 python3.11 examples/beautiful_mnist.py | tee beautiful_mnist.txt
|
||||
- name: Run 10 CIFAR training steps
|
||||
@@ -134,7 +136,7 @@ jobs:
|
||||
testnvidiabenchmark:
|
||||
name: tinybox green Benchmark
|
||||
runs-on: [self-hosted, Linux, tinyboxgreen]
|
||||
timeout-minutes: 20
|
||||
timeout-minutes: 30
|
||||
defaults:
|
||||
run:
|
||||
shell: bash -o pipefail {0}
|
||||
@@ -161,19 +163,22 @@ jobs:
|
||||
- name: reset process replay
|
||||
run: test/external/process_replay/reset.py
|
||||
- name: Run model inference benchmark
|
||||
run: NV=1 RUN_PROCESS_REPLAY=0 NOCLANG=1 python3 test/external/external_model_benchmark.py
|
||||
run: NV=1 CAPTURE_PROCESS_REPLAY=0 NOCLANG=1 python3 test/external/external_model_benchmark.py
|
||||
- name: Test speed vs torch
|
||||
run: NV=1 RUN_PROCESS_REPLAY=0 HALF=1 BIG=2 TORCHCUDA=1 python3 test/test_speed_v_torch.py | tee torch_speed.txt
|
||||
run: NV=1 CAPTURE_PROCESS_REPLAY=0 HALF=1 BIG=2 TORCHCUDA=1 python3 test/test_speed_v_torch.py | tee torch_speed.txt
|
||||
- name: Test speed vs theoretical
|
||||
run: NV=1 IGNORE_BEAM_CACHE=1 BEAM_DEBUG=1 DEBUG=1 python -m pytest -rA test/external/speed_v_theoretical.py --durations=20
|
||||
- name: Test benchmark allreduce
|
||||
run: NV=1 python test/external/external_benchmark_multitensor_allreduce.py
|
||||
- name: Test tensor cores
|
||||
run: |
|
||||
NV=1 python3 test/test_linearizer.py TestLinearizer.test_tensor_cores TestLinearizer.test_tensor_cores_padded
|
||||
PTX=1 NV=1 python3 test/test_linearizer.py TestLinearizer.test_tensor_cores TestLinearizer.test_tensor_cores_padded
|
||||
NV=1 ALLOW_TF32=1 python3 test/test_linearizer.py TestLinearizer.test_tensor_cores TestLinearizer.test_tensor_cores_padded
|
||||
PTX=1 ALLOW_TF32=1 NV=1 python3 test/test_linearizer.py TestLinearizer.test_tensor_cores TestLinearizer.test_tensor_cores_padded
|
||||
- name: Run Tensor Core GEMM (CUDA)
|
||||
run: |
|
||||
CUDA=1 HALF=1 DEBUG=2 python3 extra/gemm/simple_matmul.py | tee matmul.txt
|
||||
CUDA=1 BFLOAT16=1 DEBUG=2 python3 extra/gemm/simple_matmul.py | tee matmul_bfloat16.txt
|
||||
CUDA=1 ALLOW_TF32=1 DEBUG=2 python3 extra/gemm/simple_matmul.py | tee matmul_tf32.txt
|
||||
- name: Run Tensor Core GEMM (PTX)
|
||||
run: NV=1 PTX=1 HALF=1 DEBUG=2 python3 extra/gemm/simple_matmul.py | tee matmul_ptx.txt
|
||||
- name: Run Tensor Core GEMM (NV)
|
||||
@@ -185,7 +190,7 @@ jobs:
|
||||
- name: Run Stable Diffusion
|
||||
run: NV=1 python3 examples/stable_diffusion.py --fp16 --seed 0 --noshow --timing | tee sd.txt
|
||||
- name: Run SDXL
|
||||
run: NV=1 RUN_PROCESS_REPLAY=0 python3 examples/sdxl.py --seed 0 --noshow --timing | tee sdxl.txt
|
||||
run: NV=1 CAPTURE_PROCESS_REPLAY=0 python3 examples/sdxl.py --seed 0 --noshow --timing | tee sdxl.txt
|
||||
- name: Run LLaMA
|
||||
run: |
|
||||
NV=1 JIT=0 python3 examples/llama.py --gen 1 --prompt "Hello." --count 10 --temperature 0 --timing | tee llama_unjitted.txt
|
||||
@@ -193,19 +198,19 @@ jobs:
|
||||
- name: Run LLaMA with BEAM
|
||||
run: NV=1 JITBEAM=2 IGNORE_BEAM_CACHE=1 python3 examples/llama.py --gen 1 --prompt "Hello." --count 10 --temperature 0 --timing | tee llama_beam.txt
|
||||
# - name: Run LLaMA 7B on 4 GPUs
|
||||
# run: NV=1 RUN_PROCESS_REPLAY=0 python3 examples/llama.py --gen 1 --size 7B --shard 4 --prompt "Hello." --count 10 --temperature 0 --timing | tee llama_four_gpu.txt
|
||||
# run: NV=1 CAPTURE_PROCESS_REPLAY=0 python3 examples/llama.py --gen 1 --size 7B --shard 4 --prompt "Hello." --count 10 --temperature 0 --timing | tee llama_four_gpu.txt
|
||||
# - name: Run LLaMA 7B on 6 GPUs
|
||||
# run: NV=1 RUN_PROCESS_REPLAY=0 python3 examples/llama.py --gen 1 --size 7B --shard 6 --prompt "Hello." --count 10 --temperature 0 --timing | tee llama_six_gpu.txt
|
||||
# run: NV=1 CAPTURE_PROCESS_REPLAY=0 python3 examples/llama.py --gen 1 --size 7B --shard 6 --prompt "Hello." --count 10 --temperature 0 --timing | tee llama_six_gpu.txt
|
||||
- name: Run LLaMA-3 8B BEAM
|
||||
run: NV=1 JITBEAM=2 IGNORE_BEAM_CACHE=1 python3 examples/llama3.py --size 8B --model weights/LLaMA-3/8B-SF-DPO/ --benchmark --temperature 0 | tee llama3_beam.txt
|
||||
- name: Run LLaMA-3 8B on 4 GPUs
|
||||
run: NV=1 RUN_PROCESS_REPLAY=0 python3 examples/llama3.py --size 8B --shard 4 --model weights/LLaMA-3/8B-SF-DPO/ --benchmark --temperature 0 | tee llama3_four_gpu.txt
|
||||
- name: Run LLaMA-3 8B on 6 GPUs
|
||||
run: NV=1 RUN_PROCESS_REPLAY=0 python3 examples/llama3.py --size 8B --shard 6 --model weights/LLaMA-3/8B-SF-DPO/ --benchmark --temperature 0 | tee llama3_six_gpu.txt
|
||||
- name: Run LLaMA-2 70B
|
||||
run: NV=1 RUN_PROCESS_REPLAY=0 MAX_CONTEXT=256 python3 examples/llama.py --gen 2 --size 70B --shard 6 --prompt "Hello." --count 10 --temperature 0 --timing | tee llama_2_70B.txt
|
||||
- name: Run LLaMA-3 8B on 4 GPUs with BEAM
|
||||
run: NV=1 JITBEAM=2 IGNORE_BEAM_CACHE=1 CAPTURE_PROCESS_REPLAY=0 python3 examples/llama3.py --size 8B --shard 4 --model weights/LLaMA-3/8B-SF-DPO/ --benchmark --temperature 0 | tee llama3_four_gpu.txt
|
||||
# - name: Run LLaMA-3 8B on 6 GPUs
|
||||
# run: NV=1 CAPTURE_PROCESS_REPLAY=0 python3 examples/llama3.py --size 8B --shard 6 --model weights/LLaMA-3/8B-SF-DPO/ --benchmark --temperature 0 | tee llama3_six_gpu.txt
|
||||
# - name: Run LLaMA-2 70B
|
||||
# run: NV=1 CAPTURE_PROCESS_REPLAY=0 MAX_CONTEXT=256 python3 examples/llama.py --gen 2 --size 70B --shard 6 --prompt "Hello." --count 10 --temperature 0 --timing | tee llama_2_70B.txt
|
||||
- name: Run Mixtral 8x7B
|
||||
run: time NV=1 RUN_PROCESS_REPLAY=0 python3 examples/mixtral.py --temperature 0 --count 10 --timing | tee mixtral.txt
|
||||
run: time NV=1 CAPTURE_PROCESS_REPLAY=0 python3 examples/mixtral.py --temperature 0 --count 10 --timing | tee mixtral.txt
|
||||
- name: Run GPT2
|
||||
run: |
|
||||
NV=1 JIT=0 python3 examples/gpt2.py --prompt "Hello." --count 10 --temperature 0 --timing | tee gpt2_unjitted.txt
|
||||
@@ -213,7 +218,7 @@ jobs:
|
||||
- name: Run GPT2 w HALF
|
||||
run: NV=1 HALF=1 python3 examples/gpt2.py --count 10 --temperature 0 --timing | tee gpt2_half.txt
|
||||
- name: Run GPT2 w HALF/BEAM
|
||||
run: NV=1 HALF=1 JITBEAM=2 IGNORE_BEAM_CACHE=1 CAST_BEFORE_VIEW=0 python3 examples/gpt2.py --count 10 --temperature 0 --timing | tee gpt2_half_beam.txt
|
||||
run: NV=1 HALF=1 JITBEAM=2 IGNORE_BEAM_CACHE=1 python3 examples/gpt2.py --count 10 --temperature 0 --timing | tee gpt2_half_beam.txt
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Speed (NVIDIA)
|
||||
@@ -222,6 +227,7 @@ jobs:
|
||||
torch_speed.txt
|
||||
matmul.txt
|
||||
matmul_bfloat16.txt
|
||||
matmul_tf32.txt
|
||||
matmul_ptx.txt
|
||||
matmul_nv.txt
|
||||
sd.txt
|
||||
@@ -282,17 +288,20 @@ jobs:
|
||||
- name: Run 10 CIFAR training steps w BF16
|
||||
run: NV=1 STEPS=10 DEFAULT_FLOAT=BFLOAT16 python3 examples/hlb_cifar10.py | tee train_cifar_bf16.txt
|
||||
- name: Run 10 CIFAR training steps w winograd
|
||||
run: NV=1 RUN_PROCESS_REPLAY=0 WINO=1 STEPS=10 DEFAULT_FLOAT=HALF python3 examples/hlb_cifar10.py | tee train_cifar_wino.txt
|
||||
run: NV=1 CAPTURE_PROCESS_REPLAY=0 WINO=1 STEPS=10 DEFAULT_FLOAT=HALF python3 examples/hlb_cifar10.py | tee train_cifar_wino.txt
|
||||
- name: Run full CIFAR training w 1 GPU
|
||||
run: time NV=1 DEFAULT_FLOAT=HALF LATEWINO=1 STEPS=1000 TARGET_EVAL_ACC_PCT=93.2 python3 examples/hlb_cifar10.py | tee train_cifar_one_gpu.txt
|
||||
- name: Run full CIFAR training steps w 6 GPUS
|
||||
run: time RUN_PROCESS_REPLAY=0 NV=1 DEFAULT_FLOAT=HALF STEPS=350 BS=1536 GPUS=6 TARGET_EVAL_ACC_PCT=93.2 python3 examples/hlb_cifar10.py | tee train_cifar_six_gpu.txt
|
||||
run: time CAPTURE_PROCESS_REPLAY=0 NV=1 DEFAULT_FLOAT=HALF STEPS=350 BS=1536 GPUS=6 TARGET_EVAL_ACC_PCT=93.2 python3 examples/hlb_cifar10.py | tee train_cifar_six_gpu.txt
|
||||
- name: Run MLPerf resnet eval on training data
|
||||
run: time NV=1 MODEL=resnet python3 examples/mlperf/model_eval.py
|
||||
- name: Run 10 MLPerf ResNet50 training steps (1 gpu)
|
||||
run: NV=1 DEFAULT_FLOAT=HALF BENCHMARK=10 BS=256 GPUS=1 MODEL=resnet python3 examples/mlperf/model_train.py | tee train_resnet_one_gpu.txt
|
||||
- name: Run 10 MLPerf ResNet50 training steps (6 gpu)
|
||||
run: NV=1 RUN_PROCESS_REPLAY=0 DEFAULT_FLOAT=HALF BENCHMARK=10 BS=1536 GPUS=6 MODEL=resnet python3 examples/mlperf/model_train.py | tee train_resnet.txt
|
||||
run: NV=1 CAPTURE_PROCESS_REPLAY=0 DEFAULT_FLOAT=HALF BENCHMARK=10 BS=1536 GPUS=6 MODEL=resnet python3 examples/mlperf/model_train.py | tee train_resnet.txt
|
||||
- name: Run 10 MLPerf Bert training steps (6 gpu)
|
||||
# TODO: remove BERT_LAYERS once scheduler is fast
|
||||
run: NV=1 CAPTURE_PROCESS_REPLAY=0 DEFAULT_FLOAT=HALF BENCHMARK=10 BS=66 GPUS=6 BERT_LAYERS=2 MODEL=bert python3 examples/mlperf/model_train.py | tee train_bert.txt
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Speed (NVIDIA Training)
|
||||
@@ -303,9 +312,10 @@ jobs:
|
||||
train_cifar_bf16.txt
|
||||
train_cifar_wino.txt
|
||||
train_cifar_one_gpu.txt
|
||||
train_cifar_six_gpu.txt
|
||||
train_resnet.txt
|
||||
train_resnet_one_gpu.txt
|
||||
train_cifar_six_gpu.txt
|
||||
train_bert.txt
|
||||
- name: Run process replay tests
|
||||
run: cp test/external/process_replay/process_replay.py ./process_replay.py && git fetch origin master && git -c advice.detachedHead=false checkout origin/master && PYTHONPATH=. python3 process_replay.py
|
||||
|
||||
@@ -320,6 +330,8 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
- name: Insert amdgpu
|
||||
run: sudo modprobe amdgpu
|
||||
- name: Symlink models and datasets
|
||||
run: |
|
||||
mkdir -p weights
|
||||
@@ -365,6 +377,12 @@ jobs:
|
||||
# TODO: AMD compiler bug causes this to fail
|
||||
#- name: Fuzz Padded Tensor Core GEMM
|
||||
# run: HSA=1 M_START=12 M_STOP=20 M_STEP=1 N_START=12 N_STOP=20 N_STEP=1 K_START=28 K_STOP=36 K_STEP=1 HALF=1 TC_OPT=2 DEBUG=2 python3 ./extra/gemm/fuzz_matmul.py
|
||||
- name: Remove amdgpu
|
||||
run: sleep 5 && sudo rmmod amdgpu # sleep a bit to let the driver unload the prev pid.
|
||||
- name: Test AM cold start time
|
||||
run: time AMD=1 AM_RESET=1 python3 test/test_tiny.py TestTiny.test_plus
|
||||
- name: Test AM warm start time
|
||||
run: time AMD=1 python3 test/test_tiny.py TestTiny.test_plus
|
||||
- name: Run Stable Diffusion
|
||||
run: AMD=1 python3 examples/stable_diffusion.py --fp16 --seed 0 --noshow --timing | tee sd.txt
|
||||
- name: Run SDXL
|
||||
@@ -376,17 +394,19 @@ jobs:
|
||||
- name: Run LLaMA 7B with BEAM
|
||||
run: AMD=1 JITBEAM=2 IGNORE_BEAM_CACHE=1 python3 examples/llama.py --gen 1 --prompt "Hello." --count 10 --temperature 0 --timing | tee llama_beam.txt
|
||||
# - name: Run LLaMA 7B on 4 GPUs
|
||||
# run: AMD=1 RUN_PROCESS_REPLAY=0 python3 examples/llama.py --gen 1 --size 7B --shard 4 --prompt "Hello." --count 10 --temperature 0 --timing | tee llama_four_gpu.txt
|
||||
# run: AMD=1 CAPTURE_PROCESS_REPLAY=0 python3 examples/llama.py --gen 1 --size 7B --shard 4 --prompt "Hello." --count 10 --temperature 0 --timing | tee llama_four_gpu.txt
|
||||
# - name: Run LLaMA 7B on 6 GPUs
|
||||
# run: AMD=1 RUN_PROCESS_REPLAY=0 python3 examples/llama.py --gen 1 --size 7B --shard 6 --prompt "Hello." --count 10 --temperature 0 --timing | tee llama_six_gpu.txt
|
||||
# run: AMD=1 CAPTURE_PROCESS_REPLAY=0 python3 examples/llama.py --gen 1 --size 7B --shard 6 --prompt "Hello." --count 10 --temperature 0 --timing | tee llama_six_gpu.txt
|
||||
- name: Run LLaMA-3 8B BEAM
|
||||
run: AMD=1 JITBEAM=2 IGNORE_BEAM_CACHE=1 python3 examples/llama3.py --size 8B --model weights/LLaMA-3/8B-SF-DPO/ --benchmark --temperature 0 | tee llama3_beam.txt
|
||||
- name: Run LLaMA-3 8B on 4 GPUs
|
||||
run: AMD=1 RUN_PROCESS_REPLAY=0 python3 examples/llama3.py --size 8B --shard 4 --model weights/LLaMA-3/8B-SF-DPO/ --benchmark --temperature 0 | tee llama3_four_gpu.txt
|
||||
- name: Run LLaMA-3 8B on 6 GPUs
|
||||
run: AMD=1 RUN_PROCESS_REPLAY=0 python3 examples/llama3.py --size 8B --shard 6 --model weights/LLaMA-3/8B-SF-DPO/ --benchmark --temperature 0 | tee llama3_six_gpu.txt
|
||||
- name: Run LLaMA-2 70B
|
||||
run: AMD=1 RUN_PROCESS_REPLAY=0 python3 examples/llama.py --gen 2 --size 70B --shard 6 --prompt "Hello." --count 10 --temperature 0 --timing | tee llama_2_70B.txt
|
||||
- name: Run LLaMA-3 8B on 4 GPUs with BEAM
|
||||
run: AMD=1 JITBEAM=2 IGNORE_BEAM_CACHE=1 CAPTURE_PROCESS_REPLAY=0 python3 examples/llama3.py --size 8B --shard 4 --model weights/LLaMA-3/8B-SF-DPO/ --benchmark --temperature 0 | tee llama3_four_gpu.txt
|
||||
# - name: Run LLaMA-3 8B on 6 GPUs
|
||||
# run: AMD=1 CAPTURE_PROCESS_REPLAY=0 python3 examples/llama3.py --size 8B --shard 6 --model weights/LLaMA-3/8B-SF-DPO/ --benchmark --temperature 0 | tee llama3_six_gpu.txt
|
||||
- name: Restore amdgpu
|
||||
run: sudo modprobe amdgpu
|
||||
# - name: Run LLaMA-2 70B
|
||||
# run: AMD=1 CAPTURE_PROCESS_REPLAY=0 python3 examples/llama.py --gen 2 --size 70B --shard 6 --prompt "Hello." --count 10 --temperature 0 --timing | tee llama_2_70B.txt
|
||||
- name: Run Mixtral 8x7B
|
||||
run: time AMD=1 python3 examples/mixtral.py --temperature 0 --count 10 --timing | tee mixtral.txt
|
||||
- name: Run GPT2
|
||||
@@ -396,7 +416,7 @@ jobs:
|
||||
- name: Run GPT2 w HALF
|
||||
run: AMD=1 HALF=1 python3 examples/gpt2.py --count 10 --temperature 0 --timing | tee gpt2_half.txt
|
||||
- name: Run GPT2 w HALF/BEAM
|
||||
run: AMD=1 HALF=1 JITBEAM=2 IGNORE_BEAM_CACHE=1 CAST_BEFORE_VIEW=0 python3 examples/gpt2.py --count 10 --temperature 0 --timing | tee gpt2_half_beam.txt
|
||||
run: AMD=1 HALF=1 JITBEAM=2 IGNORE_BEAM_CACHE=1 python3 examples/gpt2.py --count 10 --temperature 0 --timing | tee gpt2_half_beam.txt
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Speed (AMD)
|
||||
@@ -433,6 +453,8 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
- name: Insert amdgpu
|
||||
run: sudo modprobe amdgpu
|
||||
- name: Symlink models and datasets
|
||||
run: |
|
||||
mkdir -p weights
|
||||
@@ -473,7 +495,10 @@ jobs:
|
||||
- name: Run 10 MLPerf ResNet50 training steps (1 gpu)
|
||||
run: AMD=1 DEFAULT_FLOAT=HALF BENCHMARK=10 BS=256 GPUS=1 MODEL=resnet python3 examples/mlperf/model_train.py | tee train_resnet_one_gpu.txt
|
||||
- name: Run 10 MLPerf ResNet50 training steps (6 gpu)
|
||||
run: AMD=1 RUN_PROCESS_REPLAY=0 DEFAULT_FLOAT=HALF BENCHMARK=10 BS=1536 GPUS=6 MODEL=resnet python3 examples/mlperf/model_train.py | tee train_resnet.txt
|
||||
run: AMD=1 CAPTURE_PROCESS_REPLAY=0 DEFAULT_FLOAT=HALF BENCHMARK=10 BS=1536 GPUS=6 MODEL=resnet python3 examples/mlperf/model_train.py | tee train_resnet.txt
|
||||
- name: Run 10 MLPerf Bert training steps (6 gpu)
|
||||
# TODO: remove BERT_LAYERS once scheduler is fast
|
||||
run: AMD=1 CAPTURE_PROCESS_REPLAY=0 DEFAULT_FLOAT=HALF BENCHMARK=10 BS=66 GPUS=6 BERT_LAYERS=2 MODEL=bert python3 examples/mlperf/model_train.py | tee train_bert.txt
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Speed (AMD Training)
|
||||
@@ -484,9 +509,10 @@ jobs:
|
||||
train_cifar_bf16.txt
|
||||
train_cifar_wino.txt
|
||||
train_cifar_one_gpu.txt
|
||||
train_cifar_six_gpu.txt
|
||||
train_resnet.txt
|
||||
train_resnet_one_gpu.txt
|
||||
train_cifar_six_gpu.txt
|
||||
train_bert.txt
|
||||
- name: Run process replay tests
|
||||
run: cp test/external/process_replay/process_replay.py ./process_replay.py && git fetch origin master && git -c advice.detachedHead=false checkout origin/master && PYTHONPATH=. python3 process_replay.py
|
||||
|
||||
|
||||
+180
-13
@@ -2,9 +2,8 @@ name: Unit Tests
|
||||
env:
|
||||
# increment this when downloads substantially change to avoid the internet
|
||||
DOWNLOAD_CACHE_VERSION: '8'
|
||||
RUN_PROCESS_REPLAY: 1
|
||||
CAPTURE_PROCESS_REPLAY: 1
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
PYTHONPATH: .
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -16,7 +15,7 @@ on:
|
||||
jobs:
|
||||
autogen:
|
||||
name: Autogen+Docs
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
@@ -27,6 +26,8 @@ jobs:
|
||||
python-version: 3.12
|
||||
- name: Install docs dependencies (no cache)
|
||||
run: pip install -e '.[docs]'
|
||||
- name: Install capstone for CLANG disassembly
|
||||
run: pip install capstone
|
||||
- name: Use as an external package
|
||||
run: |
|
||||
mkdir $HOME/test_external_dir
|
||||
@@ -89,6 +90,11 @@ jobs:
|
||||
/opt/rocm/lib64
|
||||
EOF
|
||||
sudo ldconfig
|
||||
- name: Install packages (llvm)
|
||||
run: |
|
||||
echo 'Acquire::http::Pipeline-Depth "5";' | sudo tee -a /etc/apt/apt.conf.d/99parallel
|
||||
sudo apt update -y || true
|
||||
sudo apt install -y --no-install-recommends llvm-14-dev
|
||||
- name: Compile EfficientNet to C and test it
|
||||
run: |
|
||||
CLANG=1 PYTHONPATH="." python examples/compile_efficientnet.py > recognize.c
|
||||
@@ -126,6 +132,11 @@ jobs:
|
||||
./autogen_stubs.sh io_uring
|
||||
diff /tmp/libc.py.bak tinygrad/runtime/autogen/libc.py
|
||||
diff /tmp/io_uring.py.bak tinygrad/runtime/autogen/io_uring.py
|
||||
- name: Verify LLVM autogen
|
||||
run: |
|
||||
cp tinygrad/runtime/autogen/llvm.py /tmp/llvm.py.bak
|
||||
./autogen_stubs.sh llvm
|
||||
diff /tmp/llvm.py.bak tinygrad/runtime/autogen/llvm.py
|
||||
|
||||
uops:
|
||||
name: uops tests
|
||||
@@ -165,14 +176,16 @@ jobs:
|
||||
- name: Test emulated CUDA tensor cores
|
||||
run: |
|
||||
DEBUG=2 EMULATE_CUDA=1 FORWARD_ONLY=1 PYTHON=1 python3 test/test_ops.py TestOps.test_gemm_fp16
|
||||
PYTHONPATH="." DEBUG=2 EMULATE_CUDA=1 FORWARD_ONLY=1 PYTHON=1 python3 test/test_linearizer.py TestLinearizer.test_tensor_cores TestLinearizer.test_tensor_cores_padded
|
||||
DEBUG=2 EMULATE_CUDA=1 ALLOW_TF32=1 FORWARD_ONLY=1 PYTHON=1 python3 test/test_ops.py TestOps.test_gemm
|
||||
DEBUG=2 EMULATE_CUDA_SM75=1 FORWARD_ONLY=1 PYTHON=1 python3 test/test_ops.py TestOps.test_gemm_fp16
|
||||
PYTHONPATH="." DEBUG=2 EMULATE_CUDA=1 ALLOW_TF32=1 FORWARD_ONLY=1 PYTHON=1 python3 test/test_linearizer.py TestLinearizer.test_tensor_cores TestLinearizer.test_tensor_cores_padded
|
||||
- name: Test emulated INTEL OpenCL tensor cores
|
||||
run: DEBUG=2 EMULATE_INTEL=1 FORWARD_ONLY=1 PYTHON=1 HALF=1 N=64 python3 ./extra/gemm/simple_matmul.py
|
||||
- name: Full test tensor cores
|
||||
run: |
|
||||
PYTHONPATH=. DEBUG=2 EMULATE_METAL=1 FORWARD_ONLY=1 PYTHON=1 python3 ./test/test_linearizer.py TestLinearizer.test_tensor_cores
|
||||
PYTHONPATH=. DEBUG=2 EMULATE_AMD=1 FORWARD_ONLY=1 PYTHON=1 python3 ./test/test_linearizer.py TestLinearizer.test_tensor_cores
|
||||
PYTHONPATH=. DEBUG=2 EMULATE_CUDA=1 FORWARD_ONLY=1 PYTHON=1 python3 ./test/test_linearizer.py TestLinearizer.test_tensor_cores
|
||||
PYTHONPATH=. DEBUG=2 EMULATE_CUDA=1 ALLOW_TF32=1 FORWARD_ONLY=1 PYTHON=1 python3 ./test/test_linearizer.py TestLinearizer.test_tensor_cores
|
||||
PYTHONPATH=. DEBUG=2 EMULATE_INTEL=1 FORWARD_ONLY=1 PYTHON=1 python3 ./test/test_linearizer.py TestLinearizer.test_tensor_cores
|
||||
PYTHONPATH=. DEBUG=2 AMX=1 EMULATE_AMX=1 FORWARD_ONLY=1 PYTHON=1 python3 ./test/test_linearizer.py TestLinearizer.test_tensor_cores
|
||||
- name: Test tensor cores (TC=3)
|
||||
@@ -192,7 +205,7 @@ jobs:
|
||||
- name: Test dtype with Python emulator
|
||||
run: DEBUG=1 PYTHONPATH=. PYTHON=1 python3 -m pytest -n=auto test/test_dtype.py test/test_dtype_alu.py
|
||||
- name: Test ops with Python emulator
|
||||
run: DEBUG=2 PYTHON=1 python3 -m pytest -n=auto test/test_ops.py -k "not (test_split or test_simple_cumsum or test_cumsum or test_einsum or test_dot or test_dot_1d or test_big_gemm or test_broadcastdot or test_multidot or test_var_axis or test_std_axis or test_broadcast_full or test_broadcast_partial or test_simple_conv3d or test_dilated_conv_transpose2d or test_simple_conv_transpose3d or test_large_input_conv2d or test_max_pool2d or test_max_pool2d_simple or test_max_pool2d_bigger_stride or test_avg_pool2d or test_cat or test_scaled_product_attention or test_scaled_product_attention_causal or test_slice_fancy_indexing_dim_inject_none or test_slice_fancy_indexing_list_indices or test_slice_fancy_indexing_no_dim_collapse or test_slice_fancy_indexing_tuple_indices or test_slice_fancy_indexing_list_with_tensors or test_slice_fancy_indexing_dim_collapse_int or test_interpolate_bilinear or test_interpolate_bilinear_corners_aligned)" --durations=20
|
||||
run: DEBUG=2 PYTHON=1 python3 -m pytest -n=auto test/test_ops.py -k "not (test_split or test_simple_cumsum or test_cumsum or test_einsum or test_dot or test_dot_1d or test_big_gemm or test_broadcastdot or test_multidot or test_var_axis or test_std_axis or test_broadcast_full or test_broadcast_partial or test_simple_conv3d or test_dilated_conv_transpose2d or test_simple_conv_transpose3d or test_large_input_conv2d or test_max_pool2d or test_max_pool2d_simple or test_max_pool2d_bigger_stride or test_avg_pool2d or test_cat or test_scaled_product_attention or test_scaled_product_attention_causal or test_slice_fancy_indexing_dim_inject_none or test_slice_fancy_indexing_list_indices or test_slice_fancy_indexing_no_dim_collapse or test_slice_fancy_indexing_tuple_indices or test_slice_fancy_indexing_list_with_tensors or test_slice_fancy_indexing_dim_collapse_int or test_interpolate_bilinear or test_interpolate_bilinear_corners_aligned or test_scaled_dot_product_attention or test_cummax)" --durations=20
|
||||
- name: Test uops with Python emulator
|
||||
run: PYTHON=1 python3 -m pytest test/test_uops.py --durations=20
|
||||
- name: Test symbolic with Python emulator
|
||||
@@ -240,8 +253,8 @@ jobs:
|
||||
run: |
|
||||
PYTHONPATH="." python test/external/fuzz_shapetracker.py
|
||||
PYTHONPATH="." python test/external/fuzz_shapetracker_math.py
|
||||
- name: Repo line count <= 9999 lines
|
||||
run: MAX_LINE_COUNT=9999 python sz.py
|
||||
- name: Repo line count < 11000 lines
|
||||
run: MAX_LINE_COUNT=11000 python sz.py
|
||||
|
||||
testopencl:
|
||||
strategy:
|
||||
@@ -295,7 +308,7 @@ jobs:
|
||||
- if: ${{ matrix.task == 'optimage' }}
|
||||
name: Test openpilot model kernel count and gate usage
|
||||
run: |
|
||||
PYTHONPATH="." ALLOWED_KERNEL_COUNT=208 ALLOWED_READ_IMAGE=2131 ALLOWED_GATED_READ_IMAGE=13 FLOAT16=0 GPU=1 IMAGE=2 python examples/openpilot/compile3.py https://github.com/commaai/openpilot/raw/v0.9.4/selfdrive/modeld/models/supercombo.onnx
|
||||
PYTHONPATH="." ALLOWED_KERNEL_COUNT=209 ALLOWED_READ_IMAGE=2105 ALLOWED_GATED_READ_IMAGE=29 FLOAT16=0 GPU=1 IMAGE=2 python examples/openpilot/compile3.py https://github.com/commaai/openpilot/raw/v0.9.4/selfdrive/modeld/models/supercombo.onnx
|
||||
- if: ${{ matrix.task == 'optimage' }}
|
||||
name: Test openpilot alt model correctness (float32)
|
||||
run: PYTHONPATH="." FLOAT16=0 DEBUGCL=1 GPU=1 IMAGE=2 python examples/openpilot/compile3.py https://github.com/commaai/openpilot/raw/3799fe46b3a629e491d4b8498b8ae83e4c88c304/selfdrive/modeld/models/supercombo.onnx
|
||||
@@ -344,9 +357,36 @@ jobs:
|
||||
export COMMIT_MESSAGE=$(git show -s --format=%B ${{ github.event.pull_request.head.sha }})
|
||||
cp test/external/process_replay/process_replay.py ./process_replay.py && git fetch origin master && git -c advice.detachedHead=false checkout origin/master && PYTHONPATH=. python3 process_replay.py
|
||||
|
||||
testdsp:
|
||||
name: DSP Tests
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up Python 3.12
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: 3.12
|
||||
- name: Install Dependencies
|
||||
run: pip install --user -e .
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Build QEMU Docker with cache
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
file: extra/dsp/Dockerfile
|
||||
push: false
|
||||
load: true
|
||||
tags: qemu-hexagon:latest
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=min
|
||||
- name: Run test_tiny on DSP
|
||||
run: DEBUG=2 DSP=1 python test/test_tiny.py
|
||||
|
||||
testwebgpu:
|
||||
name: WebGPU Tests
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
@@ -481,7 +521,7 @@ jobs:
|
||||
path: ~/.cache/tinygrad/downloads/
|
||||
key: downloads-cache-${{ matrix.backend }}-${{ env.DOWNLOAD_CACHE_VERSION }}
|
||||
- name: Set env
|
||||
run: printf "${{ matrix.backend == 'llvm' && 'LLVM=1' || matrix.backend == 'clang' && 'CLANG=1' || matrix.backend == 'gpu' && 'GPU=1' || matrix.backend == 'PTX' && 'FORWARD_ONLY=1\nJIT=1\nOPT=2\nNV=1\nPTX=1\nMOCKGPU=1' || matrix.backend == 'triton' && 'FORWARD_ONLY=1\nJIT=1\nOPT=2\nNV=1\nMOCKGPU=1\nTRITON=1\nTRITON_PTXAS_PATH=/usr/bin/ptxas' || matrix.backend == 'amd' && 'AMD=1\nMOCKGPU=1\nFORWARD_ONLY=1' || matrix.backend == 'nv' && 'NV=1\nMOCKGPU=1\nFORWARD_ONLY=1' }}" >> $GITHUB_ENV
|
||||
run: printf "${{ matrix.backend == 'llvm' && 'LLVM=1' || matrix.backend == 'clang' && 'CLANG=1' || matrix.backend == 'gpu' && 'GPU=1' || matrix.backend == 'PTX' && 'FORWARD_ONLY=1\nJIT=1\nOPT=2\nCUDA=1\nPTX=1\nMOCKGPU=1' || matrix.backend == 'triton' && 'FORWARD_ONLY=1\nJIT=1\nOPT=2\nNV=1\nMOCKGPU=1\nTRITON=1\nTRITON_PTXAS_PATH=/usr/bin/ptxas' || matrix.backend == 'amd' && 'AMD=1\nMOCKGPU=1\nFORWARD_ONLY=1' || matrix.backend == 'nv' && 'NV=1\nMOCKGPU=1\nFORWARD_ONLY=1' }}" >> $GITHUB_ENV
|
||||
- name: Install OpenCL
|
||||
if: matrix.backend == 'gpu'
|
||||
run: |
|
||||
@@ -543,7 +583,7 @@ jobs:
|
||||
EOF
|
||||
sudo ldconfig
|
||||
- name: Install dependencies
|
||||
run: pip install -e '.[testing${{matrix.backend=='llvm'&&',llvm'||matrix.backend=='ptx'&&',cuda'||matrix.backend=='triton'&&',triton'||''}}]' --extra-index-url https://download.pytorch.org/whl/cpu --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/Triton-Nightly/pypi/simple/
|
||||
run: pip install -e '.[testing${{matrix.backend=='ptx'&&',cuda'||matrix.backend=='triton'&&',triton'||''}}]' --extra-index-url https://download.pytorch.org/whl/cpu --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/Triton-Nightly/pypi/simple/
|
||||
- name: Check Device.DEFAULT and print some source
|
||||
run: |
|
||||
PYTHONPATH=${{ github.workspace }} python3 -c "from tinygrad import Device; assert Device.DEFAULT in ['LLVM','CLANG','CUDA','GPU','AMD','NV'], Device.DEFAULT"
|
||||
@@ -559,7 +599,7 @@ jobs:
|
||||
run: python -m pytest -n=auto test/ -k 'not (half or test_efficientnet_safetensors)' --ignore=test/external --ignore=test/models --ignore=test/unit --ignore test/test_gc.py --durations=20
|
||||
- name: Run pytest (amd)
|
||||
if: matrix.backend=='amd'
|
||||
run: python -m pytest -n=auto test/test_ops.py test/test_dtype.py test/test_dtype_alu.py test/test_linearizer.py test/test_randomness.py test/imported/test_indexing.py test/test_hcq.py --durations=20
|
||||
run: python -m pytest -n=auto test/test_ops.py test/test_dtype.py test/test_dtype_alu.py test/test_linearizer.py test/test_randomness.py test/imported/test_indexing.py test/test_hcq.py test/external/external_test_am.py --durations=20
|
||||
- name: Run TRANSCENDENTAL math
|
||||
run: TRANSCENDENTAL=2 python -m pytest -n=auto test/test_ops.py::TestOps::test_sin test/test_ops.py::TestOps::test_cos test/test_ops.py::TestOps::test_tan test/test_ops.py::TestOps::test_exp test/test_ops.py::TestOps::test_log --durations=20
|
||||
- name: Run process replay tests
|
||||
@@ -568,6 +608,133 @@ jobs:
|
||||
export COMMIT_MESSAGE=$(git show -s --format=%B ${{ github.event.pull_request.head.sha }})
|
||||
cp test/external/process_replay/process_replay.py ./process_replay.py && git fetch origin master && git -c advice.detachedHead=false checkout origin/master && PYTHONPATH=. python3 process_replay.py
|
||||
|
||||
osxtests:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
||||
name: Tests on MacOS
|
||||
runs-on: macos-15
|
||||
timeout-minutes: 45
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 2 # NOTE: this fetches the HEAD commit of the PR
|
||||
- name: Set up Python 3.12
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: 3.12
|
||||
- name: Cache python packages
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: /Users/runner/Library/Python/3.12/lib/python/site-packages
|
||||
key: mockgpu-osx-${{ matrix.backend }}-packages-${{ hashFiles('**/setup.py') }}
|
||||
- name: Install llvm
|
||||
run: |
|
||||
brew install llvm
|
||||
- name: Install comgr
|
||||
run: |
|
||||
sudo mkdir -p /usr/local/lib
|
||||
curl -s -H "Authorization: token $GH_TOKEN" curl -s https://api.github.com/repos/nimlgen/amdcomgr_dylib/releases/latest | \
|
||||
jq -r '.assets[] | select(.name == "libamd_comgr.dylib").browser_download_url' | \
|
||||
sudo xargs curl -L -o /usr/local/lib/libamd_comgr.dylib
|
||||
- name: Install remu
|
||||
run: |
|
||||
curl -s -H "Authorization: token $GH_TOKEN" curl -s https://api.github.com/repos/Qazalin/remu/releases/latest | \
|
||||
jq -r '.assets[] | select(.name == "libremu.dylib").browser_download_url' | \
|
||||
sudo xargs curl -L -o /usr/local/lib/libremu.dylib
|
||||
- name: Install dependencies
|
||||
run: pip install --user -e '.[testing]' --extra-index-url https://download.pytorch.org/whl/cpu
|
||||
- name: Check Device.DEFAULT and print some source (AMD)
|
||||
env:
|
||||
PYTHONPATH: ${{ github.workspace }}
|
||||
MOCKGPU: 1
|
||||
AMD: 1
|
||||
FORWARD_ONLY: 1
|
||||
run: |
|
||||
python3 -c "from tinygrad import Device; assert Device.DEFAULT == 'AMD', Device.DEFAULT"
|
||||
DEBUG=5 python3 test/test_ops.py TestOps.test_add
|
||||
- name: Check Device.DEFAULT and print some source (LLVM)
|
||||
env:
|
||||
LLVM: 1
|
||||
run: |
|
||||
python3 -c "from tinygrad import Device; assert Device.DEFAULT == 'LLVM', Device.DEFAULT"
|
||||
DEBUG=5 python3 test/test_ops.py TestOps.test_add
|
||||
- name: Check Device.DEFAULT and print some source (CLANG)
|
||||
env:
|
||||
CLANG: 1
|
||||
run: |
|
||||
python3 -c "from tinygrad import Device; assert Device.DEFAULT == 'CLANG', Device.DEFAULT"
|
||||
DEBUG=5 python3 test/test_ops.py TestOps.test_add
|
||||
- name: Run pytest (amd)
|
||||
env:
|
||||
MOCKGPU: 1
|
||||
AMD: 1
|
||||
FORWARD_ONLY: 1
|
||||
run: |
|
||||
python3 -m pytest -n=auto test/test_hcq.py test/test_tiny.py --durations=20
|
||||
- name: Run pytest (llvm)
|
||||
env:
|
||||
LLVM: 1
|
||||
run: |
|
||||
python3 -m pytest -n=auto test/ --ignore=test/unit --durations=20
|
||||
! (DEBUG=7 python3 test/test_zero_copy.py 2>&1 || true) | grep -E '^0x.*[^0](x18|w18).*$'
|
||||
- name: Run pytest (clang)
|
||||
env:
|
||||
CLANG: 1
|
||||
run: |
|
||||
python3 -m pytest -n=auto test/ --ignore=test/unit --durations=20
|
||||
! (DEBUG=7 python3 test/test_zero_copy.py 2>&1 || true) | grep -E '^0x.*[^0](x18|w18).*$'
|
||||
|
||||
wintests:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
name: Tests on Windows (llvm+clang)
|
||||
runs-on: windows-latest
|
||||
timeout-minutes: 45
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 2 # NOTE: this fetches the HEAD commit of the PR
|
||||
- name: Set up Python 3.12
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: 3.12
|
||||
- name: Cache python packages
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ env.Python3_ROOT_DIR }}\Lib\site-packages
|
||||
key: windows-packages-${{ hashFiles('**/setup.py') }}
|
||||
- name: Set env
|
||||
shell: bash
|
||||
run: |
|
||||
if [ "${{ matrix.backend }}" = "clang" ]; then
|
||||
echo "CLANG=1" >> $GITHUB_ENV
|
||||
elif [ "${{ matrix.backend }}" = "llvm" ]; then
|
||||
echo "LLVM=1" >> $GITHUB_ENV
|
||||
fi
|
||||
- name: Install dependencies
|
||||
run: pip install -e '.[testing]' --extra-index-url https://download.pytorch.org/whl/cpu
|
||||
- name: Check Device.DEFAULT and print some source (llvm)
|
||||
shell: bash
|
||||
run: |
|
||||
PYTHONPATH=${{ github.workspace }} LLVM=1 python3 -c "from tinygrad import Device; assert Device.DEFAULT == 'LLVM', Device.DEFAULT"
|
||||
DEBUG=5 PYTHONPATH=${{ github.workspace }} LLVM=1 FORWARD_ONLY=1 python3 test/test_ops.py TestOps.test_add
|
||||
- name: Check Device.DEFAULT and print some source (clang)
|
||||
shell: bash
|
||||
run: |
|
||||
PYTHONPATH=${{ github.workspace }} CLANG=1 python3 -c "from tinygrad import Device; assert Device.DEFAULT == 'CLANG', Device.DEFAULT"
|
||||
DEBUG=5 PYTHONPATH=${{ github.workspace }} CLANG=1 FORWARD_ONLY=1 python3 test/test_ops.py TestOps.test_add
|
||||
- name: Run pytest (llvm)
|
||||
shell: bash
|
||||
run: |
|
||||
LLVM=1 python -m pytest -n=auto test/test_tiny.py test/test_ops.py --durations=20
|
||||
- name: Run pytest (clang)
|
||||
shell: bash
|
||||
run: |
|
||||
CLANG=1 python -m pytest -n=auto test/test_tiny.py test/test_ops.py --durations=20
|
||||
|
||||
#testunicorn:
|
||||
# name: ARM64 unicorn Test
|
||||
# runs-on: ubuntu-latest
|
||||
|
||||
+2
-2
@@ -35,9 +35,8 @@ extra/datasets/COCO/
|
||||
extra/datasets/audio*
|
||||
extra/weights
|
||||
venv
|
||||
examples/**/**/net*.*[js,json]
|
||||
examples/**/net.*[js,json]
|
||||
examples/**/*.safetensors
|
||||
examples/webgpu/stable_diffusion/*.*[js,mjs]
|
||||
node_modules
|
||||
package.json
|
||||
package-lock.json
|
||||
@@ -57,3 +56,4 @@ comgr_*
|
||||
*.pkl
|
||||
site/
|
||||
master_schedule.py
|
||||
profile_stats
|
||||
|
||||
@@ -7,7 +7,7 @@ extension-pkg-whitelist=scipy,cereal.messaging.messaging_pyx,PyQt5,av
|
||||
|
||||
# Add files or directories to the blacklist. They should be base names, not
|
||||
# paths.
|
||||
ignore=CVS,autogen,msm_kgsl.py
|
||||
ignore=CVS,autogen,msm_kgsl.py,runtime
|
||||
|
||||
# Add files or directories matching the regex patterns to the blacklist. The
|
||||
# regex matches against base names, not paths.
|
||||
|
||||
+110
-2
@@ -69,7 +69,7 @@ generate_comgr() {
|
||||
--clang-args="-D__HIP_PLATFORM_AMD__ -I/opt/rocm/include -x c++" -o $BASE/comgr.py -l /opt/rocm/lib/libamd_comgr.so
|
||||
fixup $BASE/comgr.py
|
||||
sed -i "s\import ctypes\import ctypes, ctypes.util, os\g" $BASE/comgr.py
|
||||
patch_dlopen $BASE/comgr.py amd_comgr "'/opt/rocm/lib/libamd_comgr.so'" "os.getenv('ROCM_PATH', '')+'/lib/libamd_comgr.so'"
|
||||
patch_dlopen $BASE/comgr.py amd_comgr "'/opt/rocm/lib/libamd_comgr.so'" "os.getenv('ROCM_PATH', '')+'/lib/libamd_comgr.so'" "'/usr/local/lib/libamd_comgr.dylib'" "'/opt/homebrew/lib/libamd_comgr.dylib'"
|
||||
sed -i "s\ctypes.CDLL('/opt/rocm/lib/libamd_comgr.so')\_try_dlopen_amd_comgr()\g" $BASE/comgr.py
|
||||
python3 -c "import tinygrad.runtime.autogen.comgr"
|
||||
}
|
||||
@@ -79,6 +79,10 @@ generate_kfd() {
|
||||
|
||||
fixup $BASE/kfd.py
|
||||
sed -i "s\import ctypes\import ctypes, os\g" $BASE/kfd.py
|
||||
sed -i "s\import fcntl, functools\import functools" $BASE/kfd.py
|
||||
sed -i "s\import ctypes,os\a from tinygrad.runtime.support import HWInterface\g" $BASE/kfd.py
|
||||
sed -i "s\def _do_ioctl(__idir, __base, __nr, __user_struct, __fd, **kwargs):\def _do_ioctl(__idir, __base, __nr, __user_struct, __fd:HWInterface, **kwargs):\g" $BASE/kfd.py
|
||||
sed -i "s\fcntl.ioctl(__fd, (__idir<<30)\__fd.ioctl((__idir<<30)\g" $BASE/kfd.py
|
||||
python3 -c "import tinygrad.runtime.autogen.kfd"
|
||||
}
|
||||
|
||||
@@ -218,11 +222,30 @@ generate_libc() {
|
||||
fixup $BASE/libc.py
|
||||
}
|
||||
|
||||
generate_llvm() {
|
||||
INC="$(llvm-config-14 --includedir)"
|
||||
clang2py -k cdefstum \
|
||||
$(find "$INC/llvm-c/" -type f -name '*.h' | sort) \
|
||||
"$INC/llvm/Config/Targets.def" \
|
||||
"$INC/llvm/Config/AsmPrinters.def" \
|
||||
"$INC/llvm/Config/AsmParsers.def" \
|
||||
"$INC/llvm/Config/Disassemblers.def" \
|
||||
--clang-args="$(llvm-config-14 --cflags)" \
|
||||
-o "$BASE/llvm.py"
|
||||
|
||||
sed -i "s\import ctypes\import ctypes, tinygrad.runtime.support.llvm as llvm_support\g" "$BASE/llvm.py"
|
||||
sed -i "s\FIXME_STUB\llvm\g" "$BASE/llvm.py"
|
||||
sed -i "s\FunctionFactoryStub()\ctypes.CDLL(llvm_support.LLVM_PATH)\g" "$BASE/llvm.py"
|
||||
|
||||
fixup "$BASE/llvm.py"
|
||||
}
|
||||
|
||||
generate_kgsl() {
|
||||
clang2py extra/qcom_gpu_driver/msm_kgsl.h -o $BASE/kgsl.py -k cdefstum
|
||||
fixup $BASE/kgsl.py
|
||||
sed -i "s\import ctypes\import ctypes, os\g" $BASE/kgsl.py
|
||||
sed -nE 's/#define ([A-Za-z0-9_]+)_SHIFT\s*[^\S\r\n]*[0-9]*$/def \1(val): return (val << \1_SHIFT) \& \1_MASK/p' extra/qcom_gpu_driver/msm_kgsl.h >> $BASE/kgsl.py
|
||||
sed -i "s\fcntl.ioctl(__fd, (__idir<<30)\__fd.ioctl((__idir<<30)\g" $BASE/kgsl.py
|
||||
python3 -c "import tinygrad.runtime.autogen.kgsl"
|
||||
}
|
||||
|
||||
@@ -247,6 +270,87 @@ generate_qcom() {
|
||||
python3 -c "import tinygrad.runtime.autogen.qcom_dsp"
|
||||
}
|
||||
|
||||
generate_pciaccess() {
|
||||
clang2py -k cdefstum \
|
||||
/usr/include/pciaccess.h \
|
||||
/usr/include/linux/pci_regs.h \
|
||||
-l /usr/lib/x86_64-linux-gnu/libpciaccess.so \
|
||||
-o $BASE/libpciaccess.py
|
||||
sed -i "s\import ctypes\import ctypes, os\g" $BASE/libpciaccess.py
|
||||
fixup $BASE/libpciaccess.py
|
||||
sed -i "s/ctypes\.CDLL('\([^']*\)')/ctypes.CDLL('\1') if os.path.exists('\1') else None/g" $BASE/libpciaccess.py
|
||||
}
|
||||
|
||||
generate_vfio() {
|
||||
clang2py -k cdefstum \
|
||||
/usr/include/linux/vfio.h \
|
||||
-o $BASE/vfio.py
|
||||
fixup $BASE/vfio.py
|
||||
sed -i "s\import ctypes\import ctypes, os\g" $BASE/vfio.py
|
||||
sed -i "s\import fcntl, functools\import functools" $BASE/vfio.py
|
||||
sed -i "s\import ctypes,os\a from tinygrad.runtime.support import HWInterface\g" $BASE/vfio.py
|
||||
sed -i "s\fcntl.ioctl(__fd, (__idir<<30)\return __fd.ioctl((__idir<<30)\g" $BASE/vfio.py
|
||||
}
|
||||
|
||||
generate_am() {
|
||||
clang2py -k cdefstum \
|
||||
extra/amdpci/headers/v11_structs.h \
|
||||
extra/amdpci/headers/amdgpu_vm.h \
|
||||
extra/amdpci/headers/discovery.h \
|
||||
extra/amdpci/headers/amdgpu_ucode.h \
|
||||
extra/amdpci/headers/soc21_enum.h \
|
||||
extra/amdpci/headers/psp_gfx_if.h \
|
||||
extra/amdpci/headers/amdgpu_psp.h \
|
||||
extra/amdpci/headers/amdgpu_irq.h \
|
||||
extra/amdpci/headers/amdgpu_doorbell.h \
|
||||
extra/amdpci/headers/soc15_ih_clientid.h \
|
||||
-o $BASE/am/am.py
|
||||
fixup $BASE/am/am.py
|
||||
|
||||
clang2py -k cdefstum \
|
||||
extra/amdpci/headers/mp_13_0_0_offset.h \
|
||||
extra/amdpci/headers/mp_13_0_0_sh_mask.h \
|
||||
-o $BASE/am/mp_13_0_0.py
|
||||
fixup $BASE/am/mp_13_0_0.py
|
||||
|
||||
clang2py -k cdefstum \
|
||||
extra/amdpci/headers/mp_11_0_offset.h \
|
||||
extra/amdpci/headers/mp_11_0_sh_mask.h \
|
||||
-o $BASE/am/mp_11_0.py
|
||||
fixup $BASE/am/mp_11_0.py
|
||||
|
||||
clang2py -k cdefstum \
|
||||
extra/amdpci/headers/gc_11_0_0_offset.h \
|
||||
extra/amdpci/headers/gc_11_0_0_sh_mask.h \
|
||||
-o $BASE/am/gc_11_0_0.py
|
||||
fixup $BASE/am/gc_11_0_0.py
|
||||
|
||||
clang2py -k cdefstum \
|
||||
extra/amdpci/headers/mmhub_3_0_0_offset.h \
|
||||
extra/amdpci/headers/mmhub_3_0_0_sh_mask.h \
|
||||
-o $BASE/am/mmhub_3_0_0.py
|
||||
fixup $BASE/am/mmhub_3_0_0.py
|
||||
|
||||
clang2py -k cdefstum \
|
||||
extra/amdpci/headers/nbio_4_3_0_offset.h \
|
||||
extra/amdpci/headers/nbio_4_3_0_sh_mask.h \
|
||||
-o $BASE/am/nbio_4_3_0.py
|
||||
fixup $BASE/am/nbio_4_3_0.py
|
||||
|
||||
clang2py -k cdefstum \
|
||||
extra/amdpci/headers/osssys_6_0_0_offset.h \
|
||||
extra/amdpci/headers/osssys_6_0_0_sh_mask.h \
|
||||
-o $BASE/am/osssys_6_0_0.py
|
||||
fixup $BASE/am/osssys_6_0_0.py
|
||||
|
||||
clang2py -k cdefstum \
|
||||
extra/amdpci/headers/smu_v13_0_0_ppsmc.h \
|
||||
extra/amdpci/headers/smu13_driver_if_v13_0_0.h \
|
||||
extra/amdpci/headers/amdgpu_smu.h \
|
||||
-o $BASE/am/smu_v13_0_0.py
|
||||
fixup $BASE/am/smu_v13_0_0.py
|
||||
}
|
||||
|
||||
if [ "$1" == "opencl" ]; then generate_opencl
|
||||
elif [ "$1" == "hip" ]; then generate_hip
|
||||
elif [ "$1" == "comgr" ]; then generate_comgr
|
||||
@@ -256,11 +360,15 @@ elif [ "$1" == "hsa" ]; then generate_hsa
|
||||
elif [ "$1" == "kfd" ]; then generate_kfd
|
||||
elif [ "$1" == "nv" ]; then generate_nv
|
||||
elif [ "$1" == "amd" ]; then generate_amd
|
||||
elif [ "$1" == "am" ]; then generate_am
|
||||
elif [ "$1" == "qcom" ]; then generate_qcom
|
||||
elif [ "$1" == "io_uring" ]; then generate_io_uring
|
||||
elif [ "$1" == "libc" ]; then generate_libc
|
||||
elif [ "$1" == "llvm" ]; then generate_llvm
|
||||
elif [ "$1" == "kgsl" ]; then generate_kgsl
|
||||
elif [ "$1" == "adreno" ]; then generate_adreno
|
||||
elif [ "$1" == "all" ]; then generate_opencl; generate_hip; generate_comgr; generate_cuda; generate_nvrtc; generate_hsa; generate_kfd; generate_nv; generate_amd; generate_io_uring; generate_libc
|
||||
elif [ "$1" == "pci" ]; then generate_pciaccess
|
||||
elif [ "$1" == "vfio" ]; then generate_vfio
|
||||
elif [ "$1" == "all" ]; then generate_opencl; generate_hip; generate_comgr; generate_cuda; generate_nvrtc; generate_hsa; generate_kfd; generate_nv; generate_amd; generate_io_uring; generate_libc; generate_am
|
||||
else echo "usage: $0 <type>"
|
||||
fi
|
||||
|
||||
+10
-10
@@ -7,7 +7,7 @@
|
||||
|
||||
print("******** first, the runtime ***********")
|
||||
|
||||
from tinygrad.runtime.ops_clang import ClangProgram, ClangCompiler, MallocAllocator
|
||||
from tinygrad.runtime.ops_clang import ClangJITCompiler, MallocAllocator, CPUProgram
|
||||
|
||||
# allocate some buffers
|
||||
out = MallocAllocator.alloc(4)
|
||||
@@ -19,10 +19,10 @@ MallocAllocator._copyin(a, memoryview(bytearray([2,0,0,0])))
|
||||
MallocAllocator._copyin(b, memoryview(bytearray([3,0,0,0])))
|
||||
|
||||
# compile a program to a binary
|
||||
lib = ClangCompiler().compile("void add(int *out, int *a, int *b) { out[0] = a[0] + b[0]; }")
|
||||
lib = ClangJITCompiler().compile("void add(int *out, int *a, int *b) { out[0] = a[0] + b[0]; }")
|
||||
|
||||
# create a runtime for the program (ctypes.CDLL)
|
||||
fxn = ClangProgram("add", lib)
|
||||
# create a runtime for the program
|
||||
fxn = CPUProgram("add", lib)
|
||||
|
||||
# run the program
|
||||
fxn(out, a, b)
|
||||
@@ -65,7 +65,7 @@ kernel = get_kernel(Device[DEVICE].renderer, s).linearize()
|
||||
# compile a program (and print the source)
|
||||
fxn = CompiledRunner(kernel.to_program())
|
||||
print(fxn.p.src)
|
||||
# NOTE: fxn.clprg is the ClangProgram
|
||||
# NOTE: fxn.clprg is the CPUProgram
|
||||
|
||||
# run the program
|
||||
fxn.exec([out, a, b])
|
||||
@@ -77,22 +77,22 @@ assert out.as_buffer().cast('I')[0] == 5
|
||||
print("******** third, the LazyBuffer ***********")
|
||||
|
||||
from tinygrad.engine.realize import run_schedule
|
||||
from tinygrad.engine.schedule import create_schedule
|
||||
from tinygrad.engine.schedule import create_schedule_with_vars
|
||||
|
||||
# allocate some values + load in values
|
||||
a = UOp.metaop(Ops.EMPTY, (1,), dtypes.int32, DEVICE)
|
||||
b = UOp.metaop(Ops.EMPTY, (1,), dtypes.int32, DEVICE)
|
||||
a.buffer.allocate().copyin(memoryview(bytearray(struct.pack("I", 2))))
|
||||
b.buffer.allocate().copyin(memoryview(bytearray(struct.pack("I", 3))))
|
||||
del a.srcs
|
||||
del b.srcs
|
||||
|
||||
# describe the computation
|
||||
out = a.alu(Ops.ADD, b)
|
||||
|
||||
# schedule the computation as a list of kernels
|
||||
sched = create_schedule([out])
|
||||
sched, _, becomes_map = create_schedule_with_vars(out.sink())
|
||||
for si in sched: print(si.ast.op) # NOTE: the first two convert it to CLANG
|
||||
# NOTE: UOps are no longer mutable, the scheduler gives you a map to lookup which BUFFER the result was written to
|
||||
out = becomes_map[out]
|
||||
|
||||
# DEBUGGING: print the compute ast
|
||||
print(sched[-1].ast)
|
||||
@@ -102,7 +102,7 @@ print(sched[-1].ast)
|
||||
run_schedule(sched)
|
||||
|
||||
# check the data out
|
||||
assert out.realized is not None and out.realized.as_buffer().cast('I')[0] == 5
|
||||
assert out.is_realized and out.buffer.as_buffer().cast('I')[0] == 5
|
||||
|
||||
|
||||
print("******** fourth, the Tensor ***********")
|
||||
|
||||
@@ -26,10 +26,11 @@ l1n, l2n = l1.numpy(), l2.numpy()
|
||||
from tinygrad.nn.optim import SGD
|
||||
optim = SGD([l1, l2])
|
||||
|
||||
Tensor.training = True
|
||||
X, Y = X_train[(samples:=Tensor.randint(128, high=X_train.shape[0]))], Y_train[samples]
|
||||
optim.zero_grad()
|
||||
model(X).sparse_categorical_crossentropy(Y).backward()
|
||||
optim._step() # this will step the optimizer without running realize
|
||||
optim.schedule_step() # this will step the optimizer without running realize
|
||||
|
||||
# *****
|
||||
# 3. Create a schedule.
|
||||
@@ -47,7 +48,7 @@ for si in schedule: print(str(si)[:80])
|
||||
# 4. Lower a schedule.
|
||||
|
||||
from tinygrad.engine.realize import lower_schedule_item, ExecItem
|
||||
lowered: List[ExecItem] = [ExecItem(lower_schedule_item(si).prg, list(si.bufs)) for si in tqdm(schedule)]
|
||||
lowered: List[ExecItem] = [lower_schedule_item(si) for si in tqdm(schedule)]
|
||||
|
||||
# *****
|
||||
# 5. Run the schedule
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
# AM Driver
|
||||
|
||||
AM driver is a userspace driver targeting AMD's 7900XTX. You only need tinygrad to send compute tasks to your GPU!
|
||||
|
||||
## How to run?
|
||||
Make sure that amdgpu module is unloaded and just run tinygrad with `AMD=1`!
|
||||
|
||||
Optional requirements:
|
||||
|
||||
* System without IOMMU for P2P / SDMA support
|
||||
* vfio-pci module for IRQ handling
|
||||
|
||||
## Environment Variables
|
||||
|
||||
| Variable | Possible Value(s) | Description |
|
||||
|----------|------------------|-------------|
|
||||
| AM_RESET | [1] | Performs a full GPU reset (reloading all firmware and IP blocks) |
|
||||
| AM_DEBUG | [0-4] | Sets the level of additional debugging information |
|
||||
|
||||
## AM Driver Details
|
||||
|
||||
### Compute & SDMA Queues
|
||||
|
||||
AM binds compute queues directly to MEC (bypassing MES). Tinygrad uses only one compute queue, which is bound at `pipe=0 queue=0`. Similarly, the single SDMA queue is bound at `engine=0 queue=0`.
|
||||
|
||||
### Boot
|
||||
|
||||
The GPU being passed can be in one of several states:
|
||||
1. Not initialized
|
||||
2. Initialized by amdgpu
|
||||
3. Initialized by AM
|
||||
|
||||
The first and second states require a full GPU setup since their states are unknown. The second state also requires a mode1 reset to reinitialize all components.
|
||||
|
||||
The third state can be set up partially to optimize boot time. In this case, only the GFX and SDMA IPs need to be initialized. To enable this, AM uses a separate boot memory that is guaranteed not to be overwritten. This physical memory is utilized for all blocks that are initialized only during the initial AM boot. To determine if the GPU is in the third state, AM uses `regSCRATCH_REG7` as a flag.
|
||||
|
||||
### VM Management
|
||||
|
||||
Each AM device sets up only a single `VMID=0` and one page directory. The page directory used is 3-level and thus supports up to 512GB of virtual addresses. All AM devices are located in one virtual address space.
|
||||
@@ -9,7 +9,7 @@ There is a good [bunch of tutorials](https://mesozoic-egg.github.io/tinygrad-not
|
||||
|
||||
## Frontend
|
||||
|
||||
Everything in [Tensor](../tensor/index.md) is syntactic sugar around [function.py](function.md), where the forwards and backwards passes are implemented for the different functions. There's about 25 of them, implemented using about 20 basic ops. Those basic ops go on to construct a graph of [UOps](../developer/uop.md).
|
||||
Everything in [Tensor](../tensor/index.md) is syntactic sugar around constructing a graph of [UOps](../developer/uop.md).
|
||||
|
||||
The `UOp` graph specifies the compute in terms of low level tinygrad ops. Not all UOps will actually become realized. There's two types of UOps, base and view. base contains compute into a contiguous buffer, and view is a view (specified by a ShapeTracker). Inputs to a base can be either base or view, inputs to a view can only be a single base.
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
::: tinygrad.function
|
||||
options:
|
||||
members: [
|
||||
"Contiguous",
|
||||
"ContiguousBackward",
|
||||
"Cast",
|
||||
"Neg",
|
||||
"Reciprocal",
|
||||
"Sin",
|
||||
"Relu",
|
||||
"Log",
|
||||
"Exp",
|
||||
"Sqrt",
|
||||
"Sigmoid",
|
||||
"Sign",
|
||||
"Less",
|
||||
"Eq",
|
||||
"Xor",
|
||||
"Add",
|
||||
"Sub",
|
||||
"Mul",
|
||||
"Div",
|
||||
"Where",
|
||||
"Sum",
|
||||
"Max",
|
||||
"Expand",
|
||||
"Reshape",
|
||||
"Permute",
|
||||
"Pad",
|
||||
"Shrink",
|
||||
"Flip",
|
||||
]
|
||||
show_source: false
|
||||
@@ -36,9 +36,9 @@ The `Allocator` class is responsible for managing memory on the device. There is
|
||||
|
||||
### Program
|
||||
|
||||
The `Program` class is created for each loaded program. It is responsible for compiling and executing the program on the device. As an example, here is a `ClangProgram` implementation which loads program and runs it.
|
||||
The `Program` class is created for each loaded program. It is responsible for executing the program on the device. As an example, here is a `CPUProgram` implementation which loads program and runs it.
|
||||
|
||||
::: tinygrad.runtime.ops_clang.ClangProgram
|
||||
::: tinygrad.runtime.ops_clang.CPUProgram
|
||||
options:
|
||||
members: true
|
||||
|
||||
|
||||
+3
-2
@@ -44,7 +44,8 @@ DEFAULT_FLOAT | [HALF, ...]| specify the default float dtype (FLOAT32, HAL
|
||||
IMAGE | [1-2] | enable 2d specific optimizations
|
||||
FLOAT16 | [1] | use float16 for images instead of float32
|
||||
PTX | [1] | enable the specialized [PTX](https://docs.nvidia.com/cuda/parallel-thread-execution/) assembler for Nvidia GPUs. If not set, defaults to generic CUDA codegen backend.
|
||||
PROFILE | [1] | enable output of [perfetto](https://ui.perfetto.dev/) compatible profile. This feature is supported in NV and AMD backends.
|
||||
PROFILE | [1] | enable profiling. This feature is supported in NV, AMD, QCOM and METAL backends.
|
||||
VISIBLE_DEVICES | [list[int]]| restricts the NV/AMD devices that are available. The format is a comma-separated list of identifiers (indexing starts with 0).
|
||||
JIT | [0-2] | 0=disabled, 1=[jit enabled](quickstart.md#jit) (default), 2=jit enabled, but graphs are disabled
|
||||
VIZ | [1] | 0=disabled, 1=[viz enabled](https://github.com/tinygrad/tinygrad/tree/master/tinygrad/viz)
|
||||
VIZ | [1] | 0=disabled, 1=[viz enabled](https://github.com/tinygrad/tinygrad/tree/master/tinygrad/viz)
|
||||
ALLOW_TF32 | [1] | enable TensorFloat-32 tensor cores on Ampere or newer GPUs.
|
||||
@@ -30,3 +30,4 @@
|
||||
::: tinygrad.nn.state.get_parameters
|
||||
::: tinygrad.nn.state.load_state_dict
|
||||
::: tinygrad.nn.state.torch_load
|
||||
::: tinygrad.nn.state.gguf_load
|
||||
|
||||
+1
-1
@@ -11,4 +11,4 @@ tinygrad supports various runtimes, enabling your code to scale across a wide ra
|
||||
| [CUDA](https://github.com/tinygrad/tinygrad/tree/master/tinygrad/runtime/ops_cuda.py) | Utilizes CUDA for acceleration on NVIDIA GPUs | NVIDIA GPU with CUDA support |
|
||||
| [GPU (OpenCL)](https://github.com/tinygrad/tinygrad/tree/master/tinygrad/runtime/ops_gpu.py) | Accelerates computations using OpenCL on GPUs | OpenCL 2.0 compatible device |
|
||||
| [CLANG (C Code)](https://github.com/tinygrad/tinygrad/tree/master/tinygrad/runtime/ops_clang.py) | Runs on CPU using the clang compiler | `clang` compiler in system `PATH` |
|
||||
| [LLVM](https://github.com/tinygrad/tinygrad/tree/master/tinygrad/runtime/ops_llvm.py) | Runs on CPU using the LLVM compiler infrastructure | `llvmlite` package installed |
|
||||
| [LLVM (LLVM IR)](https://github.com/tinygrad/tinygrad/tree/master/tinygrad/runtime/ops_llvm.py) | Runs on CPU using the LLVM compiler infrastructure | llvm libraries installed and findable |
|
||||
|
||||
@@ -63,6 +63,8 @@ Elementwise ops operate on a per element basis. They don't change the shape of t
|
||||
::: tinygrad.Tensor.sub
|
||||
::: tinygrad.Tensor.mul
|
||||
::: tinygrad.Tensor.div
|
||||
::: tinygrad.Tensor.idiv
|
||||
::: tinygrad.Tensor.mod
|
||||
::: tinygrad.Tensor.xor
|
||||
::: tinygrad.Tensor.lshift
|
||||
::: tinygrad.Tensor.rshift
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
## Movement (high level)
|
||||
|
||||
::: tinygrad.Tensor.__getitem__
|
||||
::: tinygrad.Tensor.gather
|
||||
::: tinygrad.Tensor.cat
|
||||
::: tinygrad.Tensor.stack
|
||||
@@ -24,3 +25,5 @@
|
||||
::: tinygrad.Tensor.transpose
|
||||
::: tinygrad.Tensor.flatten
|
||||
::: tinygrad.Tensor.unflatten
|
||||
::: tinygrad.Tensor.roll
|
||||
::: tinygrad.Tensor.rearrange
|
||||
@@ -31,4 +31,8 @@
|
||||
::: tinygrad.Tensor.shard_
|
||||
::: tinygrad.Tensor.contiguous
|
||||
::: tinygrad.Tensor.contiguous_backward
|
||||
|
||||
## Gradient
|
||||
|
||||
::: tinygrad.Tensor.gradient
|
||||
::: tinygrad.Tensor.backward
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import sys, onnx, time
|
||||
from tinygrad import TinyJit, Device, GlobalCounters, fetch, getenv
|
||||
from extra.onnx import OnnxRunner
|
||||
from extra.onnx_helpers import get_example_inputs, validate
|
||||
|
||||
def load_onnx_model(onnx_file):
|
||||
onnx_model = onnx.load(onnx_file)
|
||||
run_onnx = OnnxRunner(onnx_model)
|
||||
run_onnx_jit = TinyJit(lambda **kwargs: next(iter(run_onnx({k:v.to(Device.DEFAULT) for k,v in kwargs.items()}).values())), prune=True)
|
||||
return run_onnx_jit, run_onnx.graph_inputs
|
||||
|
||||
if __name__ == "__main__":
|
||||
onnx_file = fetch(sys.argv[1])
|
||||
run_onnx_jit, input_specs = load_onnx_model(onnx_file)
|
||||
print("loaded model")
|
||||
|
||||
for i in range(3):
|
||||
new_inputs = get_example_inputs(input_specs)
|
||||
GlobalCounters.reset()
|
||||
print(f"run {i}")
|
||||
run_onnx_jit(**new_inputs)
|
||||
|
||||
# run 20 times
|
||||
for _ in range(20):
|
||||
new_inputs = get_example_inputs(input_specs)
|
||||
GlobalCounters.reset()
|
||||
st = time.perf_counter()
|
||||
out = run_onnx_jit(**new_inputs)
|
||||
mt = time.perf_counter()
|
||||
val = out.numpy()
|
||||
et = time.perf_counter()
|
||||
print(f"enqueue {(mt-st)*1e3:6.2f} ms -- total run {(et-st)*1e3:6.2f} ms")
|
||||
|
||||
if getenv("ORT"):
|
||||
validate(onnx_file, new_inputs, rtol=1e-3, atol=1e-3)
|
||||
print("model validated")
|
||||
@@ -8,7 +8,7 @@ import numpy as np
|
||||
import subprocess
|
||||
import tensorflow as tf
|
||||
import tf2onnx
|
||||
from extra.onnx import get_run_onnx
|
||||
from extra.onnx import OnnxRunner
|
||||
from tinygrad.tensor import Tensor
|
||||
from extra.export_model import export_model_clang, compile_net, jit_model
|
||||
|
||||
@@ -25,7 +25,7 @@ class TinyOnnx:
|
||||
def __init__(self, keras_model):
|
||||
input_signature = [tf.TensorSpec([1,32], tf.float32, name='x')]
|
||||
onnx_model, _ = tf2onnx.convert.from_keras(keras_model, input_signature, opset=13)
|
||||
self.run_onnx = get_run_onnx(onnx_model)
|
||||
self.run_onnx = OnnxRunner(onnx_model)
|
||||
|
||||
def forward(self, x):
|
||||
return self.run_onnx({"x": x}, debug=False)['predictions']
|
||||
|
||||
@@ -117,7 +117,7 @@ def tts(
|
||||
stn_tst = text_mapper.get_text(text_to_synthesize, hps.data.add_blank, hps.data.text_cleaners)
|
||||
init_shape = stn_tst.shape
|
||||
assert init_shape[0] < pad_length, "text is too long"
|
||||
x_tst, x_tst_lengths = stn_tst.pad(((0, pad_length - init_shape[0]),), 1).unsqueeze(0), Tensor([init_shape[0]], dtype=dtypes.int64)
|
||||
x_tst, x_tst_lengths = stn_tst.pad(((0, pad_length - init_shape[0]),), value=1).unsqueeze(0), Tensor([init_shape[0]], dtype=dtypes.int64)
|
||||
sid = Tensor([speaker_id], dtype=dtypes.int64) if model_has_multiple_speakers else None
|
||||
|
||||
# Perform inference.
|
||||
|
||||
@@ -6,7 +6,6 @@ from tinygrad import Tensor, Device, dtypes, nn
|
||||
from tinygrad.codegen.kernel import Kernel
|
||||
from tinygrad.ops import Ops, sym_infer
|
||||
from tinygrad.device import Compiled
|
||||
from tinygrad.engine.schedule import create_schedule
|
||||
from tinygrad.engine.search import time_linearizer, beam_search, bufs_from_lin
|
||||
from tinygrad.helpers import DEBUG, ansilen, getenv, colored, TRACEMETA
|
||||
|
||||
@@ -18,12 +17,12 @@ def get_sched_resnet():
|
||||
# run model twice to get only what changes, these are the kernels of the model
|
||||
for _ in range(2):
|
||||
out = mdl(Tensor.empty(BS, 3, 224, 224))
|
||||
targets = [out.lazydata]
|
||||
targets = [out]
|
||||
if getenv("BACKWARD"):
|
||||
optim.zero_grad()
|
||||
out.sparse_categorical_crossentropy(Tensor.empty(BS, dtype=dtypes.int)).backward()
|
||||
targets += [x.lazydata for x in optim.schedule_step()]
|
||||
sched = create_schedule(targets)
|
||||
targets += [x for x in optim.schedule_step()]
|
||||
sched = Tensor.schedule(*targets)
|
||||
print(f"schedule length {len(sched)}")
|
||||
return sched
|
||||
|
||||
@@ -42,17 +41,16 @@ def get_sched_bert():
|
||||
next_sentence_labels = Tensor.empty((BS, 1), dtype=dtypes.float32)
|
||||
|
||||
# run model twice to get only what changes, these are the kernels of the model
|
||||
seen = set()
|
||||
for _ in range(2):
|
||||
lm_logits, seq_relationship_logits = mdl(input_ids, attention_mask, masked_positions, segment_ids)
|
||||
targets = [lm_logits.lazydata, seq_relationship_logits.lazydata]
|
||||
targets = [lm_logits, seq_relationship_logits]
|
||||
if getenv("BACKWARD"):
|
||||
optim.zero_grad()
|
||||
loss = mdl.loss(lm_logits, seq_relationship_logits, masked_lm_ids, masked_lm_weights, next_sentence_labels)
|
||||
# ignore grad norm and loss scaler for now
|
||||
loss.backward()
|
||||
targets += [x.lazydata for x in optim.schedule_step()]
|
||||
sched = create_schedule(targets)
|
||||
targets += [x for x in optim.schedule_step()]
|
||||
sched = Tensor.schedule(*targets)
|
||||
print(f"schedule length {len(sched)}")
|
||||
return sched
|
||||
|
||||
@@ -109,7 +107,7 @@ if __name__ == "__main__":
|
||||
choices = []
|
||||
for lin, nm in lins:
|
||||
tm = time_linearizer(lin, rawbufs, allow_test_size=False, cnt=10, disable_cache=True)
|
||||
ops = (prg:=lin.to_program()).op_estimate
|
||||
ops = (prg:=lin.to_program()).estimates.ops
|
||||
gflops = sym_infer(ops, {k:k.min for k in lin.ast.variables()})*1e-9/tm
|
||||
choices.append((tm, gflops, lin, prg, nm))
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ from tinygrad import nn, dtypes, Tensor, Device, GlobalCounters, TinyJit
|
||||
from tinygrad.nn.state import get_state_dict, get_parameters
|
||||
from tinygrad.nn import optim
|
||||
from tinygrad.helpers import Context, BEAM, WINO, getenv, colored, prod
|
||||
from tinygrad.multi import MultiLazyBuffer
|
||||
|
||||
cifar_mean = [0.4913997551666284, 0.48215855929893703, 0.4465309133731618]
|
||||
cifar_std = [0.24703225141799082, 0.24348516474564, 0.26158783926049628]
|
||||
@@ -35,8 +34,6 @@ class UnsyncedBatchNorm:
|
||||
self.num_batches_tracked = Tensor.zeros(1, dtype=dtypes.int, requires_grad=False)
|
||||
|
||||
def __call__(self, x:Tensor):
|
||||
if isinstance(x.lazydata, MultiLazyBuffer): assert x.lazydata.axis is None or x.lazydata.axis == 0 and len(x.lazydata.lbs) == self.num_devices
|
||||
|
||||
xr = x.reshape(self.num_devices, -1, *x.shape[1:]).cast(dtypes.float32)
|
||||
batch_mean, batch_invstd = self.calc_stats(xr)
|
||||
ret = xr.batchnorm(
|
||||
|
||||
+4
-4
@@ -247,11 +247,11 @@ if __name__ == "__main__":
|
||||
fetch("https://huggingface.co/TriAiExperiments/SFR-Iterative-DPO-LLaMA-3-8B-R/resolve/main/model-00004-of-00004.safetensors", "model-00004-of-00004.safetensors", subdir="llama3-8b-sfr")
|
||||
args.model = fetch("https://huggingface.co/TriAiExperiments/SFR-Iterative-DPO-LLaMA-3-8B-R/raw/main/model.safetensors.index.json", "model.safetensors.index.json", subdir="llama3-8b-sfr")
|
||||
elif args.size == "70B":
|
||||
subdir = "Llama-3.1-Nemotron-70B-Instruct-HF"
|
||||
args.model = fetch("https://huggingface.co/nvidia/Llama-3.1-Nemotron-70B-Instruct-HF/resolve/main/model.safetensors.index.json?download=true", "model.safetensors.index.json", subdir=subdir)
|
||||
subdir = "DeepSeek-R1-Distill-Llama-70B"
|
||||
args.model = fetch("https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Llama-70B/resolve/main/model.safetensors.index.json?download=true", "model.safetensors.index.json", subdir=subdir)
|
||||
fetch("https://huggingface.co/bofenghuang/Meta-Llama-3-8B/resolve/main/original/tokenizer.model", "tokenizer.model", subdir=subdir)
|
||||
for i in range(30):
|
||||
fetch(f"https://huggingface.co/nvidia/Llama-3.1-Nemotron-70B-Instruct-HF/resolve/main/model-{i+1:05d}-of-00030.safetensors?download=true", f"model-{i+1:05d}-of-00030.safetensors", subdir=subdir)
|
||||
for i in range(17):
|
||||
fetch(f"https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Llama-70B/resolve/main/model-{i+1:05d}-of-000017.safetensors?download=true", f"model-{i+1:05d}-of-000017.safetensors", subdir=subdir)
|
||||
|
||||
assert args.model is not None, "please provide --model option"
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ from tinygrad import Device, nn, Tensor, dtypes, Variable
|
||||
Device.DEFAULT = "CLANG"
|
||||
from train_gpt2 import GPT, GPTConfig
|
||||
from tinygrad.helpers import dedup, to_function_name, flatten, getenv, GlobalCounters, ansilen, to_function_name
|
||||
from tinygrad.engine.schedule import create_schedule
|
||||
from tinygrad.engine.realize import get_kernel, run_schedule
|
||||
from tinygrad.engine.memory import memory_planner
|
||||
from tinygrad.ops import Ops
|
||||
@@ -37,7 +36,7 @@ if __name__ == "__main__":
|
||||
tensors = optimizer.schedule_step()
|
||||
else:
|
||||
tensors = []
|
||||
sched = create_schedule([loss.lazydata] + [x.lazydata for x in tensors])
|
||||
sched = loss.schedule(*tensors)
|
||||
print(f"calls {i}:", len(sched))
|
||||
#run_schedule(sched[:])
|
||||
sched = memory_planner(sched)
|
||||
|
||||
@@ -223,14 +223,8 @@ def batch_load_train_bert(BS:int):
|
||||
assert cycle_length > 0, "cycle_length must be greater than 0"
|
||||
|
||||
dataset = InterleavedDataset(train_files, cycle_length)
|
||||
buffer = [dataset.get() for _ in range(1000)]
|
||||
while True:
|
||||
batch = []
|
||||
for _ in range(BS):
|
||||
index = random.randint(0, 999)
|
||||
batch.append(buffer[index])
|
||||
buffer[index] = dataset.get()
|
||||
yield process_batch_bert(batch)
|
||||
yield process_batch_bert([dataset.get() for _ in range(BS)])
|
||||
|
||||
# Reference: https://github.com/mlcommons/training/blob/1c8a098ae3e70962a4f7422c0b0bd35ae639e357/language_model/tensorflow/bert/run_pretraining.py, Line 416
|
||||
def batch_load_val_bert(BS:int):
|
||||
|
||||
@@ -203,7 +203,7 @@ def get_mlperf_bert_config():
|
||||
"intermediate_size": 4096,
|
||||
"max_position_embeddings": 512,
|
||||
"num_attention_heads": 16,
|
||||
"num_hidden_layers": 24,
|
||||
"num_hidden_layers": getenv("BERT_LAYERS", 24),
|
||||
"type_vocab_size": 2,
|
||||
"vocab_size": 30522
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ def train_resnet():
|
||||
lr_warmup_epochs = config["lr_warmup_epochs"] = getenv("WARMUP_EPOCHS", 2)
|
||||
decay = config["decay"] = getenv("DECAY", 2e-4)
|
||||
|
||||
loss_scaler = config["LOSS_SCALER"] = getenv("LOSS_SCALER", 128.0 if dtypes.default_float == dtypes.float16 else 1.0)
|
||||
loss_scaler = config["LOSS_SCALER"] = getenv("LOSS_SCALER", 256.0 if dtypes.default_float == dtypes.float16 else 1.0)
|
||||
|
||||
target, achieved = getenv("TARGET", 0.759), False
|
||||
eval_start_epoch = getenv("EVAL_START_EPOCH", 0)
|
||||
@@ -572,7 +572,8 @@ def train_rnnt():
|
||||
pass
|
||||
|
||||
@TinyJit
|
||||
def train_step_bert(model, optimizer, scheduler, loss_scaler:float, input_ids:Tensor, segment_ids:Tensor, attention_mask:Tensor, masked_positions:Tensor, masked_lm_ids:Tensor, masked_lm_weights:Tensor, next_sentence_labels:Tensor):
|
||||
def train_step_bert(model, optimizer, scheduler, loss_scaler:float, input_ids:Tensor, segment_ids:Tensor, attention_mask:Tensor,
|
||||
masked_positions:Tensor, masked_lm_ids:Tensor, masked_lm_weights:Tensor, next_sentence_labels:Tensor):
|
||||
optimizer.zero_grad()
|
||||
|
||||
lm_logits, seq_relationship_logits = model(input_ids, attention_mask, masked_positions, segment_ids)
|
||||
@@ -588,18 +589,15 @@ def train_step_bert(model, optimizer, scheduler, loss_scaler:float, input_ids:Te
|
||||
|
||||
optimizer.step()
|
||||
scheduler.step()
|
||||
return loss.realize()
|
||||
return loss.realize(), global_norm.realize()
|
||||
|
||||
@TinyJit
|
||||
def eval_step_bert(model, input_ids:Tensor, segment_ids:Tensor, attention_mask:Tensor, masked_positions:Tensor, masked_lm_ids:Tensor, masked_lm_weights:Tensor, next_sentence_labels:Tensor):
|
||||
def eval_step_bert(model, input_ids:Tensor, segment_ids:Tensor, attention_mask:Tensor, masked_positions:Tensor, masked_lm_ids:Tensor,
|
||||
masked_lm_weights:Tensor, next_sentence_labels:Tensor):
|
||||
lm_logits, seq_relationship_logits = model(input_ids, attention_mask, masked_positions, segment_ids)
|
||||
masked_lm_accuracy, seq_relationship_accuracy, masked_lm_loss, next_sentence_loss = model.accuracy(lm_logits, seq_relationship_logits, masked_lm_ids, masked_lm_weights, next_sentence_labels)
|
||||
return {
|
||||
"masked_lm_accuracy": masked_lm_accuracy.realize(),
|
||||
"next_sentence_accuracy": seq_relationship_accuracy.realize(),
|
||||
"masked_lm_loss": masked_lm_loss.realize(),
|
||||
"next_sentence_loss": next_sentence_loss.realize()
|
||||
}
|
||||
masked_lm_accuracy, seq_relationship_accuracy, masked_lm_loss, next_sentence_loss = \
|
||||
model.accuracy(lm_logits, seq_relationship_logits, masked_lm_ids, masked_lm_weights, next_sentence_labels)
|
||||
return masked_lm_accuracy.realize(), seq_relationship_accuracy.realize(), masked_lm_loss.realize(), next_sentence_loss.realize()
|
||||
|
||||
def train_bert():
|
||||
# NOTE: pip install tensorflow, wandb required
|
||||
@@ -687,9 +685,9 @@ def train_bert():
|
||||
|
||||
model = get_mlperf_bert_model(init_ckpt if RUNMLPERF else None)
|
||||
|
||||
for _, x in get_state_dict(model).items():
|
||||
x.realize().to_(GPUS)
|
||||
parameters = get_parameters(model)
|
||||
for p in parameters:
|
||||
p.to_(GPUS)
|
||||
|
||||
# ** Log run config **
|
||||
for key, value in config.items(): print(f'HParam: "{key}": {value}')
|
||||
@@ -735,7 +733,7 @@ def train_bert():
|
||||
previous_step = None
|
||||
if ckpt:=getenv("RESUME", ""):
|
||||
load_training_state(model, optimizer_group, scheduler_group, safe_load(ckpt))
|
||||
start_step = int(scheduler_wd.epoch_counter.numpy().item())
|
||||
start_step = int(scheduler_wd.epoch_counter.item())
|
||||
print(f"resuming from {ckpt} at step {start_step}")
|
||||
|
||||
if RUNMLPERF:
|
||||
@@ -761,7 +759,7 @@ def train_bert():
|
||||
BEAM.value = TRAIN_BEAM
|
||||
st = time.perf_counter()
|
||||
GlobalCounters.reset()
|
||||
loss = train_step_bert(model, optimizer_group, scheduler_group, loss_scaler,
|
||||
loss, global_norm = train_step_bert(model, optimizer_group, scheduler_group, loss_scaler,
|
||||
train_data["input_ids"], train_data["segment_ids"], train_data["input_mask"], train_data["masked_lm_positions"], \
|
||||
train_data["masked_lm_ids"], train_data["masked_lm_weights"], train_data["next_sentence_labels"])
|
||||
|
||||
@@ -778,7 +776,7 @@ def train_bert():
|
||||
dt = time.perf_counter()
|
||||
|
||||
device_str = loss.device if isinstance(loss.device, str) else f"{loss.device[0]} * {len(loss.device)}"
|
||||
loss = loss.numpy().item()
|
||||
loss = loss.item()
|
||||
|
||||
cl = time.perf_counter()
|
||||
if BENCHMARK: step_times.append(cl - st)
|
||||
@@ -788,7 +786,7 @@ def train_bert():
|
||||
f"{(cl - dt) * 1000.0:7.2f} ms {device_str}, {loss:5.2f} loss, {optimizer_wd.lr.numpy()[0]:.6f} LR, "
|
||||
f"{GlobalCounters.mem_used / 1e9:.2f} GB used, {GlobalCounters.global_ops * 1e-9 / (cl - st):9.2f} GFLOPS")
|
||||
if WANDB:
|
||||
wandb.log({"lr": optimizer_wd.lr.numpy(), "train/loss": loss, "train/step_time": cl - st,
|
||||
wandb.log({"lr": optimizer_wd.lr.numpy(), "train/loss": loss, "train/global_norm": global_norm.item(), "train/step_time": cl - st,
|
||||
"train/python_time": pt - st, "train/data_time": dt - pt, "train/cl_time": cl - dt,
|
||||
"train/GFLOPS": GlobalCounters.global_ops * 1e-9 / (cl - st), "epoch": (i+1)*BS})
|
||||
|
||||
@@ -823,12 +821,10 @@ def train_bert():
|
||||
GlobalCounters.reset()
|
||||
st = time.time()
|
||||
|
||||
eval_result: dict[str, Tensor] = eval_step_bert(model,
|
||||
lm_acc, clsf_acc, lm_loss, clsf_loss = eval_step_bert(model,
|
||||
eval_data["input_ids"], eval_data["segment_ids"], eval_data["input_mask"], eval_data["masked_lm_positions"],
|
||||
eval_data["masked_lm_ids"], eval_data["masked_lm_weights"], eval_data["next_sentence_labels"])
|
||||
|
||||
lm_loss, clsf_loss = eval_result["masked_lm_loss"].item(), eval_result["next_sentence_loss"].item()
|
||||
lm_acc, clsf_acc = eval_result["masked_lm_accuracy"].item(), eval_result["next_sentence_accuracy"].item()
|
||||
lm_acc, clsf_acc, lm_loss, clsf_loss = lm_acc.item(), clsf_acc.item(), lm_loss.item(), clsf_loss.item()
|
||||
|
||||
eval_lm_losses.append(lm_loss)
|
||||
eval_clsf_losses.append(clsf_loss)
|
||||
@@ -845,7 +841,7 @@ def train_bert():
|
||||
return
|
||||
|
||||
if getenv("RESET_STEP", 1): eval_step_bert.reset()
|
||||
del eval_data, eval_result
|
||||
del eval_data
|
||||
avg_lm_loss = sum(eval_lm_losses) / len(eval_lm_losses)
|
||||
avg_clsf_loss = sum(eval_clsf_losses) / len(eval_clsf_losses)
|
||||
avg_lm_acc = sum(eval_lm_accs) / len(eval_lm_accs)
|
||||
|
||||
+4
-2
@@ -2,11 +2,13 @@
|
||||
|
||||
export PYTHONPATH="."
|
||||
export MODEL="bert"
|
||||
export DEFAULT_FLOAT="HALF" GPUS=6 BS=72 EVAL_BS=6
|
||||
export DEFAULT_FLOAT="HALF" GPUS=6 BS=66 EVAL_BS=36
|
||||
|
||||
export BEAM=4 BEAM_UOPS_MAX=2000 BEAM_UPCAST_MAX=64 BEAM_LOCAL_MAX=512
|
||||
export BEAM=4 BEAM_UOPS_MAX=2000 BEAM_UPCAST_MAX=256 BEAM_LOCAL_MAX=1024
|
||||
export IGNORE_JIT_FIRST_BEAM=1
|
||||
export BASEDIR="/raid/datasets/wiki"
|
||||
# TODO: remove DISABLE_DROPOUT=1
|
||||
export DISABLE_DROPOUT=1
|
||||
|
||||
export BENCHMARK=10 DEBUG=2
|
||||
|
||||
|
||||
+4
-2
@@ -2,11 +2,13 @@
|
||||
|
||||
export PYTHONPATH="."
|
||||
export MODEL="bert"
|
||||
export DEFAULT_FLOAT="HALF" GPUS=6 BS=72 EVAL_BS=6
|
||||
export DEFAULT_FLOAT="HALF" GPUS=6 BS=66 EVAL_BS=36
|
||||
|
||||
export BEAM=4 BEAM_UOPS_MAX=2000 BEAM_UPCAST_MAX=64 BEAM_LOCAL_MAX=512
|
||||
export BEAM=4 BEAM_UOPS_MAX=2000 BEAM_UPCAST_MAX=256 BEAM_LOCAL_MAX=1024
|
||||
export IGNORE_JIT_FIRST_BEAM=1
|
||||
export BASEDIR="/raid/datasets/wiki"
|
||||
# TODO: remove DISABLE_DROPOUT=1
|
||||
export DISABLE_DROPOUT=1
|
||||
|
||||
export WANDB=1 PARALLEL=0
|
||||
|
||||
|
||||
+4
-2
@@ -3,11 +3,13 @@
|
||||
export PYTHONPATH="."
|
||||
export MODEL="bert"
|
||||
export SUBMISSION_PLATFORM="tinybox_green"
|
||||
export DEFAULT_FLOAT="HALF" GPUS=6 BS=72 EVAL_BS=6
|
||||
export DEFAULT_FLOAT="HALF" GPUS=6 BS=66 EVAL_BS=36
|
||||
|
||||
export BEAM=4 BEAM_UOPS_MAX=2000 BEAM_UPCAST_MAX=64 BEAM_LOCAL_MAX=512
|
||||
export BEAM=4 BEAM_UOPS_MAX=2000 BEAM_UPCAST_MAX=256 BEAM_LOCAL_MAX=1024
|
||||
export IGNORE_JIT_FIRST_BEAM=1
|
||||
export BASEDIR="/raid/datasets/wiki"
|
||||
# TODO: remove DISABLE_DROPOUT=1
|
||||
export DISABLE_DROPOUT=1
|
||||
|
||||
# pip install -e ".[mlperf]"
|
||||
export LOGMLPERF=1
|
||||
|
||||
+4
-2
@@ -2,11 +2,13 @@
|
||||
|
||||
export PYTHONPATH="."
|
||||
export MODEL="bert"
|
||||
export DEFAULT_FLOAT="HALF" GPUS=6 BS=72 EVAL_BS=6
|
||||
export DEFAULT_FLOAT="HALF" GPUS=6 BS=66 EVAL_BS=36
|
||||
|
||||
export BEAM=3
|
||||
export BEAM=3 BEAM_UOPS_MAX=3000 BEAM_UPCAST_MAX=256 BEAM_LOCAL_MAX=1024
|
||||
export IGNORE_JIT_FIRST_BEAM=1
|
||||
export BASEDIR="/raid/datasets/wiki"
|
||||
# TODO: remove DISABLE_DROPOUT=1
|
||||
export DISABLE_DROPOUT=1
|
||||
|
||||
export BENCHMARK=10 DEBUG=2
|
||||
|
||||
|
||||
+4
-2
@@ -2,11 +2,13 @@
|
||||
|
||||
export PYTHONPATH="."
|
||||
export MODEL="bert"
|
||||
export DEFAULT_FLOAT="HALF" GPUS=6 BS=72 EVAL_BS=6
|
||||
export DEFAULT_FLOAT="HALF" GPUS=6 BS=66 EVAL_BS=36
|
||||
|
||||
export BEAM=3
|
||||
export BEAM=3 BEAM_UOPS_MAX=3000 BEAM_UPCAST_MAX=256 BEAM_LOCAL_MAX=1024
|
||||
export IGNORE_JIT_FIRST_BEAM=1
|
||||
export BASEDIR="/raid/datasets/wiki"
|
||||
# TODO: remove DISABLE_DROPOUT=1
|
||||
export DISABLE_DROPOUT=1
|
||||
|
||||
export WANDB=1 PARALLEL=0
|
||||
|
||||
|
||||
+4
-2
@@ -3,11 +3,13 @@
|
||||
export PYTHONPATH="."
|
||||
export MODEL="bert"
|
||||
export SUBMISSION_PLATFORM="tinybox_red"
|
||||
export DEFAULT_FLOAT="HALF" GPUS=6 BS=72 EVAL_BS=6
|
||||
export DEFAULT_FLOAT="HALF" GPUS=6 BS=66 EVAL_BS=36
|
||||
|
||||
export BEAM=3
|
||||
export BEAM=3 BEAM_UOPS_MAX=3000 BEAM_UPCAST_MAX=256 BEAM_LOCAL_MAX=1024
|
||||
export IGNORE_JIT_FIRST_BEAM=1
|
||||
export BASEDIR="/raid/datasets/wiki"
|
||||
# TODO: remove DISABLE_DROPOUT=1
|
||||
export DISABLE_DROPOUT=1
|
||||
|
||||
# pip install -e ".[mlperf]"
|
||||
export LOGMLPERF=1
|
||||
|
||||
@@ -12,22 +12,20 @@ from tinygrad.engine.realize import CompiledRunner
|
||||
|
||||
import onnx
|
||||
from onnx.helper import tensor_dtype_to_np_dtype
|
||||
from extra.onnx import get_run_onnx # TODO: port to main tinygrad
|
||||
from extra.onnx import OnnxRunner # TODO: port to main tinygrad
|
||||
|
||||
OPENPILOT_MODEL = sys.argv[1] if len(sys.argv) > 1 else "https://github.com/commaai/openpilot/raw/v0.9.7/selfdrive/modeld/models/supercombo.onnx"
|
||||
OUTPUT = "/tmp/openpilot.pkl"
|
||||
OUTPUT = sys.argv[2] if len(sys.argv) > 2 else "/tmp/openpilot.pkl"
|
||||
|
||||
def compile(onnx_file):
|
||||
onnx_model = onnx.load(onnx_file)
|
||||
Tensor.no_grad = True
|
||||
Tensor.training = False
|
||||
|
||||
run_onnx = get_run_onnx(onnx_model)
|
||||
run_onnx = OnnxRunner(onnx_model)
|
||||
print("loaded model")
|
||||
|
||||
input_shapes = {inp.name:tuple(x.dim_value for x in inp.type.tensor_type.shape.dim) for inp in onnx_model.graph.input}
|
||||
input_types = {inp.name: tensor_dtype_to_np_dtype(inp.type.tensor_type.elem_type) for inp in onnx_model.graph.input}
|
||||
if getenv("FLOAT16", 0) == 0: input_types = {k:(np.float32 if v==np.float16 else v) for k,v in input_types.items()}
|
||||
# Float inputs and outputs to tinyjits for openpilot are always float32
|
||||
input_types = {k:(np.float32 if v==np.float16 else v) for k,v in input_types.items()}
|
||||
Tensor.manual_seed(100)
|
||||
new_inputs = {k:Tensor.randn(*shp, dtype=_from_np_dtype(input_types[k])).mul(8).realize() for k,shp in sorted(input_shapes.items())}
|
||||
new_inputs_numpy = {k:v.numpy() for k,v in new_inputs.items()}
|
||||
|
||||
+3
-2
@@ -3,10 +3,10 @@
|
||||
# Stability-AI/generative-models | MIT | https://github.com/Stability-AI/generative-models/blob/fbdc58cab9f4ee2be7a5e1f2e2787ecd9311942f/LICENSE-CODE
|
||||
# mlfoundations/open_clip | MIT | https://github.com/mlfoundations/open_clip/blob/58e4e39aaabc6040839b0d2a7e8bf20979e4558a/LICENSE
|
||||
|
||||
from tinygrad import Tensor, TinyJit, dtypes
|
||||
from tinygrad import Tensor, TinyJit, dtypes, GlobalCounters
|
||||
from tinygrad.nn import Conv2d, GroupNorm
|
||||
from tinygrad.nn.state import safe_load, load_state_dict
|
||||
from tinygrad.helpers import fetch, trange, colored, Timing, GlobalCounters
|
||||
from tinygrad.helpers import fetch, trange, colored, Timing
|
||||
from extra.models.clip import Embedder, FrozenClosedClipEmbedder, FrozenOpenClipEmbedder
|
||||
from extra.models.unet import UNetModel, Upsample, Downsample, timestep_embedding
|
||||
from examples.stable_diffusion import ResnetBlock, Mid
|
||||
@@ -345,6 +345,7 @@ class DPMPP2MSampler:
|
||||
old_denoised = None
|
||||
for i in trange(num_sigmas - 1):
|
||||
with Timing("step in ", enabled=timing, on_exit=lambda _: f", using {GlobalCounters.mem_used/1e9:.2f} GB"):
|
||||
GlobalCounters.reset()
|
||||
x, old_denoised = self.sampler_step(
|
||||
old_denoised=old_denoised,
|
||||
prev_sigma=(None if i==0 else sigmas[i-1].expand(x.shape[0])),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import os, pathlib
|
||||
import os, pathlib, argparse
|
||||
from examples.llama3 import Tokenizer
|
||||
from tabulate import tabulate
|
||||
from tinygrad import fetch
|
||||
@@ -15,10 +15,19 @@ def read_code(base_path):
|
||||
if 'tinygrad/runtime/autogen' in path.replace('\\', '/'): continue
|
||||
fullpath = os.path.join(path, name)
|
||||
code = pathlib.Path(fullpath).read_text()
|
||||
ret += [(fullpath.split("tinygrad/", 1)[1], code)]
|
||||
ret.append(("### " + fullpath.split("tinygrad/", 1)[1], code))
|
||||
return ret
|
||||
|
||||
def write_code_to_file(filename, code_list):
|
||||
"""Writes the combined code to a specified file."""
|
||||
with open(filename, 'w') as f:
|
||||
f.write('\n'.join(flatten(code_list)))
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Analyze and optionally save tinygrad code.")
|
||||
parser.add_argument("--output", help="Output file to write the combined code to.")
|
||||
args = parser.parse_args()
|
||||
|
||||
ret = read_code(".")
|
||||
|
||||
table = []
|
||||
@@ -33,3 +42,7 @@ if __name__ == "__main__":
|
||||
|
||||
encoded = tokenizer.encode(code_str)
|
||||
print(f"code has {len(encoded)} tokens")
|
||||
|
||||
if args.output:
|
||||
write_code_to_file(args.output, ret)
|
||||
print(f"Combined code written to {args.output}")
|
||||
@@ -0,0 +1,73 @@
|
||||
import random, sys
|
||||
import numpy as np
|
||||
from extra.datasets.imagenet import get_imagenet_categories, get_val_files, center_crop
|
||||
from examples.benchmark_onnx import load_onnx_model
|
||||
from PIL import Image
|
||||
from tinygrad import Tensor, dtypes
|
||||
from tinygrad.helpers import fetch, getenv
|
||||
|
||||
# works:
|
||||
# ~70% - https://github.com/onnx/models/raw/refs/heads/main/validated/vision/classification/resnet/model/resnet50-v2-7.onnx
|
||||
# ~43% - https://github.com/onnx/models/raw/refs/heads/main/Computer_Vision/alexnet_Opset16_torch_hub/alexnet_Opset16.onnx
|
||||
# ~72% - https://github.com/xamcat/mobcat-samples/raw/refs/heads/master/onnx_runtime/InferencingSample/InferencingSample/mobilenetv2-7.onnx
|
||||
# ~71% - https://github.com/axinc-ai/onnx-quantization/raw/refs/heads/main/models/mobilenetv2_1.0.opt.onnx
|
||||
# ~67% - https://github.com/xamcat/mobcat-samples/raw/refs/heads/master/onnx_runtime/InferencingSample/InferencingSample/mobilenetv2-7-quantized.onnx
|
||||
# broken:
|
||||
# https://github.com/MTlab/onnx2caffe/raw/refs/heads/master/model/MobileNetV2.onnx
|
||||
# https://huggingface.co/qualcomm/MobileNet-v2-Quantized/resolve/main/MobileNet-v2-Quantized.onnx
|
||||
# ~35% - https://github.com/axinc-ai/onnx-quantization/raw/refs/heads/main/models/mobilenev2_quantized.onnx
|
||||
|
||||
# QUANT=1 python3 examples/test_onnx_imagenet.py
|
||||
# https://github.com/xamcat/mobcat-samples/raw/refs/heads/master/onnx_runtime/InferencingSample/InferencingSample/mobilenetv2-7.onnx
|
||||
# VIZ=1 DONT_REALIZE_EXPAND=1 python3 examples/benchmark_onnx.py /tmp/model.quant.onnx
|
||||
|
||||
def imagenet_dataloader(cnt=0):
|
||||
input_mean = Tensor([0.485, 0.456, 0.406]).reshape(1, -1, 1, 1)
|
||||
input_std = Tensor([0.229, 0.224, 0.225]).reshape(1, -1, 1, 1)
|
||||
files = get_val_files()
|
||||
random.shuffle(files)
|
||||
if cnt != 0: files = files[:cnt]
|
||||
cir = get_imagenet_categories()
|
||||
for fn in files:
|
||||
img = Image.open(fn)
|
||||
img = img.convert('RGB') if img.mode != "RGB" else img
|
||||
img = center_crop(img)
|
||||
img = np.array(img)
|
||||
img = Tensor(img).permute(2,0,1).reshape(1,3,224,224)
|
||||
img = ((img.cast(dtypes.float32)/255.0) - input_mean) / input_std
|
||||
y = cir[fn.split("/")[-2]]
|
||||
yield img,y
|
||||
|
||||
if __name__ == "__main__":
|
||||
fn = sys.argv[1]
|
||||
if getenv("QUANT"):
|
||||
from onnxruntime.quantization import quantize_dynamic, quantize_static, QuantFormat, QuantType, CalibrationDataReader
|
||||
model_fp32 = fetch(fn)
|
||||
fn = '/tmp/model.quant.onnx'
|
||||
if getenv("DYNAMIC"):
|
||||
quantize_dynamic(model_fp32, fn)
|
||||
else:
|
||||
class ImagenetReader(CalibrationDataReader):
|
||||
def __init__(self):
|
||||
self.iter = imagenet_dataloader(cnt=1000)
|
||||
def get_next(self) -> dict:
|
||||
try:
|
||||
img,y = next(self.iter)
|
||||
except StopIteration:
|
||||
return None
|
||||
return {"input": img.numpy()}
|
||||
quantize_static(model_fp32, fn, ImagenetReader(), quant_format=QuantFormat.QDQ, per_channel=False,
|
||||
activation_type=QuantType.QInt8, weight_type=QuantType.QInt8,
|
||||
extra_options={"ActivationSymmetric": True})
|
||||
|
||||
run_onnx_jit, input_specs = load_onnx_model(fn)
|
||||
t_name, t_spec = list(input_specs.items())[0]
|
||||
assert t_spec.shape[1:] == (3,224,224), f"shape is {t_spec.shape}"
|
||||
|
||||
hit = 0
|
||||
for i,(img,y) in enumerate(imagenet_dataloader(cnt=100)):
|
||||
p = run_onnx_jit(**{t_name:img})
|
||||
assert p.shape == (1,1000)
|
||||
t = p.argmax().item()
|
||||
hit += y==t
|
||||
print(f"target: {y:3d} pred: {t:3d} acc: {hit/(i+1)*100:.2f}%")
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
Vendored
+1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -9,11 +9,15 @@ fetch "cdn.jsdelivr.net/npm/@alpine-collective/[email protected]/dist/cdn.min.js"
|
||||
fetch "cdn.jsdelivr.net/npm/@alpinejs/[email protected]/dist/cdn.min.js"
|
||||
fetch "cdn.jsdelivr.net/npm/@alpinejs/[email protected]/dist/cdn.min.js"
|
||||
fetch "unpkg.com/@marcreichel/[email protected]/dist/alpine-autosize.min.js"
|
||||
fetch "unpkg.com/@marcreichel/[email protected]/dist/alpine-autosize.min.js.map"
|
||||
fetch "unpkg.com/[email protected]/dist/cdn.min.js"
|
||||
fetch "unpkg.com/[email protected]/dist/purify.min.js"
|
||||
fetch "unpkg.com/[email protected]/dist/purify.min.js.map"
|
||||
fetch "unpkg.com/[email protected]/marked.min.js"
|
||||
fetch "unpkg.com/[email protected]/lib/index.umd.js"
|
||||
fetch "unpkg.com/@highlightjs/[email protected]/highlight.min.js"
|
||||
fetch "cdn.jsdelivr.net/npm/[email protected]/build/base-min.css"
|
||||
fetch "cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css"
|
||||
fetch "unpkg.com/@highlightjs/[email protected]/styles/vs2015.min.css"
|
||||
fetch "cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/webfonts/fa-solid-900.ttf"
|
||||
fetch "cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/webfonts/fa-solid-900.woff2"
|
||||
|
||||
+9
-18
@@ -42,10 +42,10 @@ class Synthesizer:
|
||||
if pad_length > -1:
|
||||
# Pad flow forward inputs to enable JIT
|
||||
assert pad_length > row_len, "pad length is too small"
|
||||
y_mask = y_mask.pad(((0, 0), (0, 0), (0, pad_length - row_len)), 0).cast(z_p.dtype)
|
||||
y_mask = y_mask.pad(((0, 0), (0, 0), (0, pad_length - row_len))).cast(z_p.dtype)
|
||||
# New y_mask tensor to remove sts mask
|
||||
y_mask = Tensor(y_mask.numpy(), device=y_mask.device, dtype=y_mask.dtype, requires_grad=y_mask.requires_grad)
|
||||
z_p = z_p.squeeze(0).pad(((0, 0), (0, pad_length - z_p.shape[2])), 1).unsqueeze(0)
|
||||
z_p = z_p.squeeze(0).pad(((0, 0), (0, pad_length - z_p.shape[2])), value=1).unsqueeze(0)
|
||||
z = self.flow.forward(z_p.realize(), y_mask.realize(), g=g.realize(), reverse=True)
|
||||
result_length = reduce(lambda x, y: x * y, self.dec.upsample_rates, row_len)
|
||||
o = self.dec.forward((z * y_mask)[:, :, :max_len], g=g)[:, :, :result_length]
|
||||
@@ -114,7 +114,7 @@ class StochasticDurationPredictor:
|
||||
flows = flows[:-2] + [flows[-1]] # remove a useless vflow
|
||||
z = Tensor.randn(x.shape[0], 2, x.shape[2], dtype=x.dtype).to(device=x.device) * noise_scale
|
||||
for flow in flows: z = flow.forward(z, x_mask, g=x, reverse=reverse)
|
||||
z0, z1 = split(z, [1, 1], 1)
|
||||
z0, z1 = z.split([1, 1], 1)
|
||||
return z0.realize()
|
||||
|
||||
class DurationPredictor:
|
||||
@@ -147,7 +147,7 @@ class TextEncoder:
|
||||
x = x.transpose(1, -1) # [b, t, h] -transpose-> [b, h, t]
|
||||
x_mask = sequence_mask(x_lengths, x.shape[2]).unsqueeze(1).cast(x.dtype)
|
||||
x = self.encoder.forward(x * x_mask, x_mask)
|
||||
m, logs = split(self.proj(x) * x_mask, self.out_channels, dim=1)
|
||||
m, logs = (self.proj(x) * x_mask).split(self.out_channels, dim=1)
|
||||
return x.realize(), m.realize(), logs.realize(), x_mask.realize()
|
||||
|
||||
class ResidualCouplingBlock:
|
||||
@@ -282,7 +282,7 @@ class ConvFlow:
|
||||
self.convs = DDSConv(filter_channels, kernel_size, n_layers, p_dropout=0.)
|
||||
self.proj = nn.Conv1d(filter_channels, self.half_channels * (num_bins * 3 - 1), 1)
|
||||
def forward(self, x, x_mask, g=None, reverse=False):
|
||||
x0, x1 = split(x, [self.half_channels] * 2, 1)
|
||||
x0, x1 = x.split([self.half_channels] * 2, 1)
|
||||
h = self.proj(self.convs.forward(self.pre(x0), x_mask, g=g)) * x_mask
|
||||
b, c, t = x0.shape
|
||||
h = h.reshape(b, c, -1, t).permute(0, 1, 3, 2) # [b, cx?, t] -> [b, c, t, ?]
|
||||
@@ -302,10 +302,10 @@ class ResidualCouplingLayer:
|
||||
self.enc = WN(hidden_channels, kernel_size, dilation_rate, n_layers, p_dropout=p_dropout, gin_channels=gin_channels)
|
||||
self.post = nn.Conv1d(hidden_channels, self.half_channels * (2 - mean_only), 1)
|
||||
def forward(self, x, x_mask, g=None, reverse=False):
|
||||
x0, x1 = split(x, [self.half_channels] * 2, 1)
|
||||
x0, x1 = x.split([self.half_channels] * 2, 1)
|
||||
stats = self.post(self.enc.forward(self.pre(x0) * x_mask, x_mask, g=g)) * x_mask
|
||||
if not self.mean_only:
|
||||
m, logs = split(stats, [self.half_channels] * 2, 1)
|
||||
m, logs = stats.split([self.half_channels] * 2, 1)
|
||||
else:
|
||||
m = stats
|
||||
logs = Tensor.zeros_like(m)
|
||||
@@ -420,7 +420,7 @@ def piecewise_rational_quadratic_transform(inputs, un_normalized_widths, un_norm
|
||||
return spline_fn(inputs=inputs, un_normalized_widths=un_normalized_widths, un_normalized_heights=un_normalized_heights, un_normalized_derivatives=un_normalized_derivatives, inverse=inverse, min_bin_width=min_bin_width, min_bin_height=min_bin_height, min_derivative=min_derivative, **spline_kwargs)
|
||||
def unconstrained_rational_quadratic_spline(inputs, un_normalized_widths, un_normalized_heights, un_normalized_derivatives, inverse=False, tails='linear', tail_bound=1., min_bin_width=DEFAULT_MIN_BIN_WIDTH, min_bin_height=DEFAULT_MIN_BIN_HEIGHT, min_derivative=DEFAULT_MIN_DERIVATIVE):
|
||||
if not tails == 'linear': raise RuntimeError('{} tails are not implemented.'.format(tails))
|
||||
constant = np.log(np.exp(1 - min_derivative) - 1)
|
||||
constant = np.log(np.exp(1 - min_derivative) - 1).item()
|
||||
un_normalized_derivatives = cat_lr(un_normalized_derivatives, constant, constant)
|
||||
output, log_abs_det = rational_quadratic_spline(inputs=inputs.squeeze(dim=0).squeeze(dim=0), unnormalized_widths=un_normalized_widths.squeeze(dim=0).squeeze(dim=0), unnormalized_heights=un_normalized_heights.squeeze(dim=0).squeeze(dim=0), unnormalized_derivatives=un_normalized_derivatives.squeeze(dim=0).squeeze(dim=0), inverse=inverse, left=-tail_bound, right=tail_bound, bottom=-tail_bound, top=tail_bound, min_bin_width=min_bin_width, min_bin_height=min_bin_height, min_derivative=min_derivative)
|
||||
return output.unsqueeze(dim=0).unsqueeze(dim=0), log_abs_det.unsqueeze(dim=0).unsqueeze(dim=0)
|
||||
@@ -478,16 +478,7 @@ def get_shape(tensor):
|
||||
return tuple(shape)
|
||||
def convert_pad_shape(pad_shape): return tuple(tuple(x) for x in pad_shape)
|
||||
def get_padding(kernel_size, dilation=1): return int((kernel_size*dilation - dilation)/2)
|
||||
def split(tensor, split_sizes, dim=0): # if split_sizes is an integer, convert it to a tuple of size split_sizes elements
|
||||
if isinstance(split_sizes, int): split_sizes = (split_sizes,) * (tensor.shape[dim] // split_sizes)
|
||||
assert sum(split_sizes) == tensor.shape[
|
||||
dim], "Sum of split_sizes must equal the dimension size of tensor along the given dimension."
|
||||
start, slices = 0, []
|
||||
for size in split_sizes:
|
||||
slice_range = [(start, start + size) if j == dim else None for j in range(len(tensor.shape))]
|
||||
slices.append(slice_range)
|
||||
start += size
|
||||
return [tensor._slice(s) for s in slices]
|
||||
|
||||
def gather(x, indices, axis):
|
||||
indices = (indices < 0).where(indices + x.shape[axis], indices).transpose(0, axis)
|
||||
permute_args = list(range(x.ndim))
|
||||
|
||||
@@ -1,28 +1,74 @@
|
||||
import os
|
||||
from extra.export_model import export_model
|
||||
from extra.export_model import compile_net, jit_model, dtype_to_js_type
|
||||
from extra.f16_decompress import u32_to_f16
|
||||
from examples.stable_diffusion import StableDiffusion
|
||||
from tinygrad.nn.state import safe_save, torch_load, load_state_dict
|
||||
from tinygrad.nn.state import get_state_dict, safe_save, safe_load_metadata, torch_load, load_state_dict
|
||||
from tinygrad.tensor import Tensor
|
||||
from tinygrad import Device, dtypes
|
||||
from tinygrad.helpers import fetch
|
||||
from typing import NamedTuple, Any, List
|
||||
import requests
|
||||
import argparse
|
||||
import numpy as np
|
||||
from pathlib import Path
|
||||
|
||||
def convert_f32_to_f16(input_file, output_file):
|
||||
with open(input_file, 'rb') as f:
|
||||
metadata_length_bytes = f.read(8)
|
||||
metadata_length = int.from_bytes(metadata_length_bytes, byteorder='little', signed=False)
|
||||
metadata_json_bytes = f.read(metadata_length)
|
||||
values = np.fromfile(f, dtype=np.float32)
|
||||
float32_values = np.fromfile(f, dtype=np.float32)
|
||||
|
||||
f16_values = values.astype(np.float16)
|
||||
first_text_model_offset = 3772703308
|
||||
num_elements = int((first_text_model_offset)/4)
|
||||
front_float16_values = float32_values[:num_elements].astype(np.float16)
|
||||
rest_float32_values = float32_values[num_elements:]
|
||||
|
||||
with open(output_file, 'wb') as f:
|
||||
f.write(metadata_length_bytes)
|
||||
f.write(metadata_json_bytes)
|
||||
f16_values.tofile(f)
|
||||
front_float16_values.tofile(f)
|
||||
rest_float32_values.tofile(f)
|
||||
|
||||
def split_safetensor(fn):
|
||||
_, data_start, metadata = safe_load_metadata(fn)
|
||||
text_model_offset = 3772703308
|
||||
chunk_size = 536870912
|
||||
|
||||
for k in metadata:
|
||||
# safetensor is in fp16, except for text moel
|
||||
if (metadata[k]["data_offsets"][0] < text_model_offset):
|
||||
metadata[k]["data_offsets"][0] = int(metadata[k]["data_offsets"][0]/2)
|
||||
metadata[k]["data_offsets"][1] = int(metadata[k]["data_offsets"][1]/2)
|
||||
|
||||
last_offset = 0
|
||||
part_end_offsets = []
|
||||
|
||||
for k in metadata:
|
||||
offset = metadata[k]['data_offsets'][0]
|
||||
|
||||
if offset == text_model_offset:
|
||||
break
|
||||
|
||||
part_offset = offset - last_offset
|
||||
|
||||
if (part_offset >= chunk_size):
|
||||
part_end_offsets.append(data_start+offset)
|
||||
last_offset = offset
|
||||
|
||||
text_model_start = int(text_model_offset/2)
|
||||
net_bytes = bytes(open(fn, 'rb').read())
|
||||
part_end_offsets.append(text_model_start+data_start)
|
||||
cur_pos = 0
|
||||
|
||||
for i, end_pos in enumerate(part_end_offsets):
|
||||
with open(os.path.join(os.path.dirname(__file__), f'./net_part{i}.safetensors'), "wb+") as f:
|
||||
f.write(net_bytes[cur_pos:end_pos])
|
||||
cur_pos = end_pos
|
||||
|
||||
with open(os.path.join(os.path.dirname(__file__), f'./net_textmodel.safetensors'), "wb+") as f:
|
||||
f.write(net_bytes[text_model_start+data_start:])
|
||||
|
||||
return part_end_offsets
|
||||
|
||||
def fetch_dep(file, url):
|
||||
with open(file, "w", encoding="utf-8") as f:
|
||||
@@ -31,29 +77,162 @@ def fetch_dep(file, url):
|
||||
if __name__ == "__main__":
|
||||
fetch_dep(os.path.join(os.path.dirname(__file__), "clip_tokenizer.js"), "https://huggingface.co/wpmed/tinygrad-sd-f16/raw/main/clip_tokenizer.js")
|
||||
fetch_dep(os.path.join(os.path.dirname(__file__), "bpe_simple_vocab_16e6.mjs"), "https://huggingface.co/wpmed/tinygrad-sd-f16/raw/main/bpe_simple_vocab_16e6.mjs")
|
||||
|
||||
parser = argparse.ArgumentParser(description='Run Stable Diffusion', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||
parser.add_argument('--remoteweights', action='store_true', help="Use safetensors from Huggingface, or from local")
|
||||
args = parser.parse_args()
|
||||
Device.DEFAULT = "WEBGPU"
|
||||
|
||||
Tensor.no_grad = True
|
||||
model = StableDiffusion()
|
||||
|
||||
# load in weights
|
||||
load_state_dict(model, torch_load(fetch('https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/sd-v1-4.ckpt', 'sd-v1-4.ckpt'))['state_dict'], strict=False)
|
||||
|
||||
model_parts = [
|
||||
("textModel", [Tensor.randn(1, 77)], model.cond_stage_model.transformer.text_model),
|
||||
("diffusor", [
|
||||
Tensor.randn(1, 77, 768), Tensor.randn(1, 77, 768), Tensor.randn(1,4,64,64),
|
||||
Tensor.rand(1), Tensor.randn(1), Tensor.randn(1), Tensor.randn(1)
|
||||
], model),
|
||||
("decoder", [Tensor.randn(1,4,64,64)], model.decode),
|
||||
("f16tof32", [Tensor.randn(2097120, dtype=dtypes.uint32)], u32_to_f16)
|
||||
class Step(NamedTuple):
|
||||
name: str = ""
|
||||
input: List[Tensor] = []
|
||||
forward: Any = None
|
||||
|
||||
sub_steps = [
|
||||
Step(name = "textModel", input = [Tensor.randn(1, 77)], forward = model.cond_stage_model.transformer.text_model),
|
||||
Step(name = "diffusor", input = [Tensor.randn(1, 77, 768), Tensor.randn(1, 77, 768), Tensor.randn(1,4,64,64), Tensor.rand(1), Tensor.randn(1), Tensor.randn(1), Tensor.randn(1)], forward = model),
|
||||
Step(name = "decoder", input = [Tensor.randn(1,4,64,64)], forward = model.decode),
|
||||
Step(name = "f16tof32", input = [Tensor.randn(2097120, dtype=dtypes.uint32)], forward = u32_to_f16)
|
||||
]
|
||||
|
||||
for model in model_parts:
|
||||
prg, inp_sizes, out_sizes, state = export_model(model[2], Device.DEFAULT.lower(), *model[1], model_name=model[0])
|
||||
dirname = Path(__file__).parent
|
||||
weight_loc = (dirname / f"net_{model[0]}.safetensors").as_posix()
|
||||
safe_save(state, weight_loc)
|
||||
if model[0] == "diffusor":
|
||||
convert_f32_to_f16(weight_loc, (dirname / f"net_diffusor_f16.safetensors").as_posix())
|
||||
prg = ""
|
||||
|
||||
with open(dirname / f"net_{model[0]}.js", "w") as text_file:
|
||||
text_file.write(prg)
|
||||
def fixup_code(code, key):
|
||||
code = code.replace(key, 'main')\
|
||||
.replace("var<uniform> INFINITY : f32;\n", "fn inf(a: f32) -> f32 { return a/0.0; }\n")\
|
||||
.replace("@group(0) @binding(0)", "")\
|
||||
.replace("INFINITY", "inf(1.0)")
|
||||
|
||||
for i in range(1,9): code = code.replace(f"binding({i})", f"binding({i-1})")
|
||||
return code
|
||||
|
||||
def compile_step(model, step: Step):
|
||||
run, special_names = jit_model(step, *step.input)
|
||||
functions, statements, bufs, _ = compile_net(run, special_names)
|
||||
state = get_state_dict(model)
|
||||
weights = {id(x.lazydata.base.realized): name for name, x in state.items()}
|
||||
kernel_code = '\n\n'.join([f"const {key} = `{fixup_code(code, key)}`;" for key, code in functions.items()])
|
||||
kernel_names = ', '.join([name for (name, _, _, _) in statements])
|
||||
input_names = [name for _,name in special_names.items() if "input" in name]
|
||||
output_names = [name for _,name in special_names.items() if "output" in name]
|
||||
input_buf_types = [dtype_to_js_type(bufs[inp_name][1]) for inp_name in input_names]
|
||||
output_buf_types = [dtype_to_js_type(bufs[out_name][1]) for out_name in output_names]
|
||||
kernel_calls = '\n '.join([f"addComputePass(device, commandEncoder, piplines[{i}], [{', '.join(args)}], {global_size});" for i, (_name, args, global_size, _local_size) in enumerate(statements) ])
|
||||
exported_bufs = '\n '.join([f"const {name} = " + (f"createEmptyBuf(device, {size});" if _key not in weights else f"createWeightBuf(device, {size}, getTensorBuffer(safetensor, metadata['{weights[_key]}'], '{weights[_key]}'))") + ";" for name,(size,dtype,_key) in bufs.items()])
|
||||
gpu_write_bufs = '\n '.join([f"const gpuWriteBuffer{i} = device.createBuffer({{size:input{i}.size, usage: GPUBufferUsage.COPY_SRC | GPUBufferUsage.MAP_WRITE }});" for i,(_,value) in enumerate(special_names.items()) if "output" not in value])
|
||||
input_writer = '\n '.join([f"await gpuWriteBuffer{i}.mapAsync(GPUMapMode.WRITE);\n new {input_buf_types[i]}(gpuWriteBuffer{i}.getMappedRange()).set(" + f'data{i});' + f"\n gpuWriteBuffer{i}.unmap();\ncommandEncoder.copyBufferToBuffer(gpuWriteBuffer{i}, 0, input{i}, 0, gpuWriteBuffer{i}.size);" for i,_ in enumerate(input_names)])
|
||||
return f"""\n var {step.name} = function() {{
|
||||
|
||||
{kernel_code}
|
||||
|
||||
return {{
|
||||
"setup": async (device, safetensor) => {{
|
||||
const metadata = safetensor ? getTensorMetadata(safetensor[0]) : null;
|
||||
|
||||
{exported_bufs}
|
||||
|
||||
{gpu_write_bufs}
|
||||
const gpuReadBuffer = device.createBuffer({{ size: output0.size, usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ }});
|
||||
|
||||
const kernels = [{kernel_names}];
|
||||
const piplines = await Promise.all(kernels.map(name => device.createComputePipelineAsync({{layout: "auto", compute: {{ module: device.createShaderModule({{ code: name }}), entryPoint: "main" }}}})));
|
||||
|
||||
return async ({",".join([f'data{i}' for i,(k,v) in enumerate(special_names.items()) if v != "output0"])}) => {{
|
||||
const commandEncoder = device.createCommandEncoder();
|
||||
|
||||
{input_writer}
|
||||
|
||||
{kernel_calls}
|
||||
commandEncoder.copyBufferToBuffer(output0, 0, gpuReadBuffer, 0, output0.size);
|
||||
const gpuCommands = commandEncoder.finish();
|
||||
device.queue.submit([gpuCommands]);
|
||||
|
||||
await gpuReadBuffer.mapAsync(GPUMapMode.READ);
|
||||
const resultBuffer = new {output_buf_types[0]}(gpuReadBuffer.size/{bufs[output_names[0]][1].itemsize});
|
||||
resultBuffer.set(new {output_buf_types[0]}(gpuReadBuffer.getMappedRange()));
|
||||
gpuReadBuffer.unmap();
|
||||
return resultBuffer;
|
||||
}}
|
||||
}}
|
||||
}}
|
||||
}}
|
||||
"""
|
||||
|
||||
for step in sub_steps:
|
||||
print(f'Executing step={step.name}')
|
||||
prg += compile_step(model, step)
|
||||
|
||||
if step.name == "diffusor":
|
||||
if args.remoteweights:
|
||||
base_url = "https://huggingface.co/wpmed/stable-diffusion-f16-new/resolve/main"
|
||||
else:
|
||||
state = get_state_dict(model)
|
||||
safe_save(state, os.path.join(os.path.dirname(__file__), "net.safetensors"))
|
||||
convert_f32_to_f16(os.path.join(os.path.dirname(__file__), "./net.safetensors"), os.path.join(os.path.dirname(__file__), "./net_conv.safetensors"))
|
||||
split_safetensor(os.path.join(os.path.dirname(__file__), "./net_conv.safetensors"))
|
||||
os.remove(os.path.join(os.path.dirname(__file__), "net.safetensors"))
|
||||
os.remove(os.path.join(os.path.dirname(__file__), "net_conv.safetensors"))
|
||||
base_url = "."
|
||||
|
||||
prekernel = f"""
|
||||
window.MODEL_BASE_URL= "{base_url}";
|
||||
const getTensorMetadata = (safetensorBuffer) => {{
|
||||
const metadataLength = Number(new DataView(safetensorBuffer.buffer).getBigUint64(0, true));
|
||||
const metadata = JSON.parse(new TextDecoder("utf8").decode(safetensorBuffer.subarray(8, 8 + metadataLength)));
|
||||
return Object.fromEntries(Object.entries(metadata).filter(([k, v]) => k !== "__metadata__").map(([k, v]) => [k, {{...v, data_offsets: v.data_offsets.map(x => 8 + metadataLength + x)}}]));
|
||||
}};
|
||||
|
||||
const getTensorBuffer = (safetensorParts, tensorMetadata, key) => {{
|
||||
let selectedPart = 0;
|
||||
let counter = 0;
|
||||
let partStartOffsets = [1131408336, 2227518416, 3308987856, 4265298864];
|
||||
let correctedOffsets = tensorMetadata.data_offsets;
|
||||
let prev_offset = 0;
|
||||
|
||||
for (let start of partStartOffsets) {{
|
||||
prev_offset = (counter == 0) ? 0 : partStartOffsets[counter-1];
|
||||
|
||||
if (tensorMetadata.data_offsets[0] < start) {{
|
||||
selectedPart = counter;
|
||||
correctedOffsets = [correctedOffsets[0]-prev_offset, correctedOffsets[1]-prev_offset];
|
||||
break;
|
||||
}}
|
||||
|
||||
counter++;
|
||||
}}
|
||||
|
||||
return safetensorParts[selectedPart].subarray(...correctedOffsets);
|
||||
}}
|
||||
|
||||
const getWeight = (safetensors, key) => {{
|
||||
let uint8Data = getTensorBuffer(safetensors, getTensorMetadata(safetensors[0])[key], key);
|
||||
return new Float32Array(uint8Data.buffer, uint8Data.byteOffset, uint8Data.byteLength / Float32Array.BYTES_PER_ELEMENT);
|
||||
}}
|
||||
|
||||
const createEmptyBuf = (device, size) => {{
|
||||
return device.createBuffer({{size, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST }});
|
||||
}};
|
||||
|
||||
const createWeightBuf = (device, size, data) => {{
|
||||
const buf = device.createBuffer({{ mappedAtCreation: true, size, usage: GPUBufferUsage.STORAGE }});
|
||||
new Uint8Array(buf.getMappedRange()).set(data);
|
||||
buf.unmap();
|
||||
return buf;
|
||||
}};
|
||||
|
||||
const addComputePass = (device, commandEncoder, pipeline, bufs, workgroup) => {{
|
||||
const bindGroup = device.createBindGroup({{layout: pipeline.getBindGroupLayout(0), entries: bufs.map((buffer, index) => ({{ binding: index, resource: {{ buffer }} }}))}});
|
||||
const passEncoder = commandEncoder.beginComputePass();
|
||||
passEncoder.setPipeline(pipeline);
|
||||
passEncoder.setBindGroup(0, bindGroup);
|
||||
passEncoder.dispatchWorkgroups(...workgroup);
|
||||
passEncoder.end();
|
||||
}};"""
|
||||
|
||||
with open(os.path.join(os.path.dirname(__file__), "net.js"), "w") as text_file:
|
||||
text_file.write(prekernel + prg)
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>tinygrad has WebGPU</title>
|
||||
<style>
|
||||
/* General Reset */
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
@@ -162,17 +163,9 @@
|
||||
|
||||
<script type="module">
|
||||
import ClipTokenizer from './clip_tokenizer.js';
|
||||
import textModel from './net_textModel.js';
|
||||
import diffusor from './net_diffusor.js';
|
||||
import decoder from './net_decoder.js';
|
||||
import f16tof32 from './net_f16tof32.js';
|
||||
|
||||
window.clipTokenizer = new ClipTokenizer();
|
||||
window.textModel = textModel;
|
||||
window.diffusor = diffusor;
|
||||
window.decoder = decoder;
|
||||
window.f16tof32 = f16tof32;
|
||||
</script>
|
||||
<script src="./net.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="wgpuError" style="display: none;">WebGPU is not supported in this browser</h1>
|
||||
@@ -363,51 +356,123 @@
|
||||
return res.arrayBuffer();
|
||||
};
|
||||
|
||||
const decompressf16Safetensor = async (device, progress, f16safeTensor) => {
|
||||
const getAndDecompressF16Safetensors = async (device, progress) => {
|
||||
let totalLoaded = 0;
|
||||
let totalSize = 0;
|
||||
let partSize = {};
|
||||
|
||||
const getPart = async(key) => {
|
||||
let part = await readTensorFromDb(db, key);
|
||||
|
||||
if (part) {
|
||||
console.log(`Cache hit: ${key}`);
|
||||
return Promise.resolve(part.content);
|
||||
} else {
|
||||
console.log(`Cache miss: ${key}`);
|
||||
return getProgressDlForPart(`${window.MODEL_BASE_URL}/${key}.safetensors`, progressCallback);
|
||||
}
|
||||
}
|
||||
|
||||
const progressCallback = (part, loaded, total) => {
|
||||
totalLoaded += loaded;
|
||||
|
||||
if (!partSize[part]) {
|
||||
totalSize += total;
|
||||
partSize[part] = true;
|
||||
}
|
||||
|
||||
progress(totalLoaded, totalSize);
|
||||
};
|
||||
|
||||
let netKeys = ["net_part0", "net_part1", "net_part2", "net_part3", "net_textmodel"];
|
||||
let buffers = await Promise.all(netKeys.map(key => getPart(key)));
|
||||
|
||||
// Combine everything except for text model, since that's already f32
|
||||
const totalLength = buffers.reduce((acc, buffer, index, array) => {
|
||||
if (index < 4) {
|
||||
return acc + buffer.byteLength;
|
||||
} else {
|
||||
return acc;
|
||||
}
|
||||
}, 0
|
||||
);
|
||||
|
||||
combinedBuffer = new Uint8Array(totalLength);
|
||||
let offset = 0;
|
||||
buffers.forEach((buffer, index) => {
|
||||
saveTensorToDb(db, netKeys[index], new Uint8Array(buffer));
|
||||
if (index < 4) {
|
||||
combinedBuffer.set(new Uint8Array(buffer), offset);
|
||||
offset += buffer.byteLength;
|
||||
buffer = null;
|
||||
}
|
||||
});
|
||||
|
||||
let textModelU8 = new Uint8Array(buffers[4]);
|
||||
document.getElementById("modelDlTitle").innerHTML = "Decompressing model";
|
||||
|
||||
const metadataLength = Number(new DataView(f16safeTensor.buffer).getBigUint64(0, true));
|
||||
const metadata = JSON.parse(new TextDecoder("utf8").decode(f16safeTensor.subarray(8, 8 + metadataLength)));
|
||||
const textModelOffset = 3772703308;
|
||||
const metadataLength = Number(new DataView(combinedBuffer.buffer).getBigUint64(0, true));
|
||||
const metadata = JSON.parse(new TextDecoder("utf8").decode(combinedBuffer.subarray(8, 8 + metadataLength)));
|
||||
|
||||
const allToDecomp = f16safeTensor.byteLength - (8 + metadataLength);
|
||||
const allToDecomp = combinedBuffer.byteLength - (8 + metadataLength);
|
||||
const decodeChunkSize = 8388480;
|
||||
const numChunks = Math.ceil(allToDecomp/decodeChunkSize);
|
||||
|
||||
console.log(allToDecomp + " bytes to decompress");
|
||||
console.log("Will be decompressed in " + numChunks+ " chunks");
|
||||
|
||||
f32safeTensor = new Uint8Array(allToDecomp*2);
|
||||
f32safeTensor.set(new Uint8Array(new BigUint64Array([BigInt(metadataLength)]).buffer), 0);
|
||||
f32safeTensor.set(f16safeTensor.subarray(8, 8 + metadataLength), 8);
|
||||
|
||||
let partOffsets = [{start: 0, end: 1131408336}, {start: 1131408336, end: 2227518416}, {start: 2227518416, end: 3308987856}, {start: 3308987856, end: 4265298864}];
|
||||
let parts = [];
|
||||
|
||||
for (let offsets of partOffsets) {
|
||||
parts.push(new Uint8Array(offsets.end-offsets.start));
|
||||
}
|
||||
parts[0].set(new Uint8Array(new BigUint64Array([BigInt(metadataLength)]).buffer), 0);
|
||||
parts[0].set(combinedBuffer.subarray(8, 8 + metadataLength), 8);
|
||||
parts[3].set(textModelU8, textModelOffset+8+metadataLength - partOffsets[3].start);
|
||||
|
||||
let start = Date.now();
|
||||
let cursor = 0;
|
||||
|
||||
for (let i = 0; i < numChunks; i++) {
|
||||
progress(i, numChunks);
|
||||
let metaOffset = 8 + metadataLength;
|
||||
let chunkStartF16 = metaOffset + (decodeChunkSize * i);
|
||||
let chunkStartF16 = 8 + metadataLength + (decodeChunkSize * i);
|
||||
let chunkEndF16 = chunkStartF16 + decodeChunkSize;
|
||||
let chunk = f16safeTensor.subarray(chunkStartF16, chunkEndF16);
|
||||
let chunk = combinedBuffer.subarray(chunkStartF16, chunkEndF16);
|
||||
let uint32Chunk = new Uint32Array(chunk.buffer, chunk.byteOffset, chunk.byteLength / 4);
|
||||
let result = await f16decomp(uint32Chunk);
|
||||
let resultUint8 = new Uint8Array(result.buffer);
|
||||
let f32offset = metaOffset + (decodeChunkSize * i * 2);
|
||||
f32safeTensor.set(resultUint8, f32offset);
|
||||
let chunkStartF32 = 8 + metadataLength + (decodeChunkSize * i * 2);
|
||||
let chunkEndF32 = chunkStartF32 + resultUint8.byteLength;
|
||||
let offsetInPart = chunkStartF32 - partOffsets[cursor].start;
|
||||
|
||||
if (chunkEndF32 < partOffsets[cursor].end || cursor === parts.length - 1) {
|
||||
parts[cursor].set(resultUint8, offsetInPart);
|
||||
} else {
|
||||
let spaceLeftInCurrentPart = partOffsets[cursor].end - chunkStartF32;
|
||||
parts[cursor].set(resultUint8.subarray(0, spaceLeftInCurrentPart), offsetInPart);
|
||||
|
||||
cursor++;
|
||||
|
||||
if (cursor < parts.length) {
|
||||
let nextPartOffset = spaceLeftInCurrentPart;
|
||||
let nextPartLength = resultUint8.length - nextPartOffset;
|
||||
parts[cursor].set(resultUint8.subarray(nextPartOffset, nextPartOffset + nextPartLength), 0);
|
||||
}
|
||||
}
|
||||
|
||||
resultUint8 = null;
|
||||
result = null;
|
||||
}
|
||||
|
||||
f16safeTensor = null;
|
||||
combinedBuffer = null;
|
||||
|
||||
let end = Date.now();
|
||||
console.log("Decoding took: " + ((end - start) / 1000) + " s");
|
||||
console.log("Avarage " + ((end - start) / numChunks) + " ms per chunk");
|
||||
|
||||
return f32safeTensor;
|
||||
return parts;
|
||||
};
|
||||
|
||||
const loadNet = async () => {
|
||||
@@ -419,15 +484,18 @@
|
||||
}
|
||||
|
||||
const device = await getDevice();
|
||||
f16decomp = await f16tof32().setup(device, safetensorParts),
|
||||
safetensorParts = await getAndDecompressF16Safetensors(device, progress);
|
||||
|
||||
modelDlTitle.innerHTML = "Compiling model"
|
||||
|
||||
let netText = await textModel.load(device, "./net_textModel.safetensors");
|
||||
let netDiffusor = await diffusor.load(device, "./net_diffusor_f16.safetensors");
|
||||
let netDecoder = await decoder.load(device, "./net_decoder.safetensors");
|
||||
let funcF16Decomp = await f16tof32.load(device);
|
||||
let models = ["textModel", "diffusor", "decoder"];
|
||||
|
||||
decompressf16Safetensor(device, progress, diffusor.getWeights());
|
||||
nets = await timer(() => Promise.all([
|
||||
textModel().setup(device, safetensorParts),
|
||||
diffusor().setup(device, safetensorParts),
|
||||
decoder().setup(device, safetensorParts)
|
||||
]).then((loadedModels) => loadedModels.reduce((acc, model, index) => { acc[models[index]] = model; return acc; }, {})), "(compilation)")
|
||||
|
||||
progress(1, 1);
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@ import os
|
||||
from ultralytics import YOLO
|
||||
import onnx
|
||||
from pathlib import Path
|
||||
from extra.onnx import get_run_onnx
|
||||
from extra.onnx import OnnxRunner
|
||||
from extra.onnx_helpers import get_example_inputs
|
||||
from tinygrad.tensor import Tensor
|
||||
|
||||
os.chdir("/tmp")
|
||||
@@ -11,8 +12,5 @@ if not Path("yolov8n-seg.onnx").is_file():
|
||||
model = YOLO("yolov8n-seg.pt")
|
||||
model.export(format="onnx", imgsz=[480,640])
|
||||
onnx_model = onnx.load(open("yolov8n-seg.onnx", "rb"))
|
||||
# TODO: move get example inputs to onnx
|
||||
input_shapes = {inp.name:tuple(x.dim_value for x in inp.type.tensor_type.shape.dim) for inp in onnx_model.graph.input}
|
||||
print(input_shapes)
|
||||
run_onnx = get_run_onnx(onnx_model)
|
||||
run_onnx({"images": Tensor.zeros(1,3,480,640)}, debug=True)
|
||||
run_onnx = OnnxRunner(onnx_model)
|
||||
run_onnx(get_example_inputs(run_onnx.graph_inputs), debug=True)
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
import time, mmap, sys, shutil, os, glob
|
||||
from tinygrad.helpers import to_mv, DEBUG, colored, ansilen
|
||||
from tinygrad.runtime.autogen import libc
|
||||
from tinygrad.runtime.autogen.am import smu_v13_0_0
|
||||
from tinygrad.runtime.support.am.amdev import AMDev, AMMemoryManager
|
||||
from tinygrad.runtime.support.am.ip import AM_SOC21, AM_GMC, AM_IH, AM_PSP, AM_SMU, AM_GFX, AM_SDMA
|
||||
|
||||
AM_VERSION = 0xA0000002
|
||||
|
||||
def bold(s): return f"\033[1m{s}\033[0m"
|
||||
|
||||
def color_temp(temp):
|
||||
if temp >= 87: return colored(f"{temp:>3}", "red")
|
||||
elif temp >= 80: return colored(f"{temp:>3}", "yellow")
|
||||
return f"{temp:>3}"
|
||||
|
||||
def color_voltage(voltage): return colored(f"{voltage/1000:>5.3f}V", "cyan")
|
||||
|
||||
def draw_bar(percentage, width=40, fill='█', empty='░'):
|
||||
filled_width = int(width * percentage)
|
||||
bar = fill * filled_width + empty * (width - filled_width)
|
||||
return f'[{bar}] {percentage*100:5.1f}%'
|
||||
|
||||
def same_line(strs:list[list[str]], split=8) -> list[str]:
|
||||
ret = []
|
||||
max_width_in_block = [max(ansilen(line) for line in block) for block in strs]
|
||||
max_height = max(len(block) for block in strs)
|
||||
for i in range(max_height):
|
||||
line = []
|
||||
for bid, block in enumerate(strs):
|
||||
if i < len(block): line.append(block[i] + ' ' * (split + max_width_in_block[bid] - ansilen(block[i])))
|
||||
else: line.append(' ' * (split + max_width_in_block[bid]))
|
||||
ret.append(' '.join(line))
|
||||
return ret
|
||||
|
||||
def get_bar0_size(pcibus):
|
||||
resource_file = f"/sys/bus/pci/devices/{pcibus}/resource"
|
||||
if not os.path.exists(resource_file): raise FileNotFoundError(f"Resource file not found: {resource_file}")
|
||||
|
||||
with open(resource_file, "r") as f: lines = f.readlines()
|
||||
bar0_info = lines[0].split()
|
||||
if len(bar0_info) < 3: raise ValueError("Unexpected resource file format for BAR0.")
|
||||
|
||||
start_hex, end_hex, _flags = bar0_info
|
||||
return int(end_hex, 16) - int(start_hex, 16) + 1
|
||||
|
||||
class AMSMI(AMDev):
|
||||
def __init__(self, pcibus, vram_bar:memoryview, doorbell_bar:memoryview, mmio_bar:memoryview):
|
||||
self.pcibus = pcibus
|
||||
self.vram, self.doorbell64, self.mmio = vram_bar, doorbell_bar, mmio_bar
|
||||
|
||||
self._run_discovery()
|
||||
self._build_regs()
|
||||
|
||||
if self.reg("regSCRATCH_REG7").read() != AM_VERSION:
|
||||
raise Exception(f"Unsupported AM version: {self.reg('regSCRATCH_REG7').read():x}")
|
||||
|
||||
self.is_booting, self.smi_dev = True, True
|
||||
self.partial_boot = True # do not init anything
|
||||
self.mm = AMMemoryManager(self, self.vram_size)
|
||||
|
||||
# Initialize IP blocks
|
||||
self.soc21:AM_SOC21 = AM_SOC21(self)
|
||||
self.gmc:AM_GMC = AM_GMC(self)
|
||||
self.ih:AM_IH = AM_IH(self)
|
||||
self.psp:AM_PSP = AM_PSP(self)
|
||||
self.smu:AM_SMU = AM_SMU(self)
|
||||
|
||||
class SMICtx:
|
||||
def __init__(self):
|
||||
self.devs = []
|
||||
self.opened_pcidevs = []
|
||||
self.opened_pci_resources = {}
|
||||
self.prev_lines_cnt = 0
|
||||
|
||||
def _open_am_device(self, pcibus):
|
||||
if pcibus not in self.opened_pci_resources:
|
||||
bar_fds = {bar: os.open(f"/sys/bus/pci/devices/{pcibus}/resource{bar}", os.O_RDWR | os.O_SYNC) for bar in [0, 2, 5]}
|
||||
bar_size = {0: get_bar0_size(pcibus), 2: os.fstat(bar_fds[2]).st_size, 5: os.fstat(bar_fds[5]).st_size}
|
||||
|
||||
def map_pci_range(bar):
|
||||
return to_mv(libc.mmap(0, bar_size[bar], mmap.PROT_READ | mmap.PROT_WRITE, mmap.MAP_SHARED, bar_fds[bar], 0), bar_size[bar])
|
||||
self.opened_pci_resources[pcibus] = (map_pci_range(0), None, map_pci_range(5).cast('I'))
|
||||
|
||||
try:
|
||||
self.devs.append(AMSMI(pcibus, *self.opened_pci_resources[pcibus]))
|
||||
except Exception as e:
|
||||
if DEBUG >= 2: print(f"Failed to open AM device {pcibus}: {e}")
|
||||
return
|
||||
|
||||
self.opened_pcidevs.append(pcibus)
|
||||
if DEBUG >= 2: print(f"Opened AM device {pcibus}")
|
||||
|
||||
def rescan_devs(self):
|
||||
pattern = os.path.join('/tmp', 'am_*.lock')
|
||||
for d in [f[8:-5] for f in glob.glob(pattern)]:
|
||||
if d not in self.opened_pcidevs:
|
||||
self._open_am_device(d)
|
||||
|
||||
for d in self.devs:
|
||||
if d.reg("regSCRATCH_REG7").read() != AM_VERSION:
|
||||
self.devs.remove(d)
|
||||
self.opened_pcidevs.remove(d.pcibus)
|
||||
os.system('clear')
|
||||
if DEBUG >= 2: print(f"Removed AM device {d.pcibus}")
|
||||
|
||||
def collect(self): return {d: d.smu.read_metrics() for d in self.devs}
|
||||
|
||||
def draw(self):
|
||||
terminal_width, _ = shutil.get_terminal_size()
|
||||
|
||||
dev_metrics = self.collect()
|
||||
dev_content = []
|
||||
for dev, metrics in dev_metrics.items():
|
||||
device_line = [f"PCIe device: {bold(dev.pcibus)}"] + [""]
|
||||
activity_line = [f"GFX Activity {draw_bar(metrics.SmuMetrics.AverageGfxActivity / 100, 50)}"] \
|
||||
+ [f"MEM Activity {draw_bar(metrics.SmuMetrics.AverageUclkActivity / 100, 50)}"] + [""]
|
||||
|
||||
# draw_metrics_table(metrics, dev)
|
||||
temps_keys = [(k, name) for k, name in smu_v13_0_0.c__EA_TEMP_e__enumvalues.items()
|
||||
if k < smu_v13_0_0.TEMP_COUNT and metrics.SmuMetrics.AvgTemperature[k] != 0]
|
||||
temps_table = ["=== Temps (C) ==="] + [f"{name:<15}: {color_temp(metrics.SmuMetrics.AvgTemperature[k])}" for k, name in temps_keys]
|
||||
|
||||
voltage_keys = [(k, name) for k, name in smu_v13_0_0.c__EA_SVI_PLANE_e__enumvalues.items() if k < smu_v13_0_0.SVI_PLANE_COUNT]
|
||||
power_table = ["=== Power ==="] \
|
||||
+ [f"Fan Speed: {metrics.SmuMetrics.AvgFanRpm} RPM"] \
|
||||
+ [f"Fan Power: {metrics.SmuMetrics.AvgFanPwm}%"] \
|
||||
+ [f"Power: {metrics.SmuMetrics.AverageSocketPower:>3}W " +
|
||||
draw_bar(metrics.SmuMetrics.AverageSocketPower / metrics.SmuMetrics.dGPU_W_MAX, 16)] \
|
||||
+ ["", "=== Voltages ==="] + [f"{name:<20}: {color_voltage(metrics.SmuMetrics.AvgVoltage[k])}" for k, name in voltage_keys]
|
||||
|
||||
frequency_table = ["=== Frequencies ===",
|
||||
f"GFXCLK Target : {metrics.SmuMetrics.AverageGfxclkFrequencyTarget:>4} MHz",
|
||||
f"GFXCLK PreDs : {metrics.SmuMetrics.AverageGfxclkFrequencyPreDs:>4} MHz",
|
||||
f"GFXCLK PostDs : {metrics.SmuMetrics.AverageGfxclkFrequencyPostDs:>4} MHz",
|
||||
f"FCLK PreDs : {metrics.SmuMetrics.AverageFclkFrequencyPreDs:>4} MHz",
|
||||
f"FCLK PostDs : {metrics.SmuMetrics.AverageFclkFrequencyPostDs:>4} MHz",
|
||||
f"MCLK PreDs : {metrics.SmuMetrics.AverageMemclkFrequencyPreDs:>4} MHz",
|
||||
f"MCLK PostDs : {metrics.SmuMetrics.AverageMemclkFrequencyPostDs:>4} MHz",
|
||||
f"VCLK0 : {metrics.SmuMetrics.AverageVclk0Frequency:>4} MHz",
|
||||
f"DCLK0 : {metrics.SmuMetrics.AverageDclk0Frequency:>4} MHz",
|
||||
f"VCLK1 : {metrics.SmuMetrics.AverageVclk1Frequency:>4} MHz",
|
||||
f"DCLK1 : {metrics.SmuMetrics.AverageDclk1Frequency:>4} MHz"]
|
||||
|
||||
dev_content.append(device_line + activity_line + same_line([temps_table, power_table, frequency_table]))
|
||||
|
||||
raw_text = 'AM Monitor'.center(terminal_width) + "\n" + "=" * terminal_width + "\n\n"
|
||||
for i in range(0, len(dev_content), 2):
|
||||
if i + 1 < len(dev_content): raw_text += '\n'.join(same_line([dev_content[i], dev_content[i+1]]))
|
||||
else: raw_text += '\n'.join(dev_content[i])
|
||||
if i + 2 < len(dev_content): raw_text += "\n" + "=" * terminal_width + "\n\n"
|
||||
|
||||
sys.stdout.write(f'\033[{self.prev_lines_cnt}A')
|
||||
sys.stdout.flush()
|
||||
print(raw_text)
|
||||
|
||||
self.prev_lines_cnt = len(raw_text.splitlines()) + 2
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
os.system('clear')
|
||||
smi_ctx = SMICtx()
|
||||
while True:
|
||||
smi_ctx.rescan_devs()
|
||||
smi_ctx.draw()
|
||||
time.sleep(1)
|
||||
except KeyboardInterrupt: print("Exiting...")
|
||||
@@ -0,0 +1,279 @@
|
||||
/*
|
||||
* Copyright 2018 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AMDGPU_DOORBELL_H
|
||||
#define AMDGPU_DOORBELL_H
|
||||
|
||||
enum AMDGPU_DOORBELL_ASSIGNMENT {
|
||||
AMDGPU_DOORBELL_KIQ = 0x000,
|
||||
AMDGPU_DOORBELL_HIQ = 0x001,
|
||||
AMDGPU_DOORBELL_DIQ = 0x002,
|
||||
AMDGPU_DOORBELL_MEC_RING0 = 0x010,
|
||||
AMDGPU_DOORBELL_MEC_RING1 = 0x011,
|
||||
AMDGPU_DOORBELL_MEC_RING2 = 0x012,
|
||||
AMDGPU_DOORBELL_MEC_RING3 = 0x013,
|
||||
AMDGPU_DOORBELL_MEC_RING4 = 0x014,
|
||||
AMDGPU_DOORBELL_MEC_RING5 = 0x015,
|
||||
AMDGPU_DOORBELL_MEC_RING6 = 0x016,
|
||||
AMDGPU_DOORBELL_MEC_RING7 = 0x017,
|
||||
AMDGPU_DOORBELL_GFX_RING0 = 0x020,
|
||||
AMDGPU_DOORBELL_sDMA_ENGINE0 = 0x1E0,
|
||||
AMDGPU_DOORBELL_sDMA_ENGINE1 = 0x1E1,
|
||||
AMDGPU_DOORBELL_IH = 0x1E8,
|
||||
AMDGPU_DOORBELL_MAX_ASSIGNMENT = 0x3FF,
|
||||
AMDGPU_DOORBELL_INVALID = 0xFFFF
|
||||
};
|
||||
|
||||
enum AMDGPU_VEGA20_DOORBELL_ASSIGNMENT {
|
||||
|
||||
/* Compute + GFX: 0~255 */
|
||||
AMDGPU_VEGA20_DOORBELL_KIQ = 0x000,
|
||||
AMDGPU_VEGA20_DOORBELL_HIQ = 0x001,
|
||||
AMDGPU_VEGA20_DOORBELL_DIQ = 0x002,
|
||||
AMDGPU_VEGA20_DOORBELL_MEC_RING0 = 0x003,
|
||||
AMDGPU_VEGA20_DOORBELL_MEC_RING1 = 0x004,
|
||||
AMDGPU_VEGA20_DOORBELL_MEC_RING2 = 0x005,
|
||||
AMDGPU_VEGA20_DOORBELL_MEC_RING3 = 0x006,
|
||||
AMDGPU_VEGA20_DOORBELL_MEC_RING4 = 0x007,
|
||||
AMDGPU_VEGA20_DOORBELL_MEC_RING5 = 0x008,
|
||||
AMDGPU_VEGA20_DOORBELL_MEC_RING6 = 0x009,
|
||||
AMDGPU_VEGA20_DOORBELL_MEC_RING7 = 0x00A,
|
||||
AMDGPU_VEGA20_DOORBELL_USERQUEUE_START = 0x00B,
|
||||
AMDGPU_VEGA20_DOORBELL_USERQUEUE_END = 0x08A,
|
||||
AMDGPU_VEGA20_DOORBELL_GFX_RING0 = 0x08B,
|
||||
/* SDMA:256~335*/
|
||||
AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE0 = 0x100,
|
||||
AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE1 = 0x10A,
|
||||
AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE2 = 0x114,
|
||||
AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE3 = 0x11E,
|
||||
AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE4 = 0x128,
|
||||
AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE5 = 0x132,
|
||||
AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE6 = 0x13C,
|
||||
AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE7 = 0x146,
|
||||
/* IH: 376~391 */
|
||||
AMDGPU_VEGA20_DOORBELL_IH = 0x178,
|
||||
/* MMSCH: 392~407
|
||||
* overlap the doorbell assignment with VCN as they are mutually exclusive
|
||||
* VCN engine's doorbell is 32 bit and two VCN ring share one QWORD
|
||||
*/
|
||||
AMDGPU_VEGA20_DOORBELL64_VCN0_1 = 0x188, /* VNC0 */
|
||||
AMDGPU_VEGA20_DOORBELL64_VCN2_3 = 0x189,
|
||||
AMDGPU_VEGA20_DOORBELL64_VCN4_5 = 0x18A,
|
||||
AMDGPU_VEGA20_DOORBELL64_VCN6_7 = 0x18B,
|
||||
|
||||
AMDGPU_VEGA20_DOORBELL64_VCN8_9 = 0x18C, /* VNC1 */
|
||||
AMDGPU_VEGA20_DOORBELL64_VCNa_b = 0x18D,
|
||||
AMDGPU_VEGA20_DOORBELL64_VCNc_d = 0x18E,
|
||||
AMDGPU_VEGA20_DOORBELL64_VCNe_f = 0x18F,
|
||||
|
||||
AMDGPU_VEGA20_DOORBELL64_UVD_RING0_1 = 0x188,
|
||||
AMDGPU_VEGA20_DOORBELL64_UVD_RING2_3 = 0x189,
|
||||
AMDGPU_VEGA20_DOORBELL64_UVD_RING4_5 = 0x18A,
|
||||
AMDGPU_VEGA20_DOORBELL64_UVD_RING6_7 = 0x18B,
|
||||
|
||||
AMDGPU_VEGA20_DOORBELL64_VCE_RING0_1 = 0x18C,
|
||||
AMDGPU_VEGA20_DOORBELL64_VCE_RING2_3 = 0x18D,
|
||||
AMDGPU_VEGA20_DOORBELL64_VCE_RING4_5 = 0x18E,
|
||||
AMDGPU_VEGA20_DOORBELL64_VCE_RING6_7 = 0x18F,
|
||||
|
||||
AMDGPU_VEGA20_DOORBELL64_FIRST_NON_CP = AMDGPU_VEGA20_DOORBELL_sDMA_ENGINE0,
|
||||
AMDGPU_VEGA20_DOORBELL64_LAST_NON_CP = AMDGPU_VEGA20_DOORBELL64_VCE_RING6_7,
|
||||
|
||||
/* kiq/kcq from second XCD. Max 8 XCDs */
|
||||
AMDGPU_VEGA20_DOORBELL_XCC1_KIQ_START = 0x190,
|
||||
/* 8 compute rings per GC. Max to 0x1CE */
|
||||
AMDGPU_VEGA20_DOORBELL_XCC1_MEC_RING0_START = 0x197,
|
||||
|
||||
/* AID1 SDMA: 0x1D0 ~ 0x1F7 */
|
||||
AMDGPU_VEGA20_DOORBELL_AID1_sDMA_START = 0x1D0,
|
||||
|
||||
AMDGPU_VEGA20_DOORBELL_MAX_ASSIGNMENT = 0x1F7,
|
||||
AMDGPU_VEGA20_DOORBELL_INVALID = 0xFFFF
|
||||
};
|
||||
|
||||
enum AMDGPU_NAVI10_DOORBELL_ASSIGNMENT {
|
||||
|
||||
/* Compute + GFX: 0~255 */
|
||||
AMDGPU_NAVI10_DOORBELL_KIQ = 0x000,
|
||||
AMDGPU_NAVI10_DOORBELL_HIQ = 0x001,
|
||||
AMDGPU_NAVI10_DOORBELL_DIQ = 0x002,
|
||||
AMDGPU_NAVI10_DOORBELL_MEC_RING0 = 0x003,
|
||||
AMDGPU_NAVI10_DOORBELL_MEC_RING1 = 0x004,
|
||||
AMDGPU_NAVI10_DOORBELL_MEC_RING2 = 0x005,
|
||||
AMDGPU_NAVI10_DOORBELL_MEC_RING3 = 0x006,
|
||||
AMDGPU_NAVI10_DOORBELL_MEC_RING4 = 0x007,
|
||||
AMDGPU_NAVI10_DOORBELL_MEC_RING5 = 0x008,
|
||||
AMDGPU_NAVI10_DOORBELL_MEC_RING6 = 0x009,
|
||||
AMDGPU_NAVI10_DOORBELL_MEC_RING7 = 0x00A,
|
||||
AMDGPU_NAVI10_DOORBELL_MES_RING0 = 0x00B,
|
||||
AMDGPU_NAVI10_DOORBELL_MES_RING1 = 0x00C,
|
||||
AMDGPU_NAVI10_DOORBELL_USERQUEUE_START = 0x00D,
|
||||
AMDGPU_NAVI10_DOORBELL_USERQUEUE_END = 0x08A,
|
||||
AMDGPU_NAVI10_DOORBELL_GFX_RING0 = 0x08B,
|
||||
AMDGPU_NAVI10_DOORBELL_GFX_RING1 = 0x08C,
|
||||
AMDGPU_NAVI10_DOORBELL_GFX_USERQUEUE_START = 0x08D,
|
||||
AMDGPU_NAVI10_DOORBELL_GFX_USERQUEUE_END = 0x0FF,
|
||||
|
||||
/* SDMA:256~335*/
|
||||
AMDGPU_NAVI10_DOORBELL_sDMA_ENGINE0 = 0x100,
|
||||
AMDGPU_NAVI10_DOORBELL_sDMA_ENGINE1 = 0x10A,
|
||||
AMDGPU_NAVI10_DOORBELL_sDMA_ENGINE2 = 0x114,
|
||||
AMDGPU_NAVI10_DOORBELL_sDMA_ENGINE3 = 0x11E,
|
||||
/* IH: 376~391 */
|
||||
AMDGPU_NAVI10_DOORBELL_IH = 0x178,
|
||||
/* MMSCH: 392~407
|
||||
* overlap the doorbell assignment with VCN as they are mutually exclusive
|
||||
* VCE engine's doorbell is 32 bit and two VCE ring share one QWORD
|
||||
*/
|
||||
AMDGPU_NAVI10_DOORBELL64_VCN0_1 = 0x188, /* lower 32 bits for VNC0 and upper 32 bits for VNC1 */
|
||||
AMDGPU_NAVI10_DOORBELL64_VCN2_3 = 0x189,
|
||||
AMDGPU_NAVI10_DOORBELL64_VCN4_5 = 0x18A,
|
||||
AMDGPU_NAVI10_DOORBELL64_VCN6_7 = 0x18B,
|
||||
|
||||
AMDGPU_NAVI10_DOORBELL64_VCN8_9 = 0x18C,
|
||||
AMDGPU_NAVI10_DOORBELL64_VCNa_b = 0x18D,
|
||||
AMDGPU_NAVI10_DOORBELL64_VCNc_d = 0x18E,
|
||||
AMDGPU_NAVI10_DOORBELL64_VCNe_f = 0x18F,
|
||||
|
||||
AMDGPU_NAVI10_DOORBELL64_VPE = 0x190,
|
||||
|
||||
AMDGPU_NAVI10_DOORBELL64_FIRST_NON_CP = AMDGPU_NAVI10_DOORBELL_sDMA_ENGINE0,
|
||||
AMDGPU_NAVI10_DOORBELL64_LAST_NON_CP = AMDGPU_NAVI10_DOORBELL64_VPE,
|
||||
|
||||
AMDGPU_NAVI10_DOORBELL_MAX_ASSIGNMENT = AMDGPU_NAVI10_DOORBELL64_VPE,
|
||||
AMDGPU_NAVI10_DOORBELL_INVALID = 0xFFFF
|
||||
};
|
||||
|
||||
/*
|
||||
* 64bit doorbell, offset are in QWORD, occupy 2KB doorbell space
|
||||
*/
|
||||
enum AMDGPU_DOORBELL64_ASSIGNMENT {
|
||||
/*
|
||||
* All compute related doorbells: kiq, hiq, diq, traditional compute queue, user queue, should locate in
|
||||
* a continues range so that programming CP_MEC_DOORBELL_RANGE_LOWER/UPPER can cover this range.
|
||||
* Compute related doorbells are allocated from 0x00 to 0x8a
|
||||
*/
|
||||
|
||||
|
||||
/* kernel scheduling */
|
||||
AMDGPU_DOORBELL64_KIQ = 0x00,
|
||||
|
||||
/* HSA interface queue and debug queue */
|
||||
AMDGPU_DOORBELL64_HIQ = 0x01,
|
||||
AMDGPU_DOORBELL64_DIQ = 0x02,
|
||||
|
||||
/* Compute engines */
|
||||
AMDGPU_DOORBELL64_MEC_RING0 = 0x03,
|
||||
AMDGPU_DOORBELL64_MEC_RING1 = 0x04,
|
||||
AMDGPU_DOORBELL64_MEC_RING2 = 0x05,
|
||||
AMDGPU_DOORBELL64_MEC_RING3 = 0x06,
|
||||
AMDGPU_DOORBELL64_MEC_RING4 = 0x07,
|
||||
AMDGPU_DOORBELL64_MEC_RING5 = 0x08,
|
||||
AMDGPU_DOORBELL64_MEC_RING6 = 0x09,
|
||||
AMDGPU_DOORBELL64_MEC_RING7 = 0x0a,
|
||||
|
||||
/* User queue doorbell range (128 doorbells) */
|
||||
AMDGPU_DOORBELL64_USERQUEUE_START = 0x0b,
|
||||
AMDGPU_DOORBELL64_USERQUEUE_END = 0x8a,
|
||||
|
||||
/* Graphics engine */
|
||||
AMDGPU_DOORBELL64_GFX_RING0 = 0x8b,
|
||||
|
||||
/*
|
||||
* Other graphics doorbells can be allocated here: from 0x8c to 0xdf
|
||||
* Graphics voltage island aperture 1
|
||||
* default non-graphics QWORD index is 0xe0 - 0xFF inclusive
|
||||
*/
|
||||
|
||||
/* For vega10 sriov, the sdma doorbell must be fixed as follow
|
||||
* to keep the same setting with host driver, or it will
|
||||
* happen conflicts
|
||||
*/
|
||||
AMDGPU_DOORBELL64_sDMA_ENGINE0 = 0xF0,
|
||||
AMDGPU_DOORBELL64_sDMA_HI_PRI_ENGINE0 = 0xF1,
|
||||
AMDGPU_DOORBELL64_sDMA_ENGINE1 = 0xF2,
|
||||
AMDGPU_DOORBELL64_sDMA_HI_PRI_ENGINE1 = 0xF3,
|
||||
|
||||
/* Interrupt handler */
|
||||
AMDGPU_DOORBELL64_IH = 0xF4, /* For legacy interrupt ring buffer */
|
||||
AMDGPU_DOORBELL64_IH_RING1 = 0xF5, /* For page migration request log */
|
||||
AMDGPU_DOORBELL64_IH_RING2 = 0xF6, /* For page migration translation/invalidation log */
|
||||
|
||||
/* VCN engine use 32 bits doorbell */
|
||||
AMDGPU_DOORBELL64_VCN0_1 = 0xF8, /* lower 32 bits for VNC0 and upper 32 bits for VNC1 */
|
||||
AMDGPU_DOORBELL64_VCN2_3 = 0xF9,
|
||||
AMDGPU_DOORBELL64_VCN4_5 = 0xFA,
|
||||
AMDGPU_DOORBELL64_VCN6_7 = 0xFB,
|
||||
|
||||
/* overlap the doorbell assignment with VCN as they are mutually exclusive
|
||||
* VCE engine's doorbell is 32 bit and two VCE ring share one QWORD
|
||||
*/
|
||||
AMDGPU_DOORBELL64_UVD_RING0_1 = 0xF8,
|
||||
AMDGPU_DOORBELL64_UVD_RING2_3 = 0xF9,
|
||||
AMDGPU_DOORBELL64_UVD_RING4_5 = 0xFA,
|
||||
AMDGPU_DOORBELL64_UVD_RING6_7 = 0xFB,
|
||||
|
||||
AMDGPU_DOORBELL64_VCE_RING0_1 = 0xFC,
|
||||
AMDGPU_DOORBELL64_VCE_RING2_3 = 0xFD,
|
||||
AMDGPU_DOORBELL64_VCE_RING4_5 = 0xFE,
|
||||
AMDGPU_DOORBELL64_VCE_RING6_7 = 0xFF,
|
||||
|
||||
AMDGPU_DOORBELL64_FIRST_NON_CP = AMDGPU_DOORBELL64_sDMA_ENGINE0,
|
||||
AMDGPU_DOORBELL64_LAST_NON_CP = AMDGPU_DOORBELL64_VCE_RING6_7,
|
||||
|
||||
AMDGPU_DOORBELL64_MAX_ASSIGNMENT = 0xFF,
|
||||
AMDGPU_DOORBELL64_INVALID = 0xFFFF
|
||||
};
|
||||
|
||||
enum AMDGPU_DOORBELL_ASSIGNMENT_LAYOUT1 {
|
||||
|
||||
/* XCC0: 0x00 ~20, XCC1: 20 ~ 2F ... */
|
||||
|
||||
/* KIQ/HIQ/DIQ */
|
||||
AMDGPU_DOORBELL_LAYOUT1_KIQ_START = 0x000,
|
||||
AMDGPU_DOORBELL_LAYOUT1_HIQ = 0x001,
|
||||
AMDGPU_DOORBELL_LAYOUT1_DIQ = 0x002,
|
||||
/* Compute: 0x08 ~ 0x20 */
|
||||
AMDGPU_DOORBELL_LAYOUT1_MEC_RING_START = 0x008,
|
||||
AMDGPU_DOORBELL_LAYOUT1_MEC_RING_END = 0x00F,
|
||||
AMDGPU_DOORBELL_LAYOUT1_USERQUEUE_START = 0x010,
|
||||
AMDGPU_DOORBELL_LAYOUT1_USERQUEUE_END = 0x01F,
|
||||
AMDGPU_DOORBELL_LAYOUT1_XCC_RANGE = 0x020,
|
||||
|
||||
/* SDMA: 0x100 ~ 0x19F */
|
||||
AMDGPU_DOORBELL_LAYOUT1_sDMA_ENGINE_START = 0x100,
|
||||
AMDGPU_DOORBELL_LAYOUT1_sDMA_ENGINE_END = 0x19F,
|
||||
/* IH: 0x1A0 ~ 0x1AF */
|
||||
AMDGPU_DOORBELL_LAYOUT1_IH = 0x1A0,
|
||||
/* VCN: 0x1B0 ~ 0x1E8 */
|
||||
AMDGPU_DOORBELL_LAYOUT1_VCN_START = 0x1B0,
|
||||
AMDGPU_DOORBELL_LAYOUT1_VCN_END = 0x1E8,
|
||||
|
||||
AMDGPU_DOORBELL_LAYOUT1_FIRST_NON_CP = AMDGPU_DOORBELL_LAYOUT1_sDMA_ENGINE_START,
|
||||
AMDGPU_DOORBELL_LAYOUT1_LAST_NON_CP = AMDGPU_DOORBELL_LAYOUT1_VCN_END,
|
||||
|
||||
AMDGPU_DOORBELL_LAYOUT1_MAX_ASSIGNMENT = 0x1E8,
|
||||
AMDGPU_DOORBELL_LAYOUT1_INVALID = 0xFFFF
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright 2014 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __AMDGPU_IRQ_H__
|
||||
#define __AMDGPU_IRQ_H__
|
||||
|
||||
// #include <linux/irqdomain.h>
|
||||
// #include "soc15_ih_clientid.h"
|
||||
// #include "amdgpu_ih.h"
|
||||
|
||||
#define int32_t int
|
||||
#define uint32_t unsigned int
|
||||
#define int8_t signed char
|
||||
#define uint8_t unsigned char
|
||||
#define uint16_t unsigned short
|
||||
#define int16_t short
|
||||
#define uint64_t unsigned long long
|
||||
#define bool _Bool
|
||||
#define u32 unsigned int
|
||||
|
||||
#define AMDGPU_MAX_IRQ_SRC_ID 0x100
|
||||
#define AMDGPU_MAX_IRQ_CLIENT_ID 0x100
|
||||
|
||||
#define AMDGPU_IRQ_CLIENTID_LEGACY 0
|
||||
#define AMDGPU_IRQ_CLIENTID_MAX SOC15_IH_CLIENTID_MAX
|
||||
|
||||
#define AMDGPU_IRQ_SRC_DATA_MAX_SIZE_DW 4
|
||||
|
||||
struct amdgpu_device;
|
||||
|
||||
enum amdgpu_interrupt_state {
|
||||
AMDGPU_IRQ_STATE_DISABLE,
|
||||
AMDGPU_IRQ_STATE_ENABLE,
|
||||
};
|
||||
|
||||
struct amdgpu_iv_entry {
|
||||
// struct amdgpu_ih_ring *ih;
|
||||
unsigned client_id;
|
||||
unsigned src_id;
|
||||
unsigned ring_id;
|
||||
unsigned vmid;
|
||||
unsigned vmid_src;
|
||||
uint64_t timestamp;
|
||||
unsigned timestamp_src;
|
||||
unsigned pasid;
|
||||
unsigned node_id;
|
||||
unsigned src_data[AMDGPU_IRQ_SRC_DATA_MAX_SIZE_DW];
|
||||
const uint32_t *iv_entry;
|
||||
};
|
||||
|
||||
enum interrupt_node_id_per_aid {
|
||||
AID0_NODEID = 0,
|
||||
XCD0_NODEID = 1,
|
||||
XCD1_NODEID = 2,
|
||||
AID1_NODEID = 4,
|
||||
XCD2_NODEID = 5,
|
||||
XCD3_NODEID = 6,
|
||||
AID2_NODEID = 8,
|
||||
XCD4_NODEID = 9,
|
||||
XCD5_NODEID = 10,
|
||||
AID3_NODEID = 12,
|
||||
XCD6_NODEID = 13,
|
||||
XCD7_NODEID = 14,
|
||||
NODEID_MAX,
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,559 @@
|
||||
/*
|
||||
* Copyright 2016 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Author: Huang Rui
|
||||
*
|
||||
*/
|
||||
#ifndef __AMDGPU_PSP_H__
|
||||
#define __AMDGPU_PSP_H__
|
||||
|
||||
// #include "amdgpu.h"
|
||||
// #include "psp_gfx_if.h"
|
||||
// #include "ta_xgmi_if.h"
|
||||
// #include "ta_ras_if.h"
|
||||
// #include "ta_rap_if.h"
|
||||
// #include "ta_secureDisplay_if.h"
|
||||
|
||||
#define PSP_FENCE_BUFFER_SIZE 0x1000
|
||||
#define PSP_CMD_BUFFER_SIZE 0x1000
|
||||
#define PSP_1_MEG 0x100000
|
||||
#define PSP_TMR_SIZE(adev) ((adev)->asic_type == CHIP_ALDEBARAN ? 0x800000 : 0x400000)
|
||||
#define PSP_TMR_ALIGNMENT 0x100000
|
||||
#define PSP_FW_NAME_LEN 0x24
|
||||
|
||||
// extern const struct attribute_group amdgpu_flash_attr_group;
|
||||
|
||||
enum psp_shared_mem_size {
|
||||
PSP_ASD_SHARED_MEM_SIZE = 0x0,
|
||||
PSP_XGMI_SHARED_MEM_SIZE = 0x4000,
|
||||
PSP_RAS_SHARED_MEM_SIZE = 0x4000,
|
||||
PSP_HDCP_SHARED_MEM_SIZE = 0x4000,
|
||||
PSP_DTM_SHARED_MEM_SIZE = 0x4000,
|
||||
PSP_RAP_SHARED_MEM_SIZE = 0x4000,
|
||||
PSP_SECUREDISPLAY_SHARED_MEM_SIZE = 0x4000,
|
||||
};
|
||||
|
||||
enum ta_type_id {
|
||||
TA_TYPE_XGMI = 1,
|
||||
TA_TYPE_RAS,
|
||||
TA_TYPE_HDCP,
|
||||
TA_TYPE_DTM,
|
||||
TA_TYPE_RAP,
|
||||
TA_TYPE_SECUREDISPLAY,
|
||||
|
||||
TA_TYPE_MAX_INDEX,
|
||||
};
|
||||
|
||||
struct psp_context;
|
||||
struct psp_xgmi_node_info;
|
||||
struct psp_xgmi_topology_info;
|
||||
struct psp_bin_desc;
|
||||
|
||||
enum psp_bootloader_cmd {
|
||||
PSP_BL__LOAD_SYSDRV = 0x10000,
|
||||
PSP_BL__LOAD_SOSDRV = 0x20000,
|
||||
PSP_BL__LOAD_KEY_DATABASE = 0x80000,
|
||||
PSP_BL__LOAD_SOCDRV = 0xB0000,
|
||||
PSP_BL__LOAD_DBGDRV = 0xC0000,
|
||||
PSP_BL__LOAD_HADDRV = PSP_BL__LOAD_DBGDRV,
|
||||
PSP_BL__LOAD_INTFDRV = 0xD0000,
|
||||
PSP_BL__LOAD_RASDRV = 0xE0000,
|
||||
PSP_BL__LOAD_IPKEYMGRDRV = 0xF0000,
|
||||
PSP_BL__DRAM_LONG_TRAIN = 0x100000,
|
||||
PSP_BL__DRAM_SHORT_TRAIN = 0x200000,
|
||||
PSP_BL__LOAD_TOS_SPL_TABLE = 0x10000000,
|
||||
};
|
||||
|
||||
enum psp_ring_type {
|
||||
PSP_RING_TYPE__INVALID = 0,
|
||||
/*
|
||||
* These values map to the way the PSP kernel identifies the
|
||||
* rings.
|
||||
*/
|
||||
PSP_RING_TYPE__UM = 1, /* User mode ring (formerly called RBI) */
|
||||
PSP_RING_TYPE__KM = 2 /* Kernel mode ring (formerly called GPCOM) */
|
||||
};
|
||||
|
||||
// struct psp_ring {
|
||||
// enum psp_ring_type ring_type;
|
||||
// struct psp_gfx_rb_frame *ring_mem;
|
||||
// uint64_t ring_mem_mc_addr;
|
||||
// void *ring_mem_handle;
|
||||
// uint32_t ring_size;
|
||||
// uint32_t ring_wptr;
|
||||
// };
|
||||
|
||||
/* More registers may will be supported */
|
||||
enum psp_reg_prog_id {
|
||||
PSP_REG_IH_RB_CNTL = 0, /* register IH_RB_CNTL */
|
||||
PSP_REG_IH_RB_CNTL_RING1 = 1, /* register IH_RB_CNTL_RING1 */
|
||||
PSP_REG_IH_RB_CNTL_RING2 = 2, /* register IH_RB_CNTL_RING2 */
|
||||
PSP_REG_LAST
|
||||
};
|
||||
|
||||
// struct psp_funcs {
|
||||
// int (*init_microcode)(struct psp_context *psp);
|
||||
// int (*wait_for_bootloader)(struct psp_context *psp);
|
||||
// int (*bootloader_load_kdb)(struct psp_context *psp);
|
||||
// int (*bootloader_load_spl)(struct psp_context *psp);
|
||||
// int (*bootloader_load_sysdrv)(struct psp_context *psp);
|
||||
// int (*bootloader_load_soc_drv)(struct psp_context *psp);
|
||||
// int (*bootloader_load_intf_drv)(struct psp_context *psp);
|
||||
// int (*bootloader_load_dbg_drv)(struct psp_context *psp);
|
||||
// int (*bootloader_load_ras_drv)(struct psp_context *psp);
|
||||
// int (*bootloader_load_ipkeymgr_drv)(struct psp_context *psp);
|
||||
// int (*bootloader_load_sos)(struct psp_context *psp);
|
||||
// int (*ring_create)(struct psp_context *psp,
|
||||
// enum psp_ring_type ring_type);
|
||||
// int (*ring_stop)(struct psp_context *psp,
|
||||
// enum psp_ring_type ring_type);
|
||||
// int (*ring_destroy)(struct psp_context *psp,
|
||||
// enum psp_ring_type ring_type);
|
||||
// bool (*smu_reload_quirk)(struct psp_context *psp);
|
||||
// int (*mode1_reset)(struct psp_context *psp);
|
||||
// int (*mem_training)(struct psp_context *psp, uint32_t ops);
|
||||
// uint32_t (*ring_get_wptr)(struct psp_context *psp);
|
||||
// void (*ring_set_wptr)(struct psp_context *psp, uint32_t value);
|
||||
// int (*load_usbc_pd_fw)(struct psp_context *psp, uint64_t fw_pri_mc_addr);
|
||||
// int (*read_usbc_pd_fw)(struct psp_context *psp, uint32_t *fw_ver);
|
||||
// int (*update_spirom)(struct psp_context *psp, uint64_t fw_pri_mc_addr);
|
||||
// int (*vbflash_stat)(struct psp_context *psp);
|
||||
// int (*fatal_error_recovery_quirk)(struct psp_context *psp);
|
||||
// bool (*get_ras_capability)(struct psp_context *psp);
|
||||
// bool (*is_aux_sos_load_required)(struct psp_context *psp);
|
||||
// };
|
||||
|
||||
// struct ta_funcs {
|
||||
// int (*fn_ta_initialize)(struct psp_context *psp);
|
||||
// int (*fn_ta_invoke)(struct psp_context *psp, uint32_t ta_cmd_id);
|
||||
// int (*fn_ta_terminate)(struct psp_context *psp);
|
||||
// };
|
||||
|
||||
#define AMDGPU_XGMI_MAX_CONNECTED_NODES 64
|
||||
// struct psp_xgmi_node_info {
|
||||
// uint64_t node_id;
|
||||
// uint8_t num_hops;
|
||||
// uint8_t is_sharing_enabled;
|
||||
// enum ta_xgmi_assigned_sdma_engine sdma_engine;
|
||||
// uint8_t num_links;
|
||||
// struct xgmi_connected_port_num port_num[TA_XGMI__MAX_PORT_NUM];
|
||||
// };
|
||||
|
||||
// struct psp_xgmi_topology_info {
|
||||
// uint32_t num_nodes;
|
||||
// struct psp_xgmi_node_info nodes[AMDGPU_XGMI_MAX_CONNECTED_NODES];
|
||||
// };
|
||||
|
||||
// struct psp_bin_desc {
|
||||
// uint32_t fw_version;
|
||||
// uint32_t feature_version;
|
||||
// uint32_t size_bytes;
|
||||
// uint8_t *start_addr;
|
||||
// };
|
||||
|
||||
// struct ta_mem_context {
|
||||
// struct amdgpu_bo *shared_bo;
|
||||
// uint64_t shared_mc_addr;
|
||||
// void *shared_buf;
|
||||
// enum psp_shared_mem_size shared_mem_size;
|
||||
// };
|
||||
|
||||
// struct ta_context {
|
||||
// bool initialized;
|
||||
// uint32_t session_id;
|
||||
// uint32_t resp_status;
|
||||
// struct ta_mem_context mem_context;
|
||||
// struct psp_bin_desc bin_desc;
|
||||
// enum psp_gfx_cmd_id ta_load_type;
|
||||
// enum ta_type_id ta_type;
|
||||
// };
|
||||
|
||||
// struct ta_cp_context {
|
||||
// struct ta_context context;
|
||||
// struct mutex mutex;
|
||||
// };
|
||||
|
||||
// struct psp_xgmi_context {
|
||||
// struct ta_context context;
|
||||
// struct psp_xgmi_topology_info top_info;
|
||||
// bool supports_extended_data;
|
||||
// uint8_t xgmi_ta_caps;
|
||||
// };
|
||||
|
||||
// struct psp_ras_context {
|
||||
// struct ta_context context;
|
||||
// struct amdgpu_ras *ras;
|
||||
// };
|
||||
|
||||
#define MEM_TRAIN_SYSTEM_SIGNATURE 0x54534942
|
||||
#define GDDR6_MEM_TRAINING_DATA_SIZE_IN_BYTES 0x1000
|
||||
#define GDDR6_MEM_TRAINING_OFFSET 0x8000
|
||||
/*Define the VRAM size that will be encroached by BIST training.*/
|
||||
#define BIST_MEM_TRAINING_ENCROACHED_SIZE 0x2000000
|
||||
|
||||
enum psp_memory_training_init_flag {
|
||||
PSP_MEM_TRAIN_NOT_SUPPORT = 0x0,
|
||||
PSP_MEM_TRAIN_SUPPORT = 0x1,
|
||||
PSP_MEM_TRAIN_INIT_FAILED = 0x2,
|
||||
PSP_MEM_TRAIN_RESERVE_SUCCESS = 0x4,
|
||||
PSP_MEM_TRAIN_INIT_SUCCESS = 0x8,
|
||||
};
|
||||
|
||||
enum psp_memory_training_ops {
|
||||
PSP_MEM_TRAIN_SEND_LONG_MSG = 0x1,
|
||||
PSP_MEM_TRAIN_SAVE = 0x2,
|
||||
PSP_MEM_TRAIN_RESTORE = 0x4,
|
||||
PSP_MEM_TRAIN_SEND_SHORT_MSG = 0x8,
|
||||
PSP_MEM_TRAIN_COLD_BOOT = PSP_MEM_TRAIN_SEND_LONG_MSG,
|
||||
PSP_MEM_TRAIN_RESUME = PSP_MEM_TRAIN_SEND_SHORT_MSG,
|
||||
};
|
||||
|
||||
// struct psp_memory_training_context {
|
||||
// /*training data size*/
|
||||
// u64 train_data_size;
|
||||
// /*
|
||||
// * sys_cache
|
||||
// * cpu virtual address
|
||||
// * system memory buffer that used to store the training data.
|
||||
// */
|
||||
// void *sys_cache;
|
||||
|
||||
// /*vram offset of the p2c training data*/
|
||||
// u64 p2c_train_data_offset;
|
||||
|
||||
// /*vram offset of the c2p training data*/
|
||||
// u64 c2p_train_data_offset;
|
||||
// struct amdgpu_bo *c2p_bo;
|
||||
|
||||
// enum psp_memory_training_init_flag init;
|
||||
// u32 training_cnt;
|
||||
// bool enable_mem_training;
|
||||
// };
|
||||
|
||||
/** PSP runtime DB **/
|
||||
#define PSP_RUNTIME_DB_SIZE_IN_BYTES 0x10000
|
||||
#define PSP_RUNTIME_DB_OFFSET 0x100000
|
||||
#define PSP_RUNTIME_DB_COOKIE_ID 0x0ed5
|
||||
#define PSP_RUNTIME_DB_VER_1 0x0100
|
||||
#define PSP_RUNTIME_DB_DIAG_ENTRY_MAX_COUNT 0x40
|
||||
|
||||
enum psp_runtime_entry_type {
|
||||
PSP_RUNTIME_ENTRY_TYPE_INVALID = 0x0,
|
||||
PSP_RUNTIME_ENTRY_TYPE_TEST = 0x1,
|
||||
PSP_RUNTIME_ENTRY_TYPE_MGPU_COMMON = 0x2, /* Common mGPU runtime data */
|
||||
PSP_RUNTIME_ENTRY_TYPE_MGPU_WAFL = 0x3, /* WAFL runtime data */
|
||||
PSP_RUNTIME_ENTRY_TYPE_MGPU_XGMI = 0x4, /* XGMI runtime data */
|
||||
PSP_RUNTIME_ENTRY_TYPE_BOOT_CONFIG = 0x5, /* Boot Config runtime data */
|
||||
PSP_RUNTIME_ENTRY_TYPE_PPTABLE_ERR_STATUS = 0x6, /* SCPM validation data */
|
||||
};
|
||||
|
||||
/* PSP runtime DB header */
|
||||
// struct psp_runtime_data_header {
|
||||
// /* determine the existence of runtime db */
|
||||
// uint16_t cookie;
|
||||
// /* version of runtime db */
|
||||
// uint16_t version;
|
||||
// };
|
||||
|
||||
// /* PSP runtime DB entry */
|
||||
// struct psp_runtime_entry {
|
||||
// /* type of runtime db entry */
|
||||
// uint32_t entry_type;
|
||||
// /* offset of entry in bytes */
|
||||
// uint16_t offset;
|
||||
// /* size of entry in bytes */
|
||||
// uint16_t size;
|
||||
// };
|
||||
|
||||
// /* PSP runtime DB directory */
|
||||
// struct psp_runtime_data_directory {
|
||||
// /* number of valid entries */
|
||||
// uint16_t entry_count;
|
||||
// /* db entries*/
|
||||
// struct psp_runtime_entry entry_list[PSP_RUNTIME_DB_DIAG_ENTRY_MAX_COUNT];
|
||||
// };
|
||||
|
||||
/* PSP runtime DB boot config feature bitmask */
|
||||
enum psp_runtime_boot_cfg_feature {
|
||||
BOOT_CFG_FEATURE_GECC = 0x1,
|
||||
BOOT_CFG_FEATURE_TWO_STAGE_DRAM_TRAINING = 0x2,
|
||||
};
|
||||
|
||||
/* PSP run time DB SCPM authentication defines */
|
||||
enum psp_runtime_scpm_authentication {
|
||||
SCPM_DISABLE = 0x0,
|
||||
SCPM_ENABLE = 0x1,
|
||||
SCPM_ENABLE_WITH_SCPM_ERR = 0x2,
|
||||
};
|
||||
|
||||
/* PSP runtime DB boot config entry */
|
||||
// struct psp_runtime_boot_cfg_entry {
|
||||
// uint32_t boot_cfg_bitmask;
|
||||
// uint32_t reserved;
|
||||
// };
|
||||
|
||||
// /* PSP runtime DB SCPM entry */
|
||||
// struct psp_runtime_scpm_entry {
|
||||
// enum psp_runtime_scpm_authentication scpm_status;
|
||||
// };
|
||||
|
||||
// struct psp_context {
|
||||
// struct amdgpu_device *adev;
|
||||
// struct psp_ring km_ring;
|
||||
// struct psp_gfx_cmd_resp *cmd;
|
||||
|
||||
// const struct psp_funcs *funcs;
|
||||
// const struct ta_funcs *ta_funcs;
|
||||
|
||||
// /* firmware buffer */
|
||||
// struct amdgpu_bo *fw_pri_bo;
|
||||
// uint64_t fw_pri_mc_addr;
|
||||
// void *fw_pri_buf;
|
||||
|
||||
// /* sos firmware */
|
||||
// const struct firmware *sos_fw;
|
||||
// struct psp_bin_desc sys;
|
||||
// struct psp_bin_desc sos;
|
||||
// struct psp_bin_desc toc;
|
||||
// struct psp_bin_desc kdb;
|
||||
// struct psp_bin_desc spl;
|
||||
// struct psp_bin_desc rl;
|
||||
// struct psp_bin_desc soc_drv;
|
||||
// struct psp_bin_desc intf_drv;
|
||||
// struct psp_bin_desc dbg_drv;
|
||||
// struct psp_bin_desc ras_drv;
|
||||
// struct psp_bin_desc ipkeymgr_drv;
|
||||
|
||||
// /* tmr buffer */
|
||||
// struct amdgpu_bo *tmr_bo;
|
||||
// uint64_t tmr_mc_addr;
|
||||
|
||||
// /* asd firmware */
|
||||
// const struct firmware *asd_fw;
|
||||
|
||||
// /* toc firmware */
|
||||
// const struct firmware *toc_fw;
|
||||
|
||||
// /* cap firmware */
|
||||
// const struct firmware *cap_fw;
|
||||
|
||||
// /* fence buffer */
|
||||
// struct amdgpu_bo *fence_buf_bo;
|
||||
// uint64_t fence_buf_mc_addr;
|
||||
// void *fence_buf;
|
||||
|
||||
// /* cmd buffer */
|
||||
// struct amdgpu_bo *cmd_buf_bo;
|
||||
// uint64_t cmd_buf_mc_addr;
|
||||
// struct psp_gfx_cmd_resp *cmd_buf_mem;
|
||||
|
||||
// /* fence value associated with cmd buffer */
|
||||
// atomic_t fence_value;
|
||||
// /* flag to mark whether gfx fw autoload is supported or not */
|
||||
// bool autoload_supported;
|
||||
// /* flag to mark whether psp use runtime TMR or boottime TMR */
|
||||
// bool boot_time_tmr;
|
||||
// /* flag to mark whether df cstate management centralized to PMFW */
|
||||
// bool pmfw_centralized_cstate_management;
|
||||
|
||||
// /* xgmi ta firmware and buffer */
|
||||
// const struct firmware *ta_fw;
|
||||
// uint32_t ta_fw_version;
|
||||
|
||||
// uint32_t cap_fw_version;
|
||||
// uint32_t cap_feature_version;
|
||||
// uint32_t cap_ucode_size;
|
||||
|
||||
// struct ta_context asd_context;
|
||||
// struct psp_xgmi_context xgmi_context;
|
||||
// struct psp_ras_context ras_context;
|
||||
// struct ta_cp_context hdcp_context;
|
||||
// struct ta_cp_context dtm_context;
|
||||
// struct ta_cp_context rap_context;
|
||||
// struct ta_cp_context securedisplay_context;
|
||||
// struct mutex mutex;
|
||||
// struct psp_memory_training_context mem_train_ctx;
|
||||
|
||||
// uint32_t boot_cfg_bitmask;
|
||||
|
||||
// /* firmware upgrades supported */
|
||||
// bool sup_pd_fw_up;
|
||||
// bool sup_ifwi_up;
|
||||
|
||||
// char *vbflash_tmp_buf;
|
||||
// size_t vbflash_image_size;
|
||||
// bool vbflash_done;
|
||||
// };
|
||||
|
||||
// struct amdgpu_psp_funcs {
|
||||
// bool (*check_fw_loading_status)(struct amdgpu_device *adev,
|
||||
// enum AMDGPU_UCODE_ID);
|
||||
// };
|
||||
|
||||
|
||||
// #define psp_ring_create(psp, type) (psp)->funcs->ring_create((psp), (type))
|
||||
// #define psp_ring_stop(psp, type) (psp)->funcs->ring_stop((psp), (type))
|
||||
// #define psp_ring_destroy(psp, type) ((psp)->funcs->ring_destroy((psp), (type)))
|
||||
// #define psp_init_microcode(psp) \
|
||||
// ((psp)->funcs->init_microcode ? (psp)->funcs->init_microcode((psp)) : 0)
|
||||
// #define psp_bootloader_load_kdb(psp) \
|
||||
// ((psp)->funcs->bootloader_load_kdb ? (psp)->funcs->bootloader_load_kdb((psp)) : 0)
|
||||
// #define psp_bootloader_load_spl(psp) \
|
||||
// ((psp)->funcs->bootloader_load_spl ? (psp)->funcs->bootloader_load_spl((psp)) : 0)
|
||||
// #define psp_bootloader_load_sysdrv(psp) \
|
||||
// ((psp)->funcs->bootloader_load_sysdrv ? (psp)->funcs->bootloader_load_sysdrv((psp)) : 0)
|
||||
// #define psp_bootloader_load_soc_drv(psp) \
|
||||
// ((psp)->funcs->bootloader_load_soc_drv ? (psp)->funcs->bootloader_load_soc_drv((psp)) : 0)
|
||||
// #define psp_bootloader_load_intf_drv(psp) \
|
||||
// ((psp)->funcs->bootloader_load_intf_drv ? (psp)->funcs->bootloader_load_intf_drv((psp)) : 0)
|
||||
// #define psp_bootloader_load_dbg_drv(psp) \
|
||||
// ((psp)->funcs->bootloader_load_dbg_drv ? (psp)->funcs->bootloader_load_dbg_drv((psp)) : 0)
|
||||
// #define psp_bootloader_load_ras_drv(psp) \
|
||||
// ((psp)->funcs->bootloader_load_ras_drv ? \
|
||||
// (psp)->funcs->bootloader_load_ras_drv((psp)) : 0)
|
||||
// #define psp_bootloader_load_ipkeymgr_drv(psp) \
|
||||
// ((psp)->funcs->bootloader_load_ipkeymgr_drv ? \
|
||||
// (psp)->funcs->bootloader_load_ipkeymgr_drv((psp)) : 0)
|
||||
// #define psp_bootloader_load_sos(psp) \
|
||||
// ((psp)->funcs->bootloader_load_sos ? (psp)->funcs->bootloader_load_sos((psp)) : 0)
|
||||
// #define psp_smu_reload_quirk(psp) \
|
||||
// ((psp)->funcs->smu_reload_quirk ? (psp)->funcs->smu_reload_quirk((psp)) : false)
|
||||
// #define psp_mode1_reset(psp) \
|
||||
// ((psp)->funcs->mode1_reset ? (psp)->funcs->mode1_reset((psp)) : false)
|
||||
// #define psp_mem_training(psp, ops) \
|
||||
// ((psp)->funcs->mem_training ? (psp)->funcs->mem_training((psp), (ops)) : 0)
|
||||
|
||||
// #define psp_ring_get_wptr(psp) (psp)->funcs->ring_get_wptr((psp))
|
||||
// #define psp_ring_set_wptr(psp, value) (psp)->funcs->ring_set_wptr((psp), (value))
|
||||
|
||||
// #define psp_load_usbc_pd_fw(psp, fw_pri_mc_addr) \
|
||||
// ((psp)->funcs->load_usbc_pd_fw ? \
|
||||
// (psp)->funcs->load_usbc_pd_fw((psp), (fw_pri_mc_addr)) : -EINVAL)
|
||||
|
||||
// #define psp_read_usbc_pd_fw(psp, fw_ver) \
|
||||
// ((psp)->funcs->read_usbc_pd_fw ? \
|
||||
// (psp)->funcs->read_usbc_pd_fw((psp), fw_ver) : -EINVAL)
|
||||
|
||||
// #define psp_update_spirom(psp, fw_pri_mc_addr) \
|
||||
// ((psp)->funcs->update_spirom ? \
|
||||
// (psp)->funcs->update_spirom((psp), fw_pri_mc_addr) : -EINVAL)
|
||||
|
||||
// #define psp_vbflash_status(psp) \
|
||||
// ((psp)->funcs->vbflash_stat ? \
|
||||
// (psp)->funcs->vbflash_stat((psp)) : -EINVAL)
|
||||
|
||||
// #define psp_fatal_error_recovery_quirk(psp) \
|
||||
// ((psp)->funcs->fatal_error_recovery_quirk ? \
|
||||
// (psp)->funcs->fatal_error_recovery_quirk((psp)) : 0)
|
||||
|
||||
// #define psp_is_aux_sos_load_required(psp) \
|
||||
// ((psp)->funcs->is_aux_sos_load_required ? (psp)->funcs->is_aux_sos_load_required((psp)) : 0)
|
||||
|
||||
// extern const struct amd_ip_funcs psp_ip_funcs;
|
||||
|
||||
// extern const struct amdgpu_ip_block_version psp_v3_1_ip_block;
|
||||
// extern const struct amdgpu_ip_block_version psp_v10_0_ip_block;
|
||||
// extern const struct amdgpu_ip_block_version psp_v11_0_ip_block;
|
||||
// extern const struct amdgpu_ip_block_version psp_v11_0_8_ip_block;
|
||||
// extern const struct amdgpu_ip_block_version psp_v12_0_ip_block;
|
||||
// extern const struct amdgpu_ip_block_version psp_v13_0_ip_block;
|
||||
// extern const struct amdgpu_ip_block_version psp_v13_0_4_ip_block;
|
||||
// extern const struct amdgpu_ip_block_version psp_v14_0_ip_block;
|
||||
|
||||
// extern int psp_wait_for(struct psp_context *psp, uint32_t reg_index,
|
||||
// uint32_t field_val, uint32_t mask, bool check_changed);
|
||||
// extern int psp_wait_for_spirom_update(struct psp_context *psp, uint32_t reg_index,
|
||||
// uint32_t field_val, uint32_t mask, uint32_t msec_timeout);
|
||||
|
||||
// int psp_execute_ip_fw_load(struct psp_context *psp,
|
||||
// struct amdgpu_firmware_info *ucode);
|
||||
|
||||
// int psp_gpu_reset(struct amdgpu_device *adev);
|
||||
|
||||
// int psp_ta_init_shared_buf(struct psp_context *psp,
|
||||
// struct ta_mem_context *mem_ctx);
|
||||
// void psp_ta_free_shared_buf(struct ta_mem_context *mem_ctx);
|
||||
// int psp_ta_unload(struct psp_context *psp, struct ta_context *context);
|
||||
// int psp_ta_load(struct psp_context *psp, struct ta_context *context);
|
||||
// int psp_ta_invoke(struct psp_context *psp,
|
||||
// uint32_t ta_cmd_id,
|
||||
// struct ta_context *context);
|
||||
|
||||
// int psp_xgmi_initialize(struct psp_context *psp, bool set_extended_data, bool load_ta);
|
||||
// int psp_xgmi_terminate(struct psp_context *psp);
|
||||
// int psp_xgmi_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
|
||||
// int psp_xgmi_get_hive_id(struct psp_context *psp, uint64_t *hive_id);
|
||||
// int psp_xgmi_get_node_id(struct psp_context *psp, uint64_t *node_id);
|
||||
// int psp_xgmi_get_topology_info(struct psp_context *psp,
|
||||
// int number_devices,
|
||||
// struct psp_xgmi_topology_info *topology,
|
||||
// bool get_extended_data);
|
||||
// int psp_xgmi_set_topology_info(struct psp_context *psp,
|
||||
// int number_devices,
|
||||
// struct psp_xgmi_topology_info *topology);
|
||||
// int psp_ras_initialize(struct psp_context *psp);
|
||||
// int psp_ras_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
|
||||
// int psp_ras_enable_features(struct psp_context *psp,
|
||||
// union ta_ras_cmd_input *info, bool enable);
|
||||
// int psp_ras_trigger_error(struct psp_context *psp,
|
||||
// struct ta_ras_trigger_error_input *info, uint32_t instance_mask);
|
||||
// int psp_ras_terminate(struct psp_context *psp);
|
||||
// int psp_ras_query_address(struct psp_context *psp,
|
||||
// struct ta_ras_query_address_input *addr_in,
|
||||
// struct ta_ras_query_address_output *addr_out);
|
||||
|
||||
// int psp_hdcp_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
|
||||
// int psp_dtm_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
|
||||
// int psp_rap_invoke(struct psp_context *psp, uint32_t ta_cmd_id, enum ta_rap_status *status);
|
||||
// int psp_securedisplay_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
|
||||
|
||||
// int psp_rlc_autoload_start(struct psp_context *psp);
|
||||
|
||||
// int psp_reg_program(struct psp_context *psp, enum psp_reg_prog_id reg,
|
||||
// uint32_t value);
|
||||
// int psp_ring_cmd_submit(struct psp_context *psp,
|
||||
// uint64_t cmd_buf_mc_addr,
|
||||
// uint64_t fence_mc_addr,
|
||||
// int index);
|
||||
// int psp_init_asd_microcode(struct psp_context *psp,
|
||||
// const char *chip_name);
|
||||
// int psp_init_toc_microcode(struct psp_context *psp,
|
||||
// const char *chip_name);
|
||||
// int psp_init_sos_microcode(struct psp_context *psp,
|
||||
// const char *chip_name);
|
||||
// int psp_init_ta_microcode(struct psp_context *psp,
|
||||
// const char *chip_name);
|
||||
// int psp_init_cap_microcode(struct psp_context *psp,
|
||||
// const char *chip_name);
|
||||
// int psp_get_fw_attestation_records_addr(struct psp_context *psp,
|
||||
// uint64_t *output_ptr);
|
||||
|
||||
// int psp_load_fw_list(struct psp_context *psp,
|
||||
// struct amdgpu_firmware_info **ucode_list, int ucode_count);
|
||||
// void psp_copy_fw(struct psp_context *psp, uint8_t *start_addr, uint32_t bin_size);
|
||||
|
||||
// int psp_spatial_partition(struct psp_context *psp, int mode);
|
||||
|
||||
// int is_psp_fw_valid(struct psp_bin_desc bin);
|
||||
|
||||
// int amdgpu_psp_wait_for_bootloader(struct amdgpu_device *adev);
|
||||
// bool amdgpu_psp_get_ras_capability(struct psp_context *psp);
|
||||
#endif
|
||||
@@ -0,0 +1,347 @@
|
||||
/*
|
||||
* Copyright 2019 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#ifndef __AMDGPU_SMU_H__
|
||||
#define __AMDGPU_SMU_H__
|
||||
|
||||
#define int32_t int
|
||||
#define uint32_t unsigned int
|
||||
#define int8_t signed char
|
||||
#define uint8_t unsigned char
|
||||
#define uint16_t unsigned short
|
||||
#define int16_t short
|
||||
#define uint64_t unsigned long long
|
||||
#define bool _Bool
|
||||
#define u32 unsigned int
|
||||
|
||||
#define SMU_THERMAL_MINIMUM_ALERT_TEMP 0
|
||||
#define SMU_THERMAL_MAXIMUM_ALERT_TEMP 255
|
||||
#define SMU_TEMPERATURE_UNITS_PER_CENTIGRADES 1000
|
||||
#define SMU_FW_NAME_LEN 0x24
|
||||
|
||||
#define SMU_DPM_USER_PROFILE_RESTORE (1 << 0)
|
||||
#define SMU_CUSTOM_FAN_SPEED_RPM (1 << 1)
|
||||
#define SMU_CUSTOM_FAN_SPEED_PWM (1 << 2)
|
||||
|
||||
// Power Throttlers
|
||||
#define SMU_THROTTLER_PPT0_BIT 0
|
||||
#define SMU_THROTTLER_PPT1_BIT 1
|
||||
#define SMU_THROTTLER_PPT2_BIT 2
|
||||
#define SMU_THROTTLER_PPT3_BIT 3
|
||||
#define SMU_THROTTLER_SPL_BIT 4
|
||||
#define SMU_THROTTLER_FPPT_BIT 5
|
||||
#define SMU_THROTTLER_SPPT_BIT 6
|
||||
#define SMU_THROTTLER_SPPT_APU_BIT 7
|
||||
|
||||
// Current Throttlers
|
||||
#define SMU_THROTTLER_TDC_GFX_BIT 16
|
||||
#define SMU_THROTTLER_TDC_SOC_BIT 17
|
||||
#define SMU_THROTTLER_TDC_MEM_BIT 18
|
||||
#define SMU_THROTTLER_TDC_VDD_BIT 19
|
||||
#define SMU_THROTTLER_TDC_CVIP_BIT 20
|
||||
#define SMU_THROTTLER_EDC_CPU_BIT 21
|
||||
#define SMU_THROTTLER_EDC_GFX_BIT 22
|
||||
#define SMU_THROTTLER_APCC_BIT 23
|
||||
|
||||
// Temperature
|
||||
#define SMU_THROTTLER_TEMP_GPU_BIT 32
|
||||
#define SMU_THROTTLER_TEMP_CORE_BIT 33
|
||||
#define SMU_THROTTLER_TEMP_MEM_BIT 34
|
||||
#define SMU_THROTTLER_TEMP_EDGE_BIT 35
|
||||
#define SMU_THROTTLER_TEMP_HOTSPOT_BIT 36
|
||||
#define SMU_THROTTLER_TEMP_SOC_BIT 37
|
||||
#define SMU_THROTTLER_TEMP_VR_GFX_BIT 38
|
||||
#define SMU_THROTTLER_TEMP_VR_SOC_BIT 39
|
||||
#define SMU_THROTTLER_TEMP_VR_MEM0_BIT 40
|
||||
#define SMU_THROTTLER_TEMP_VR_MEM1_BIT 41
|
||||
#define SMU_THROTTLER_TEMP_LIQUID0_BIT 42
|
||||
#define SMU_THROTTLER_TEMP_LIQUID1_BIT 43
|
||||
#define SMU_THROTTLER_VRHOT0_BIT 44
|
||||
#define SMU_THROTTLER_VRHOT1_BIT 45
|
||||
#define SMU_THROTTLER_PROCHOT_CPU_BIT 46
|
||||
#define SMU_THROTTLER_PROCHOT_GFX_BIT 47
|
||||
|
||||
// Other
|
||||
#define SMU_THROTTLER_PPM_BIT 56
|
||||
#define SMU_THROTTLER_FIT_BIT 57
|
||||
|
||||
struct smu_hw_power_state {
|
||||
unsigned int magic;
|
||||
};
|
||||
|
||||
struct smu_power_state;
|
||||
|
||||
enum smu_state_ui_label {
|
||||
SMU_STATE_UI_LABEL_NONE,
|
||||
SMU_STATE_UI_LABEL_BATTERY,
|
||||
SMU_STATE_UI_TABEL_MIDDLE_LOW,
|
||||
SMU_STATE_UI_LABEL_BALLANCED,
|
||||
SMU_STATE_UI_LABEL_MIDDLE_HIGHT,
|
||||
SMU_STATE_UI_LABEL_PERFORMANCE,
|
||||
SMU_STATE_UI_LABEL_BACO,
|
||||
};
|
||||
|
||||
enum smu_state_classification_flag {
|
||||
SMU_STATE_CLASSIFICATION_FLAG_BOOT = 0x0001,
|
||||
SMU_STATE_CLASSIFICATION_FLAG_THERMAL = 0x0002,
|
||||
SMU_STATE_CLASSIFICATIN_FLAG_LIMITED_POWER_SOURCE = 0x0004,
|
||||
SMU_STATE_CLASSIFICATION_FLAG_RESET = 0x0008,
|
||||
SMU_STATE_CLASSIFICATION_FLAG_FORCED = 0x0010,
|
||||
SMU_STATE_CLASSIFICATION_FLAG_USER_3D_PERFORMANCE = 0x0020,
|
||||
SMU_STATE_CLASSIFICATION_FLAG_USER_2D_PERFORMANCE = 0x0040,
|
||||
SMU_STATE_CLASSIFICATION_FLAG_3D_PERFORMANCE = 0x0080,
|
||||
SMU_STATE_CLASSIFICATION_FLAG_AC_OVERDIRVER_TEMPLATE = 0x0100,
|
||||
SMU_STATE_CLASSIFICATION_FLAG_UVD = 0x0200,
|
||||
SMU_STATE_CLASSIFICATION_FLAG_3D_PERFORMANCE_LOW = 0x0400,
|
||||
SMU_STATE_CLASSIFICATION_FLAG_ACPI = 0x0800,
|
||||
SMU_STATE_CLASSIFICATION_FLAG_HD2 = 0x1000,
|
||||
SMU_STATE_CLASSIFICATION_FLAG_UVD_HD = 0x2000,
|
||||
SMU_STATE_CLASSIFICATION_FLAG_UVD_SD = 0x4000,
|
||||
SMU_STATE_CLASSIFICATION_FLAG_USER_DC_PERFORMANCE = 0x8000,
|
||||
SMU_STATE_CLASSIFICATION_FLAG_DC_OVERDIRVER_TEMPLATE = 0x10000,
|
||||
SMU_STATE_CLASSIFICATION_FLAG_BACO = 0x20000,
|
||||
SMU_STATE_CLASSIFICATIN_FLAG_LIMITED_POWER_SOURCE2 = 0x40000,
|
||||
SMU_STATE_CLASSIFICATION_FLAG_ULV = 0x80000,
|
||||
SMU_STATE_CLASSIFICATION_FLAG_UVD_MVC = 0x100000,
|
||||
};
|
||||
|
||||
struct smu_state_classification_block {
|
||||
enum smu_state_ui_label ui_label;
|
||||
enum smu_state_classification_flag flags;
|
||||
int bios_index;
|
||||
bool temporary_state;
|
||||
bool to_be_deleted;
|
||||
};
|
||||
|
||||
struct smu_state_pcie_block {
|
||||
unsigned int lanes;
|
||||
};
|
||||
|
||||
enum smu_refreshrate_source {
|
||||
SMU_REFRESHRATE_SOURCE_EDID,
|
||||
SMU_REFRESHRATE_SOURCE_EXPLICIT
|
||||
};
|
||||
|
||||
struct smu_state_display_block {
|
||||
bool disable_frame_modulation;
|
||||
bool limit_refreshrate;
|
||||
enum smu_refreshrate_source refreshrate_source;
|
||||
int explicit_refreshrate;
|
||||
int edid_refreshrate_index;
|
||||
bool enable_vari_bright;
|
||||
};
|
||||
|
||||
struct smu_state_memory_block {
|
||||
bool dll_off;
|
||||
uint8_t m3arb;
|
||||
uint8_t unused[3];
|
||||
};
|
||||
|
||||
struct smu_state_software_algorithm_block {
|
||||
bool disable_load_balancing;
|
||||
bool enable_sleep_for_timestamps;
|
||||
};
|
||||
|
||||
struct smu_temperature_range {
|
||||
int min;
|
||||
int max;
|
||||
int edge_emergency_max;
|
||||
int hotspot_min;
|
||||
int hotspot_crit_max;
|
||||
int hotspot_emergency_max;
|
||||
int mem_min;
|
||||
int mem_crit_max;
|
||||
int mem_emergency_max;
|
||||
int software_shutdown_temp;
|
||||
int software_shutdown_temp_offset;
|
||||
};
|
||||
|
||||
struct smu_state_validation_block {
|
||||
bool single_display_only;
|
||||
bool disallow_on_dc;
|
||||
uint8_t supported_power_levels;
|
||||
};
|
||||
|
||||
struct smu_uvd_clocks {
|
||||
uint32_t vclk;
|
||||
uint32_t dclk;
|
||||
};
|
||||
|
||||
/**
|
||||
* Structure to hold a SMU Power State.
|
||||
*/
|
||||
|
||||
enum smu_power_src_type {
|
||||
SMU_POWER_SOURCE_AC,
|
||||
SMU_POWER_SOURCE_DC,
|
||||
SMU_POWER_SOURCE_COUNT,
|
||||
};
|
||||
|
||||
enum smu_ppt_limit_type {
|
||||
SMU_DEFAULT_PPT_LIMIT = 0,
|
||||
SMU_FAST_PPT_LIMIT,
|
||||
};
|
||||
|
||||
enum smu_ppt_limit_level {
|
||||
SMU_PPT_LIMIT_MIN = -1,
|
||||
SMU_PPT_LIMIT_CURRENT,
|
||||
SMU_PPT_LIMIT_DEFAULT,
|
||||
SMU_PPT_LIMIT_MAX,
|
||||
};
|
||||
|
||||
enum smu_memory_pool_size {
|
||||
SMU_MEMORY_POOL_SIZE_ZERO = 0,
|
||||
SMU_MEMORY_POOL_SIZE_256_MB = 0x10000000,
|
||||
SMU_MEMORY_POOL_SIZE_512_MB = 0x20000000,
|
||||
SMU_MEMORY_POOL_SIZE_1_GB = 0x40000000,
|
||||
SMU_MEMORY_POOL_SIZE_2_GB = 0x80000000,
|
||||
};
|
||||
|
||||
enum smu_clk_type {
|
||||
SMU_GFXCLK,
|
||||
SMU_VCLK,
|
||||
SMU_DCLK,
|
||||
SMU_VCLK1,
|
||||
SMU_DCLK1,
|
||||
SMU_ECLK,
|
||||
SMU_SOCCLK,
|
||||
SMU_UCLK,
|
||||
SMU_DCEFCLK,
|
||||
SMU_DISPCLK,
|
||||
SMU_PIXCLK,
|
||||
SMU_PHYCLK,
|
||||
SMU_FCLK,
|
||||
SMU_SCLK,
|
||||
SMU_MCLK,
|
||||
SMU_PCIE,
|
||||
SMU_LCLK,
|
||||
SMU_OD_CCLK,
|
||||
SMU_OD_SCLK,
|
||||
SMU_OD_MCLK,
|
||||
SMU_OD_VDDC_CURVE,
|
||||
SMU_OD_RANGE,
|
||||
SMU_OD_VDDGFX_OFFSET,
|
||||
SMU_OD_FAN_CURVE,
|
||||
SMU_OD_ACOUSTIC_LIMIT,
|
||||
SMU_OD_ACOUSTIC_TARGET,
|
||||
SMU_OD_FAN_TARGET_TEMPERATURE,
|
||||
SMU_OD_FAN_MINIMUM_PWM,
|
||||
SMU_CLK_COUNT,
|
||||
};
|
||||
|
||||
struct smu_user_dpm_profile {
|
||||
uint32_t fan_mode;
|
||||
uint32_t power_limit;
|
||||
uint32_t fan_speed_pwm;
|
||||
uint32_t fan_speed_rpm;
|
||||
uint32_t flags;
|
||||
uint32_t user_od;
|
||||
|
||||
/* user clock state information */
|
||||
uint32_t clk_mask[SMU_CLK_COUNT];
|
||||
uint32_t clk_dependency;
|
||||
};
|
||||
|
||||
#define SMU_TABLE_INIT(tables, table_id, s, a, d) \
|
||||
do { \
|
||||
tables[table_id].size = s; \
|
||||
tables[table_id].align = a; \
|
||||
tables[table_id].domain = d; \
|
||||
} while (0)
|
||||
|
||||
struct smu_table {
|
||||
uint64_t size;
|
||||
uint32_t align;
|
||||
uint8_t domain;
|
||||
uint64_t mc_address;
|
||||
void *cpu_addr;
|
||||
struct amdgpu_bo *bo;
|
||||
uint32_t version;
|
||||
};
|
||||
|
||||
enum smu_perf_level_designation {
|
||||
PERF_LEVEL_ACTIVITY,
|
||||
PERF_LEVEL_POWER_CONTAINMENT,
|
||||
};
|
||||
|
||||
struct smu_performance_level {
|
||||
uint32_t core_clock;
|
||||
uint32_t memory_clock;
|
||||
uint32_t vddc;
|
||||
uint32_t vddci;
|
||||
uint32_t non_local_mem_freq;
|
||||
uint32_t non_local_mem_width;
|
||||
};
|
||||
|
||||
struct smu_clock_info {
|
||||
uint32_t min_mem_clk;
|
||||
uint32_t max_mem_clk;
|
||||
uint32_t min_eng_clk;
|
||||
uint32_t max_eng_clk;
|
||||
uint32_t min_bus_bandwidth;
|
||||
uint32_t max_bus_bandwidth;
|
||||
};
|
||||
|
||||
struct smu_bios_boot_up_values {
|
||||
uint32_t revision;
|
||||
uint32_t gfxclk;
|
||||
uint32_t uclk;
|
||||
uint32_t socclk;
|
||||
uint32_t dcefclk;
|
||||
uint32_t eclk;
|
||||
uint32_t vclk;
|
||||
uint32_t dclk;
|
||||
uint16_t vddc;
|
||||
uint16_t vddci;
|
||||
uint16_t mvddc;
|
||||
uint16_t vdd_gfx;
|
||||
uint8_t cooling_id;
|
||||
uint32_t pp_table_id;
|
||||
uint32_t format_revision;
|
||||
uint32_t content_revision;
|
||||
uint32_t fclk;
|
||||
uint32_t lclk;
|
||||
uint32_t firmware_caps;
|
||||
};
|
||||
|
||||
enum smu_table_id {
|
||||
SMU_TABLE_PPTABLE = 0,
|
||||
SMU_TABLE_WATERMARKS,
|
||||
SMU_TABLE_CUSTOM_DPM,
|
||||
SMU_TABLE_DPMCLOCKS,
|
||||
SMU_TABLE_AVFS,
|
||||
SMU_TABLE_AVFS_PSM_DEBUG,
|
||||
SMU_TABLE_AVFS_FUSE_OVERRIDE,
|
||||
SMU_TABLE_PMSTATUSLOG,
|
||||
SMU_TABLE_SMU_METRICS,
|
||||
SMU_TABLE_DRIVER_SMU_CONFIG,
|
||||
SMU_TABLE_ACTIVITY_MONITOR_COEFF,
|
||||
SMU_TABLE_OVERDRIVE,
|
||||
SMU_TABLE_I2C_COMMANDS,
|
||||
SMU_TABLE_PACE,
|
||||
SMU_TABLE_ECCINFO,
|
||||
SMU_TABLE_COMBO_PPTABLE,
|
||||
SMU_TABLE_WIFIBAND,
|
||||
SMU_TABLE_COUNT,
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,634 @@
|
||||
/*
|
||||
* Copyright 2012 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
#ifndef __AMDGPU_UCODE_H__
|
||||
#define __AMDGPU_UCODE_H__
|
||||
|
||||
// #include "amdgpu_socbb.h"
|
||||
#define int32_t int
|
||||
#define uint32_t unsigned int
|
||||
#define int8_t signed char
|
||||
#define uint8_t unsigned char
|
||||
#define uint16_t unsigned short
|
||||
#define int16_t short
|
||||
#define uint64_t unsigned long long
|
||||
#define bool _Bool
|
||||
#define u32 unsigned int
|
||||
|
||||
struct common_firmware_header {
|
||||
uint32_t size_bytes; /* size of the entire header+image(s) in bytes */
|
||||
uint32_t header_size_bytes; /* size of just the header in bytes */
|
||||
uint16_t header_version_major; /* header version */
|
||||
uint16_t header_version_minor; /* header version */
|
||||
uint16_t ip_version_major; /* IP version */
|
||||
uint16_t ip_version_minor; /* IP version */
|
||||
uint32_t ucode_version;
|
||||
uint32_t ucode_size_bytes; /* size of ucode in bytes */
|
||||
uint32_t ucode_array_offset_bytes; /* payload offset from the start of the header */
|
||||
uint32_t crc32; /* crc32 checksum of the payload */
|
||||
};
|
||||
|
||||
/* version_major=1, version_minor=0 */
|
||||
struct mc_firmware_header_v1_0 {
|
||||
struct common_firmware_header header;
|
||||
uint32_t io_debug_size_bytes; /* size of debug array in dwords */
|
||||
uint32_t io_debug_array_offset_bytes; /* payload offset from the start of the header */
|
||||
};
|
||||
|
||||
/* version_major=1, version_minor=0 */
|
||||
struct smc_firmware_header_v1_0 {
|
||||
struct common_firmware_header header;
|
||||
uint32_t ucode_start_addr;
|
||||
};
|
||||
|
||||
/* version_major=2, version_minor=0 */
|
||||
struct smc_firmware_header_v2_0 {
|
||||
struct smc_firmware_header_v1_0 v1_0;
|
||||
uint32_t ppt_offset_bytes; /* soft pptable offset */
|
||||
uint32_t ppt_size_bytes; /* soft pptable size */
|
||||
};
|
||||
|
||||
struct smc_soft_pptable_entry {
|
||||
uint32_t id;
|
||||
uint32_t ppt_offset_bytes;
|
||||
uint32_t ppt_size_bytes;
|
||||
};
|
||||
|
||||
/* version_major=2, version_minor=1 */
|
||||
struct smc_firmware_header_v2_1 {
|
||||
struct smc_firmware_header_v1_0 v1_0;
|
||||
uint32_t pptable_count;
|
||||
uint32_t pptable_entry_offset;
|
||||
};
|
||||
|
||||
struct psp_fw_legacy_bin_desc {
|
||||
uint32_t fw_version;
|
||||
uint32_t offset_bytes;
|
||||
uint32_t size_bytes;
|
||||
};
|
||||
|
||||
/* version_major=1, version_minor=0 */
|
||||
struct psp_firmware_header_v1_0 {
|
||||
struct common_firmware_header header;
|
||||
struct psp_fw_legacy_bin_desc sos;
|
||||
};
|
||||
|
||||
/* version_major=1, version_minor=1 */
|
||||
struct psp_firmware_header_v1_1 {
|
||||
struct psp_firmware_header_v1_0 v1_0;
|
||||
struct psp_fw_legacy_bin_desc toc;
|
||||
struct psp_fw_legacy_bin_desc kdb;
|
||||
};
|
||||
|
||||
/* version_major=1, version_minor=2 */
|
||||
struct psp_firmware_header_v1_2 {
|
||||
struct psp_firmware_header_v1_0 v1_0;
|
||||
struct psp_fw_legacy_bin_desc res;
|
||||
struct psp_fw_legacy_bin_desc kdb;
|
||||
};
|
||||
|
||||
/* version_major=1, version_minor=3 */
|
||||
struct psp_firmware_header_v1_3 {
|
||||
struct psp_firmware_header_v1_1 v1_1;
|
||||
struct psp_fw_legacy_bin_desc spl;
|
||||
struct psp_fw_legacy_bin_desc rl;
|
||||
struct psp_fw_legacy_bin_desc sys_drv_aux;
|
||||
struct psp_fw_legacy_bin_desc sos_aux;
|
||||
};
|
||||
|
||||
struct psp_fw_bin_desc {
|
||||
uint32_t fw_type;
|
||||
uint32_t fw_version;
|
||||
uint32_t offset_bytes;
|
||||
uint32_t size_bytes;
|
||||
};
|
||||
|
||||
enum psp_fw_type {
|
||||
PSP_FW_TYPE_UNKOWN,
|
||||
PSP_FW_TYPE_PSP_SOS,
|
||||
PSP_FW_TYPE_PSP_SYS_DRV,
|
||||
PSP_FW_TYPE_PSP_KDB,
|
||||
PSP_FW_TYPE_PSP_TOC,
|
||||
PSP_FW_TYPE_PSP_SPL,
|
||||
PSP_FW_TYPE_PSP_RL,
|
||||
PSP_FW_TYPE_PSP_SOC_DRV,
|
||||
PSP_FW_TYPE_PSP_INTF_DRV,
|
||||
PSP_FW_TYPE_PSP_DBG_DRV,
|
||||
PSP_FW_TYPE_PSP_RAS_DRV,
|
||||
PSP_FW_TYPE_PSP_IPKEYMGR_DRV,
|
||||
PSP_FW_TYPE_MAX_INDEX,
|
||||
};
|
||||
|
||||
/* version_major=2, version_minor=0 */
|
||||
struct psp_firmware_header_v2_0 {
|
||||
struct common_firmware_header header;
|
||||
uint32_t psp_fw_bin_count;
|
||||
struct psp_fw_bin_desc psp_fw_bin[1];
|
||||
};
|
||||
|
||||
/* version_major=2, version_minor=1 */
|
||||
struct psp_firmware_header_v2_1 {
|
||||
struct common_firmware_header header;
|
||||
uint32_t psp_fw_bin_count;
|
||||
uint32_t psp_aux_fw_bin_index;
|
||||
struct psp_fw_bin_desc psp_fw_bin[1];
|
||||
};
|
||||
|
||||
/* version_major=1, version_minor=0 */
|
||||
struct ta_firmware_header_v1_0 {
|
||||
struct common_firmware_header header;
|
||||
struct psp_fw_legacy_bin_desc xgmi;
|
||||
struct psp_fw_legacy_bin_desc ras;
|
||||
struct psp_fw_legacy_bin_desc hdcp;
|
||||
struct psp_fw_legacy_bin_desc dtm;
|
||||
struct psp_fw_legacy_bin_desc securedisplay;
|
||||
};
|
||||
|
||||
enum ta_fw_type {
|
||||
TA_FW_TYPE_UNKOWN,
|
||||
TA_FW_TYPE_PSP_ASD,
|
||||
TA_FW_TYPE_PSP_XGMI,
|
||||
TA_FW_TYPE_PSP_RAS,
|
||||
TA_FW_TYPE_PSP_HDCP,
|
||||
TA_FW_TYPE_PSP_DTM,
|
||||
TA_FW_TYPE_PSP_RAP,
|
||||
TA_FW_TYPE_PSP_SECUREDISPLAY,
|
||||
TA_FW_TYPE_MAX_INDEX,
|
||||
};
|
||||
|
||||
/* version_major=2, version_minor=0 */
|
||||
struct ta_firmware_header_v2_0 {
|
||||
struct common_firmware_header header;
|
||||
uint32_t ta_fw_bin_count;
|
||||
struct psp_fw_bin_desc ta_fw_bin[1];
|
||||
};
|
||||
|
||||
/* version_major=1, version_minor=0 */
|
||||
struct gfx_firmware_header_v1_0 {
|
||||
struct common_firmware_header header;
|
||||
uint32_t ucode_feature_version;
|
||||
uint32_t jt_offset; /* jt location */
|
||||
uint32_t jt_size; /* size of jt */
|
||||
};
|
||||
|
||||
/* version_major=2, version_minor=0 */
|
||||
struct gfx_firmware_header_v2_0 {
|
||||
struct common_firmware_header header;
|
||||
uint32_t ucode_feature_version;
|
||||
uint32_t ucode_size_bytes;
|
||||
uint32_t ucode_offset_bytes;
|
||||
uint32_t data_size_bytes;
|
||||
uint32_t data_offset_bytes;
|
||||
uint32_t ucode_start_addr_lo;
|
||||
uint32_t ucode_start_addr_hi;
|
||||
};
|
||||
|
||||
/* version_major=1, version_minor=0 */
|
||||
struct mes_firmware_header_v1_0 {
|
||||
struct common_firmware_header header;
|
||||
uint32_t mes_ucode_version;
|
||||
uint32_t mes_ucode_size_bytes;
|
||||
uint32_t mes_ucode_offset_bytes;
|
||||
uint32_t mes_ucode_data_version;
|
||||
uint32_t mes_ucode_data_size_bytes;
|
||||
uint32_t mes_ucode_data_offset_bytes;
|
||||
uint32_t mes_uc_start_addr_lo;
|
||||
uint32_t mes_uc_start_addr_hi;
|
||||
uint32_t mes_data_start_addr_lo;
|
||||
uint32_t mes_data_start_addr_hi;
|
||||
};
|
||||
|
||||
/* version_major=1, version_minor=0 */
|
||||
struct rlc_firmware_header_v1_0 {
|
||||
struct common_firmware_header header;
|
||||
uint32_t ucode_feature_version;
|
||||
uint32_t save_and_restore_offset;
|
||||
uint32_t clear_state_descriptor_offset;
|
||||
uint32_t avail_scratch_ram_locations;
|
||||
uint32_t master_pkt_description_offset;
|
||||
};
|
||||
|
||||
/* version_major=2, version_minor=0 */
|
||||
struct rlc_firmware_header_v2_0 {
|
||||
struct common_firmware_header header;
|
||||
uint32_t ucode_feature_version;
|
||||
uint32_t jt_offset; /* jt location */
|
||||
uint32_t jt_size; /* size of jt */
|
||||
uint32_t save_and_restore_offset;
|
||||
uint32_t clear_state_descriptor_offset;
|
||||
uint32_t avail_scratch_ram_locations;
|
||||
uint32_t reg_restore_list_size;
|
||||
uint32_t reg_list_format_start;
|
||||
uint32_t reg_list_format_separate_start;
|
||||
uint32_t starting_offsets_start;
|
||||
uint32_t reg_list_format_size_bytes; /* size of reg list format array in bytes */
|
||||
uint32_t reg_list_format_array_offset_bytes; /* payload offset from the start of the header */
|
||||
uint32_t reg_list_size_bytes; /* size of reg list array in bytes */
|
||||
uint32_t reg_list_array_offset_bytes; /* payload offset from the start of the header */
|
||||
uint32_t reg_list_format_separate_size_bytes; /* size of reg list format array in bytes */
|
||||
uint32_t reg_list_format_separate_array_offset_bytes; /* payload offset from the start of the header */
|
||||
uint32_t reg_list_separate_size_bytes; /* size of reg list array in bytes */
|
||||
uint32_t reg_list_separate_array_offset_bytes; /* payload offset from the start of the header */
|
||||
};
|
||||
|
||||
/* version_major=2, version_minor=1 */
|
||||
struct rlc_firmware_header_v2_1 {
|
||||
struct rlc_firmware_header_v2_0 v2_0;
|
||||
uint32_t reg_list_format_direct_reg_list_length; /* length of direct reg list format array */
|
||||
uint32_t save_restore_list_cntl_ucode_ver;
|
||||
uint32_t save_restore_list_cntl_feature_ver;
|
||||
uint32_t save_restore_list_cntl_size_bytes;
|
||||
uint32_t save_restore_list_cntl_offset_bytes;
|
||||
uint32_t save_restore_list_gpm_ucode_ver;
|
||||
uint32_t save_restore_list_gpm_feature_ver;
|
||||
uint32_t save_restore_list_gpm_size_bytes;
|
||||
uint32_t save_restore_list_gpm_offset_bytes;
|
||||
uint32_t save_restore_list_srm_ucode_ver;
|
||||
uint32_t save_restore_list_srm_feature_ver;
|
||||
uint32_t save_restore_list_srm_size_bytes;
|
||||
uint32_t save_restore_list_srm_offset_bytes;
|
||||
};
|
||||
|
||||
/* version_major=2, version_minor=2 */
|
||||
struct rlc_firmware_header_v2_2 {
|
||||
struct rlc_firmware_header_v2_1 v2_1;
|
||||
uint32_t rlc_iram_ucode_size_bytes;
|
||||
uint32_t rlc_iram_ucode_offset_bytes;
|
||||
uint32_t rlc_dram_ucode_size_bytes;
|
||||
uint32_t rlc_dram_ucode_offset_bytes;
|
||||
};
|
||||
|
||||
/* version_major=2, version_minor=3 */
|
||||
struct rlc_firmware_header_v2_3 {
|
||||
struct rlc_firmware_header_v2_2 v2_2;
|
||||
uint32_t rlcp_ucode_version;
|
||||
uint32_t rlcp_ucode_feature_version;
|
||||
uint32_t rlcp_ucode_size_bytes;
|
||||
uint32_t rlcp_ucode_offset_bytes;
|
||||
uint32_t rlcv_ucode_version;
|
||||
uint32_t rlcv_ucode_feature_version;
|
||||
uint32_t rlcv_ucode_size_bytes;
|
||||
uint32_t rlcv_ucode_offset_bytes;
|
||||
};
|
||||
|
||||
/* version_major=2, version_minor=4 */
|
||||
struct rlc_firmware_header_v2_4 {
|
||||
struct rlc_firmware_header_v2_3 v2_3;
|
||||
uint32_t global_tap_delays_ucode_size_bytes;
|
||||
uint32_t global_tap_delays_ucode_offset_bytes;
|
||||
uint32_t se0_tap_delays_ucode_size_bytes;
|
||||
uint32_t se0_tap_delays_ucode_offset_bytes;
|
||||
uint32_t se1_tap_delays_ucode_size_bytes;
|
||||
uint32_t se1_tap_delays_ucode_offset_bytes;
|
||||
uint32_t se2_tap_delays_ucode_size_bytes;
|
||||
uint32_t se2_tap_delays_ucode_offset_bytes;
|
||||
uint32_t se3_tap_delays_ucode_size_bytes;
|
||||
uint32_t se3_tap_delays_ucode_offset_bytes;
|
||||
};
|
||||
|
||||
/* version_major=1, version_minor=0 */
|
||||
struct sdma_firmware_header_v1_0 {
|
||||
struct common_firmware_header header;
|
||||
uint32_t ucode_feature_version;
|
||||
uint32_t ucode_change_version;
|
||||
uint32_t jt_offset; /* jt location */
|
||||
uint32_t jt_size; /* size of jt */
|
||||
};
|
||||
|
||||
/* version_major=1, version_minor=1 */
|
||||
struct sdma_firmware_header_v1_1 {
|
||||
struct sdma_firmware_header_v1_0 v1_0;
|
||||
uint32_t digest_size;
|
||||
};
|
||||
|
||||
/* version_major=2, version_minor=0 */
|
||||
struct sdma_firmware_header_v2_0 {
|
||||
struct common_firmware_header header;
|
||||
uint32_t ucode_feature_version;
|
||||
uint32_t ctx_ucode_size_bytes; /* context thread ucode size */
|
||||
uint32_t ctx_jt_offset; /* context thread jt location */
|
||||
uint32_t ctx_jt_size; /* context thread size of jt */
|
||||
uint32_t ctl_ucode_offset;
|
||||
uint32_t ctl_ucode_size_bytes; /* control thread ucode size */
|
||||
uint32_t ctl_jt_offset; /* control thread jt location */
|
||||
uint32_t ctl_jt_size; /* control thread size of jt */
|
||||
};
|
||||
|
||||
/* version_major=1, version_minor=0 */
|
||||
struct vpe_firmware_header_v1_0 {
|
||||
struct common_firmware_header header;
|
||||
uint32_t ucode_feature_version;
|
||||
uint32_t ctx_ucode_size_bytes; /* context thread ucode size */
|
||||
uint32_t ctx_jt_offset; /* context thread jt location */
|
||||
uint32_t ctx_jt_size; /* context thread size of jt */
|
||||
uint32_t ctl_ucode_offset;
|
||||
uint32_t ctl_ucode_size_bytes; /* control thread ucode size */
|
||||
uint32_t ctl_jt_offset; /* control thread jt location */
|
||||
uint32_t ctl_jt_size; /* control thread size of jt */
|
||||
};
|
||||
|
||||
/* version_major=1, version_minor=0 */
|
||||
struct umsch_mm_firmware_header_v1_0 {
|
||||
struct common_firmware_header header;
|
||||
uint32_t umsch_mm_ucode_version;
|
||||
uint32_t umsch_mm_ucode_size_bytes;
|
||||
uint32_t umsch_mm_ucode_offset_bytes;
|
||||
uint32_t umsch_mm_ucode_data_version;
|
||||
uint32_t umsch_mm_ucode_data_size_bytes;
|
||||
uint32_t umsch_mm_ucode_data_offset_bytes;
|
||||
uint32_t umsch_mm_irq_start_addr_lo;
|
||||
uint32_t umsch_mm_irq_start_addr_hi;
|
||||
uint32_t umsch_mm_uc_start_addr_lo;
|
||||
uint32_t umsch_mm_uc_start_addr_hi;
|
||||
uint32_t umsch_mm_data_start_addr_lo;
|
||||
uint32_t umsch_mm_data_start_addr_hi;
|
||||
};
|
||||
|
||||
/* version_major=3, version_minor=0 */
|
||||
struct sdma_firmware_header_v3_0 {
|
||||
struct common_firmware_header header;
|
||||
uint32_t ucode_feature_version;
|
||||
uint32_t ucode_offset_bytes;
|
||||
uint32_t ucode_size_bytes;
|
||||
};
|
||||
|
||||
/* gpu info payload */
|
||||
struct gpu_info_firmware_v1_0 {
|
||||
uint32_t gc_num_se;
|
||||
uint32_t gc_num_cu_per_sh;
|
||||
uint32_t gc_num_sh_per_se;
|
||||
uint32_t gc_num_rb_per_se;
|
||||
uint32_t gc_num_tccs;
|
||||
uint32_t gc_num_gprs;
|
||||
uint32_t gc_num_max_gs_thds;
|
||||
uint32_t gc_gs_table_depth;
|
||||
uint32_t gc_gsprim_buff_depth;
|
||||
uint32_t gc_parameter_cache_depth;
|
||||
uint32_t gc_double_offchip_lds_buffer;
|
||||
uint32_t gc_wave_size;
|
||||
uint32_t gc_max_waves_per_simd;
|
||||
uint32_t gc_max_scratch_slots_per_cu;
|
||||
uint32_t gc_lds_size;
|
||||
};
|
||||
|
||||
struct gpu_info_firmware_v1_1 {
|
||||
struct gpu_info_firmware_v1_0 v1_0;
|
||||
uint32_t num_sc_per_sh;
|
||||
uint32_t num_packer_per_sc;
|
||||
};
|
||||
|
||||
/* gpu info payload
|
||||
* version_major=1, version_minor=1 */
|
||||
// struct gpu_info_firmware_v1_2 {
|
||||
// struct gpu_info_firmware_v1_1 v1_1;
|
||||
// struct gpu_info_soc_bounding_box_v1_0 soc_bounding_box;
|
||||
// };
|
||||
|
||||
/* version_major=1, version_minor=0 */
|
||||
struct gpu_info_firmware_header_v1_0 {
|
||||
struct common_firmware_header header;
|
||||
uint16_t version_major; /* version */
|
||||
uint16_t version_minor; /* version */
|
||||
};
|
||||
|
||||
/* version_major=1, version_minor=0 */
|
||||
struct dmcu_firmware_header_v1_0 {
|
||||
struct common_firmware_header header;
|
||||
uint32_t intv_offset_bytes; /* interrupt vectors offset from end of header, in bytes */
|
||||
uint32_t intv_size_bytes; /* size of interrupt vectors, in bytes */
|
||||
};
|
||||
|
||||
/* version_major=1, version_minor=0 */
|
||||
struct dmcub_firmware_header_v1_0 {
|
||||
struct common_firmware_header header;
|
||||
uint32_t inst_const_bytes; /* size of instruction region, in bytes */
|
||||
uint32_t bss_data_bytes; /* size of bss/data region, in bytes */
|
||||
};
|
||||
|
||||
/* version_major=1, version_minor=0 */
|
||||
struct imu_firmware_header_v1_0 {
|
||||
struct common_firmware_header header;
|
||||
uint32_t imu_iram_ucode_size_bytes;
|
||||
uint32_t imu_iram_ucode_offset_bytes;
|
||||
uint32_t imu_dram_ucode_size_bytes;
|
||||
uint32_t imu_dram_ucode_offset_bytes;
|
||||
};
|
||||
|
||||
/* header is fixed size */
|
||||
union amdgpu_firmware_header {
|
||||
struct common_firmware_header common;
|
||||
struct mc_firmware_header_v1_0 mc;
|
||||
struct smc_firmware_header_v1_0 smc;
|
||||
struct smc_firmware_header_v2_0 smc_v2_0;
|
||||
struct psp_firmware_header_v1_0 psp;
|
||||
struct psp_firmware_header_v1_1 psp_v1_1;
|
||||
struct psp_firmware_header_v1_3 psp_v1_3;
|
||||
struct psp_firmware_header_v2_0 psp_v2_0;
|
||||
struct psp_firmware_header_v2_0 psp_v2_1;
|
||||
struct ta_firmware_header_v1_0 ta;
|
||||
struct ta_firmware_header_v2_0 ta_v2_0;
|
||||
struct gfx_firmware_header_v1_0 gfx;
|
||||
struct gfx_firmware_header_v2_0 gfx_v2_0;
|
||||
struct rlc_firmware_header_v1_0 rlc;
|
||||
struct rlc_firmware_header_v2_0 rlc_v2_0;
|
||||
struct rlc_firmware_header_v2_1 rlc_v2_1;
|
||||
struct rlc_firmware_header_v2_2 rlc_v2_2;
|
||||
struct rlc_firmware_header_v2_3 rlc_v2_3;
|
||||
struct rlc_firmware_header_v2_4 rlc_v2_4;
|
||||
struct sdma_firmware_header_v1_0 sdma;
|
||||
struct sdma_firmware_header_v1_1 sdma_v1_1;
|
||||
struct sdma_firmware_header_v2_0 sdma_v2_0;
|
||||
struct sdma_firmware_header_v3_0 sdma_v3_0;
|
||||
struct gpu_info_firmware_header_v1_0 gpu_info;
|
||||
struct dmcu_firmware_header_v1_0 dmcu;
|
||||
struct dmcub_firmware_header_v1_0 dmcub;
|
||||
struct imu_firmware_header_v1_0 imu;
|
||||
uint8_t raw[0x100];
|
||||
};
|
||||
|
||||
#define UCODE_MAX_PSP_PACKAGING (((sizeof(union amdgpu_firmware_header) - sizeof(struct common_firmware_header) - 4) / sizeof(struct psp_fw_bin_desc)) * 2)
|
||||
|
||||
/*
|
||||
* fw loading support
|
||||
*/
|
||||
enum AMDGPU_UCODE_ID {
|
||||
AMDGPU_UCODE_ID_CAP = 0,
|
||||
AMDGPU_UCODE_ID_SDMA0,
|
||||
AMDGPU_UCODE_ID_SDMA1,
|
||||
AMDGPU_UCODE_ID_SDMA2,
|
||||
AMDGPU_UCODE_ID_SDMA3,
|
||||
AMDGPU_UCODE_ID_SDMA4,
|
||||
AMDGPU_UCODE_ID_SDMA5,
|
||||
AMDGPU_UCODE_ID_SDMA6,
|
||||
AMDGPU_UCODE_ID_SDMA7,
|
||||
AMDGPU_UCODE_ID_SDMA_UCODE_TH0,
|
||||
AMDGPU_UCODE_ID_SDMA_UCODE_TH1,
|
||||
AMDGPU_UCODE_ID_SDMA_RS64,
|
||||
AMDGPU_UCODE_ID_CP_CE,
|
||||
AMDGPU_UCODE_ID_CP_PFP,
|
||||
AMDGPU_UCODE_ID_CP_ME,
|
||||
AMDGPU_UCODE_ID_CP_RS64_PFP,
|
||||
AMDGPU_UCODE_ID_CP_RS64_ME,
|
||||
AMDGPU_UCODE_ID_CP_RS64_MEC,
|
||||
AMDGPU_UCODE_ID_CP_RS64_PFP_P0_STACK,
|
||||
AMDGPU_UCODE_ID_CP_RS64_PFP_P1_STACK,
|
||||
AMDGPU_UCODE_ID_CP_RS64_ME_P0_STACK,
|
||||
AMDGPU_UCODE_ID_CP_RS64_ME_P1_STACK,
|
||||
AMDGPU_UCODE_ID_CP_RS64_MEC_P0_STACK,
|
||||
AMDGPU_UCODE_ID_CP_RS64_MEC_P1_STACK,
|
||||
AMDGPU_UCODE_ID_CP_RS64_MEC_P2_STACK,
|
||||
AMDGPU_UCODE_ID_CP_RS64_MEC_P3_STACK,
|
||||
AMDGPU_UCODE_ID_CP_MEC1,
|
||||
AMDGPU_UCODE_ID_CP_MEC1_JT,
|
||||
AMDGPU_UCODE_ID_CP_MEC2,
|
||||
AMDGPU_UCODE_ID_CP_MEC2_JT,
|
||||
AMDGPU_UCODE_ID_CP_MES,
|
||||
AMDGPU_UCODE_ID_CP_MES_DATA,
|
||||
AMDGPU_UCODE_ID_CP_MES1,
|
||||
AMDGPU_UCODE_ID_CP_MES1_DATA,
|
||||
AMDGPU_UCODE_ID_IMU_I,
|
||||
AMDGPU_UCODE_ID_IMU_D,
|
||||
AMDGPU_UCODE_ID_GLOBAL_TAP_DELAYS,
|
||||
AMDGPU_UCODE_ID_SE0_TAP_DELAYS,
|
||||
AMDGPU_UCODE_ID_SE1_TAP_DELAYS,
|
||||
AMDGPU_UCODE_ID_SE2_TAP_DELAYS,
|
||||
AMDGPU_UCODE_ID_SE3_TAP_DELAYS,
|
||||
AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL,
|
||||
AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM,
|
||||
AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM,
|
||||
AMDGPU_UCODE_ID_RLC_IRAM,
|
||||
AMDGPU_UCODE_ID_RLC_DRAM,
|
||||
AMDGPU_UCODE_ID_RLC_P,
|
||||
AMDGPU_UCODE_ID_RLC_V,
|
||||
AMDGPU_UCODE_ID_RLC_G,
|
||||
AMDGPU_UCODE_ID_STORAGE,
|
||||
AMDGPU_UCODE_ID_SMC,
|
||||
AMDGPU_UCODE_ID_PPTABLE,
|
||||
AMDGPU_UCODE_ID_UVD,
|
||||
AMDGPU_UCODE_ID_UVD1,
|
||||
AMDGPU_UCODE_ID_VCE,
|
||||
AMDGPU_UCODE_ID_VCN,
|
||||
AMDGPU_UCODE_ID_VCN1,
|
||||
AMDGPU_UCODE_ID_DMCU_ERAM,
|
||||
AMDGPU_UCODE_ID_DMCU_INTV,
|
||||
AMDGPU_UCODE_ID_VCN0_RAM,
|
||||
AMDGPU_UCODE_ID_VCN1_RAM,
|
||||
AMDGPU_UCODE_ID_DMCUB,
|
||||
AMDGPU_UCODE_ID_VPE_CTX,
|
||||
AMDGPU_UCODE_ID_VPE_CTL,
|
||||
AMDGPU_UCODE_ID_VPE,
|
||||
AMDGPU_UCODE_ID_UMSCH_MM_UCODE,
|
||||
AMDGPU_UCODE_ID_UMSCH_MM_DATA,
|
||||
AMDGPU_UCODE_ID_UMSCH_MM_CMD_BUFFER,
|
||||
AMDGPU_UCODE_ID_P2S_TABLE,
|
||||
AMDGPU_UCODE_ID_JPEG_RAM,
|
||||
AMDGPU_UCODE_ID_ISP,
|
||||
AMDGPU_UCODE_ID_MAXIMUM,
|
||||
};
|
||||
|
||||
/* engine firmware status */
|
||||
enum AMDGPU_UCODE_STATUS {
|
||||
AMDGPU_UCODE_STATUS_INVALID,
|
||||
AMDGPU_UCODE_STATUS_NOT_LOADED,
|
||||
AMDGPU_UCODE_STATUS_LOADED,
|
||||
};
|
||||
|
||||
enum amdgpu_firmware_load_type {
|
||||
AMDGPU_FW_LOAD_DIRECT = 0,
|
||||
AMDGPU_FW_LOAD_PSP,
|
||||
AMDGPU_FW_LOAD_SMU,
|
||||
AMDGPU_FW_LOAD_RLC_BACKDOOR_AUTO,
|
||||
};
|
||||
|
||||
/* conform to smu_ucode_xfer_cz.h */
|
||||
#define AMDGPU_SDMA0_UCODE_LOADED 0x00000001
|
||||
#define AMDGPU_SDMA1_UCODE_LOADED 0x00000002
|
||||
#define AMDGPU_CPCE_UCODE_LOADED 0x00000004
|
||||
#define AMDGPU_CPPFP_UCODE_LOADED 0x00000008
|
||||
#define AMDGPU_CPME_UCODE_LOADED 0x00000010
|
||||
#define AMDGPU_CPMEC1_UCODE_LOADED 0x00000020
|
||||
#define AMDGPU_CPMEC2_UCODE_LOADED 0x00000040
|
||||
#define AMDGPU_CPRLC_UCODE_LOADED 0x00000100
|
||||
|
||||
/* amdgpu firmware info */
|
||||
struct amdgpu_firmware_info {
|
||||
/* ucode ID */
|
||||
enum AMDGPU_UCODE_ID ucode_id;
|
||||
/* request_firmware */
|
||||
const struct firmware *fw;
|
||||
/* starting mc address */
|
||||
uint64_t mc_addr;
|
||||
/* kernel linear address */
|
||||
void *kaddr;
|
||||
/* ucode_size_bytes */
|
||||
uint32_t ucode_size;
|
||||
/* starting tmr mc address */
|
||||
uint32_t tmr_mc_addr_lo;
|
||||
uint32_t tmr_mc_addr_hi;
|
||||
};
|
||||
|
||||
// struct amdgpu_firmware {
|
||||
// struct amdgpu_firmware_info ucode[AMDGPU_UCODE_ID_MAXIMUM];
|
||||
// enum amdgpu_firmware_load_type load_type;
|
||||
// struct amdgpu_bo *fw_buf;
|
||||
// unsigned int fw_size;
|
||||
// unsigned int max_ucodes;
|
||||
// /* firmwares are loaded by psp instead of smu from vega10 */
|
||||
// const struct amdgpu_psp_funcs *funcs;
|
||||
// struct amdgpu_bo *rbuf;
|
||||
// struct mutex mutex;
|
||||
|
||||
// /* gpu info firmware data pointer */
|
||||
// const struct firmware *gpu_info_fw;
|
||||
|
||||
// void *fw_buf_ptr;
|
||||
// uint64_t fw_buf_mc;
|
||||
// };
|
||||
|
||||
// void amdgpu_ucode_print_mc_hdr(const struct common_firmware_header *hdr);
|
||||
// void amdgpu_ucode_print_smc_hdr(const struct common_firmware_header *hdr);
|
||||
// void amdgpu_ucode_print_imu_hdr(const struct common_firmware_header *hdr);
|
||||
// void amdgpu_ucode_print_gfx_hdr(const struct common_firmware_header *hdr);
|
||||
// void amdgpu_ucode_print_rlc_hdr(const struct common_firmware_header *hdr);
|
||||
// void amdgpu_ucode_print_sdma_hdr(const struct common_firmware_header *hdr);
|
||||
// void amdgpu_ucode_print_psp_hdr(const struct common_firmware_header *hdr);
|
||||
// void amdgpu_ucode_print_gpu_info_hdr(const struct common_firmware_header *hdr);
|
||||
// int amdgpu_ucode_request(struct amdgpu_device *adev, const struct firmware **fw,
|
||||
// const char *fw_name);
|
||||
// void amdgpu_ucode_release(const struct firmware **fw);
|
||||
// bool amdgpu_ucode_hdr_version(union amdgpu_firmware_header *hdr,
|
||||
// uint16_t hdr_major, uint16_t hdr_minor);
|
||||
|
||||
// int amdgpu_ucode_init_bo(struct amdgpu_device *adev);
|
||||
// int amdgpu_ucode_create_bo(struct amdgpu_device *adev);
|
||||
// int amdgpu_ucode_sysfs_init(struct amdgpu_device *adev);
|
||||
// void amdgpu_ucode_free_bo(struct amdgpu_device *adev);
|
||||
// void amdgpu_ucode_sysfs_fini(struct amdgpu_device *adev);
|
||||
|
||||
// enum amdgpu_firmware_load_type
|
||||
// amdgpu_ucode_get_load_type(struct amdgpu_device *adev, int load_type);
|
||||
|
||||
// const char *amdgpu_ucode_name(enum AMDGPU_UCODE_ID ucode_id);
|
||||
|
||||
// void amdgpu_ucode_ip_version_decode(struct amdgpu_device *adev, int block_type, char *ucode_prefix, int len);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,665 @@
|
||||
/*
|
||||
* Copyright 2016 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Authors: Christian König
|
||||
*/
|
||||
#ifndef __AMDGPU_VM_H__
|
||||
#define __AMDGPU_VM_H__
|
||||
|
||||
// #include <linux/idr.h>
|
||||
// #include <linux/kfifo.h>
|
||||
// #include <linux/rbtree.h>
|
||||
// #include <drm/gpu_scheduler.h>
|
||||
// #include <drm/drm_file.h>
|
||||
// #include <drm/ttm/ttm_bo.h>
|
||||
// #include <linux/sched/mm.h>
|
||||
|
||||
// #include "amdgpu_sync.h"
|
||||
// #include "amdgpu_ring.h"
|
||||
// #include "amdgpu_ids.h"
|
||||
|
||||
// struct drm_exec;
|
||||
|
||||
// struct amdgpu_bo_va;
|
||||
// struct amdgpu_job;
|
||||
// struct amdgpu_bo_list_entry;
|
||||
// struct amdgpu_bo_vm;
|
||||
// struct amdgpu_mem_stats;
|
||||
|
||||
/*
|
||||
* GPUVM handling
|
||||
*/
|
||||
|
||||
/* Maximum number of PTEs the hardware can write with one command */
|
||||
#define AMDGPU_VM_MAX_UPDATE_SIZE 0x3FFFF
|
||||
|
||||
/* number of entries in page table */
|
||||
#define AMDGPU_VM_PTE_COUNT(adev) (1 << (adev)->vm_manager.block_size)
|
||||
|
||||
#define AMDGPU_PTE_VALID (1ULL << 0)
|
||||
#define AMDGPU_PTE_SYSTEM (1ULL << 1)
|
||||
#define AMDGPU_PTE_SNOOPED (1ULL << 2)
|
||||
|
||||
/* RV+ */
|
||||
#define AMDGPU_PTE_TMZ (1ULL << 3)
|
||||
|
||||
/* VI only */
|
||||
#define AMDGPU_PTE_EXECUTABLE (1ULL << 4)
|
||||
|
||||
#define AMDGPU_PTE_READABLE (1ULL << 5)
|
||||
#define AMDGPU_PTE_WRITEABLE (1ULL << 6)
|
||||
|
||||
#define AMDGPU_PTE_FRAG(x) ((x & 0x1fULL) << 7)
|
||||
|
||||
/* TILED for VEGA10, reserved for older ASICs */
|
||||
#define AMDGPU_PTE_PRT (1ULL << 51)
|
||||
|
||||
/* PDE is handled as PTE for VEGA10 */
|
||||
#define AMDGPU_PDE_PTE (1ULL << 54)
|
||||
|
||||
#define AMDGPU_PTE_LOG (1ULL << 55)
|
||||
|
||||
/* PTE is handled as PDE for VEGA10 (Translate Further) */
|
||||
#define AMDGPU_PTE_TF (1ULL << 56)
|
||||
|
||||
/* MALL noalloc for sienna_cichlid, reserved for older ASICs */
|
||||
#define AMDGPU_PTE_NOALLOC (1ULL << 58)
|
||||
|
||||
/* PDE Block Fragment Size for VEGA10 */
|
||||
#define AMDGPU_PDE_BFS(a) ((uint64_t)a << 59)
|
||||
|
||||
/* Flag combination to set no-retry with TF disabled */
|
||||
#define AMDGPU_VM_NORETRY_FLAGS (AMDGPU_PTE_EXECUTABLE | AMDGPU_PDE_PTE | \
|
||||
AMDGPU_PTE_TF)
|
||||
|
||||
/* Flag combination to set no-retry with TF enabled */
|
||||
#define AMDGPU_VM_NORETRY_FLAGS_TF (AMDGPU_PTE_VALID | AMDGPU_PTE_SYSTEM | \
|
||||
AMDGPU_PTE_PRT)
|
||||
/* For GFX9 */
|
||||
#define AMDGPU_PTE_MTYPE_VG10_SHIFT(mtype) ((uint64_t)(mtype) << 57)
|
||||
#define AMDGPU_PTE_MTYPE_VG10_MASK AMDGPU_PTE_MTYPE_VG10_SHIFT(3ULL)
|
||||
#define AMDGPU_PTE_MTYPE_VG10(flags, mtype) \
|
||||
(((uint64_t)(flags) & (~AMDGPU_PTE_MTYPE_VG10_MASK)) | \
|
||||
AMDGPU_PTE_MTYPE_VG10_SHIFT(mtype))
|
||||
|
||||
#define AMDGPU_MTYPE_NC 0
|
||||
#define AMDGPU_MTYPE_CC 2
|
||||
|
||||
#define AMDGPU_PTE_DEFAULT_ATC (AMDGPU_PTE_SYSTEM \
|
||||
| AMDGPU_PTE_SNOOPED \
|
||||
| AMDGPU_PTE_EXECUTABLE \
|
||||
| AMDGPU_PTE_READABLE \
|
||||
| AMDGPU_PTE_WRITEABLE \
|
||||
| AMDGPU_PTE_MTYPE_VG10(AMDGPU_MTYPE_CC))
|
||||
|
||||
/* gfx10 */
|
||||
#define AMDGPU_PTE_MTYPE_NV10_SHIFT(mtype) ((uint64_t)(mtype) << 48)
|
||||
#define AMDGPU_PTE_MTYPE_NV10_MASK AMDGPU_PTE_MTYPE_NV10_SHIFT(7ULL)
|
||||
#define AMDGPU_PTE_MTYPE_NV10(flags, mtype) \
|
||||
(((uint64_t)(flags) & (~AMDGPU_PTE_MTYPE_NV10_MASK)) | \
|
||||
AMDGPU_PTE_MTYPE_NV10_SHIFT(mtype))
|
||||
|
||||
/* gfx12 */
|
||||
#define AMDGPU_PTE_PRT_GFX12 (1ULL << 56)
|
||||
#define AMDGPU_PTE_PRT_FLAG(adev) \
|
||||
((amdgpu_ip_version((adev), GC_HWIP, 0) >= IP_VERSION(12, 0, 0)) ? AMDGPU_PTE_PRT_GFX12 : AMDGPU_PTE_PRT)
|
||||
|
||||
#define AMDGPU_PTE_MTYPE_GFX12_SHIFT(mtype) ((uint64_t)(mtype) << 54)
|
||||
#define AMDGPU_PTE_MTYPE_GFX12_MASK AMDGPU_PTE_MTYPE_GFX12_SHIFT(3ULL)
|
||||
#define AMDGPU_PTE_MTYPE_GFX12(flags, mtype) \
|
||||
(((uint64_t)(flags) & (~AMDGPU_PTE_MTYPE_GFX12_MASK)) | \
|
||||
AMDGPU_PTE_MTYPE_GFX12_SHIFT(mtype))
|
||||
|
||||
#define AMDGPU_PTE_IS_PTE (1ULL << 63)
|
||||
|
||||
/* PDE Block Fragment Size for gfx v12 */
|
||||
#define AMDGPU_PDE_BFS_GFX12(a) ((uint64_t)((a) & 0x1fULL) << 58)
|
||||
#define AMDGPU_PDE_BFS_FLAG(adev, a) \
|
||||
((amdgpu_ip_version((adev), GC_HWIP, 0) >= IP_VERSION(12, 0, 0)) ? AMDGPU_PDE_BFS_GFX12(a) : AMDGPU_PDE_BFS(a))
|
||||
/* PDE is handled as PTE for gfx v12 */
|
||||
#define AMDGPU_PDE_PTE_GFX12 (1ULL << 63)
|
||||
#define AMDGPU_PDE_PTE_FLAG(adev) \
|
||||
((amdgpu_ip_version((adev), GC_HWIP, 0) >= IP_VERSION(12, 0, 0)) ? AMDGPU_PDE_PTE_GFX12 : AMDGPU_PDE_PTE)
|
||||
|
||||
/* How to program VM fault handling */
|
||||
#define AMDGPU_VM_FAULT_STOP_NEVER 0
|
||||
#define AMDGPU_VM_FAULT_STOP_FIRST 1
|
||||
#define AMDGPU_VM_FAULT_STOP_ALWAYS 2
|
||||
|
||||
/* How much VRAM be reserved for page tables */
|
||||
#define AMDGPU_VM_RESERVED_VRAM (8ULL << 20)
|
||||
|
||||
/*
|
||||
* max number of VMHUB
|
||||
* layout: max 8 GFXHUB + 4 MMHUB0 + 1 MMHUB1
|
||||
*/
|
||||
#define AMDGPU_MAX_VMHUBS 13
|
||||
#define AMDGPU_GFXHUB_START 0
|
||||
#define AMDGPU_MMHUB0_START 8
|
||||
#define AMDGPU_MMHUB1_START 12
|
||||
#define AMDGPU_GFXHUB(x) (AMDGPU_GFXHUB_START + (x))
|
||||
#define AMDGPU_MMHUB0(x) (AMDGPU_MMHUB0_START + (x))
|
||||
#define AMDGPU_MMHUB1(x) (AMDGPU_MMHUB1_START + (x))
|
||||
|
||||
#define AMDGPU_IS_GFXHUB(x) ((x) >= AMDGPU_GFXHUB_START && (x) < AMDGPU_MMHUB0_START)
|
||||
#define AMDGPU_IS_MMHUB0(x) ((x) >= AMDGPU_MMHUB0_START && (x) < AMDGPU_MMHUB1_START)
|
||||
#define AMDGPU_IS_MMHUB1(x) ((x) >= AMDGPU_MMHUB1_START && (x) < AMDGPU_MAX_VMHUBS)
|
||||
|
||||
/* Reserve space at top/bottom of address space for kernel use */
|
||||
#define AMDGPU_VA_RESERVED_CSA_SIZE (2ULL << 20)
|
||||
#define AMDGPU_VA_RESERVED_CSA_START(adev) (((adev)->vm_manager.max_pfn \
|
||||
<< AMDGPU_GPU_PAGE_SHIFT) \
|
||||
- AMDGPU_VA_RESERVED_CSA_SIZE)
|
||||
#define AMDGPU_VA_RESERVED_SEQ64_SIZE (2ULL << 20)
|
||||
#define AMDGPU_VA_RESERVED_SEQ64_START(adev) (AMDGPU_VA_RESERVED_CSA_START(adev) \
|
||||
- AMDGPU_VA_RESERVED_SEQ64_SIZE)
|
||||
#define AMDGPU_VA_RESERVED_TRAP_SIZE (2ULL << 12)
|
||||
#define AMDGPU_VA_RESERVED_TRAP_START(adev) (AMDGPU_VA_RESERVED_SEQ64_START(adev) \
|
||||
- AMDGPU_VA_RESERVED_TRAP_SIZE)
|
||||
#define AMDGPU_VA_RESERVED_BOTTOM (1ULL << 16)
|
||||
#define AMDGPU_VA_RESERVED_TOP (AMDGPU_VA_RESERVED_TRAP_SIZE + \
|
||||
AMDGPU_VA_RESERVED_SEQ64_SIZE + \
|
||||
AMDGPU_VA_RESERVED_CSA_SIZE)
|
||||
|
||||
/* See vm_update_mode */
|
||||
#define AMDGPU_VM_USE_CPU_FOR_GFX (1 << 0)
|
||||
#define AMDGPU_VM_USE_CPU_FOR_COMPUTE (1 << 1)
|
||||
|
||||
/* VMPT level enumerate, and the hiberachy is:
|
||||
* PDB2->PDB1->PDB0->PTB
|
||||
*/
|
||||
enum amdgpu_vm_level {
|
||||
AMDGPU_VM_PDB2,
|
||||
AMDGPU_VM_PDB1,
|
||||
AMDGPU_VM_PDB0,
|
||||
AMDGPU_VM_PTB
|
||||
};
|
||||
|
||||
// /* base structure for tracking BO usage in a VM */
|
||||
// struct amdgpu_vm_bo_base {
|
||||
// /* constant after initialization */
|
||||
// struct amdgpu_vm *vm;
|
||||
// struct amdgpu_bo *bo;
|
||||
|
||||
// /* protected by bo being reserved */
|
||||
// struct amdgpu_vm_bo_base *next;
|
||||
|
||||
// /* protected by spinlock */
|
||||
// struct list_head vm_status;
|
||||
|
||||
// /* protected by the BO being reserved */
|
||||
// bool moved;
|
||||
// };
|
||||
|
||||
// /* provided by hw blocks that can write ptes, e.g., sdma */
|
||||
// struct amdgpu_vm_pte_funcs {
|
||||
// /* number of dw to reserve per operation */
|
||||
// unsigned copy_pte_num_dw;
|
||||
|
||||
// /* copy pte entries from GART */
|
||||
// void (*copy_pte)(struct amdgpu_ib *ib,
|
||||
// uint64_t pe, uint64_t src,
|
||||
// unsigned count);
|
||||
|
||||
// /* write pte one entry at a time with addr mapping */
|
||||
// void (*write_pte)(struct amdgpu_ib *ib, uint64_t pe,
|
||||
// uint64_t value, unsigned count,
|
||||
// uint32_t incr);
|
||||
// /* for linear pte/pde updates without addr mapping */
|
||||
// void (*set_pte_pde)(struct amdgpu_ib *ib,
|
||||
// uint64_t pe,
|
||||
// uint64_t addr, unsigned count,
|
||||
// uint32_t incr, uint64_t flags);
|
||||
// };
|
||||
|
||||
// struct amdgpu_task_info {
|
||||
// char process_name[TASK_COMM_LEN];
|
||||
// char task_name[TASK_COMM_LEN];
|
||||
// pid_t pid;
|
||||
// pid_t tgid;
|
||||
// struct kref refcount;
|
||||
// };
|
||||
|
||||
// /**
|
||||
// * struct amdgpu_vm_update_params
|
||||
// *
|
||||
// * Encapsulate some VM table update parameters to reduce
|
||||
// * the number of function parameters
|
||||
// *
|
||||
// */
|
||||
// struct amdgpu_vm_update_params {
|
||||
|
||||
// /**
|
||||
// * @adev: amdgpu device we do this update for
|
||||
// */
|
||||
// struct amdgpu_device *adev;
|
||||
|
||||
// /**
|
||||
// * @vm: optional amdgpu_vm we do this update for
|
||||
// */
|
||||
// struct amdgpu_vm *vm;
|
||||
|
||||
// /**
|
||||
// * @immediate: if changes should be made immediately
|
||||
// */
|
||||
// bool immediate;
|
||||
|
||||
// /**
|
||||
// * @unlocked: true if the root BO is not locked
|
||||
// */
|
||||
// bool unlocked;
|
||||
|
||||
// /**
|
||||
// * @pages_addr:
|
||||
// *
|
||||
// * DMA addresses to use for mapping
|
||||
// */
|
||||
// dma_addr_t *pages_addr;
|
||||
|
||||
// /**
|
||||
// * @job: job to used for hw submission
|
||||
// */
|
||||
// struct amdgpu_job *job;
|
||||
|
||||
// /**
|
||||
// * @num_dw_left: number of dw left for the IB
|
||||
// */
|
||||
// unsigned int num_dw_left;
|
||||
|
||||
// /**
|
||||
// * @needs_flush: true whenever we need to invalidate the TLB
|
||||
// */
|
||||
// bool needs_flush;
|
||||
|
||||
// /**
|
||||
// * @allow_override: true for memory that is not uncached: allows MTYPE
|
||||
// * to be overridden for NUMA local memory.
|
||||
// */
|
||||
// bool allow_override;
|
||||
|
||||
// /**
|
||||
// * @tlb_flush_waitlist: temporary storage for BOs until tlb_flush
|
||||
// */
|
||||
// struct list_head tlb_flush_waitlist;
|
||||
// };
|
||||
|
||||
// struct amdgpu_vm_update_funcs {
|
||||
// int (*map_table)(struct amdgpu_bo_vm *bo);
|
||||
// int (*prepare)(struct amdgpu_vm_update_params *p, struct dma_resv *resv,
|
||||
// enum amdgpu_sync_mode sync_mode);
|
||||
// int (*update)(struct amdgpu_vm_update_params *p,
|
||||
// struct amdgpu_bo_vm *bo, uint64_t pe, uint64_t addr,
|
||||
// unsigned count, uint32_t incr, uint64_t flags);
|
||||
// int (*commit)(struct amdgpu_vm_update_params *p,
|
||||
// struct dma_fence **fence);
|
||||
// };
|
||||
|
||||
// struct amdgpu_vm_fault_info {
|
||||
// /* fault address */
|
||||
// uint64_t addr;
|
||||
// /* fault status register */
|
||||
// uint32_t status;
|
||||
// /* which vmhub? gfxhub, mmhub, etc. */
|
||||
// unsigned int vmhub;
|
||||
// };
|
||||
|
||||
// struct amdgpu_vm {
|
||||
// /* tree of virtual addresses mapped */
|
||||
// #ifndef HAVE_TREE_INSERT_HAVE_RB_ROOT_CACHED
|
||||
// struct rb_root va;
|
||||
// #else
|
||||
// struct rb_root_cached va;
|
||||
// #endif
|
||||
|
||||
// /* Lock to prevent eviction while we are updating page tables
|
||||
// * use vm_eviction_lock/unlock(vm)
|
||||
// */
|
||||
// struct mutex eviction_lock;
|
||||
// bool evicting;
|
||||
// unsigned int saved_flags;
|
||||
|
||||
// /* Lock to protect vm_bo add/del/move on all lists of vm */
|
||||
// spinlock_t status_lock;
|
||||
|
||||
// /* Per-VM and PT BOs who needs a validation */
|
||||
// struct list_head evicted;
|
||||
|
||||
// /* BOs for user mode queues that need a validation */
|
||||
// struct list_head evicted_user;
|
||||
|
||||
// /* PT BOs which relocated and their parent need an update */
|
||||
// struct list_head relocated;
|
||||
|
||||
// /* per VM BOs moved, but not yet updated in the PT */
|
||||
// struct list_head moved;
|
||||
|
||||
// /* All BOs of this VM not currently in the state machine */
|
||||
// struct list_head idle;
|
||||
|
||||
// /* regular invalidated BOs, but not yet updated in the PT */
|
||||
// struct list_head invalidated;
|
||||
|
||||
// /* BO mappings freed, but not yet updated in the PT */
|
||||
// struct list_head freed;
|
||||
|
||||
// /* BOs which are invalidated, has been updated in the PTs */
|
||||
// struct list_head done;
|
||||
|
||||
// /* PT BOs scheduled to free and fill with zero if vm_resv is not hold */
|
||||
// struct list_head pt_freed;
|
||||
// struct work_struct pt_free_work;
|
||||
|
||||
// /* contains the page directory */
|
||||
// struct amdgpu_vm_bo_base root;
|
||||
// struct dma_fence *last_update;
|
||||
|
||||
// /* Scheduler entities for page table updates */
|
||||
// struct drm_sched_entity immediate;
|
||||
// struct drm_sched_entity delayed;
|
||||
|
||||
// /* Last finished delayed update */
|
||||
// atomic64_t tlb_seq;
|
||||
// struct dma_fence *last_tlb_flush;
|
||||
// atomic64_t kfd_last_flushed_seq;
|
||||
// uint64_t tlb_fence_context;
|
||||
|
||||
// /* How many times we had to re-generate the page tables */
|
||||
// uint64_t generation;
|
||||
|
||||
// /* Last unlocked submission to the scheduler entities */
|
||||
// struct dma_fence *last_unlocked;
|
||||
|
||||
// unsigned int pasid;
|
||||
// bool reserved_vmid[AMDGPU_MAX_VMHUBS];
|
||||
|
||||
// /* Flag to indicate if VM tables are updated by CPU or GPU (SDMA) */
|
||||
// bool use_cpu_for_update;
|
||||
|
||||
// /* Functions to use for VM table updates */
|
||||
// const struct amdgpu_vm_update_funcs *update_funcs;
|
||||
|
||||
// /* Up to 128 pending retry page faults */
|
||||
// DECLARE_KFIFO(faults, u64, 128);
|
||||
|
||||
// /* Points to the KFD process VM info */
|
||||
// struct amdkfd_process_info *process_info;
|
||||
|
||||
// /* List node in amdkfd_process_info.vm_list_head */
|
||||
// struct list_head vm_list_node;
|
||||
|
||||
// /* Valid while the PD is reserved or fenced */
|
||||
// uint64_t pd_phys_addr;
|
||||
|
||||
// /* Some basic info about the task */
|
||||
// struct amdgpu_task_info *task_info;
|
||||
|
||||
// /* Store positions of group of BOs */
|
||||
// struct ttm_lru_bulk_move lru_bulk_move;
|
||||
// /* Flag to indicate if VM is used for compute */
|
||||
// bool is_compute_context;
|
||||
|
||||
// /* Memory partition number, -1 means any partition */
|
||||
// int8_t mem_id;
|
||||
|
||||
// /* cached fault info */
|
||||
// struct amdgpu_vm_fault_info fault_info;
|
||||
// };
|
||||
|
||||
// struct amdgpu_vm_manager {
|
||||
// /* Handling of VMIDs */
|
||||
// struct amdgpu_vmid_mgr id_mgr[AMDGPU_MAX_VMHUBS];
|
||||
// unsigned int first_kfd_vmid;
|
||||
// bool concurrent_flush;
|
||||
|
||||
// /* Handling of VM fences */
|
||||
// u64 fence_context;
|
||||
// unsigned seqno[AMDGPU_MAX_RINGS];
|
||||
|
||||
// uint64_t max_pfn;
|
||||
// uint32_t num_level;
|
||||
// uint32_t block_size;
|
||||
// uint32_t fragment_size;
|
||||
// enum amdgpu_vm_level root_level;
|
||||
// /* vram base address for page table entry */
|
||||
// u64 vram_base_offset;
|
||||
// /* vm pte handling */
|
||||
// const struct amdgpu_vm_pte_funcs *vm_pte_funcs;
|
||||
// struct drm_gpu_scheduler *vm_pte_scheds[AMDGPU_MAX_RINGS];
|
||||
// unsigned vm_pte_num_scheds;
|
||||
// struct amdgpu_ring *page_fault;
|
||||
|
||||
// /* partial resident texture handling */
|
||||
// spinlock_t prt_lock;
|
||||
// atomic_t num_prt_users;
|
||||
|
||||
// /* controls how VM page tables are updated for Graphics and Compute.
|
||||
// * BIT0[= 0] Graphics updated by SDMA [= 1] by CPU
|
||||
// * BIT1[= 0] Compute updated by SDMA [= 1] by CPU
|
||||
// */
|
||||
// int vm_update_mode;
|
||||
|
||||
// /* PASID to VM mapping, will be used in interrupt context to
|
||||
// * look up VM of a page fault
|
||||
// */
|
||||
// #ifdef HAVE_STRUCT_XARRAY
|
||||
// struct xarray pasids;
|
||||
// #else
|
||||
// struct idr pasid_idr;
|
||||
// spinlock_t pasid_lock;
|
||||
// #endif
|
||||
// /* Global registration of recent page fault information */
|
||||
// struct amdgpu_vm_fault_info fault_info;
|
||||
// };
|
||||
|
||||
// struct amdgpu_bo_va_mapping;
|
||||
|
||||
// #define amdgpu_vm_copy_pte(adev, ib, pe, src, count) ((adev)->vm_manager.vm_pte_funcs->copy_pte((ib), (pe), (src), (count)))
|
||||
// #define amdgpu_vm_write_pte(adev, ib, pe, value, count, incr) ((adev)->vm_manager.vm_pte_funcs->write_pte((ib), (pe), (value), (count), (incr)))
|
||||
// #define amdgpu_vm_set_pte_pde(adev, ib, pe, addr, count, incr, flags) ((adev)->vm_manager.vm_pte_funcs->set_pte_pde((ib), (pe), (addr), (count), (incr), (flags)))
|
||||
|
||||
// extern const struct amdgpu_vm_update_funcs amdgpu_vm_cpu_funcs;
|
||||
// extern const struct amdgpu_vm_update_funcs amdgpu_vm_sdma_funcs;
|
||||
|
||||
// void amdgpu_vm_manager_init(struct amdgpu_device *adev);
|
||||
// void amdgpu_vm_manager_fini(struct amdgpu_device *adev);
|
||||
|
||||
// int amdgpu_vm_set_pasid(struct amdgpu_device *adev, struct amdgpu_vm *vm,
|
||||
// u32 pasid);
|
||||
|
||||
// long amdgpu_vm_wait_idle(struct amdgpu_vm *vm, long timeout);
|
||||
// int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, int32_t xcp_id);
|
||||
// int amdgpu_vm_make_compute(struct amdgpu_device *adev, struct amdgpu_vm *vm);
|
||||
// void amdgpu_vm_release_compute(struct amdgpu_device *adev, struct amdgpu_vm *vm);
|
||||
// void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm);
|
||||
// int amdgpu_vm_lock_pd(struct amdgpu_vm *vm, struct drm_exec *exec,
|
||||
// unsigned int num_fences);
|
||||
// bool amdgpu_vm_ready(struct amdgpu_vm *vm);
|
||||
// uint64_t amdgpu_vm_generation(struct amdgpu_device *adev, struct amdgpu_vm *vm);
|
||||
// int amdgpu_vm_validate(struct amdgpu_device *adev, struct amdgpu_vm *vm,
|
||||
// struct ww_acquire_ctx *ticket,
|
||||
// int (*callback)(void *p, struct amdgpu_bo *bo),
|
||||
// void *param);
|
||||
// int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, bool need_pipe_sync);
|
||||
// int amdgpu_vm_update_pdes(struct amdgpu_device *adev,
|
||||
// struct amdgpu_vm *vm, bool immediate);
|
||||
// int amdgpu_vm_clear_freed(struct amdgpu_device *adev,
|
||||
// struct amdgpu_vm *vm,
|
||||
// struct dma_fence **fence);
|
||||
// int amdgpu_vm_handle_moved(struct amdgpu_device *adev,
|
||||
// struct amdgpu_vm *vm,
|
||||
// struct ww_acquire_ctx *ticket);
|
||||
// int amdgpu_vm_flush_compute_tlb(struct amdgpu_device *adev,
|
||||
// struct amdgpu_vm *vm,
|
||||
// uint32_t flush_type,
|
||||
// uint32_t xcc_mask);
|
||||
// void amdgpu_vm_bo_base_init(struct amdgpu_vm_bo_base *base,
|
||||
// struct amdgpu_vm *vm, struct amdgpu_bo *bo);
|
||||
// int amdgpu_vm_update_range(struct amdgpu_device *adev, struct amdgpu_vm *vm,
|
||||
// bool immediate, bool unlocked, bool flush_tlb, bool allow_override,
|
||||
// struct dma_resv *resv, uint64_t start, uint64_t last,
|
||||
// uint64_t flags, uint64_t offset, uint64_t vram_base,
|
||||
// struct ttm_resource *res, dma_addr_t *pages_addr,
|
||||
// struct dma_fence **fence);
|
||||
// int amdgpu_vm_bo_update(struct amdgpu_device *adev,
|
||||
// struct amdgpu_bo_va *bo_va,
|
||||
// bool clear);
|
||||
// bool amdgpu_vm_evictable(struct amdgpu_bo *bo);
|
||||
// void amdgpu_vm_bo_invalidate(struct amdgpu_device *adev,
|
||||
// struct amdgpu_bo *bo, bool evicted);
|
||||
// uint64_t amdgpu_vm_map_gart(const dma_addr_t *pages_addr, uint64_t addr);
|
||||
// struct amdgpu_bo_va *amdgpu_vm_bo_find(struct amdgpu_vm *vm,
|
||||
// struct amdgpu_bo *bo);
|
||||
// struct amdgpu_bo_va *amdgpu_vm_bo_add(struct amdgpu_device *adev,
|
||||
// struct amdgpu_vm *vm,
|
||||
// struct amdgpu_bo *bo);
|
||||
// int amdgpu_vm_bo_map(struct amdgpu_device *adev,
|
||||
// struct amdgpu_bo_va *bo_va,
|
||||
// uint64_t addr, uint64_t offset,
|
||||
// uint64_t size, uint64_t flags);
|
||||
// int amdgpu_vm_bo_replace_map(struct amdgpu_device *adev,
|
||||
// struct amdgpu_bo_va *bo_va,
|
||||
// uint64_t addr, uint64_t offset,
|
||||
// uint64_t size, uint64_t flags);
|
||||
// int amdgpu_vm_bo_unmap(struct amdgpu_device *adev,
|
||||
// struct amdgpu_bo_va *bo_va,
|
||||
// uint64_t addr);
|
||||
// int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev,
|
||||
// struct amdgpu_vm *vm,
|
||||
// uint64_t saddr, uint64_t size);
|
||||
// struct amdgpu_bo_va_mapping *amdgpu_vm_bo_lookup_mapping(struct amdgpu_vm *vm,
|
||||
// uint64_t addr);
|
||||
// void amdgpu_vm_bo_trace_cs(struct amdgpu_vm *vm, struct ww_acquire_ctx *ticket);
|
||||
// void amdgpu_vm_bo_del(struct amdgpu_device *adev,
|
||||
// struct amdgpu_bo_va *bo_va);
|
||||
// void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint32_t min_vm_size,
|
||||
// uint32_t fragment_size_default, unsigned max_level,
|
||||
// unsigned max_bits);
|
||||
// int amdgpu_vm_ioctl(struct drm_device *dev, void *data, struct drm_file *filp);
|
||||
// bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,
|
||||
// struct amdgpu_job *job);
|
||||
// void amdgpu_vm_check_compute_bug(struct amdgpu_device *adev);
|
||||
|
||||
// struct amdgpu_task_info *
|
||||
// amdgpu_vm_get_task_info_pasid(struct amdgpu_device *adev, u32 pasid);
|
||||
|
||||
// struct amdgpu_task_info *
|
||||
// amdgpu_vm_get_task_info_vm(struct amdgpu_vm *vm);
|
||||
|
||||
// void amdgpu_vm_put_task_info(struct amdgpu_task_info *task_info);
|
||||
|
||||
// bool amdgpu_vm_handle_fault(struct amdgpu_device *adev, u32 pasid,
|
||||
// u32 vmid, u32 node_id, uint64_t addr,
|
||||
// bool write_fault);
|
||||
|
||||
// void amdgpu_vm_set_task_info(struct amdgpu_vm *vm);
|
||||
|
||||
// void amdgpu_vm_move_to_lru_tail(struct amdgpu_device *adev,
|
||||
// struct amdgpu_vm *vm);
|
||||
// void amdgpu_vm_get_memory(struct amdgpu_vm *vm,
|
||||
// struct amdgpu_mem_stats *stats);
|
||||
|
||||
// int amdgpu_vm_pt_clear(struct amdgpu_device *adev, struct amdgpu_vm *vm,
|
||||
// struct amdgpu_bo_vm *vmbo, bool immediate);
|
||||
// int amdgpu_vm_pt_create(struct amdgpu_device *adev, struct amdgpu_vm *vm,
|
||||
// int level, bool immediate, struct amdgpu_bo_vm **vmbo,
|
||||
// int32_t xcp_id);
|
||||
// void amdgpu_vm_pt_free_root(struct amdgpu_device *adev, struct amdgpu_vm *vm);
|
||||
|
||||
// int amdgpu_vm_pde_update(struct amdgpu_vm_update_params *params,
|
||||
// struct amdgpu_vm_bo_base *entry);
|
||||
// int amdgpu_vm_ptes_update(struct amdgpu_vm_update_params *params,
|
||||
// uint64_t start, uint64_t end,
|
||||
// uint64_t dst, uint64_t flags);
|
||||
// void amdgpu_vm_pt_free_work(struct work_struct *work);
|
||||
// void amdgpu_vm_pt_free_list(struct amdgpu_device *adev,
|
||||
// struct amdgpu_vm_update_params *params);
|
||||
|
||||
// #if defined(CONFIG_DEBUG_FS)
|
||||
// void amdgpu_debugfs_vm_bo_info(struct amdgpu_vm *vm, struct seq_file *m);
|
||||
// #endif
|
||||
|
||||
// int amdgpu_vm_pt_map_tables(struct amdgpu_device *adev, struct amdgpu_vm *vm);
|
||||
|
||||
// bool amdgpu_vm_is_bo_always_valid(struct amdgpu_vm *vm, struct amdgpu_bo *bo);
|
||||
|
||||
// /**
|
||||
// * amdgpu_vm_tlb_seq - return tlb flush sequence number
|
||||
// * @vm: the amdgpu_vm structure to query
|
||||
// *
|
||||
// * Returns the tlb flush sequence number which indicates that the VM TLBs needs
|
||||
// * to be invalidated whenever the sequence number change.
|
||||
// */
|
||||
// static inline uint64_t amdgpu_vm_tlb_seq(struct amdgpu_vm *vm)
|
||||
// {
|
||||
// unsigned long flags;
|
||||
// spinlock_t *lock;
|
||||
|
||||
// /*
|
||||
// * Workaround to stop racing between the fence signaling and handling
|
||||
// * the cb. The lock is static after initially setting it up, just make
|
||||
// * sure that the dma_fence structure isn't freed up.
|
||||
// */
|
||||
// rcu_read_lock();
|
||||
// lock = vm->last_tlb_flush->lock;
|
||||
// rcu_read_unlock();
|
||||
|
||||
// spin_lock_irqsave(lock, flags);
|
||||
// spin_unlock_irqrestore(lock, flags);
|
||||
|
||||
// return atomic64_read(&vm->tlb_seq);
|
||||
// }
|
||||
|
||||
// /*
|
||||
// * vm eviction_lock can be taken in MMU notifiers. Make sure no reclaim-FS
|
||||
// * happens while holding this lock anywhere to prevent deadlocks when
|
||||
// * an MMU notifier runs in reclaim-FS context.
|
||||
// */
|
||||
// static inline void amdgpu_vm_eviction_lock(struct amdgpu_vm *vm)
|
||||
// {
|
||||
// mutex_lock(&vm->eviction_lock);
|
||||
// vm->saved_flags = memalloc_noreclaim_save();
|
||||
// }
|
||||
|
||||
// static inline bool amdgpu_vm_eviction_trylock(struct amdgpu_vm *vm)
|
||||
// {
|
||||
// if (mutex_trylock(&vm->eviction_lock)) {
|
||||
// vm->saved_flags = memalloc_noreclaim_save();
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// static inline void amdgpu_vm_eviction_unlock(struct amdgpu_vm *vm)
|
||||
// {
|
||||
// memalloc_noreclaim_restore(vm->saved_flags);
|
||||
// mutex_unlock(&vm->eviction_lock);
|
||||
// }
|
||||
|
||||
// void amdgpu_vm_update_fault_cache(struct amdgpu_device *adev,
|
||||
// unsigned int pasid,
|
||||
// uint64_t addr,
|
||||
// uint32_t status,
|
||||
// unsigned int vmhub);
|
||||
// void amdgpu_vm_tlb_fence_create(struct amdgpu_device *adev,
|
||||
// struct amdgpu_vm *vm,
|
||||
// struct dma_fence **fence);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,567 @@
|
||||
/*
|
||||
* Copyright 2018 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _DISCOVERY_H_
|
||||
#define _DISCOVERY_H_
|
||||
|
||||
#define uint32_t unsigned int
|
||||
#define uint8_t unsigned char
|
||||
#define uint16_t unsigned short
|
||||
#define uint64_t unsigned long long
|
||||
#define u32 unsigned int
|
||||
#define u8 unsigned char
|
||||
#define u16 unsigned short
|
||||
#define u64 unsigned long long
|
||||
#define bool unsigned char
|
||||
|
||||
#define PSP_HEADER_SIZE 256
|
||||
#define BINARY_SIGNATURE 0x28211407
|
||||
#define DISCOVERY_TABLE_SIGNATURE 0x53445049
|
||||
#define GC_TABLE_ID 0x4347
|
||||
#define HARVEST_TABLE_SIGNATURE 0x56524148
|
||||
#define VCN_INFO_TABLE_ID 0x004E4356
|
||||
#define MALL_INFO_TABLE_ID 0x4C4C414D
|
||||
#define NPS_INFO_TABLE_ID 0x0053504E
|
||||
|
||||
typedef enum {
|
||||
IP_DISCOVERY = 0,
|
||||
GC,
|
||||
HARVEST_INFO,
|
||||
VCN_INFO,
|
||||
MALL_INFO,
|
||||
NPS_INFO,
|
||||
TOTAL_TABLES = 6
|
||||
} table;
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
typedef struct table_info
|
||||
{
|
||||
uint16_t offset; /* Byte offset */
|
||||
uint16_t checksum; /* Byte sum of the table */
|
||||
uint16_t size; /* Table size */
|
||||
uint16_t padding;
|
||||
} table_info;
|
||||
|
||||
typedef struct binary_header
|
||||
{
|
||||
/* psp structure should go at the top of this structure */
|
||||
uint32_t binary_signature; /* 0x7, 0x14, 0x21, 0x28 */
|
||||
uint16_t version_major;
|
||||
uint16_t version_minor;
|
||||
uint16_t binary_checksum; /* Byte sum of the binary after this field */
|
||||
uint16_t binary_size; /* Binary Size*/
|
||||
table_info table_list[TOTAL_TABLES];
|
||||
} binary_header;
|
||||
|
||||
typedef struct die_info
|
||||
{
|
||||
uint16_t die_id;
|
||||
uint16_t die_offset; /* Points to the corresponding die_header structure */
|
||||
} die_info;
|
||||
|
||||
|
||||
typedef struct ip_discovery_header
|
||||
{
|
||||
uint32_t signature; /* Table Signature */
|
||||
uint16_t version; /* Table Version */
|
||||
uint16_t size; /* Table Size */
|
||||
uint32_t id; /* Table ID */
|
||||
uint16_t num_dies; /* Number of Dies */
|
||||
die_info die_info[16]; /* list die information for up to 16 dies */
|
||||
union {
|
||||
uint16_t padding[1]; /* version <= 3 */
|
||||
struct { /* version == 4 */
|
||||
uint8_t base_addr_64_bit : 1; /* ip structures are using 64 bit base address */
|
||||
uint8_t reserved : 7;
|
||||
uint8_t reserved2;
|
||||
};
|
||||
};
|
||||
} ip_discovery_header;
|
||||
|
||||
typedef struct ip
|
||||
{
|
||||
uint16_t hw_id; /* Hardware ID */
|
||||
uint8_t number_instance; /* instance of the IP */
|
||||
uint8_t num_base_address; /* Number of Base Addresses */
|
||||
uint8_t major; /* HCID Major */
|
||||
uint8_t minor; /* HCID Minor */
|
||||
uint8_t revision; /* HCID Revision */
|
||||
#if defined(__BIG_ENDIAN)
|
||||
uint8_t reserved : 4; /* Placeholder field */
|
||||
uint8_t harvest : 4; /* Harvest */
|
||||
#else
|
||||
uint8_t harvest : 4; /* Harvest */
|
||||
uint8_t reserved : 4; /* Placeholder field */
|
||||
#endif
|
||||
uint32_t base_address[1]; /* variable number of Addresses */
|
||||
} ip;
|
||||
|
||||
typedef struct ip_v3
|
||||
{
|
||||
uint16_t hw_id; /* Hardware ID */
|
||||
uint8_t instance_number; /* Instance number for the IP */
|
||||
uint8_t num_base_address; /* Number of base addresses*/
|
||||
uint8_t major; /* Hardware ID.major version */
|
||||
uint8_t minor; /* Hardware ID.minor version */
|
||||
uint8_t revision; /* Hardware ID.revision version */
|
||||
#if defined(__BIG_ENDIAN)
|
||||
uint8_t variant : 4; /* HW variant */
|
||||
uint8_t sub_revision : 4; /* HCID Sub-Revision */
|
||||
#else
|
||||
uint8_t sub_revision : 4; /* HCID Sub-Revision */
|
||||
uint8_t variant : 4; /* HW variant */
|
||||
#endif
|
||||
uint32_t base_address[1]; /* Base Address list. Corresponds to the num_base_address field*/
|
||||
} ip_v3;
|
||||
|
||||
typedef struct ip_v4 {
|
||||
uint16_t hw_id; /* Hardware ID */
|
||||
uint8_t instance_number; /* Instance number for the IP */
|
||||
uint8_t num_base_address; /* Number of base addresses*/
|
||||
uint8_t major; /* Hardware ID.major version */
|
||||
uint8_t minor; /* Hardware ID.minor version */
|
||||
uint8_t revision; /* Hardware ID.revision version */
|
||||
#if defined(LITTLEENDIAN_CPU)
|
||||
uint8_t sub_revision : 4; /* HCID Sub-Revision */
|
||||
uint8_t variant : 4; /* HW variant */
|
||||
#elif defined(BIGENDIAN_CPU)
|
||||
uint8_t variant : 4; /* HW variant */
|
||||
uint8_t sub_revision : 4; /* HCID Sub-Revision */
|
||||
#endif
|
||||
uint64_t base_address_64[1];
|
||||
} ip_v4;
|
||||
|
||||
typedef struct die_header
|
||||
{
|
||||
uint16_t die_id;
|
||||
uint16_t num_ips;
|
||||
} die_header;
|
||||
|
||||
typedef struct ip_structure
|
||||
{
|
||||
ip_discovery_header* header;
|
||||
struct die
|
||||
{
|
||||
die_header *die_header;
|
||||
union
|
||||
{
|
||||
ip *ip_list;
|
||||
ip_v3 *ip_v3_list;
|
||||
ip_v4 *ip_v4_list;
|
||||
}; /* IP list. Variable size*/
|
||||
} die;
|
||||
} ip_structure;
|
||||
|
||||
struct gpu_info_header {
|
||||
uint32_t table_id; /* table ID */
|
||||
uint16_t version_major; /* table version */
|
||||
uint16_t version_minor; /* table version */
|
||||
uint32_t size; /* size of the entire header+data in bytes */
|
||||
};
|
||||
|
||||
struct gc_info_v1_0 {
|
||||
struct gpu_info_header header;
|
||||
|
||||
uint32_t gc_num_se;
|
||||
uint32_t gc_num_wgp0_per_sa;
|
||||
uint32_t gc_num_wgp1_per_sa;
|
||||
uint32_t gc_num_rb_per_se;
|
||||
uint32_t gc_num_gl2c;
|
||||
uint32_t gc_num_gprs;
|
||||
uint32_t gc_num_max_gs_thds;
|
||||
uint32_t gc_gs_table_depth;
|
||||
uint32_t gc_gsprim_buff_depth;
|
||||
uint32_t gc_parameter_cache_depth;
|
||||
uint32_t gc_double_offchip_lds_buffer;
|
||||
uint32_t gc_wave_size;
|
||||
uint32_t gc_max_waves_per_simd;
|
||||
uint32_t gc_max_scratch_slots_per_cu;
|
||||
uint32_t gc_lds_size;
|
||||
uint32_t gc_num_sc_per_se;
|
||||
uint32_t gc_num_sa_per_se;
|
||||
uint32_t gc_num_packer_per_sc;
|
||||
uint32_t gc_num_gl2a;
|
||||
};
|
||||
|
||||
struct gc_info_v1_1 {
|
||||
struct gpu_info_header header;
|
||||
|
||||
uint32_t gc_num_se;
|
||||
uint32_t gc_num_wgp0_per_sa;
|
||||
uint32_t gc_num_wgp1_per_sa;
|
||||
uint32_t gc_num_rb_per_se;
|
||||
uint32_t gc_num_gl2c;
|
||||
uint32_t gc_num_gprs;
|
||||
uint32_t gc_num_max_gs_thds;
|
||||
uint32_t gc_gs_table_depth;
|
||||
uint32_t gc_gsprim_buff_depth;
|
||||
uint32_t gc_parameter_cache_depth;
|
||||
uint32_t gc_double_offchip_lds_buffer;
|
||||
uint32_t gc_wave_size;
|
||||
uint32_t gc_max_waves_per_simd;
|
||||
uint32_t gc_max_scratch_slots_per_cu;
|
||||
uint32_t gc_lds_size;
|
||||
uint32_t gc_num_sc_per_se;
|
||||
uint32_t gc_num_sa_per_se;
|
||||
uint32_t gc_num_packer_per_sc;
|
||||
uint32_t gc_num_gl2a;
|
||||
uint32_t gc_num_tcp_per_sa;
|
||||
uint32_t gc_num_sdp_interface;
|
||||
uint32_t gc_num_tcps;
|
||||
};
|
||||
|
||||
struct gc_info_v1_2 {
|
||||
struct gpu_info_header header;
|
||||
uint32_t gc_num_se;
|
||||
uint32_t gc_num_wgp0_per_sa;
|
||||
uint32_t gc_num_wgp1_per_sa;
|
||||
uint32_t gc_num_rb_per_se;
|
||||
uint32_t gc_num_gl2c;
|
||||
uint32_t gc_num_gprs;
|
||||
uint32_t gc_num_max_gs_thds;
|
||||
uint32_t gc_gs_table_depth;
|
||||
uint32_t gc_gsprim_buff_depth;
|
||||
uint32_t gc_parameter_cache_depth;
|
||||
uint32_t gc_double_offchip_lds_buffer;
|
||||
uint32_t gc_wave_size;
|
||||
uint32_t gc_max_waves_per_simd;
|
||||
uint32_t gc_max_scratch_slots_per_cu;
|
||||
uint32_t gc_lds_size;
|
||||
uint32_t gc_num_sc_per_se;
|
||||
uint32_t gc_num_sa_per_se;
|
||||
uint32_t gc_num_packer_per_sc;
|
||||
uint32_t gc_num_gl2a;
|
||||
uint32_t gc_num_tcp_per_sa;
|
||||
uint32_t gc_num_sdp_interface;
|
||||
uint32_t gc_num_tcps;
|
||||
uint32_t gc_num_tcp_per_wpg;
|
||||
uint32_t gc_tcp_l1_size;
|
||||
uint32_t gc_num_sqc_per_wgp;
|
||||
uint32_t gc_l1_instruction_cache_size_per_sqc;
|
||||
uint32_t gc_l1_data_cache_size_per_sqc;
|
||||
uint32_t gc_gl1c_per_sa;
|
||||
uint32_t gc_gl1c_size_per_instance;
|
||||
uint32_t gc_gl2c_per_gpu;
|
||||
};
|
||||
|
||||
struct gc_info_v2_0 {
|
||||
struct gpu_info_header header;
|
||||
|
||||
uint32_t gc_num_se;
|
||||
uint32_t gc_num_cu_per_sh;
|
||||
uint32_t gc_num_sh_per_se;
|
||||
uint32_t gc_num_rb_per_se;
|
||||
uint32_t gc_num_tccs;
|
||||
uint32_t gc_num_gprs;
|
||||
uint32_t gc_num_max_gs_thds;
|
||||
uint32_t gc_gs_table_depth;
|
||||
uint32_t gc_gsprim_buff_depth;
|
||||
uint32_t gc_parameter_cache_depth;
|
||||
uint32_t gc_double_offchip_lds_buffer;
|
||||
uint32_t gc_wave_size;
|
||||
uint32_t gc_max_waves_per_simd;
|
||||
uint32_t gc_max_scratch_slots_per_cu;
|
||||
uint32_t gc_lds_size;
|
||||
uint32_t gc_num_sc_per_se;
|
||||
uint32_t gc_num_packer_per_sc;
|
||||
};
|
||||
|
||||
struct gc_info_v2_1 {
|
||||
struct gpu_info_header header;
|
||||
|
||||
uint32_t gc_num_se;
|
||||
uint32_t gc_num_cu_per_sh;
|
||||
uint32_t gc_num_sh_per_se;
|
||||
uint32_t gc_num_rb_per_se;
|
||||
uint32_t gc_num_tccs;
|
||||
uint32_t gc_num_gprs;
|
||||
uint32_t gc_num_max_gs_thds;
|
||||
uint32_t gc_gs_table_depth;
|
||||
uint32_t gc_gsprim_buff_depth;
|
||||
uint32_t gc_parameter_cache_depth;
|
||||
uint32_t gc_double_offchip_lds_buffer;
|
||||
uint32_t gc_wave_size;
|
||||
uint32_t gc_max_waves_per_simd;
|
||||
uint32_t gc_max_scratch_slots_per_cu;
|
||||
uint32_t gc_lds_size;
|
||||
uint32_t gc_num_sc_per_se;
|
||||
uint32_t gc_num_packer_per_sc;
|
||||
/* new for v2_1 */
|
||||
uint32_t gc_num_tcp_per_sh;
|
||||
uint32_t gc_tcp_size_per_cu;
|
||||
uint32_t gc_num_sdp_interface;
|
||||
uint32_t gc_num_cu_per_sqc;
|
||||
uint32_t gc_instruction_cache_size_per_sqc;
|
||||
uint32_t gc_scalar_data_cache_size_per_sqc;
|
||||
uint32_t gc_tcc_size;
|
||||
};
|
||||
|
||||
typedef struct harvest_info_header {
|
||||
uint32_t signature; /* Table Signature */
|
||||
uint32_t version; /* Table Version */
|
||||
} harvest_info_header;
|
||||
|
||||
typedef struct harvest_info {
|
||||
uint16_t hw_id; /* Hardware ID */
|
||||
uint8_t number_instance; /* Instance of the IP */
|
||||
uint8_t reserved; /* Reserved for alignment */
|
||||
} harvest_info;
|
||||
|
||||
typedef struct harvest_table {
|
||||
harvest_info_header header;
|
||||
harvest_info list[32];
|
||||
} harvest_table;
|
||||
|
||||
struct mall_info_header {
|
||||
uint32_t table_id; /* table ID */
|
||||
uint16_t version_major; /* table version */
|
||||
uint16_t version_minor; /* table version */
|
||||
uint32_t size_bytes; /* size of the entire header+data in bytes */
|
||||
};
|
||||
|
||||
struct mall_info_v1_0 {
|
||||
struct mall_info_header header;
|
||||
uint32_t mall_size_per_m;
|
||||
uint32_t m_s_present;
|
||||
uint32_t m_half_use;
|
||||
uint32_t m_mall_config;
|
||||
uint32_t reserved[5];
|
||||
};
|
||||
|
||||
struct mall_info_v2_0 {
|
||||
struct mall_info_header header;
|
||||
uint32_t mall_size_per_umc;
|
||||
uint32_t reserved[8];
|
||||
};
|
||||
|
||||
#define VCN_INFO_TABLE_MAX_NUM_INSTANCES 4
|
||||
|
||||
struct vcn_info_header {
|
||||
uint32_t table_id; /* table ID */
|
||||
uint16_t version_major; /* table version */
|
||||
uint16_t version_minor; /* table version */
|
||||
uint32_t size_bytes; /* size of the entire header+data in bytes */
|
||||
};
|
||||
|
||||
struct vcn_instance_info_v1_0
|
||||
{
|
||||
uint32_t instance_num; /* VCN IP instance number. 0 - VCN0; 1 - VCN1 etc*/
|
||||
union _fuse_data {
|
||||
struct {
|
||||
uint32_t av1_disabled : 1;
|
||||
uint32_t vp9_disabled : 1;
|
||||
uint32_t hevc_disabled : 1;
|
||||
uint32_t h264_disabled : 1;
|
||||
uint32_t reserved : 28;
|
||||
} bits;
|
||||
uint32_t all_bits;
|
||||
} fuse_data;
|
||||
uint32_t reserved[2];
|
||||
};
|
||||
|
||||
struct vcn_info_v1_0 {
|
||||
struct vcn_info_header header;
|
||||
uint32_t num_of_instances; /* number of entries used in instance_info below*/
|
||||
struct vcn_instance_info_v1_0 instance_info[VCN_INFO_TABLE_MAX_NUM_INSTANCES];
|
||||
uint32_t reserved[4];
|
||||
};
|
||||
|
||||
#define NPS_INFO_TABLE_MAX_NUM_INSTANCES 12
|
||||
|
||||
struct nps_info_header {
|
||||
uint32_t table_id; /* table ID */
|
||||
uint16_t version_major; /* table version */
|
||||
uint16_t version_minor; /* table version */
|
||||
uint32_t size_bytes; /* size of the entire header+data in bytes = 0x000000D4 (212) */
|
||||
};
|
||||
|
||||
struct nps_instance_info_v1_0 {
|
||||
uint64_t base_address;
|
||||
uint64_t limit_address;
|
||||
};
|
||||
|
||||
struct nps_info_v1_0 {
|
||||
struct nps_info_header header;
|
||||
uint32_t nps_type;
|
||||
uint32_t count;
|
||||
struct nps_instance_info_v1_0
|
||||
instance_info[NPS_INFO_TABLE_MAX_NUM_INSTANCES];
|
||||
};
|
||||
|
||||
enum amd_hw_ip_block_type {
|
||||
GC_HWIP = 1,
|
||||
HDP_HWIP,
|
||||
SDMA0_HWIP,
|
||||
SDMA1_HWIP,
|
||||
SDMA2_HWIP,
|
||||
SDMA3_HWIP,
|
||||
SDMA4_HWIP,
|
||||
SDMA5_HWIP,
|
||||
SDMA6_HWIP,
|
||||
SDMA7_HWIP,
|
||||
LSDMA_HWIP,
|
||||
MMHUB_HWIP,
|
||||
ATHUB_HWIP,
|
||||
NBIO_HWIP,
|
||||
MP0_HWIP,
|
||||
MP1_HWIP,
|
||||
UVD_HWIP,
|
||||
VCN_HWIP = UVD_HWIP,
|
||||
JPEG_HWIP = VCN_HWIP,
|
||||
VCN1_HWIP,
|
||||
VCE_HWIP,
|
||||
VPE_HWIP,
|
||||
DF_HWIP,
|
||||
DCE_HWIP,
|
||||
OSSSYS_HWIP,
|
||||
SMUIO_HWIP,
|
||||
PWR_HWIP,
|
||||
NBIF_HWIP,
|
||||
THM_HWIP,
|
||||
CLK_HWIP,
|
||||
UMC_HWIP,
|
||||
RSMU_HWIP,
|
||||
XGMI_HWIP,
|
||||
DCI_HWIP,
|
||||
PCIE_HWIP,
|
||||
ISP_HWIP,
|
||||
MAX_HWIP
|
||||
};
|
||||
|
||||
#define HWIP_MAX_INSTANCE 44
|
||||
|
||||
#define HW_ID_MAX 300
|
||||
|
||||
// HW ID
|
||||
#define MP1_HWID 1
|
||||
#define MP2_HWID 2
|
||||
#define THM_HWID 3
|
||||
#define SMUIO_HWID 4
|
||||
#define FUSE_HWID 5
|
||||
#define CLKA_HWID 6
|
||||
#define PWR_HWID 10
|
||||
#define GC_HWID 11
|
||||
#define UVD_HWID 12
|
||||
#define VCN_HWID UVD_HWID
|
||||
#define AUDIO_AZ_HWID 13
|
||||
#define ACP_HWID 14
|
||||
#define DCI_HWID 15
|
||||
#define DMU_HWID 271
|
||||
#define DCO_HWID 16
|
||||
#define DIO_HWID 272
|
||||
#define XDMA_HWID 17
|
||||
#define DCEAZ_HWID 18
|
||||
#define DAZ_HWID 274
|
||||
#define SDPMUX_HWID 19
|
||||
#define NTB_HWID 20
|
||||
#define VPE_HWID 21
|
||||
#define IOHC_HWID 24
|
||||
#define L2IMU_HWID 28
|
||||
#define VCE_HWID 32
|
||||
#define MMHUB_HWID 34
|
||||
#define ATHUB_HWID 35
|
||||
#define DBGU_NBIO_HWID 36
|
||||
#define DFX_HWID 37
|
||||
#define DBGU0_HWID 38
|
||||
#define DBGU1_HWID 39
|
||||
#define OSSSYS_HWID 40
|
||||
#define HDP_HWID 41
|
||||
#define SDMA0_HWID 42
|
||||
#define SDMA1_HWID 43
|
||||
#define ISP_HWID 44
|
||||
#define DBGU_IO_HWID 45
|
||||
#define DF_HWID 46
|
||||
#define CLKB_HWID 47
|
||||
#define FCH_HWID 48
|
||||
#define DFX_DAP_HWID 49
|
||||
#define L1IMU_PCIE_HWID 50
|
||||
#define L1IMU_NBIF_HWID 51
|
||||
#define L1IMU_IOAGR_HWID 52
|
||||
#define L1IMU3_HWID 53
|
||||
#define L1IMU4_HWID 54
|
||||
#define L1IMU5_HWID 55
|
||||
#define L1IMU6_HWID 56
|
||||
#define L1IMU7_HWID 57
|
||||
#define L1IMU8_HWID 58
|
||||
#define L1IMU9_HWID 59
|
||||
#define L1IMU10_HWID 60
|
||||
#define L1IMU11_HWID 61
|
||||
#define L1IMU12_HWID 62
|
||||
#define L1IMU13_HWID 63
|
||||
#define L1IMU14_HWID 64
|
||||
#define L1IMU15_HWID 65
|
||||
#define WAFLC_HWID 66
|
||||
#define FCH_USB_PD_HWID 67
|
||||
#define SDMA2_HWID 68
|
||||
#define SDMA3_HWID 69
|
||||
#define PCIE_HWID 70
|
||||
#define PCS_HWID 80
|
||||
#define DDCL_HWID 89
|
||||
#define SST_HWID 90
|
||||
#define LSDMA_HWID 91
|
||||
#define IOAGR_HWID 100
|
||||
#define NBIF_HWID 108
|
||||
#define IOAPIC_HWID 124
|
||||
#define SYSTEMHUB_HWID 128
|
||||
#define NTBCCP_HWID 144
|
||||
#define UMC_HWID 150
|
||||
#define SATA_HWID 168
|
||||
#define USB_HWID 170
|
||||
#define CCXSEC_HWID 176
|
||||
#define XGMI_HWID 200
|
||||
#define XGBE_HWID 216
|
||||
#define MP0_HWID 255
|
||||
|
||||
static int hw_id_map[MAX_HWIP] = {
|
||||
[GC_HWIP] = GC_HWID,
|
||||
[HDP_HWIP] = HDP_HWID,
|
||||
[SDMA0_HWIP] = SDMA0_HWID,
|
||||
[SDMA1_HWIP] = SDMA1_HWID,
|
||||
[SDMA2_HWIP] = SDMA2_HWID,
|
||||
[SDMA3_HWIP] = SDMA3_HWID,
|
||||
[LSDMA_HWIP] = LSDMA_HWID,
|
||||
[MMHUB_HWIP] = MMHUB_HWID,
|
||||
[ATHUB_HWIP] = ATHUB_HWID,
|
||||
[NBIO_HWIP] = NBIF_HWID,
|
||||
[MP0_HWIP] = MP0_HWID,
|
||||
[MP1_HWIP] = MP1_HWID,
|
||||
[UVD_HWIP] = UVD_HWID,
|
||||
[VCE_HWIP] = VCE_HWID,
|
||||
[DF_HWIP] = DF_HWID,
|
||||
[DCE_HWIP] = DMU_HWID,
|
||||
[OSSSYS_HWIP] = OSSSYS_HWID,
|
||||
[SMUIO_HWIP] = SMUIO_HWID,
|
||||
[PWR_HWIP] = PWR_HWID,
|
||||
[NBIF_HWIP] = NBIF_HWID,
|
||||
[THM_HWIP] = THM_HWID,
|
||||
[CLK_HWIP] = CLKA_HWID,
|
||||
[UMC_HWIP] = UMC_HWID,
|
||||
[XGMI_HWIP] = XGMI_HWID,
|
||||
[DCI_HWIP] = DCI_HWID,
|
||||
[PCIE_HWIP] = PCIE_HWID,
|
||||
[VPE_HWIP] = VPE_HWID,
|
||||
[ISP_HWIP] = ISP_HWID,
|
||||
};
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,365 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _mp_11_0_2_OFFSET_HEADER
|
||||
#define _mp_11_0_2_OFFSET_HEADER
|
||||
|
||||
|
||||
// addressBlock: mp_SmuMp0_SmnDec
|
||||
// base address: 0x0
|
||||
#define mmMP0_SMN_C2PMSG_32 0x0060
|
||||
#define mmMP0_SMN_C2PMSG_32_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_33 0x0061
|
||||
#define mmMP0_SMN_C2PMSG_33_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_34 0x0062
|
||||
#define mmMP0_SMN_C2PMSG_34_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_35 0x0063
|
||||
#define mmMP0_SMN_C2PMSG_35_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_36 0x0064
|
||||
#define mmMP0_SMN_C2PMSG_36_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_37 0x0065
|
||||
#define mmMP0_SMN_C2PMSG_37_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_38 0x0066
|
||||
#define mmMP0_SMN_C2PMSG_38_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_39 0x0067
|
||||
#define mmMP0_SMN_C2PMSG_39_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_40 0x0068
|
||||
#define mmMP0_SMN_C2PMSG_40_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_41 0x0069
|
||||
#define mmMP0_SMN_C2PMSG_41_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_42 0x006a
|
||||
#define mmMP0_SMN_C2PMSG_42_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_43 0x006b
|
||||
#define mmMP0_SMN_C2PMSG_43_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_44 0x006c
|
||||
#define mmMP0_SMN_C2PMSG_44_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_45 0x006d
|
||||
#define mmMP0_SMN_C2PMSG_45_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_46 0x006e
|
||||
#define mmMP0_SMN_C2PMSG_46_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_47 0x006f
|
||||
#define mmMP0_SMN_C2PMSG_47_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_48 0x0070
|
||||
#define mmMP0_SMN_C2PMSG_48_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_49 0x0071
|
||||
#define mmMP0_SMN_C2PMSG_49_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_50 0x0072
|
||||
#define mmMP0_SMN_C2PMSG_50_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_51 0x0073
|
||||
#define mmMP0_SMN_C2PMSG_51_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_52 0x0074
|
||||
#define mmMP0_SMN_C2PMSG_52_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_53 0x0075
|
||||
#define mmMP0_SMN_C2PMSG_53_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_54 0x0076
|
||||
#define mmMP0_SMN_C2PMSG_54_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_55 0x0077
|
||||
#define mmMP0_SMN_C2PMSG_55_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_56 0x0078
|
||||
#define mmMP0_SMN_C2PMSG_56_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_57 0x0079
|
||||
#define mmMP0_SMN_C2PMSG_57_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_58 0x007a
|
||||
#define mmMP0_SMN_C2PMSG_58_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_59 0x007b
|
||||
#define mmMP0_SMN_C2PMSG_59_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_60 0x007c
|
||||
#define mmMP0_SMN_C2PMSG_60_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_61 0x007d
|
||||
#define mmMP0_SMN_C2PMSG_61_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_62 0x007e
|
||||
#define mmMP0_SMN_C2PMSG_62_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_63 0x007f
|
||||
#define mmMP0_SMN_C2PMSG_63_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_64 0x0080
|
||||
#define mmMP0_SMN_C2PMSG_64_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_65 0x0081
|
||||
#define mmMP0_SMN_C2PMSG_65_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_66 0x0082
|
||||
#define mmMP0_SMN_C2PMSG_66_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_67 0x0083
|
||||
#define mmMP0_SMN_C2PMSG_67_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_68 0x0084
|
||||
#define mmMP0_SMN_C2PMSG_68_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_69 0x0085
|
||||
#define mmMP0_SMN_C2PMSG_69_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_70 0x0086
|
||||
#define mmMP0_SMN_C2PMSG_70_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_71 0x0087
|
||||
#define mmMP0_SMN_C2PMSG_71_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_72 0x0088
|
||||
#define mmMP0_SMN_C2PMSG_72_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_73 0x0089
|
||||
#define mmMP0_SMN_C2PMSG_73_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_74 0x008a
|
||||
#define mmMP0_SMN_C2PMSG_74_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_75 0x008b
|
||||
#define mmMP0_SMN_C2PMSG_75_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_76 0x008c
|
||||
#define mmMP0_SMN_C2PMSG_76_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_77 0x008d
|
||||
#define mmMP0_SMN_C2PMSG_77_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_78 0x008e
|
||||
#define mmMP0_SMN_C2PMSG_78_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_79 0x008f
|
||||
#define mmMP0_SMN_C2PMSG_79_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_80 0x0090
|
||||
#define mmMP0_SMN_C2PMSG_80_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_81 0x0091
|
||||
#define mmMP0_SMN_C2PMSG_81_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_82 0x0092
|
||||
#define mmMP0_SMN_C2PMSG_82_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_83 0x0093
|
||||
#define mmMP0_SMN_C2PMSG_83_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_84 0x0094
|
||||
#define mmMP0_SMN_C2PMSG_84_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_85 0x0095
|
||||
#define mmMP0_SMN_C2PMSG_85_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_86 0x0096
|
||||
#define mmMP0_SMN_C2PMSG_86_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_87 0x0097
|
||||
#define mmMP0_SMN_C2PMSG_87_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_88 0x0098
|
||||
#define mmMP0_SMN_C2PMSG_88_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_89 0x0099
|
||||
#define mmMP0_SMN_C2PMSG_89_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_90 0x009a
|
||||
#define mmMP0_SMN_C2PMSG_90_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_91 0x009b
|
||||
#define mmMP0_SMN_C2PMSG_91_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_92 0x009c
|
||||
#define mmMP0_SMN_C2PMSG_92_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_93 0x009d
|
||||
#define mmMP0_SMN_C2PMSG_93_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_94 0x009e
|
||||
#define mmMP0_SMN_C2PMSG_94_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_95 0x009f
|
||||
#define mmMP0_SMN_C2PMSG_95_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_96 0x00a0
|
||||
#define mmMP0_SMN_C2PMSG_96_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_97 0x00a1
|
||||
#define mmMP0_SMN_C2PMSG_97_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_98 0x00a2
|
||||
#define mmMP0_SMN_C2PMSG_98_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_99 0x00a3
|
||||
#define mmMP0_SMN_C2PMSG_99_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_100 0x00a4
|
||||
#define mmMP0_SMN_C2PMSG_100_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_101 0x00a5
|
||||
#define mmMP0_SMN_C2PMSG_101_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_102 0x00a6
|
||||
#define mmMP0_SMN_C2PMSG_102_BASE_IDX 0
|
||||
#define mmMP0_SMN_C2PMSG_103 0x00a7
|
||||
#define mmMP0_SMN_C2PMSG_103_BASE_IDX 0
|
||||
#define mmMP0_SMN_ACTIVE_FCN_ID 0x00c0
|
||||
#define mmMP0_SMN_ACTIVE_FCN_ID_BASE_IDX 0
|
||||
#define mmMP0_SMN_IH_CREDIT 0x00c1
|
||||
#define mmMP0_SMN_IH_CREDIT_BASE_IDX 0
|
||||
#define mmMP0_SMN_IH_SW_INT 0x00c2
|
||||
#define mmMP0_SMN_IH_SW_INT_BASE_IDX 0
|
||||
#define mmMP0_SMN_IH_SW_INT_CTRL 0x00c3
|
||||
#define mmMP0_SMN_IH_SW_INT_CTRL_BASE_IDX 0
|
||||
|
||||
|
||||
// addressBlock: mp_SmuMp1_SmnDec
|
||||
// base address: 0x0
|
||||
#define mmMP1_SMN_C2PMSG_32 0x0260
|
||||
#define mmMP1_SMN_C2PMSG_32_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_33 0x0261
|
||||
#define mmMP1_SMN_C2PMSG_33_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_34 0x0262
|
||||
#define mmMP1_SMN_C2PMSG_34_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_35 0x0263
|
||||
#define mmMP1_SMN_C2PMSG_35_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_36 0x0264
|
||||
#define mmMP1_SMN_C2PMSG_36_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_37 0x0265
|
||||
#define mmMP1_SMN_C2PMSG_37_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_38 0x0266
|
||||
#define mmMP1_SMN_C2PMSG_38_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_39 0x0267
|
||||
#define mmMP1_SMN_C2PMSG_39_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_40 0x0268
|
||||
#define mmMP1_SMN_C2PMSG_40_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_41 0x0269
|
||||
#define mmMP1_SMN_C2PMSG_41_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_42 0x026a
|
||||
#define mmMP1_SMN_C2PMSG_42_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_43 0x026b
|
||||
#define mmMP1_SMN_C2PMSG_43_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_44 0x026c
|
||||
#define mmMP1_SMN_C2PMSG_44_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_45 0x026d
|
||||
#define mmMP1_SMN_C2PMSG_45_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_46 0x026e
|
||||
#define mmMP1_SMN_C2PMSG_46_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_47 0x026f
|
||||
#define mmMP1_SMN_C2PMSG_47_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_48 0x0270
|
||||
#define mmMP1_SMN_C2PMSG_48_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_49 0x0271
|
||||
#define mmMP1_SMN_C2PMSG_49_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_50 0x0272
|
||||
#define mmMP1_SMN_C2PMSG_50_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_51 0x0273
|
||||
#define mmMP1_SMN_C2PMSG_51_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_52 0x0274
|
||||
#define mmMP1_SMN_C2PMSG_52_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_53 0x0275
|
||||
#define mmMP1_SMN_C2PMSG_53_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_54 0x0276
|
||||
#define mmMP1_SMN_C2PMSG_54_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_55 0x0277
|
||||
#define mmMP1_SMN_C2PMSG_55_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_56 0x0278
|
||||
#define mmMP1_SMN_C2PMSG_56_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_57 0x0279
|
||||
#define mmMP1_SMN_C2PMSG_57_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_58 0x027a
|
||||
#define mmMP1_SMN_C2PMSG_58_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_59 0x027b
|
||||
#define mmMP1_SMN_C2PMSG_59_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_60 0x027c
|
||||
#define mmMP1_SMN_C2PMSG_60_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_61 0x027d
|
||||
#define mmMP1_SMN_C2PMSG_61_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_62 0x027e
|
||||
#define mmMP1_SMN_C2PMSG_62_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_63 0x027f
|
||||
#define mmMP1_SMN_C2PMSG_63_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_64 0x0280
|
||||
#define mmMP1_SMN_C2PMSG_64_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_65 0x0281
|
||||
#define mmMP1_SMN_C2PMSG_65_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_66 0x0282
|
||||
#define mmMP1_SMN_C2PMSG_66_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_67 0x0283
|
||||
#define mmMP1_SMN_C2PMSG_67_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_68 0x0284
|
||||
#define mmMP1_SMN_C2PMSG_68_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_69 0x0285
|
||||
#define mmMP1_SMN_C2PMSG_69_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_70 0x0286
|
||||
#define mmMP1_SMN_C2PMSG_70_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_71 0x0287
|
||||
#define mmMP1_SMN_C2PMSG_71_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_72 0x0288
|
||||
#define mmMP1_SMN_C2PMSG_72_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_73 0x0289
|
||||
#define mmMP1_SMN_C2PMSG_73_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_74 0x028a
|
||||
#define mmMP1_SMN_C2PMSG_74_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_75 0x028b
|
||||
#define mmMP1_SMN_C2PMSG_75_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_76 0x028c
|
||||
#define mmMP1_SMN_C2PMSG_76_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_77 0x028d
|
||||
#define mmMP1_SMN_C2PMSG_77_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_78 0x028e
|
||||
#define mmMP1_SMN_C2PMSG_78_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_79 0x028f
|
||||
#define mmMP1_SMN_C2PMSG_79_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_80 0x0290
|
||||
#define mmMP1_SMN_C2PMSG_80_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_81 0x0291
|
||||
#define mmMP1_SMN_C2PMSG_81_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_82 0x0292
|
||||
#define mmMP1_SMN_C2PMSG_82_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_83 0x0293
|
||||
#define mmMP1_SMN_C2PMSG_83_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_84 0x0294
|
||||
#define mmMP1_SMN_C2PMSG_84_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_85 0x0295
|
||||
#define mmMP1_SMN_C2PMSG_85_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_86 0x0296
|
||||
#define mmMP1_SMN_C2PMSG_86_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_87 0x0297
|
||||
#define mmMP1_SMN_C2PMSG_87_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_88 0x0298
|
||||
#define mmMP1_SMN_C2PMSG_88_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_89 0x0299
|
||||
#define mmMP1_SMN_C2PMSG_89_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_90 0x029a
|
||||
#define mmMP1_SMN_C2PMSG_90_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_91 0x029b
|
||||
#define mmMP1_SMN_C2PMSG_91_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_92 0x029c
|
||||
#define mmMP1_SMN_C2PMSG_92_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_93 0x029d
|
||||
#define mmMP1_SMN_C2PMSG_93_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_94 0x029e
|
||||
#define mmMP1_SMN_C2PMSG_94_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_95 0x029f
|
||||
#define mmMP1_SMN_C2PMSG_95_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_96 0x02a0
|
||||
#define mmMP1_SMN_C2PMSG_96_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_97 0x02a1
|
||||
#define mmMP1_SMN_C2PMSG_97_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_98 0x02a2
|
||||
#define mmMP1_SMN_C2PMSG_98_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_99 0x02a3
|
||||
#define mmMP1_SMN_C2PMSG_99_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_100 0x02a4
|
||||
#define mmMP1_SMN_C2PMSG_100_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_101 0x02a5
|
||||
#define mmMP1_SMN_C2PMSG_101_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_102 0x02a6
|
||||
#define mmMP1_SMN_C2PMSG_102_BASE_IDX 0
|
||||
#define mmMP1_SMN_C2PMSG_103 0x02a7
|
||||
#define mmMP1_SMN_C2PMSG_103_BASE_IDX 0
|
||||
#define mmMP1_SMN_ACTIVE_FCN_ID 0x02c0
|
||||
#define mmMP1_SMN_ACTIVE_FCN_ID_BASE_IDX 0
|
||||
#define mmMP1_SMN_IH_CREDIT 0x02c1
|
||||
#define mmMP1_SMN_IH_CREDIT_BASE_IDX 0
|
||||
#define mmMP1_SMN_IH_SW_INT 0x02c2
|
||||
#define mmMP1_SMN_IH_SW_INT_BASE_IDX 0
|
||||
#define mmMP1_SMN_IH_SW_INT_CTRL 0x02c3
|
||||
#define mmMP1_SMN_IH_SW_INT_CTRL_BASE_IDX 0
|
||||
#define mmMP1_SMN_FPS_CNT 0x02c4
|
||||
#define mmMP1_SMN_FPS_CNT_BASE_IDX 0
|
||||
#define mmMP1_SMN_PUB_CTRL 0x02c5
|
||||
#define mmMP1_SMN_PUB_CTRL_BASE_IDX 0
|
||||
#define mmMP1_SMN_EXT_SCRATCH0 0x03c0
|
||||
#define mmMP1_SMN_EXT_SCRATCH0_BASE_IDX 0
|
||||
#define mmMP1_SMN_EXT_SCRATCH1 0x03c1
|
||||
#define mmMP1_SMN_EXT_SCRATCH1_BASE_IDX 0
|
||||
#define mmMP1_SMN_EXT_SCRATCH2 0x03c2
|
||||
#define mmMP1_SMN_EXT_SCRATCH2_BASE_IDX 0
|
||||
#define mmMP1_SMN_EXT_SCRATCH3 0x03c3
|
||||
#define mmMP1_SMN_EXT_SCRATCH3_BASE_IDX 0
|
||||
#define mmMP1_SMN_EXT_SCRATCH4 0x03c4
|
||||
#define mmMP1_SMN_EXT_SCRATCH4_BASE_IDX 0
|
||||
#define mmMP1_SMN_EXT_SCRATCH5 0x03c5
|
||||
#define mmMP1_SMN_EXT_SCRATCH5_BASE_IDX 0
|
||||
#define mmMP1_SMN_EXT_SCRATCH6 0x03c6
|
||||
#define mmMP1_SMN_EXT_SCRATCH6_BASE_IDX 0
|
||||
#define mmMP1_SMN_EXT_SCRATCH7 0x03c7
|
||||
#define mmMP1_SMN_EXT_SCRATCH7_BASE_IDX 0
|
||||
|
||||
/*
|
||||
* addressBlock: mp_SmuMp1Pub_MmuDec
|
||||
* base address: 0x0
|
||||
*/
|
||||
#define smnMP1_PMI_3_START 0x3030204
|
||||
#define smnMP1_PMI_3_FIFO 0x3030208
|
||||
#define smnMP1_PMI_3 0x3030600
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,975 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _mp_11_0_2_SH_MASK_HEADER
|
||||
#define _mp_11_0_2_SH_MASK_HEADER
|
||||
|
||||
|
||||
// addressBlock: mp_SmuMp0_SmnDec
|
||||
//MP0_SMN_C2PMSG_32
|
||||
#define MP0_SMN_C2PMSG_32__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_32__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_33
|
||||
#define MP0_SMN_C2PMSG_33__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_33__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_34
|
||||
#define MP0_SMN_C2PMSG_34__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_34__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_35
|
||||
#define MP0_SMN_C2PMSG_35__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_35__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_36
|
||||
#define MP0_SMN_C2PMSG_36__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_36__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_37
|
||||
#define MP0_SMN_C2PMSG_37__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_37__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_38
|
||||
#define MP0_SMN_C2PMSG_38__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_38__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_39
|
||||
#define MP0_SMN_C2PMSG_39__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_39__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_40
|
||||
#define MP0_SMN_C2PMSG_40__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_40__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_41
|
||||
#define MP0_SMN_C2PMSG_41__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_41__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_42
|
||||
#define MP0_SMN_C2PMSG_42__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_42__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_43
|
||||
#define MP0_SMN_C2PMSG_43__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_43__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_44
|
||||
#define MP0_SMN_C2PMSG_44__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_44__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_45
|
||||
#define MP0_SMN_C2PMSG_45__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_45__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_46
|
||||
#define MP0_SMN_C2PMSG_46__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_46__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_47
|
||||
#define MP0_SMN_C2PMSG_47__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_47__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_48
|
||||
#define MP0_SMN_C2PMSG_48__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_48__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_49
|
||||
#define MP0_SMN_C2PMSG_49__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_49__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_50
|
||||
#define MP0_SMN_C2PMSG_50__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_50__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_51
|
||||
#define MP0_SMN_C2PMSG_51__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_51__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_52
|
||||
#define MP0_SMN_C2PMSG_52__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_52__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_53
|
||||
#define MP0_SMN_C2PMSG_53__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_53__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_54
|
||||
#define MP0_SMN_C2PMSG_54__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_54__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_55
|
||||
#define MP0_SMN_C2PMSG_55__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_55__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_56
|
||||
#define MP0_SMN_C2PMSG_56__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_56__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_57
|
||||
#define MP0_SMN_C2PMSG_57__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_57__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_58
|
||||
#define MP0_SMN_C2PMSG_58__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_58__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_59
|
||||
#define MP0_SMN_C2PMSG_59__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_59__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_60
|
||||
#define MP0_SMN_C2PMSG_60__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_60__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_61
|
||||
#define MP0_SMN_C2PMSG_61__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_61__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_62
|
||||
#define MP0_SMN_C2PMSG_62__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_62__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_63
|
||||
#define MP0_SMN_C2PMSG_63__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_63__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_64
|
||||
#define MP0_SMN_C2PMSG_64__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_64__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_65
|
||||
#define MP0_SMN_C2PMSG_65__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_65__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_66
|
||||
#define MP0_SMN_C2PMSG_66__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_66__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_67
|
||||
#define MP0_SMN_C2PMSG_67__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_67__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_68
|
||||
#define MP0_SMN_C2PMSG_68__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_68__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_69
|
||||
#define MP0_SMN_C2PMSG_69__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_69__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_70
|
||||
#define MP0_SMN_C2PMSG_70__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_70__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_71
|
||||
#define MP0_SMN_C2PMSG_71__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_71__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_72
|
||||
#define MP0_SMN_C2PMSG_72__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_72__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_73
|
||||
#define MP0_SMN_C2PMSG_73__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_73__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_74
|
||||
#define MP0_SMN_C2PMSG_74__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_74__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_75
|
||||
#define MP0_SMN_C2PMSG_75__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_75__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_76
|
||||
#define MP0_SMN_C2PMSG_76__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_76__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_77
|
||||
#define MP0_SMN_C2PMSG_77__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_77__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_78
|
||||
#define MP0_SMN_C2PMSG_78__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_78__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_79
|
||||
#define MP0_SMN_C2PMSG_79__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_79__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_80
|
||||
#define MP0_SMN_C2PMSG_80__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_80__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_81
|
||||
#define MP0_SMN_C2PMSG_81__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_81__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_82
|
||||
#define MP0_SMN_C2PMSG_82__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_82__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_83
|
||||
#define MP0_SMN_C2PMSG_83__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_83__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_84
|
||||
#define MP0_SMN_C2PMSG_84__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_84__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_85
|
||||
#define MP0_SMN_C2PMSG_85__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_85__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_86
|
||||
#define MP0_SMN_C2PMSG_86__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_86__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_87
|
||||
#define MP0_SMN_C2PMSG_87__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_87__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_88
|
||||
#define MP0_SMN_C2PMSG_88__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_88__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_89
|
||||
#define MP0_SMN_C2PMSG_89__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_89__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_90
|
||||
#define MP0_SMN_C2PMSG_90__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_90__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_91
|
||||
#define MP0_SMN_C2PMSG_91__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_91__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_92
|
||||
#define MP0_SMN_C2PMSG_92__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_92__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_93
|
||||
#define MP0_SMN_C2PMSG_93__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_93__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_94
|
||||
#define MP0_SMN_C2PMSG_94__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_94__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_95
|
||||
#define MP0_SMN_C2PMSG_95__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_95__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_96
|
||||
#define MP0_SMN_C2PMSG_96__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_96__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_97
|
||||
#define MP0_SMN_C2PMSG_97__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_97__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_98
|
||||
#define MP0_SMN_C2PMSG_98__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_98__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_99
|
||||
#define MP0_SMN_C2PMSG_99__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_99__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_100
|
||||
#define MP0_SMN_C2PMSG_100__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_100__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_101
|
||||
#define MP0_SMN_C2PMSG_101__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_101__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_102
|
||||
#define MP0_SMN_C2PMSG_102__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_102__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_103
|
||||
#define MP0_SMN_C2PMSG_103__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_103__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_ACTIVE_FCN_ID
|
||||
#define MP0_SMN_ACTIVE_FCN_ID__VFID__SHIFT 0x0
|
||||
#define MP0_SMN_ACTIVE_FCN_ID__VF__SHIFT 0x1f
|
||||
#define MP0_SMN_ACTIVE_FCN_ID__VFID_MASK 0x0000001FL
|
||||
#define MP0_SMN_ACTIVE_FCN_ID__VF_MASK 0x80000000L
|
||||
//MP0_SMN_IH_CREDIT
|
||||
#define MP0_SMN_IH_CREDIT__CREDIT_VALUE__SHIFT 0x0
|
||||
#define MP0_SMN_IH_CREDIT__CLIENT_ID__SHIFT 0x10
|
||||
#define MP0_SMN_IH_CREDIT__CREDIT_VALUE_MASK 0x00000003L
|
||||
#define MP0_SMN_IH_CREDIT__CLIENT_ID_MASK 0x00FF0000L
|
||||
//MP0_SMN_IH_SW_INT
|
||||
#define MP0_SMN_IH_SW_INT__ID__SHIFT 0x0
|
||||
#define MP0_SMN_IH_SW_INT__VALID__SHIFT 0x8
|
||||
#define MP0_SMN_IH_SW_INT__ID_MASK 0x000000FFL
|
||||
#define MP0_SMN_IH_SW_INT__VALID_MASK 0x00000100L
|
||||
//MP0_SMN_IH_SW_INT_CTRL
|
||||
#define MP0_SMN_IH_SW_INT_CTRL__INT_MASK__SHIFT 0x0
|
||||
#define MP0_SMN_IH_SW_INT_CTRL__INT_ACK__SHIFT 0x8
|
||||
#define MP0_SMN_IH_SW_INT_CTRL__INT_MASK_MASK 0x00000001L
|
||||
#define MP0_SMN_IH_SW_INT_CTRL__INT_ACK_MASK 0x00000100L
|
||||
|
||||
|
||||
//MP1_FIRMWARE_FLAGS
|
||||
#define MP1_FIRMWARE_FLAGS__INTERRUPTS_ENABLED__SHIFT 0x0
|
||||
#define MP1_FIRMWARE_FLAGS__RESERVED__SHIFT 0x1
|
||||
#define MP1_FIRMWARE_FLAGS__INTERRUPTS_ENABLED_MASK 0x00000001L
|
||||
#define MP1_FIRMWARE_FLAGS__RESERVED_MASK 0xFFFFFFFEL
|
||||
//MP1_PUB_SCRATCH0
|
||||
#define MP1_PUB_SCRATCH0__DATA__SHIFT 0x0
|
||||
#define MP1_PUB_SCRATCH0__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_PUB_SCRATCH1
|
||||
#define MP1_PUB_SCRATCH1__DATA__SHIFT 0x0
|
||||
#define MP1_PUB_SCRATCH1__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_PUB_SCRATCH2
|
||||
#define MP1_PUB_SCRATCH2__DATA__SHIFT 0x0
|
||||
#define MP1_PUB_SCRATCH2__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_PUB_SCRATCH3
|
||||
#define MP1_PUB_SCRATCH3__DATA__SHIFT 0x0
|
||||
#define MP1_PUB_SCRATCH3__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_0
|
||||
#define MP1_C2PMSG_0__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_0__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_1
|
||||
#define MP1_C2PMSG_1__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_1__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_2
|
||||
#define MP1_C2PMSG_2__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_2__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_3
|
||||
#define MP1_C2PMSG_3__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_3__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_4
|
||||
#define MP1_C2PMSG_4__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_4__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_5
|
||||
#define MP1_C2PMSG_5__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_5__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_6
|
||||
#define MP1_C2PMSG_6__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_6__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_7
|
||||
#define MP1_C2PMSG_7__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_7__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_8
|
||||
#define MP1_C2PMSG_8__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_8__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_9
|
||||
#define MP1_C2PMSG_9__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_9__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_10
|
||||
#define MP1_C2PMSG_10__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_10__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_11
|
||||
#define MP1_C2PMSG_11__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_11__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_12
|
||||
#define MP1_C2PMSG_12__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_12__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_13
|
||||
#define MP1_C2PMSG_13__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_13__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_14
|
||||
#define MP1_C2PMSG_14__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_14__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_15
|
||||
#define MP1_C2PMSG_15__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_15__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_16
|
||||
#define MP1_C2PMSG_16__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_16__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_17
|
||||
#define MP1_C2PMSG_17__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_17__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_18
|
||||
#define MP1_C2PMSG_18__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_18__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_19
|
||||
#define MP1_C2PMSG_19__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_19__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_20
|
||||
#define MP1_C2PMSG_20__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_20__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_21
|
||||
#define MP1_C2PMSG_21__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_21__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_22
|
||||
#define MP1_C2PMSG_22__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_22__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_23
|
||||
#define MP1_C2PMSG_23__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_23__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_24
|
||||
#define MP1_C2PMSG_24__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_24__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_25
|
||||
#define MP1_C2PMSG_25__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_25__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_26
|
||||
#define MP1_C2PMSG_26__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_26__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_27
|
||||
#define MP1_C2PMSG_27__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_27__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_28
|
||||
#define MP1_C2PMSG_28__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_28__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_29
|
||||
#define MP1_C2PMSG_29__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_29__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_30
|
||||
#define MP1_C2PMSG_30__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_30__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_31
|
||||
#define MP1_C2PMSG_31__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_31__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_P2CMSG_0
|
||||
#define MP1_P2CMSG_0__CONTENT__SHIFT 0x0
|
||||
#define MP1_P2CMSG_0__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_P2CMSG_1
|
||||
#define MP1_P2CMSG_1__CONTENT__SHIFT 0x0
|
||||
#define MP1_P2CMSG_1__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_P2CMSG_2
|
||||
#define MP1_P2CMSG_2__CONTENT__SHIFT 0x0
|
||||
#define MP1_P2CMSG_2__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_P2CMSG_3
|
||||
#define MP1_P2CMSG_3__CONTENT__SHIFT 0x0
|
||||
#define MP1_P2CMSG_3__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_P2CMSG_INTEN
|
||||
#define MP1_P2CMSG_INTEN__INTEN__SHIFT 0x0
|
||||
#define MP1_P2CMSG_INTEN__INTEN_MASK 0x0000000FL
|
||||
//MP1_P2CMSG_INTSTS
|
||||
#define MP1_P2CMSG_INTSTS__INTSTS0__SHIFT 0x0
|
||||
#define MP1_P2CMSG_INTSTS__INTSTS1__SHIFT 0x1
|
||||
#define MP1_P2CMSG_INTSTS__INTSTS2__SHIFT 0x2
|
||||
#define MP1_P2CMSG_INTSTS__INTSTS3__SHIFT 0x3
|
||||
#define MP1_P2CMSG_INTSTS__INTSTS0_MASK 0x00000001L
|
||||
#define MP1_P2CMSG_INTSTS__INTSTS1_MASK 0x00000002L
|
||||
#define MP1_P2CMSG_INTSTS__INTSTS2_MASK 0x00000004L
|
||||
#define MP1_P2CMSG_INTSTS__INTSTS3_MASK 0x00000008L
|
||||
//MP1_P2SMSG_0
|
||||
#define MP1_P2SMSG_0__CONTENT__SHIFT 0x0
|
||||
#define MP1_P2SMSG_0__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_P2SMSG_1
|
||||
#define MP1_P2SMSG_1__CONTENT__SHIFT 0x0
|
||||
#define MP1_P2SMSG_1__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_P2SMSG_2
|
||||
#define MP1_P2SMSG_2__CONTENT__SHIFT 0x0
|
||||
#define MP1_P2SMSG_2__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_P2SMSG_3
|
||||
#define MP1_P2SMSG_3__CONTENT__SHIFT 0x0
|
||||
#define MP1_P2SMSG_3__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_P2SMSG_INTSTS
|
||||
#define MP1_P2SMSG_INTSTS__INTSTS0__SHIFT 0x0
|
||||
#define MP1_P2SMSG_INTSTS__INTSTS1__SHIFT 0x1
|
||||
#define MP1_P2SMSG_INTSTS__INTSTS2__SHIFT 0x2
|
||||
#define MP1_P2SMSG_INTSTS__INTSTS3__SHIFT 0x3
|
||||
#define MP1_P2SMSG_INTSTS__INTSTS0_MASK 0x00000001L
|
||||
#define MP1_P2SMSG_INTSTS__INTSTS1_MASK 0x00000002L
|
||||
#define MP1_P2SMSG_INTSTS__INTSTS2_MASK 0x00000004L
|
||||
#define MP1_P2SMSG_INTSTS__INTSTS3_MASK 0x00000008L
|
||||
//MP1_S2PMSG_0
|
||||
#define MP1_S2PMSG_0__CONTENT__SHIFT 0x0
|
||||
#define MP1_S2PMSG_0__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_32
|
||||
#define MP1_C2PMSG_32__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_32__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_33
|
||||
#define MP1_C2PMSG_33__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_33__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_34
|
||||
#define MP1_C2PMSG_34__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_34__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_35
|
||||
#define MP1_C2PMSG_35__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_35__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_36
|
||||
#define MP1_C2PMSG_36__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_36__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_37
|
||||
#define MP1_C2PMSG_37__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_37__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_38
|
||||
#define MP1_C2PMSG_38__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_38__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_39
|
||||
#define MP1_C2PMSG_39__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_39__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_40
|
||||
#define MP1_C2PMSG_40__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_40__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_41
|
||||
#define MP1_C2PMSG_41__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_41__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_42
|
||||
#define MP1_C2PMSG_42__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_42__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_43
|
||||
#define MP1_C2PMSG_43__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_43__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_44
|
||||
#define MP1_C2PMSG_44__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_44__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_45
|
||||
#define MP1_C2PMSG_45__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_45__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_46
|
||||
#define MP1_C2PMSG_46__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_46__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_47
|
||||
#define MP1_C2PMSG_47__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_47__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_48
|
||||
#define MP1_C2PMSG_48__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_48__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_49
|
||||
#define MP1_C2PMSG_49__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_49__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_50
|
||||
#define MP1_C2PMSG_50__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_50__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_51
|
||||
#define MP1_C2PMSG_51__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_51__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_52
|
||||
#define MP1_C2PMSG_52__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_52__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_53
|
||||
#define MP1_C2PMSG_53__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_53__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_54
|
||||
#define MP1_C2PMSG_54__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_54__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_55
|
||||
#define MP1_C2PMSG_55__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_55__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_56
|
||||
#define MP1_C2PMSG_56__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_56__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_57
|
||||
#define MP1_C2PMSG_57__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_57__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_58
|
||||
#define MP1_C2PMSG_58__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_58__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_59
|
||||
#define MP1_C2PMSG_59__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_59__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_60
|
||||
#define MP1_C2PMSG_60__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_60__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_61
|
||||
#define MP1_C2PMSG_61__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_61__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_62
|
||||
#define MP1_C2PMSG_62__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_62__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_63
|
||||
#define MP1_C2PMSG_63__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_63__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_64
|
||||
#define MP1_C2PMSG_64__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_64__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_65
|
||||
#define MP1_C2PMSG_65__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_65__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_66
|
||||
#define MP1_C2PMSG_66__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_66__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_67
|
||||
#define MP1_C2PMSG_67__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_67__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_68
|
||||
#define MP1_C2PMSG_68__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_68__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_69
|
||||
#define MP1_C2PMSG_69__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_69__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_70
|
||||
#define MP1_C2PMSG_70__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_70__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_71
|
||||
#define MP1_C2PMSG_71__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_71__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_72
|
||||
#define MP1_C2PMSG_72__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_72__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_73
|
||||
#define MP1_C2PMSG_73__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_73__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_74
|
||||
#define MP1_C2PMSG_74__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_74__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_75
|
||||
#define MP1_C2PMSG_75__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_75__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_76
|
||||
#define MP1_C2PMSG_76__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_76__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_77
|
||||
#define MP1_C2PMSG_77__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_77__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_78
|
||||
#define MP1_C2PMSG_78__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_78__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_79
|
||||
#define MP1_C2PMSG_79__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_79__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_80
|
||||
#define MP1_C2PMSG_80__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_80__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_81
|
||||
#define MP1_C2PMSG_81__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_81__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_82
|
||||
#define MP1_C2PMSG_82__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_82__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_83
|
||||
#define MP1_C2PMSG_83__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_83__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_84
|
||||
#define MP1_C2PMSG_84__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_84__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_85
|
||||
#define MP1_C2PMSG_85__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_85__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_86
|
||||
#define MP1_C2PMSG_86__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_86__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_87
|
||||
#define MP1_C2PMSG_87__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_87__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_88
|
||||
#define MP1_C2PMSG_88__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_88__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_89
|
||||
#define MP1_C2PMSG_89__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_89__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_90
|
||||
#define MP1_C2PMSG_90__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_90__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_91
|
||||
#define MP1_C2PMSG_91__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_91__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_92
|
||||
#define MP1_C2PMSG_92__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_92__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_93
|
||||
#define MP1_C2PMSG_93__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_93__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_94
|
||||
#define MP1_C2PMSG_94__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_94__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_95
|
||||
#define MP1_C2PMSG_95__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_95__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_96
|
||||
#define MP1_C2PMSG_96__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_96__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_97
|
||||
#define MP1_C2PMSG_97__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_97__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_98
|
||||
#define MP1_C2PMSG_98__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_98__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_99
|
||||
#define MP1_C2PMSG_99__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_99__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_100
|
||||
#define MP1_C2PMSG_100__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_100__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_101
|
||||
#define MP1_C2PMSG_101__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_101__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_102
|
||||
#define MP1_C2PMSG_102__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_102__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_C2PMSG_103
|
||||
#define MP1_C2PMSG_103__CONTENT__SHIFT 0x0
|
||||
#define MP1_C2PMSG_103__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_ACTIVE_FCN_ID
|
||||
#define MP1_ACTIVE_FCN_ID__VFID__SHIFT 0x0
|
||||
#define MP1_ACTIVE_FCN_ID__VF__SHIFT 0x1f
|
||||
#define MP1_ACTIVE_FCN_ID__VFID_MASK 0x0000001FL
|
||||
#define MP1_ACTIVE_FCN_ID__VF_MASK 0x80000000L
|
||||
//MP1_IH_CREDIT
|
||||
#define MP1_IH_CREDIT__CREDIT_VALUE__SHIFT 0x0
|
||||
#define MP1_IH_CREDIT__CLIENT_ID__SHIFT 0x10
|
||||
#define MP1_IH_CREDIT__CREDIT_VALUE_MASK 0x00000003L
|
||||
#define MP1_IH_CREDIT__CLIENT_ID_MASK 0x00FF0000L
|
||||
//MP1_IH_SW_INT
|
||||
#define MP1_IH_SW_INT__ID__SHIFT 0x0
|
||||
#define MP1_IH_SW_INT__VALID__SHIFT 0x8
|
||||
#define MP1_IH_SW_INT__ID_MASK 0x000000FFL
|
||||
#define MP1_IH_SW_INT__VALID_MASK 0x00000100L
|
||||
//MP1_IH_SW_INT_CTRL
|
||||
#define MP1_IH_SW_INT_CTRL__INT_MASK__SHIFT 0x0
|
||||
#define MP1_IH_SW_INT_CTRL__INT_ACK__SHIFT 0x8
|
||||
#define MP1_IH_SW_INT_CTRL__INT_MASK_MASK 0x00000001L
|
||||
#define MP1_IH_SW_INT_CTRL__INT_ACK_MASK 0x00000100L
|
||||
//MP1_FPS_CNT
|
||||
#define MP1_FPS_CNT__COUNT__SHIFT 0x0
|
||||
#define MP1_FPS_CNT__COUNT_MASK 0xFFFFFFFFL
|
||||
//MP1_PUB_CTRL
|
||||
#define MP1_PUB_CTRL__RESET__SHIFT 0x0
|
||||
#define MP1_PUB_CTRL__RESET_MASK 0x00000001L
|
||||
//MP1_EXT_SCRATCH0
|
||||
#define MP1_EXT_SCRATCH0__DATA__SHIFT 0x0
|
||||
#define MP1_EXT_SCRATCH0__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_EXT_SCRATCH1
|
||||
#define MP1_EXT_SCRATCH1__DATA__SHIFT 0x0
|
||||
#define MP1_EXT_SCRATCH1__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_EXT_SCRATCH2
|
||||
#define MP1_EXT_SCRATCH2__DATA__SHIFT 0x0
|
||||
#define MP1_EXT_SCRATCH2__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_EXT_SCRATCH3
|
||||
#define MP1_EXT_SCRATCH3__DATA__SHIFT 0x0
|
||||
#define MP1_EXT_SCRATCH3__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_EXT_SCRATCH4
|
||||
#define MP1_EXT_SCRATCH4__DATA__SHIFT 0x0
|
||||
#define MP1_EXT_SCRATCH4__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_EXT_SCRATCH5
|
||||
#define MP1_EXT_SCRATCH5__DATA__SHIFT 0x0
|
||||
#define MP1_EXT_SCRATCH5__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_EXT_SCRATCH6
|
||||
#define MP1_EXT_SCRATCH6__DATA__SHIFT 0x0
|
||||
#define MP1_EXT_SCRATCH6__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_EXT_SCRATCH7
|
||||
#define MP1_EXT_SCRATCH7__DATA__SHIFT 0x0
|
||||
#define MP1_EXT_SCRATCH7__DATA_MASK 0xFFFFFFFFL
|
||||
|
||||
|
||||
// addressBlock: mp_SmuMp1_SmnDec
|
||||
//MP1_SMN_C2PMSG_32
|
||||
#define MP1_SMN_C2PMSG_32__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_32__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_33
|
||||
#define MP1_SMN_C2PMSG_33__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_33__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_34
|
||||
#define MP1_SMN_C2PMSG_34__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_34__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_35
|
||||
#define MP1_SMN_C2PMSG_35__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_35__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_36
|
||||
#define MP1_SMN_C2PMSG_36__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_36__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_37
|
||||
#define MP1_SMN_C2PMSG_37__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_37__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_38
|
||||
#define MP1_SMN_C2PMSG_38__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_38__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_39
|
||||
#define MP1_SMN_C2PMSG_39__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_39__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_40
|
||||
#define MP1_SMN_C2PMSG_40__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_40__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_41
|
||||
#define MP1_SMN_C2PMSG_41__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_41__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_42
|
||||
#define MP1_SMN_C2PMSG_42__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_42__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_43
|
||||
#define MP1_SMN_C2PMSG_43__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_43__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_44
|
||||
#define MP1_SMN_C2PMSG_44__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_44__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_45
|
||||
#define MP1_SMN_C2PMSG_45__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_45__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_46
|
||||
#define MP1_SMN_C2PMSG_46__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_46__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_47
|
||||
#define MP1_SMN_C2PMSG_47__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_47__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_48
|
||||
#define MP1_SMN_C2PMSG_48__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_48__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_49
|
||||
#define MP1_SMN_C2PMSG_49__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_49__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_50
|
||||
#define MP1_SMN_C2PMSG_50__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_50__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_51
|
||||
#define MP1_SMN_C2PMSG_51__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_51__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_52
|
||||
#define MP1_SMN_C2PMSG_52__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_52__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_53
|
||||
#define MP1_SMN_C2PMSG_53__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_53__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_54
|
||||
#define MP1_SMN_C2PMSG_54__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_54__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_55
|
||||
#define MP1_SMN_C2PMSG_55__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_55__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_56
|
||||
#define MP1_SMN_C2PMSG_56__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_56__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_57
|
||||
#define MP1_SMN_C2PMSG_57__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_57__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_58
|
||||
#define MP1_SMN_C2PMSG_58__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_58__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_59
|
||||
#define MP1_SMN_C2PMSG_59__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_59__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_60
|
||||
#define MP1_SMN_C2PMSG_60__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_60__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_61
|
||||
#define MP1_SMN_C2PMSG_61__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_61__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_62
|
||||
#define MP1_SMN_C2PMSG_62__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_62__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_63
|
||||
#define MP1_SMN_C2PMSG_63__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_63__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_64
|
||||
#define MP1_SMN_C2PMSG_64__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_64__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_65
|
||||
#define MP1_SMN_C2PMSG_65__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_65__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_66
|
||||
#define MP1_SMN_C2PMSG_66__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_66__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_67
|
||||
#define MP1_SMN_C2PMSG_67__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_67__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_68
|
||||
#define MP1_SMN_C2PMSG_68__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_68__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_69
|
||||
#define MP1_SMN_C2PMSG_69__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_69__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_70
|
||||
#define MP1_SMN_C2PMSG_70__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_70__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_71
|
||||
#define MP1_SMN_C2PMSG_71__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_71__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_72
|
||||
#define MP1_SMN_C2PMSG_72__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_72__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_73
|
||||
#define MP1_SMN_C2PMSG_73__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_73__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_74
|
||||
#define MP1_SMN_C2PMSG_74__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_74__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_75
|
||||
#define MP1_SMN_C2PMSG_75__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_75__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_76
|
||||
#define MP1_SMN_C2PMSG_76__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_76__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_77
|
||||
#define MP1_SMN_C2PMSG_77__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_77__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_78
|
||||
#define MP1_SMN_C2PMSG_78__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_78__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_79
|
||||
#define MP1_SMN_C2PMSG_79__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_79__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_80
|
||||
#define MP1_SMN_C2PMSG_80__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_80__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_81
|
||||
#define MP1_SMN_C2PMSG_81__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_81__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_82
|
||||
#define MP1_SMN_C2PMSG_82__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_82__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_83
|
||||
#define MP1_SMN_C2PMSG_83__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_83__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_84
|
||||
#define MP1_SMN_C2PMSG_84__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_84__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_85
|
||||
#define MP1_SMN_C2PMSG_85__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_85__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_86
|
||||
#define MP1_SMN_C2PMSG_86__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_86__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_87
|
||||
#define MP1_SMN_C2PMSG_87__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_87__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_88
|
||||
#define MP1_SMN_C2PMSG_88__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_88__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_89
|
||||
#define MP1_SMN_C2PMSG_89__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_89__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_90
|
||||
#define MP1_SMN_C2PMSG_90__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_90__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_91
|
||||
#define MP1_SMN_C2PMSG_91__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_91__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_92
|
||||
#define MP1_SMN_C2PMSG_92__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_92__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_93
|
||||
#define MP1_SMN_C2PMSG_93__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_93__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_94
|
||||
#define MP1_SMN_C2PMSG_94__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_94__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_95
|
||||
#define MP1_SMN_C2PMSG_95__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_95__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_96
|
||||
#define MP1_SMN_C2PMSG_96__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_96__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_97
|
||||
#define MP1_SMN_C2PMSG_97__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_97__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_98
|
||||
#define MP1_SMN_C2PMSG_98__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_98__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_99
|
||||
#define MP1_SMN_C2PMSG_99__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_99__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_100
|
||||
#define MP1_SMN_C2PMSG_100__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_100__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_101
|
||||
#define MP1_SMN_C2PMSG_101__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_101__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_102
|
||||
#define MP1_SMN_C2PMSG_102__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_102__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_103
|
||||
#define MP1_SMN_C2PMSG_103__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_103__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_ACTIVE_FCN_ID
|
||||
#define MP1_SMN_ACTIVE_FCN_ID__VFID__SHIFT 0x0
|
||||
#define MP1_SMN_ACTIVE_FCN_ID__VF__SHIFT 0x1f
|
||||
#define MP1_SMN_ACTIVE_FCN_ID__VFID_MASK 0x0000001FL
|
||||
#define MP1_SMN_ACTIVE_FCN_ID__VF_MASK 0x80000000L
|
||||
//MP1_SMN_IH_CREDIT
|
||||
#define MP1_SMN_IH_CREDIT__CREDIT_VALUE__SHIFT 0x0
|
||||
#define MP1_SMN_IH_CREDIT__CLIENT_ID__SHIFT 0x10
|
||||
#define MP1_SMN_IH_CREDIT__CREDIT_VALUE_MASK 0x00000003L
|
||||
#define MP1_SMN_IH_CREDIT__CLIENT_ID_MASK 0x00FF0000L
|
||||
//MP1_SMN_IH_SW_INT
|
||||
#define MP1_SMN_IH_SW_INT__ID__SHIFT 0x0
|
||||
#define MP1_SMN_IH_SW_INT__VALID__SHIFT 0x8
|
||||
#define MP1_SMN_IH_SW_INT__ID_MASK 0x000000FFL
|
||||
#define MP1_SMN_IH_SW_INT__VALID_MASK 0x00000100L
|
||||
//MP1_SMN_IH_SW_INT_CTRL
|
||||
#define MP1_SMN_IH_SW_INT_CTRL__INT_MASK__SHIFT 0x0
|
||||
#define MP1_SMN_IH_SW_INT_CTRL__INT_ACK__SHIFT 0x8
|
||||
#define MP1_SMN_IH_SW_INT_CTRL__INT_MASK_MASK 0x00000001L
|
||||
#define MP1_SMN_IH_SW_INT_CTRL__INT_ACK_MASK 0x00000100L
|
||||
//MP1_SMN_FPS_CNT
|
||||
#define MP1_SMN_FPS_CNT__COUNT__SHIFT 0x0
|
||||
#define MP1_SMN_FPS_CNT__COUNT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_PUB_CTRL
|
||||
#define MP1_SMN_PUB_CTRL__RESET__SHIFT 0x0
|
||||
#define MP1_SMN_PUB_CTRL__RESET_MASK 0x00000001L
|
||||
//MP1_SMN_EXT_SCRATCH0
|
||||
#define MP1_SMN_EXT_SCRATCH0__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH0__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH1
|
||||
#define MP1_SMN_EXT_SCRATCH1__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH1__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH2
|
||||
#define MP1_SMN_EXT_SCRATCH2__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH2__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH3
|
||||
#define MP1_SMN_EXT_SCRATCH3__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH3__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH4
|
||||
#define MP1_SMN_EXT_SCRATCH4__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH4__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH5
|
||||
#define MP1_SMN_EXT_SCRATCH5__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH5__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH6
|
||||
#define MP1_SMN_EXT_SCRATCH6__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH6__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH7
|
||||
#define MP1_SMN_EXT_SCRATCH7__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH7__DATA_MASK 0xFFFFFFFFL
|
||||
|
||||
// MP1_PMI_3_START
|
||||
#define MP1_PMI_3_START__ENABLE_MASK 0x80000000L
|
||||
// MP1_PMI_3_FIFO
|
||||
#define MP1_PMI_3_FIFO__DEPTH_MASK 0x00000fffL
|
||||
|
||||
// MP1_PMI_3_START
|
||||
#define MP1_PMI_3_START__ENABLE__SHIFT 0x0000001f
|
||||
// MP1_PMI_3_FIFO
|
||||
#define MP1_PMI_3_FIFO__DEPTH__SHIFT 0x00000000
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,461 @@
|
||||
/*
|
||||
* Copyright 2021 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
#ifndef _mp_13_0_0_OFFSET_HEADER
|
||||
#define _mp_13_0_0_OFFSET_HEADER
|
||||
|
||||
|
||||
// addressBlock: mp_SmuMp0_SmnDec
|
||||
// base address: 0x0
|
||||
#define regMP0_SMN_C2PMSG_32 0x0060
|
||||
#define regMP0_SMN_C2PMSG_32_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_33 0x0061
|
||||
#define regMP0_SMN_C2PMSG_33_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_34 0x0062
|
||||
#define regMP0_SMN_C2PMSG_34_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_35 0x0063
|
||||
#define regMP0_SMN_C2PMSG_35_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_36 0x0064
|
||||
#define regMP0_SMN_C2PMSG_36_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_37 0x0065
|
||||
#define regMP0_SMN_C2PMSG_37_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_38 0x0066
|
||||
#define regMP0_SMN_C2PMSG_38_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_39 0x0067
|
||||
#define regMP0_SMN_C2PMSG_39_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_40 0x0068
|
||||
#define regMP0_SMN_C2PMSG_40_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_41 0x0069
|
||||
#define regMP0_SMN_C2PMSG_41_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_42 0x006a
|
||||
#define regMP0_SMN_C2PMSG_42_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_43 0x006b
|
||||
#define regMP0_SMN_C2PMSG_43_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_44 0x006c
|
||||
#define regMP0_SMN_C2PMSG_44_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_45 0x006d
|
||||
#define regMP0_SMN_C2PMSG_45_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_46 0x006e
|
||||
#define regMP0_SMN_C2PMSG_46_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_47 0x006f
|
||||
#define regMP0_SMN_C2PMSG_47_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_48 0x0070
|
||||
#define regMP0_SMN_C2PMSG_48_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_49 0x0071
|
||||
#define regMP0_SMN_C2PMSG_49_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_50 0x0072
|
||||
#define regMP0_SMN_C2PMSG_50_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_51 0x0073
|
||||
#define regMP0_SMN_C2PMSG_51_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_52 0x0074
|
||||
#define regMP0_SMN_C2PMSG_52_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_53 0x0075
|
||||
#define regMP0_SMN_C2PMSG_53_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_54 0x0076
|
||||
#define regMP0_SMN_C2PMSG_54_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_55 0x0077
|
||||
#define regMP0_SMN_C2PMSG_55_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_56 0x0078
|
||||
#define regMP0_SMN_C2PMSG_56_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_57 0x0079
|
||||
#define regMP0_SMN_C2PMSG_57_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_58 0x007a
|
||||
#define regMP0_SMN_C2PMSG_58_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_59 0x007b
|
||||
#define regMP0_SMN_C2PMSG_59_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_60 0x007c
|
||||
#define regMP0_SMN_C2PMSG_60_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_61 0x007d
|
||||
#define regMP0_SMN_C2PMSG_61_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_62 0x007e
|
||||
#define regMP0_SMN_C2PMSG_62_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_63 0x007f
|
||||
#define regMP0_SMN_C2PMSG_63_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_64 0x0080
|
||||
#define regMP0_SMN_C2PMSG_64_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_65 0x0081
|
||||
#define regMP0_SMN_C2PMSG_65_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_66 0x0082
|
||||
#define regMP0_SMN_C2PMSG_66_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_67 0x0083
|
||||
#define regMP0_SMN_C2PMSG_67_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_68 0x0084
|
||||
#define regMP0_SMN_C2PMSG_68_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_69 0x0085
|
||||
#define regMP0_SMN_C2PMSG_69_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_70 0x0086
|
||||
#define regMP0_SMN_C2PMSG_70_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_71 0x0087
|
||||
#define regMP0_SMN_C2PMSG_71_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_72 0x0088
|
||||
#define regMP0_SMN_C2PMSG_72_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_73 0x0089
|
||||
#define regMP0_SMN_C2PMSG_73_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_74 0x008a
|
||||
#define regMP0_SMN_C2PMSG_74_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_75 0x008b
|
||||
#define regMP0_SMN_C2PMSG_75_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_76 0x008c
|
||||
#define regMP0_SMN_C2PMSG_76_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_77 0x008d
|
||||
#define regMP0_SMN_C2PMSG_77_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_78 0x008e
|
||||
#define regMP0_SMN_C2PMSG_78_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_79 0x008f
|
||||
#define regMP0_SMN_C2PMSG_79_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_80 0x0090
|
||||
#define regMP0_SMN_C2PMSG_80_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_81 0x0091
|
||||
#define regMP0_SMN_C2PMSG_81_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_82 0x0092
|
||||
#define regMP0_SMN_C2PMSG_82_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_83 0x0093
|
||||
#define regMP0_SMN_C2PMSG_83_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_84 0x0094
|
||||
#define regMP0_SMN_C2PMSG_84_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_85 0x0095
|
||||
#define regMP0_SMN_C2PMSG_85_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_86 0x0096
|
||||
#define regMP0_SMN_C2PMSG_86_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_87 0x0097
|
||||
#define regMP0_SMN_C2PMSG_87_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_88 0x0098
|
||||
#define regMP0_SMN_C2PMSG_88_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_89 0x0099
|
||||
#define regMP0_SMN_C2PMSG_89_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_90 0x009a
|
||||
#define regMP0_SMN_C2PMSG_90_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_91 0x009b
|
||||
#define regMP0_SMN_C2PMSG_91_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_92 0x009c
|
||||
#define regMP0_SMN_C2PMSG_92_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_93 0x009d
|
||||
#define regMP0_SMN_C2PMSG_93_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_94 0x009e
|
||||
#define regMP0_SMN_C2PMSG_94_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_95 0x009f
|
||||
#define regMP0_SMN_C2PMSG_95_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_96 0x00a0
|
||||
#define regMP0_SMN_C2PMSG_96_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_97 0x00a1
|
||||
#define regMP0_SMN_C2PMSG_97_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_98 0x00a2
|
||||
#define regMP0_SMN_C2PMSG_98_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_99 0x00a3
|
||||
#define regMP0_SMN_C2PMSG_99_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_100 0x00a4
|
||||
#define regMP0_SMN_C2PMSG_100_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_101 0x00a5
|
||||
#define regMP0_SMN_C2PMSG_101_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_102 0x00a6
|
||||
#define regMP0_SMN_C2PMSG_102_BASE_IDX 0
|
||||
#define regMP0_SMN_C2PMSG_103 0x00a7
|
||||
#define regMP0_SMN_C2PMSG_103_BASE_IDX 0
|
||||
#define regMP0_SMN_IH_CREDIT 0x00c1
|
||||
#define regMP0_SMN_IH_CREDIT_BASE_IDX 0
|
||||
#define regMP0_SMN_IH_SW_INT 0x00c2
|
||||
#define regMP0_SMN_IH_SW_INT_BASE_IDX 0
|
||||
#define regMP0_SMN_IH_SW_INT_CTRL 0x00c3
|
||||
#define regMP0_SMN_IH_SW_INT_CTRL_BASE_IDX 0
|
||||
|
||||
|
||||
// addressBlock: mp_SmuMp1_SmnDec
|
||||
// base address: 0x0
|
||||
#define regMP1_SMN_C2PMSG_32 0x0260
|
||||
#define regMP1_SMN_C2PMSG_32_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_33 0x0261
|
||||
#define regMP1_SMN_C2PMSG_33_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_34 0x0262
|
||||
#define regMP1_SMN_C2PMSG_34_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_35 0x0263
|
||||
#define regMP1_SMN_C2PMSG_35_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_36 0x0264
|
||||
#define regMP1_SMN_C2PMSG_36_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_37 0x0265
|
||||
#define regMP1_SMN_C2PMSG_37_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_38 0x0266
|
||||
#define regMP1_SMN_C2PMSG_38_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_39 0x0267
|
||||
#define regMP1_SMN_C2PMSG_39_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_40 0x0268
|
||||
#define regMP1_SMN_C2PMSG_40_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_41 0x0269
|
||||
#define regMP1_SMN_C2PMSG_41_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_42 0x026a
|
||||
#define regMP1_SMN_C2PMSG_42_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_43 0x026b
|
||||
#define regMP1_SMN_C2PMSG_43_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_44 0x026c
|
||||
#define regMP1_SMN_C2PMSG_44_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_45 0x026d
|
||||
#define regMP1_SMN_C2PMSG_45_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_46 0x026e
|
||||
#define regMP1_SMN_C2PMSG_46_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_47 0x026f
|
||||
#define regMP1_SMN_C2PMSG_47_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_48 0x0270
|
||||
#define regMP1_SMN_C2PMSG_48_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_49 0x0271
|
||||
#define regMP1_SMN_C2PMSG_49_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_50 0x0272
|
||||
#define regMP1_SMN_C2PMSG_50_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_51 0x0273
|
||||
#define regMP1_SMN_C2PMSG_51_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_52 0x0274
|
||||
#define regMP1_SMN_C2PMSG_52_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_53 0x0275
|
||||
#define regMP1_SMN_C2PMSG_53_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_54 0x0276
|
||||
#define regMP1_SMN_C2PMSG_54_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_55 0x0277
|
||||
#define regMP1_SMN_C2PMSG_55_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_56 0x0278
|
||||
#define regMP1_SMN_C2PMSG_56_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_57 0x0279
|
||||
#define regMP1_SMN_C2PMSG_57_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_58 0x027a
|
||||
#define regMP1_SMN_C2PMSG_58_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_59 0x027b
|
||||
#define regMP1_SMN_C2PMSG_59_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_60 0x027c
|
||||
#define regMP1_SMN_C2PMSG_60_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_61 0x027d
|
||||
#define regMP1_SMN_C2PMSG_61_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_62 0x027e
|
||||
#define regMP1_SMN_C2PMSG_62_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_63 0x027f
|
||||
#define regMP1_SMN_C2PMSG_63_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_64 0x0280
|
||||
#define regMP1_SMN_C2PMSG_64_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_65 0x0281
|
||||
#define regMP1_SMN_C2PMSG_65_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_66 0x0282
|
||||
#define regMP1_SMN_C2PMSG_66_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_67 0x0283
|
||||
#define regMP1_SMN_C2PMSG_67_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_68 0x0284
|
||||
#define regMP1_SMN_C2PMSG_68_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_69 0x0285
|
||||
#define regMP1_SMN_C2PMSG_69_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_70 0x0286
|
||||
#define regMP1_SMN_C2PMSG_70_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_71 0x0287
|
||||
#define regMP1_SMN_C2PMSG_71_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_72 0x0288
|
||||
#define regMP1_SMN_C2PMSG_72_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_73 0x0289
|
||||
#define regMP1_SMN_C2PMSG_73_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_74 0x028a
|
||||
#define regMP1_SMN_C2PMSG_74_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_75 0x028b
|
||||
#define regMP1_SMN_C2PMSG_75_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_76 0x028c
|
||||
#define regMP1_SMN_C2PMSG_76_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_77 0x028d
|
||||
#define regMP1_SMN_C2PMSG_77_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_78 0x028e
|
||||
#define regMP1_SMN_C2PMSG_78_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_79 0x028f
|
||||
#define regMP1_SMN_C2PMSG_79_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_80 0x0290
|
||||
#define regMP1_SMN_C2PMSG_80_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_81 0x0291
|
||||
#define regMP1_SMN_C2PMSG_81_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_82 0x0292
|
||||
#define regMP1_SMN_C2PMSG_82_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_83 0x0293
|
||||
#define regMP1_SMN_C2PMSG_83_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_84 0x0294
|
||||
#define regMP1_SMN_C2PMSG_84_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_85 0x0295
|
||||
#define regMP1_SMN_C2PMSG_85_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_86 0x0296
|
||||
#define regMP1_SMN_C2PMSG_86_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_87 0x0297
|
||||
#define regMP1_SMN_C2PMSG_87_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_88 0x0298
|
||||
#define regMP1_SMN_C2PMSG_88_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_89 0x0299
|
||||
#define regMP1_SMN_C2PMSG_89_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_90 0x029a
|
||||
#define regMP1_SMN_C2PMSG_90_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_91 0x029b
|
||||
#define regMP1_SMN_C2PMSG_91_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_92 0x029c
|
||||
#define regMP1_SMN_C2PMSG_92_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_93 0x029d
|
||||
#define regMP1_SMN_C2PMSG_93_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_94 0x029e
|
||||
#define regMP1_SMN_C2PMSG_94_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_95 0x029f
|
||||
#define regMP1_SMN_C2PMSG_95_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_96 0x02a0
|
||||
#define regMP1_SMN_C2PMSG_96_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_97 0x02a1
|
||||
#define regMP1_SMN_C2PMSG_97_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_98 0x02a2
|
||||
#define regMP1_SMN_C2PMSG_98_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_99 0x02a3
|
||||
#define regMP1_SMN_C2PMSG_99_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_100 0x02a4
|
||||
#define regMP1_SMN_C2PMSG_100_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_101 0x02a5
|
||||
#define regMP1_SMN_C2PMSG_101_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_102 0x02a6
|
||||
#define regMP1_SMN_C2PMSG_102_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_103 0x02a7
|
||||
#define regMP1_SMN_C2PMSG_103_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_104 0x02a8
|
||||
#define regMP1_SMN_C2PMSG_104_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_105 0x02a9
|
||||
#define regMP1_SMN_C2PMSG_105_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_106 0x02aa
|
||||
#define regMP1_SMN_C2PMSG_106_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_107 0x02ab
|
||||
#define regMP1_SMN_C2PMSG_107_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_108 0x02ac
|
||||
#define regMP1_SMN_C2PMSG_108_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_109 0x02ad
|
||||
#define regMP1_SMN_C2PMSG_109_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_110 0x02ae
|
||||
#define regMP1_SMN_C2PMSG_110_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_111 0x02af
|
||||
#define regMP1_SMN_C2PMSG_111_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_112 0x02b0
|
||||
#define regMP1_SMN_C2PMSG_112_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_113 0x02b1
|
||||
#define regMP1_SMN_C2PMSG_113_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_114 0x02b2
|
||||
#define regMP1_SMN_C2PMSG_114_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_115 0x02b3
|
||||
#define regMP1_SMN_C2PMSG_115_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_116 0x02b4
|
||||
#define regMP1_SMN_C2PMSG_116_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_117 0x02b5
|
||||
#define regMP1_SMN_C2PMSG_117_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_118 0x02b6
|
||||
#define regMP1_SMN_C2PMSG_118_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_119 0x02b7
|
||||
#define regMP1_SMN_C2PMSG_119_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_120 0x02b8
|
||||
#define regMP1_SMN_C2PMSG_120_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_121 0x02b9
|
||||
#define regMP1_SMN_C2PMSG_121_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_122 0x02ba
|
||||
#define regMP1_SMN_C2PMSG_122_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_123 0x02bb
|
||||
#define regMP1_SMN_C2PMSG_123_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_124 0x02bc
|
||||
#define regMP1_SMN_C2PMSG_124_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_125 0x02bd
|
||||
#define regMP1_SMN_C2PMSG_125_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_126 0x02be
|
||||
#define regMP1_SMN_C2PMSG_126_BASE_IDX 0
|
||||
#define regMP1_SMN_C2PMSG_127 0x02bf
|
||||
#define regMP1_SMN_C2PMSG_127_BASE_IDX 0
|
||||
#define regMP1_SMN_IH_CREDIT 0x02c1
|
||||
#define regMP1_SMN_IH_CREDIT_BASE_IDX 0
|
||||
#define regMP1_SMN_IH_SW_INT 0x02c2
|
||||
#define regMP1_SMN_IH_SW_INT_BASE_IDX 0
|
||||
#define regMP1_SMN_IH_SW_INT_CTRL 0x02c3
|
||||
#define regMP1_SMN_IH_SW_INT_CTRL_BASE_IDX 0
|
||||
#define regMP1_SMN_FPS_CNT 0x02c4
|
||||
#define regMP1_SMN_FPS_CNT_BASE_IDX 0
|
||||
#define regMP1_SMN_PUB_CTRL 0x02c5
|
||||
#define regMP1_SMN_PUB_CTRL_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH0 0x0340
|
||||
#define regMP1_SMN_EXT_SCRATCH0_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH1 0x0341
|
||||
#define regMP1_SMN_EXT_SCRATCH1_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH2 0x0342
|
||||
#define regMP1_SMN_EXT_SCRATCH2_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH3 0x0343
|
||||
#define regMP1_SMN_EXT_SCRATCH3_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH4 0x0344
|
||||
#define regMP1_SMN_EXT_SCRATCH4_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH5 0x0345
|
||||
#define regMP1_SMN_EXT_SCRATCH5_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH6 0x0346
|
||||
#define regMP1_SMN_EXT_SCRATCH6_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH7 0x0347
|
||||
#define regMP1_SMN_EXT_SCRATCH7_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH8 0x0348
|
||||
#define regMP1_SMN_EXT_SCRATCH8_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH10 0x034a
|
||||
#define regMP1_SMN_EXT_SCRATCH10_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH11 0x034b
|
||||
#define regMP1_SMN_EXT_SCRATCH11_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH12 0x034c
|
||||
#define regMP1_SMN_EXT_SCRATCH12_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH13 0x034d
|
||||
#define regMP1_SMN_EXT_SCRATCH13_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH14 0x034e
|
||||
#define regMP1_SMN_EXT_SCRATCH14_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH15 0x034f
|
||||
#define regMP1_SMN_EXT_SCRATCH15_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH16 0x0350
|
||||
#define regMP1_SMN_EXT_SCRATCH16_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH17 0x0351
|
||||
#define regMP1_SMN_EXT_SCRATCH17_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH18 0x0352
|
||||
#define regMP1_SMN_EXT_SCRATCH18_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH19 0x0353
|
||||
#define regMP1_SMN_EXT_SCRATCH19_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH20 0x0354
|
||||
#define regMP1_SMN_EXT_SCRATCH20_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH21 0x0355
|
||||
#define regMP1_SMN_EXT_SCRATCH21_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH22 0x0356
|
||||
#define regMP1_SMN_EXT_SCRATCH22_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH23 0x0357
|
||||
#define regMP1_SMN_EXT_SCRATCH23_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH24 0x0358
|
||||
#define regMP1_SMN_EXT_SCRATCH24_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH25 0x0359
|
||||
#define regMP1_SMN_EXT_SCRATCH25_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH26 0x035a
|
||||
#define regMP1_SMN_EXT_SCRATCH26_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH27 0x035b
|
||||
#define regMP1_SMN_EXT_SCRATCH27_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH28 0x035c
|
||||
#define regMP1_SMN_EXT_SCRATCH28_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH29 0x035d
|
||||
#define regMP1_SMN_EXT_SCRATCH29_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH30 0x035e
|
||||
#define regMP1_SMN_EXT_SCRATCH30_BASE_IDX 0
|
||||
#define regMP1_SMN_EXT_SCRATCH31 0x035f
|
||||
#define regMP1_SMN_EXT_SCRATCH31_BASE_IDX 0
|
||||
|
||||
|
||||
// addressBlock: mp_SmuMp1Pub_CruDec
|
||||
// base address: 0x0
|
||||
#define regMP1_FIRMWARE_FLAGS 0xbee009
|
||||
#define regMP1_FIRMWARE_FLAGS_BASE_IDX 0
|
||||
|
||||
|
||||
// addressBlock: mp_SmuMpIOPub_CruDec
|
||||
// base address: 0x0
|
||||
#define regMPIO_FIRMWARE_FLAGS 0xbee009
|
||||
#define regMPIO_FIRMWARE_FLAGS_BASE_IDX 0
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,682 @@
|
||||
/*
|
||||
* Copyright 2021 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
#ifndef _mp_13_0_0_SH_MASK_HEADER
|
||||
#define _mp_13_0_0_SH_MASK_HEADER
|
||||
|
||||
|
||||
// addressBlock: mp_SmuMp0_SmnDec
|
||||
//MP0_SMN_C2PMSG_32
|
||||
#define MP0_SMN_C2PMSG_32__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_32__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_33
|
||||
#define MP0_SMN_C2PMSG_33__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_33__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_34
|
||||
#define MP0_SMN_C2PMSG_34__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_34__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_35
|
||||
#define MP0_SMN_C2PMSG_35__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_35__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_36
|
||||
#define MP0_SMN_C2PMSG_36__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_36__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_37
|
||||
#define MP0_SMN_C2PMSG_37__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_37__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_38
|
||||
#define MP0_SMN_C2PMSG_38__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_38__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_39
|
||||
#define MP0_SMN_C2PMSG_39__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_39__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_40
|
||||
#define MP0_SMN_C2PMSG_40__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_40__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_41
|
||||
#define MP0_SMN_C2PMSG_41__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_41__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_42
|
||||
#define MP0_SMN_C2PMSG_42__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_42__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_43
|
||||
#define MP0_SMN_C2PMSG_43__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_43__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_44
|
||||
#define MP0_SMN_C2PMSG_44__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_44__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_45
|
||||
#define MP0_SMN_C2PMSG_45__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_45__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_46
|
||||
#define MP0_SMN_C2PMSG_46__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_46__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_47
|
||||
#define MP0_SMN_C2PMSG_47__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_47__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_48
|
||||
#define MP0_SMN_C2PMSG_48__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_48__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_49
|
||||
#define MP0_SMN_C2PMSG_49__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_49__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_50
|
||||
#define MP0_SMN_C2PMSG_50__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_50__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_51
|
||||
#define MP0_SMN_C2PMSG_51__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_51__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_52
|
||||
#define MP0_SMN_C2PMSG_52__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_52__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_53
|
||||
#define MP0_SMN_C2PMSG_53__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_53__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_54
|
||||
#define MP0_SMN_C2PMSG_54__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_54__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_55
|
||||
#define MP0_SMN_C2PMSG_55__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_55__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_56
|
||||
#define MP0_SMN_C2PMSG_56__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_56__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_57
|
||||
#define MP0_SMN_C2PMSG_57__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_57__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_58
|
||||
#define MP0_SMN_C2PMSG_58__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_58__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_59
|
||||
#define MP0_SMN_C2PMSG_59__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_59__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_60
|
||||
#define MP0_SMN_C2PMSG_60__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_60__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_61
|
||||
#define MP0_SMN_C2PMSG_61__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_61__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_62
|
||||
#define MP0_SMN_C2PMSG_62__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_62__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_63
|
||||
#define MP0_SMN_C2PMSG_63__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_63__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_64
|
||||
#define MP0_SMN_C2PMSG_64__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_64__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_65
|
||||
#define MP0_SMN_C2PMSG_65__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_65__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_66
|
||||
#define MP0_SMN_C2PMSG_66__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_66__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_67
|
||||
#define MP0_SMN_C2PMSG_67__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_67__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_68
|
||||
#define MP0_SMN_C2PMSG_68__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_68__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_69
|
||||
#define MP0_SMN_C2PMSG_69__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_69__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_70
|
||||
#define MP0_SMN_C2PMSG_70__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_70__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_71
|
||||
#define MP0_SMN_C2PMSG_71__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_71__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_72
|
||||
#define MP0_SMN_C2PMSG_72__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_72__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_73
|
||||
#define MP0_SMN_C2PMSG_73__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_73__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_74
|
||||
#define MP0_SMN_C2PMSG_74__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_74__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_75
|
||||
#define MP0_SMN_C2PMSG_75__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_75__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_76
|
||||
#define MP0_SMN_C2PMSG_76__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_76__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_77
|
||||
#define MP0_SMN_C2PMSG_77__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_77__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_78
|
||||
#define MP0_SMN_C2PMSG_78__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_78__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_79
|
||||
#define MP0_SMN_C2PMSG_79__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_79__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_80
|
||||
#define MP0_SMN_C2PMSG_80__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_80__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_81
|
||||
#define MP0_SMN_C2PMSG_81__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_81__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_82
|
||||
#define MP0_SMN_C2PMSG_82__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_82__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_83
|
||||
#define MP0_SMN_C2PMSG_83__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_83__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_84
|
||||
#define MP0_SMN_C2PMSG_84__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_84__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_85
|
||||
#define MP0_SMN_C2PMSG_85__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_85__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_86
|
||||
#define MP0_SMN_C2PMSG_86__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_86__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_87
|
||||
#define MP0_SMN_C2PMSG_87__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_87__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_88
|
||||
#define MP0_SMN_C2PMSG_88__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_88__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_89
|
||||
#define MP0_SMN_C2PMSG_89__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_89__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_90
|
||||
#define MP0_SMN_C2PMSG_90__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_90__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_91
|
||||
#define MP0_SMN_C2PMSG_91__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_91__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_92
|
||||
#define MP0_SMN_C2PMSG_92__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_92__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_93
|
||||
#define MP0_SMN_C2PMSG_93__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_93__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_94
|
||||
#define MP0_SMN_C2PMSG_94__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_94__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_95
|
||||
#define MP0_SMN_C2PMSG_95__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_95__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_96
|
||||
#define MP0_SMN_C2PMSG_96__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_96__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_97
|
||||
#define MP0_SMN_C2PMSG_97__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_97__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_98
|
||||
#define MP0_SMN_C2PMSG_98__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_98__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_99
|
||||
#define MP0_SMN_C2PMSG_99__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_99__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_100
|
||||
#define MP0_SMN_C2PMSG_100__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_100__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_101
|
||||
#define MP0_SMN_C2PMSG_101__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_101__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_102
|
||||
#define MP0_SMN_C2PMSG_102__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_102__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_C2PMSG_103
|
||||
#define MP0_SMN_C2PMSG_103__CONTENT__SHIFT 0x0
|
||||
#define MP0_SMN_C2PMSG_103__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP0_SMN_IH_CREDIT
|
||||
#define MP0_SMN_IH_CREDIT__CREDIT_VALUE__SHIFT 0x0
|
||||
#define MP0_SMN_IH_CREDIT__CLIENT_ID__SHIFT 0x10
|
||||
#define MP0_SMN_IH_CREDIT__CREDIT_VALUE_MASK 0x00000003L
|
||||
#define MP0_SMN_IH_CREDIT__CLIENT_ID_MASK 0x00FF0000L
|
||||
//MP0_SMN_IH_SW_INT
|
||||
#define MP0_SMN_IH_SW_INT__ID__SHIFT 0x0
|
||||
#define MP0_SMN_IH_SW_INT__VALID__SHIFT 0x8
|
||||
#define MP0_SMN_IH_SW_INT__ID_MASK 0x000000FFL
|
||||
#define MP0_SMN_IH_SW_INT__VALID_MASK 0x00000100L
|
||||
//MP0_SMN_IH_SW_INT_CTRL
|
||||
#define MP0_SMN_IH_SW_INT_CTRL__INT_MASK__SHIFT 0x0
|
||||
#define MP0_SMN_IH_SW_INT_CTRL__INT_ACK__SHIFT 0x8
|
||||
#define MP0_SMN_IH_SW_INT_CTRL__INT_MASK_MASK 0x00000001L
|
||||
#define MP0_SMN_IH_SW_INT_CTRL__INT_ACK_MASK 0x00000100L
|
||||
|
||||
|
||||
// addressBlock: mp_SmuMp1_SmnDec
|
||||
//MP1_SMN_C2PMSG_32
|
||||
#define MP1_SMN_C2PMSG_32__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_32__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_33
|
||||
#define MP1_SMN_C2PMSG_33__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_33__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_34
|
||||
#define MP1_SMN_C2PMSG_34__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_34__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_35
|
||||
#define MP1_SMN_C2PMSG_35__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_35__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_36
|
||||
#define MP1_SMN_C2PMSG_36__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_36__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_37
|
||||
#define MP1_SMN_C2PMSG_37__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_37__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_38
|
||||
#define MP1_SMN_C2PMSG_38__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_38__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_39
|
||||
#define MP1_SMN_C2PMSG_39__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_39__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_40
|
||||
#define MP1_SMN_C2PMSG_40__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_40__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_41
|
||||
#define MP1_SMN_C2PMSG_41__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_41__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_42
|
||||
#define MP1_SMN_C2PMSG_42__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_42__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_43
|
||||
#define MP1_SMN_C2PMSG_43__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_43__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_44
|
||||
#define MP1_SMN_C2PMSG_44__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_44__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_45
|
||||
#define MP1_SMN_C2PMSG_45__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_45__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_46
|
||||
#define MP1_SMN_C2PMSG_46__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_46__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_47
|
||||
#define MP1_SMN_C2PMSG_47__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_47__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_48
|
||||
#define MP1_SMN_C2PMSG_48__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_48__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_49
|
||||
#define MP1_SMN_C2PMSG_49__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_49__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_50
|
||||
#define MP1_SMN_C2PMSG_50__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_50__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_51
|
||||
#define MP1_SMN_C2PMSG_51__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_51__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_52
|
||||
#define MP1_SMN_C2PMSG_52__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_52__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_53
|
||||
#define MP1_SMN_C2PMSG_53__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_53__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_54
|
||||
#define MP1_SMN_C2PMSG_54__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_54__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_55
|
||||
#define MP1_SMN_C2PMSG_55__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_55__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_56
|
||||
#define MP1_SMN_C2PMSG_56__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_56__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_57
|
||||
#define MP1_SMN_C2PMSG_57__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_57__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_58
|
||||
#define MP1_SMN_C2PMSG_58__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_58__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_59
|
||||
#define MP1_SMN_C2PMSG_59__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_59__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_60
|
||||
#define MP1_SMN_C2PMSG_60__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_60__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_61
|
||||
#define MP1_SMN_C2PMSG_61__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_61__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_62
|
||||
#define MP1_SMN_C2PMSG_62__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_62__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_63
|
||||
#define MP1_SMN_C2PMSG_63__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_63__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_64
|
||||
#define MP1_SMN_C2PMSG_64__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_64__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_65
|
||||
#define MP1_SMN_C2PMSG_65__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_65__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_66
|
||||
#define MP1_SMN_C2PMSG_66__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_66__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_67
|
||||
#define MP1_SMN_C2PMSG_67__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_67__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_68
|
||||
#define MP1_SMN_C2PMSG_68__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_68__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_69
|
||||
#define MP1_SMN_C2PMSG_69__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_69__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_70
|
||||
#define MP1_SMN_C2PMSG_70__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_70__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_71
|
||||
#define MP1_SMN_C2PMSG_71__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_71__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_72
|
||||
#define MP1_SMN_C2PMSG_72__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_72__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_73
|
||||
#define MP1_SMN_C2PMSG_73__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_73__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_74
|
||||
#define MP1_SMN_C2PMSG_74__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_74__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_75
|
||||
#define MP1_SMN_C2PMSG_75__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_75__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_76
|
||||
#define MP1_SMN_C2PMSG_76__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_76__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_77
|
||||
#define MP1_SMN_C2PMSG_77__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_77__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_78
|
||||
#define MP1_SMN_C2PMSG_78__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_78__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_79
|
||||
#define MP1_SMN_C2PMSG_79__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_79__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_80
|
||||
#define MP1_SMN_C2PMSG_80__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_80__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_81
|
||||
#define MP1_SMN_C2PMSG_81__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_81__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_82
|
||||
#define MP1_SMN_C2PMSG_82__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_82__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_83
|
||||
#define MP1_SMN_C2PMSG_83__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_83__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_84
|
||||
#define MP1_SMN_C2PMSG_84__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_84__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_85
|
||||
#define MP1_SMN_C2PMSG_85__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_85__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_86
|
||||
#define MP1_SMN_C2PMSG_86__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_86__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_87
|
||||
#define MP1_SMN_C2PMSG_87__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_87__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_88
|
||||
#define MP1_SMN_C2PMSG_88__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_88__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_89
|
||||
#define MP1_SMN_C2PMSG_89__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_89__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_90
|
||||
#define MP1_SMN_C2PMSG_90__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_90__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_91
|
||||
#define MP1_SMN_C2PMSG_91__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_91__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_92
|
||||
#define MP1_SMN_C2PMSG_92__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_92__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_93
|
||||
#define MP1_SMN_C2PMSG_93__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_93__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_94
|
||||
#define MP1_SMN_C2PMSG_94__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_94__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_95
|
||||
#define MP1_SMN_C2PMSG_95__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_95__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_96
|
||||
#define MP1_SMN_C2PMSG_96__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_96__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_97
|
||||
#define MP1_SMN_C2PMSG_97__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_97__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_98
|
||||
#define MP1_SMN_C2PMSG_98__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_98__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_99
|
||||
#define MP1_SMN_C2PMSG_99__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_99__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_100
|
||||
#define MP1_SMN_C2PMSG_100__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_100__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_101
|
||||
#define MP1_SMN_C2PMSG_101__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_101__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_102
|
||||
#define MP1_SMN_C2PMSG_102__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_102__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_103
|
||||
#define MP1_SMN_C2PMSG_103__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_103__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_104
|
||||
#define MP1_SMN_C2PMSG_104__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_104__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_105
|
||||
#define MP1_SMN_C2PMSG_105__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_105__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_106
|
||||
#define MP1_SMN_C2PMSG_106__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_106__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_107
|
||||
#define MP1_SMN_C2PMSG_107__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_107__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_108
|
||||
#define MP1_SMN_C2PMSG_108__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_108__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_109
|
||||
#define MP1_SMN_C2PMSG_109__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_109__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_110
|
||||
#define MP1_SMN_C2PMSG_110__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_110__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_111
|
||||
#define MP1_SMN_C2PMSG_111__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_111__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_112
|
||||
#define MP1_SMN_C2PMSG_112__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_112__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_113
|
||||
#define MP1_SMN_C2PMSG_113__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_113__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_114
|
||||
#define MP1_SMN_C2PMSG_114__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_114__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_115
|
||||
#define MP1_SMN_C2PMSG_115__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_115__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_116
|
||||
#define MP1_SMN_C2PMSG_116__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_116__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_117
|
||||
#define MP1_SMN_C2PMSG_117__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_117__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_118
|
||||
#define MP1_SMN_C2PMSG_118__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_118__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_119
|
||||
#define MP1_SMN_C2PMSG_119__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_119__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_120
|
||||
#define MP1_SMN_C2PMSG_120__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_120__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_121
|
||||
#define MP1_SMN_C2PMSG_121__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_121__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_122
|
||||
#define MP1_SMN_C2PMSG_122__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_122__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_123
|
||||
#define MP1_SMN_C2PMSG_123__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_123__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_124
|
||||
#define MP1_SMN_C2PMSG_124__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_124__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_125
|
||||
#define MP1_SMN_C2PMSG_125__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_125__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_126
|
||||
#define MP1_SMN_C2PMSG_126__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_126__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_C2PMSG_127
|
||||
#define MP1_SMN_C2PMSG_127__CONTENT__SHIFT 0x0
|
||||
#define MP1_SMN_C2PMSG_127__CONTENT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_IH_CREDIT
|
||||
#define MP1_SMN_IH_CREDIT__CREDIT_VALUE__SHIFT 0x0
|
||||
#define MP1_SMN_IH_CREDIT__CLIENT_ID__SHIFT 0x10
|
||||
#define MP1_SMN_IH_CREDIT__CREDIT_VALUE_MASK 0x00000003L
|
||||
#define MP1_SMN_IH_CREDIT__CLIENT_ID_MASK 0x00FF0000L
|
||||
//MP1_SMN_IH_SW_INT
|
||||
#define MP1_SMN_IH_SW_INT__ID__SHIFT 0x0
|
||||
#define MP1_SMN_IH_SW_INT__VALID__SHIFT 0x8
|
||||
#define MP1_SMN_IH_SW_INT__ID_MASK 0x000000FFL
|
||||
#define MP1_SMN_IH_SW_INT__VALID_MASK 0x00000100L
|
||||
//MP1_SMN_IH_SW_INT_CTRL
|
||||
#define MP1_SMN_IH_SW_INT_CTRL__INT_MASK__SHIFT 0x0
|
||||
#define MP1_SMN_IH_SW_INT_CTRL__INT_ACK__SHIFT 0x8
|
||||
#define MP1_SMN_IH_SW_INT_CTRL__INT_MASK_MASK 0x00000001L
|
||||
#define MP1_SMN_IH_SW_INT_CTRL__INT_ACK_MASK 0x00000100L
|
||||
//MP1_SMN_FPS_CNT
|
||||
#define MP1_SMN_FPS_CNT__COUNT__SHIFT 0x0
|
||||
#define MP1_SMN_FPS_CNT__COUNT_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_PUB_CTRL
|
||||
#define MP1_SMN_PUB_CTRL__LX3_RESET__SHIFT 0x0
|
||||
#define MP1_SMN_PUB_CTRL__LX3_RESET_MASK 0x00000001L
|
||||
//MP1_SMN_EXT_SCRATCH0
|
||||
#define MP1_SMN_EXT_SCRATCH0__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH0__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH1
|
||||
#define MP1_SMN_EXT_SCRATCH1__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH1__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH2
|
||||
#define MP1_SMN_EXT_SCRATCH2__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH2__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH3
|
||||
#define MP1_SMN_EXT_SCRATCH3__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH3__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH4
|
||||
#define MP1_SMN_EXT_SCRATCH4__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH4__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH5
|
||||
#define MP1_SMN_EXT_SCRATCH5__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH5__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH6
|
||||
#define MP1_SMN_EXT_SCRATCH6__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH6__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH7
|
||||
#define MP1_SMN_EXT_SCRATCH7__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH7__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH8
|
||||
#define MP1_SMN_EXT_SCRATCH8__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH8__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH10
|
||||
#define MP1_SMN_EXT_SCRATCH10__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH10__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH11
|
||||
#define MP1_SMN_EXT_SCRATCH11__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH11__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH12
|
||||
#define MP1_SMN_EXT_SCRATCH12__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH12__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH13
|
||||
#define MP1_SMN_EXT_SCRATCH13__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH13__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH14
|
||||
#define MP1_SMN_EXT_SCRATCH14__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH14__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH15
|
||||
#define MP1_SMN_EXT_SCRATCH15__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH15__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH16
|
||||
#define MP1_SMN_EXT_SCRATCH16__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH16__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH17
|
||||
#define MP1_SMN_EXT_SCRATCH17__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH17__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH18
|
||||
#define MP1_SMN_EXT_SCRATCH18__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH18__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH19
|
||||
#define MP1_SMN_EXT_SCRATCH19__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH19__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH20
|
||||
#define MP1_SMN_EXT_SCRATCH20__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH20__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH21
|
||||
#define MP1_SMN_EXT_SCRATCH21__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH21__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH22
|
||||
#define MP1_SMN_EXT_SCRATCH22__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH22__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH23
|
||||
#define MP1_SMN_EXT_SCRATCH23__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH23__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH24
|
||||
#define MP1_SMN_EXT_SCRATCH24__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH24__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH25
|
||||
#define MP1_SMN_EXT_SCRATCH25__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH25__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH26
|
||||
#define MP1_SMN_EXT_SCRATCH26__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH26__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH27
|
||||
#define MP1_SMN_EXT_SCRATCH27__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH27__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH28
|
||||
#define MP1_SMN_EXT_SCRATCH28__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH28__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH29
|
||||
#define MP1_SMN_EXT_SCRATCH29__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH29__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH30
|
||||
#define MP1_SMN_EXT_SCRATCH30__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH30__DATA_MASK 0xFFFFFFFFL
|
||||
//MP1_SMN_EXT_SCRATCH31
|
||||
#define MP1_SMN_EXT_SCRATCH31__DATA__SHIFT 0x0
|
||||
#define MP1_SMN_EXT_SCRATCH31__DATA_MASK 0xFFFFFFFFL
|
||||
|
||||
|
||||
// addressBlock: mp_SmuMp1Pub_CruDec
|
||||
//MP1_FIRMWARE_FLAGS
|
||||
#define MP1_FIRMWARE_FLAGS__INTERRUPTS_ENABLED__SHIFT 0x0
|
||||
#define MP1_FIRMWARE_FLAGS__RESERVED__SHIFT 0x1
|
||||
#define MP1_FIRMWARE_FLAGS__INTERRUPTS_ENABLED_MASK 0x00000001L
|
||||
#define MP1_FIRMWARE_FLAGS__RESERVED_MASK 0xFFFFFFFEL
|
||||
|
||||
|
||||
// addressBlock: mp_SmuMpIOPub_CruDec
|
||||
//MPIO_FIRMWARE_FLAGS
|
||||
#define MPIO_FIRMWARE_FLAGS__INTERRUPTS_ENABLED__SHIFT 0x0
|
||||
#define MPIO_FIRMWARE_FLAGS__RESERVED__SHIFT 0x1
|
||||
#define MPIO_FIRMWARE_FLAGS__INTERRUPTS_ENABLED_MASK 0x00000001L
|
||||
#define MPIO_FIRMWARE_FLAGS__RESERVED_MASK 0xFFFFFFFEL
|
||||
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,267 @@
|
||||
/*
|
||||
* Copyright 2021 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
#ifndef _osssys_6_0_0_OFFSET_HEADER
|
||||
#define _osssys_6_0_0_OFFSET_HEADER
|
||||
|
||||
|
||||
|
||||
// addressBlock: osssys_osssysdec
|
||||
// base address: 0x4280
|
||||
#define regIH_VMID_0_LUT 0x0000
|
||||
#define regIH_VMID_0_LUT_BASE_IDX 0
|
||||
#define regIH_VMID_1_LUT 0x0001
|
||||
#define regIH_VMID_1_LUT_BASE_IDX 0
|
||||
#define regIH_VMID_2_LUT 0x0002
|
||||
#define regIH_VMID_2_LUT_BASE_IDX 0
|
||||
#define regIH_VMID_3_LUT 0x0003
|
||||
#define regIH_VMID_3_LUT_BASE_IDX 0
|
||||
#define regIH_VMID_4_LUT 0x0004
|
||||
#define regIH_VMID_4_LUT_BASE_IDX 0
|
||||
#define regIH_VMID_5_LUT 0x0005
|
||||
#define regIH_VMID_5_LUT_BASE_IDX 0
|
||||
#define regIH_VMID_6_LUT 0x0006
|
||||
#define regIH_VMID_6_LUT_BASE_IDX 0
|
||||
#define regIH_VMID_7_LUT 0x0007
|
||||
#define regIH_VMID_7_LUT_BASE_IDX 0
|
||||
#define regIH_VMID_8_LUT 0x0008
|
||||
#define regIH_VMID_8_LUT_BASE_IDX 0
|
||||
#define regIH_VMID_9_LUT 0x0009
|
||||
#define regIH_VMID_9_LUT_BASE_IDX 0
|
||||
#define regIH_VMID_10_LUT 0x000a
|
||||
#define regIH_VMID_10_LUT_BASE_IDX 0
|
||||
#define regIH_VMID_11_LUT 0x000b
|
||||
#define regIH_VMID_11_LUT_BASE_IDX 0
|
||||
#define regIH_VMID_12_LUT 0x000c
|
||||
#define regIH_VMID_12_LUT_BASE_IDX 0
|
||||
#define regIH_VMID_13_LUT 0x000d
|
||||
#define regIH_VMID_13_LUT_BASE_IDX 0
|
||||
#define regIH_VMID_14_LUT 0x000e
|
||||
#define regIH_VMID_14_LUT_BASE_IDX 0
|
||||
#define regIH_VMID_15_LUT 0x000f
|
||||
#define regIH_VMID_15_LUT_BASE_IDX 0
|
||||
#define regIH_VMID_0_LUT_MM 0x0010
|
||||
#define regIH_VMID_0_LUT_MM_BASE_IDX 0
|
||||
#define regIH_VMID_1_LUT_MM 0x0011
|
||||
#define regIH_VMID_1_LUT_MM_BASE_IDX 0
|
||||
#define regIH_VMID_2_LUT_MM 0x0012
|
||||
#define regIH_VMID_2_LUT_MM_BASE_IDX 0
|
||||
#define regIH_VMID_3_LUT_MM 0x0013
|
||||
#define regIH_VMID_3_LUT_MM_BASE_IDX 0
|
||||
#define regIH_VMID_4_LUT_MM 0x0014
|
||||
#define regIH_VMID_4_LUT_MM_BASE_IDX 0
|
||||
#define regIH_VMID_5_LUT_MM 0x0015
|
||||
#define regIH_VMID_5_LUT_MM_BASE_IDX 0
|
||||
#define regIH_VMID_6_LUT_MM 0x0016
|
||||
#define regIH_VMID_6_LUT_MM_BASE_IDX 0
|
||||
#define regIH_VMID_7_LUT_MM 0x0017
|
||||
#define regIH_VMID_7_LUT_MM_BASE_IDX 0
|
||||
#define regIH_VMID_8_LUT_MM 0x0018
|
||||
#define regIH_VMID_8_LUT_MM_BASE_IDX 0
|
||||
#define regIH_VMID_9_LUT_MM 0x0019
|
||||
#define regIH_VMID_9_LUT_MM_BASE_IDX 0
|
||||
#define regIH_VMID_10_LUT_MM 0x001a
|
||||
#define regIH_VMID_10_LUT_MM_BASE_IDX 0
|
||||
#define regIH_VMID_11_LUT_MM 0x001b
|
||||
#define regIH_VMID_11_LUT_MM_BASE_IDX 0
|
||||
#define regIH_VMID_12_LUT_MM 0x001c
|
||||
#define regIH_VMID_12_LUT_MM_BASE_IDX 0
|
||||
#define regIH_VMID_13_LUT_MM 0x001d
|
||||
#define regIH_VMID_13_LUT_MM_BASE_IDX 0
|
||||
#define regIH_VMID_14_LUT_MM 0x001e
|
||||
#define regIH_VMID_14_LUT_MM_BASE_IDX 0
|
||||
#define regIH_VMID_15_LUT_MM 0x001f
|
||||
#define regIH_VMID_15_LUT_MM_BASE_IDX 0
|
||||
#define regIH_COOKIE_0 0x0020
|
||||
#define regIH_COOKIE_0_BASE_IDX 0
|
||||
#define regIH_COOKIE_1 0x0021
|
||||
#define regIH_COOKIE_1_BASE_IDX 0
|
||||
#define regIH_COOKIE_2 0x0022
|
||||
#define regIH_COOKIE_2_BASE_IDX 0
|
||||
#define regIH_COOKIE_3 0x0023
|
||||
#define regIH_COOKIE_3_BASE_IDX 0
|
||||
#define regIH_COOKIE_4 0x0024
|
||||
#define regIH_COOKIE_4_BASE_IDX 0
|
||||
#define regIH_COOKIE_5 0x0025
|
||||
#define regIH_COOKIE_5_BASE_IDX 0
|
||||
#define regIH_COOKIE_6 0x0026
|
||||
#define regIH_COOKIE_6_BASE_IDX 0
|
||||
#define regIH_COOKIE_7 0x0027
|
||||
#define regIH_COOKIE_7_BASE_IDX 0
|
||||
#define regIH_REGISTER_LAST_PART0 0x003f
|
||||
#define regIH_REGISTER_LAST_PART0_BASE_IDX 0
|
||||
#define regIH_RB_CNTL 0x0080
|
||||
#define regIH_RB_CNTL_BASE_IDX 0
|
||||
#define regIH_RB_BASE 0x0081
|
||||
#define regIH_RB_BASE_BASE_IDX 0
|
||||
#define regIH_RB_BASE_HI 0x0082
|
||||
#define regIH_RB_BASE_HI_BASE_IDX 0
|
||||
#define regIH_RB_RPTR 0x0083
|
||||
#define regIH_RB_RPTR_BASE_IDX 0
|
||||
#define regIH_RB_WPTR 0x0084
|
||||
#define regIH_RB_WPTR_BASE_IDX 0
|
||||
#define regIH_RB_WPTR_ADDR_HI 0x0085
|
||||
#define regIH_RB_WPTR_ADDR_HI_BASE_IDX 0
|
||||
#define regIH_RB_WPTR_ADDR_LO 0x0086
|
||||
#define regIH_RB_WPTR_ADDR_LO_BASE_IDX 0
|
||||
#define regIH_DOORBELL_RPTR 0x0087
|
||||
#define regIH_DOORBELL_RPTR_BASE_IDX 0
|
||||
#define regIH_DOORBELL_RETRY_CAM 0x0088
|
||||
#define regIH_DOORBELL_RETRY_CAM_BASE_IDX 0
|
||||
#define regIH_RB_CNTL_RING1 0x008c
|
||||
#define regIH_RB_CNTL_RING1_BASE_IDX 0
|
||||
#define regIH_RB_BASE_RING1 0x008d
|
||||
#define regIH_RB_BASE_RING1_BASE_IDX 0
|
||||
#define regIH_RB_BASE_HI_RING1 0x008e
|
||||
#define regIH_RB_BASE_HI_RING1_BASE_IDX 0
|
||||
#define regIH_RB_RPTR_RING1 0x008f
|
||||
#define regIH_RB_RPTR_RING1_BASE_IDX 0
|
||||
#define regIH_RB_WPTR_RING1 0x0090
|
||||
#define regIH_RB_WPTR_RING1_BASE_IDX 0
|
||||
#define regIH_DOORBELL_RPTR_RING1 0x0093
|
||||
#define regIH_DOORBELL_RPTR_RING1_BASE_IDX 0
|
||||
#define regIH_RETRY_CAM_ACK 0x00a4
|
||||
#define regIH_RETRY_CAM_ACK_BASE_IDX 0
|
||||
#define regIH_VERSION 0x00a5
|
||||
#define regIH_VERSION_BASE_IDX 0
|
||||
#define regIH_CNTL 0x00c0
|
||||
#define regIH_CNTL_BASE_IDX 0
|
||||
#define regIH_CNTL2 0x00c1
|
||||
#define regIH_CNTL2_BASE_IDX 0
|
||||
#define regIH_STATUS 0x00c2
|
||||
#define regIH_STATUS_BASE_IDX 0
|
||||
#define regIH_PERFMON_CNTL 0x00c3
|
||||
#define regIH_PERFMON_CNTL_BASE_IDX 0
|
||||
#define regIH_PERFCOUNTER0_RESULT 0x00c4
|
||||
#define regIH_PERFCOUNTER0_RESULT_BASE_IDX 0
|
||||
#define regIH_PERFCOUNTER1_RESULT 0x00c5
|
||||
#define regIH_PERFCOUNTER1_RESULT_BASE_IDX 0
|
||||
#define regIH_DSM_MATCH_VALUE_BIT_31_0 0x00c7
|
||||
#define regIH_DSM_MATCH_VALUE_BIT_31_0_BASE_IDX 0
|
||||
#define regIH_DSM_MATCH_VALUE_BIT_63_32 0x00c8
|
||||
#define regIH_DSM_MATCH_VALUE_BIT_63_32_BASE_IDX 0
|
||||
#define regIH_DSM_MATCH_VALUE_BIT_95_64 0x00c9
|
||||
#define regIH_DSM_MATCH_VALUE_BIT_95_64_BASE_IDX 0
|
||||
#define regIH_DSM_MATCH_FIELD_CONTROL 0x00ca
|
||||
#define regIH_DSM_MATCH_FIELD_CONTROL_BASE_IDX 0
|
||||
#define regIH_DSM_MATCH_DATA_CONTROL 0x00cb
|
||||
#define regIH_DSM_MATCH_DATA_CONTROL_BASE_IDX 0
|
||||
#define regIH_DSM_MATCH_FCN_ID 0x00cc
|
||||
#define regIH_DSM_MATCH_FCN_ID_BASE_IDX 0
|
||||
#define regIH_LIMIT_INT_RATE_CNTL 0x00cd
|
||||
#define regIH_LIMIT_INT_RATE_CNTL_BASE_IDX 0
|
||||
#define regIH_VF_RB_STATUS 0x00ce
|
||||
#define regIH_VF_RB_STATUS_BASE_IDX 0
|
||||
#define regIH_VF_RB_STATUS2 0x00cf
|
||||
#define regIH_VF_RB_STATUS2_BASE_IDX 0
|
||||
#define regIH_VF_RB1_STATUS 0x00d0
|
||||
#define regIH_VF_RB1_STATUS_BASE_IDX 0
|
||||
#define regIH_VF_RB1_STATUS2 0x00d1
|
||||
#define regIH_VF_RB1_STATUS2_BASE_IDX 0
|
||||
#define regIH_RB_STATUS 0x00d4
|
||||
#define regIH_RB_STATUS_BASE_IDX 0
|
||||
#define regIH_INT_FLOOD_CNTL 0x00d5
|
||||
#define regIH_INT_FLOOD_CNTL_BASE_IDX 0
|
||||
#define regIH_RB0_INT_FLOOD_STATUS 0x00d6
|
||||
#define regIH_RB0_INT_FLOOD_STATUS_BASE_IDX 0
|
||||
#define regIH_RB1_INT_FLOOD_STATUS 0x00d7
|
||||
#define regIH_RB1_INT_FLOOD_STATUS_BASE_IDX 0
|
||||
#define regIH_INT_FLOOD_STATUS 0x00d9
|
||||
#define regIH_INT_FLOOD_STATUS_BASE_IDX 0
|
||||
#define regIH_STORM_CLIENT_LIST_CNTL 0x00da
|
||||
#define regIH_STORM_CLIENT_LIST_CNTL_BASE_IDX 0
|
||||
#define regIH_CLK_CTRL 0x00db
|
||||
#define regIH_CLK_CTRL_BASE_IDX 0
|
||||
#define regIH_INT_FLAGS 0x00dc
|
||||
#define regIH_INT_FLAGS_BASE_IDX 0
|
||||
#define regIH_LAST_INT_INFO0 0x00dd
|
||||
#define regIH_LAST_INT_INFO0_BASE_IDX 0
|
||||
#define regIH_LAST_INT_INFO1 0x00de
|
||||
#define regIH_LAST_INT_INFO1_BASE_IDX 0
|
||||
#define regIH_LAST_INT_INFO2 0x00df
|
||||
#define regIH_LAST_INT_INFO2_BASE_IDX 0
|
||||
#define regIH_SCRATCH 0x00e0
|
||||
#define regIH_SCRATCH_BASE_IDX 0
|
||||
#define regIH_CLIENT_CREDIT_ERROR 0x00e1
|
||||
#define regIH_CLIENT_CREDIT_ERROR_BASE_IDX 0
|
||||
#define regIH_COOKIE_REC_VIOLATION_LOG 0x00e4
|
||||
#define regIH_COOKIE_REC_VIOLATION_LOG_BASE_IDX 0
|
||||
#define regIH_CREDIT_STATUS 0x00e5
|
||||
#define regIH_CREDIT_STATUS_BASE_IDX 0
|
||||
#define regIH_MMHUB_ERROR 0x00e6
|
||||
#define regIH_MMHUB_ERROR_BASE_IDX 0
|
||||
#define regIH_MEM_POWER_CTRL 0x00e9
|
||||
#define regIH_MEM_POWER_CTRL_BASE_IDX 0
|
||||
#define regIH_VF_RB_STATUS3 0x00ea
|
||||
#define regIH_VF_RB_STATUS3_BASE_IDX 0
|
||||
#define regIH_VF_RB_STATUS4 0x00eb
|
||||
#define regIH_VF_RB_STATUS4_BASE_IDX 0
|
||||
#define regIH_VF_RB1_STATUS3 0x00ec
|
||||
#define regIH_VF_RB1_STATUS3_BASE_IDX 0
|
||||
#define regIH_RETRY_INT_CAM_CNTL 0x00ef
|
||||
#define regIH_RETRY_INT_CAM_CNTL_BASE_IDX 0
|
||||
#define regIH_MEM_POWER_CTRL2 0x00f0
|
||||
#define regIH_MEM_POWER_CTRL2_BASE_IDX 0
|
||||
#define regIH_MSI_STORM_CTRL 0x00f1
|
||||
#define regIH_MSI_STORM_CTRL_BASE_IDX 0
|
||||
#define regIH_MSI_STORM_CLIENT_INDEX 0x00f2
|
||||
#define regIH_MSI_STORM_CLIENT_INDEX_BASE_IDX 0
|
||||
#define regIH_MSI_STORM_CLIENT_DATA 0x00f3
|
||||
#define regIH_MSI_STORM_CLIENT_DATA_BASE_IDX 0
|
||||
#define regIH_REGISTER_LAST_PART2 0x00ff
|
||||
#define regIH_REGISTER_LAST_PART2_BASE_IDX 0
|
||||
#define regSEM_MAILBOX 0x010a
|
||||
#define regSEM_MAILBOX_BASE_IDX 0
|
||||
#define regSEM_MAILBOX_CLEAR 0x010b
|
||||
#define regSEM_MAILBOX_CLEAR_BASE_IDX 0
|
||||
#define regSEM_REGISTER_LAST_PART2 0x017f
|
||||
#define regSEM_REGISTER_LAST_PART2_BASE_IDX 0
|
||||
#define regIH_CLIENT_CFG 0x0184
|
||||
#define regIH_CLIENT_CFG_BASE_IDX 0
|
||||
#define regIH_RING1_CLIENT_CFG_INDEX 0x0185
|
||||
#define regIH_RING1_CLIENT_CFG_INDEX_BASE_IDX 0
|
||||
#define regIH_RING1_CLIENT_CFG_DATA 0x0186
|
||||
#define regIH_RING1_CLIENT_CFG_DATA_BASE_IDX 0
|
||||
#define regIH_CLIENT_CFG_INDEX 0x0188
|
||||
#define regIH_CLIENT_CFG_INDEX_BASE_IDX 0
|
||||
#define regIH_CLIENT_CFG_DATA 0x0189
|
||||
#define regIH_CLIENT_CFG_DATA_BASE_IDX 0
|
||||
#define regIH_CID_REMAP_INDEX 0x018b
|
||||
#define regIH_CID_REMAP_INDEX_BASE_IDX 0
|
||||
#define regIH_CID_REMAP_DATA 0x018c
|
||||
#define regIH_CID_REMAP_DATA_BASE_IDX 0
|
||||
#define regIH_CHICKEN 0x018d
|
||||
#define regIH_CHICKEN_BASE_IDX 0
|
||||
#define regIH_INT_DROP_CNTL 0x018f
|
||||
#define regIH_INT_DROP_CNTL_BASE_IDX 0
|
||||
#define regIH_INT_DROP_MATCH_VALUE0 0x0190
|
||||
#define regIH_INT_DROP_MATCH_VALUE0_BASE_IDX 0
|
||||
#define regIH_INT_DROP_MATCH_VALUE1 0x0191
|
||||
#define regIH_INT_DROP_MATCH_VALUE1_BASE_IDX 0
|
||||
#define regIH_INT_DROP_MATCH_MASK0 0x0192
|
||||
#define regIH_INT_DROP_MATCH_MASK0_BASE_IDX 0
|
||||
#define regIH_INT_DROP_MATCH_MASK1 0x0193
|
||||
#define regIH_INT_DROP_MATCH_MASK1_BASE_IDX 0
|
||||
#define regIH_REGISTER_LAST_PART1 0x019f
|
||||
#define regIH_REGISTER_LAST_PART1_BASE_IDX 0
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,979 @@
|
||||
/*
|
||||
* Copyright 2021 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
#ifndef _osssys_6_0_0_SH_MASK_HEADER
|
||||
#define _osssys_6_0_0_SH_MASK_HEADER
|
||||
|
||||
|
||||
// addressBlock: osssys_osssysdec
|
||||
//IH_VMID_0_LUT
|
||||
#define IH_VMID_0_LUT__PASID__SHIFT 0x0
|
||||
#define IH_VMID_0_LUT__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_1_LUT
|
||||
#define IH_VMID_1_LUT__PASID__SHIFT 0x0
|
||||
#define IH_VMID_1_LUT__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_2_LUT
|
||||
#define IH_VMID_2_LUT__PASID__SHIFT 0x0
|
||||
#define IH_VMID_2_LUT__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_3_LUT
|
||||
#define IH_VMID_3_LUT__PASID__SHIFT 0x0
|
||||
#define IH_VMID_3_LUT__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_4_LUT
|
||||
#define IH_VMID_4_LUT__PASID__SHIFT 0x0
|
||||
#define IH_VMID_4_LUT__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_5_LUT
|
||||
#define IH_VMID_5_LUT__PASID__SHIFT 0x0
|
||||
#define IH_VMID_5_LUT__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_6_LUT
|
||||
#define IH_VMID_6_LUT__PASID__SHIFT 0x0
|
||||
#define IH_VMID_6_LUT__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_7_LUT
|
||||
#define IH_VMID_7_LUT__PASID__SHIFT 0x0
|
||||
#define IH_VMID_7_LUT__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_8_LUT
|
||||
#define IH_VMID_8_LUT__PASID__SHIFT 0x0
|
||||
#define IH_VMID_8_LUT__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_9_LUT
|
||||
#define IH_VMID_9_LUT__PASID__SHIFT 0x0
|
||||
#define IH_VMID_9_LUT__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_10_LUT
|
||||
#define IH_VMID_10_LUT__PASID__SHIFT 0x0
|
||||
#define IH_VMID_10_LUT__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_11_LUT
|
||||
#define IH_VMID_11_LUT__PASID__SHIFT 0x0
|
||||
#define IH_VMID_11_LUT__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_12_LUT
|
||||
#define IH_VMID_12_LUT__PASID__SHIFT 0x0
|
||||
#define IH_VMID_12_LUT__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_13_LUT
|
||||
#define IH_VMID_13_LUT__PASID__SHIFT 0x0
|
||||
#define IH_VMID_13_LUT__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_14_LUT
|
||||
#define IH_VMID_14_LUT__PASID__SHIFT 0x0
|
||||
#define IH_VMID_14_LUT__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_15_LUT
|
||||
#define IH_VMID_15_LUT__PASID__SHIFT 0x0
|
||||
#define IH_VMID_15_LUT__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_0_LUT_MM
|
||||
#define IH_VMID_0_LUT_MM__PASID__SHIFT 0x0
|
||||
#define IH_VMID_0_LUT_MM__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_1_LUT_MM
|
||||
#define IH_VMID_1_LUT_MM__PASID__SHIFT 0x0
|
||||
#define IH_VMID_1_LUT_MM__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_2_LUT_MM
|
||||
#define IH_VMID_2_LUT_MM__PASID__SHIFT 0x0
|
||||
#define IH_VMID_2_LUT_MM__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_3_LUT_MM
|
||||
#define IH_VMID_3_LUT_MM__PASID__SHIFT 0x0
|
||||
#define IH_VMID_3_LUT_MM__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_4_LUT_MM
|
||||
#define IH_VMID_4_LUT_MM__PASID__SHIFT 0x0
|
||||
#define IH_VMID_4_LUT_MM__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_5_LUT_MM
|
||||
#define IH_VMID_5_LUT_MM__PASID__SHIFT 0x0
|
||||
#define IH_VMID_5_LUT_MM__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_6_LUT_MM
|
||||
#define IH_VMID_6_LUT_MM__PASID__SHIFT 0x0
|
||||
#define IH_VMID_6_LUT_MM__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_7_LUT_MM
|
||||
#define IH_VMID_7_LUT_MM__PASID__SHIFT 0x0
|
||||
#define IH_VMID_7_LUT_MM__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_8_LUT_MM
|
||||
#define IH_VMID_8_LUT_MM__PASID__SHIFT 0x0
|
||||
#define IH_VMID_8_LUT_MM__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_9_LUT_MM
|
||||
#define IH_VMID_9_LUT_MM__PASID__SHIFT 0x0
|
||||
#define IH_VMID_9_LUT_MM__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_10_LUT_MM
|
||||
#define IH_VMID_10_LUT_MM__PASID__SHIFT 0x0
|
||||
#define IH_VMID_10_LUT_MM__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_11_LUT_MM
|
||||
#define IH_VMID_11_LUT_MM__PASID__SHIFT 0x0
|
||||
#define IH_VMID_11_LUT_MM__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_12_LUT_MM
|
||||
#define IH_VMID_12_LUT_MM__PASID__SHIFT 0x0
|
||||
#define IH_VMID_12_LUT_MM__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_13_LUT_MM
|
||||
#define IH_VMID_13_LUT_MM__PASID__SHIFT 0x0
|
||||
#define IH_VMID_13_LUT_MM__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_14_LUT_MM
|
||||
#define IH_VMID_14_LUT_MM__PASID__SHIFT 0x0
|
||||
#define IH_VMID_14_LUT_MM__PASID_MASK 0x0000FFFFL
|
||||
//IH_VMID_15_LUT_MM
|
||||
#define IH_VMID_15_LUT_MM__PASID__SHIFT 0x0
|
||||
#define IH_VMID_15_LUT_MM__PASID_MASK 0x0000FFFFL
|
||||
//IH_COOKIE_0
|
||||
#define IH_COOKIE_0__CLIENT_ID__SHIFT 0x0
|
||||
#define IH_COOKIE_0__SOURCE_ID__SHIFT 0x8
|
||||
#define IH_COOKIE_0__RING_ID__SHIFT 0x10
|
||||
#define IH_COOKIE_0__VM_ID__SHIFT 0x18
|
||||
#define IH_COOKIE_0__RESERVED__SHIFT 0x1c
|
||||
#define IH_COOKIE_0__VMID_TYPE__SHIFT 0x1f
|
||||
#define IH_COOKIE_0__CLIENT_ID_MASK 0x000000FFL
|
||||
#define IH_COOKIE_0__SOURCE_ID_MASK 0x0000FF00L
|
||||
#define IH_COOKIE_0__RING_ID_MASK 0x00FF0000L
|
||||
#define IH_COOKIE_0__VM_ID_MASK 0x0F000000L
|
||||
#define IH_COOKIE_0__RESERVED_MASK 0x70000000L
|
||||
#define IH_COOKIE_0__VMID_TYPE_MASK 0x80000000L
|
||||
//IH_COOKIE_1
|
||||
#define IH_COOKIE_1__TIMESTAMP_31_0__SHIFT 0x0
|
||||
#define IH_COOKIE_1__TIMESTAMP_31_0_MASK 0xFFFFFFFFL
|
||||
//IH_COOKIE_2
|
||||
#define IH_COOKIE_2__TIMESTAMP_47_32__SHIFT 0x0
|
||||
#define IH_COOKIE_2__RESERVED__SHIFT 0x10
|
||||
#define IH_COOKIE_2__TIMESTAMP_SRC__SHIFT 0x1f
|
||||
#define IH_COOKIE_2__TIMESTAMP_47_32_MASK 0x0000FFFFL
|
||||
#define IH_COOKIE_2__RESERVED_MASK 0x7FFF0000L
|
||||
#define IH_COOKIE_2__TIMESTAMP_SRC_MASK 0x80000000L
|
||||
//IH_COOKIE_3
|
||||
#define IH_COOKIE_3__PAS_ID__SHIFT 0x0
|
||||
#define IH_COOKIE_3__RESERVED__SHIFT 0x10
|
||||
#define IH_COOKIE_3__PASID_SRC__SHIFT 0x1f
|
||||
#define IH_COOKIE_3__PAS_ID_MASK 0x0000FFFFL
|
||||
#define IH_COOKIE_3__RESERVED_MASK 0x7FFF0000L
|
||||
#define IH_COOKIE_3__PASID_SRC_MASK 0x80000000L
|
||||
//IH_COOKIE_4
|
||||
#define IH_COOKIE_4__CONTEXT_ID_31_0__SHIFT 0x0
|
||||
#define IH_COOKIE_4__CONTEXT_ID_31_0_MASK 0xFFFFFFFFL
|
||||
//IH_COOKIE_5
|
||||
#define IH_COOKIE_5__CONTEXT_ID_63_32__SHIFT 0x0
|
||||
#define IH_COOKIE_5__CONTEXT_ID_63_32_MASK 0xFFFFFFFFL
|
||||
//IH_COOKIE_6
|
||||
#define IH_COOKIE_6__CONTEXT_ID_95_64__SHIFT 0x0
|
||||
#define IH_COOKIE_6__CONTEXT_ID_95_64_MASK 0xFFFFFFFFL
|
||||
//IH_COOKIE_7
|
||||
#define IH_COOKIE_7__CONTEXT_ID_128_96__SHIFT 0x0
|
||||
#define IH_COOKIE_7__CONTEXT_ID_128_96_MASK 0xFFFFFFFFL
|
||||
//IH_REGISTER_LAST_PART0
|
||||
#define IH_REGISTER_LAST_PART0__RESERVED__SHIFT 0x0
|
||||
#define IH_REGISTER_LAST_PART0__RESERVED_MASK 0xFFFFFFFFL
|
||||
//IH_RB_CNTL
|
||||
#define IH_RB_CNTL__RB_ENABLE__SHIFT 0x0
|
||||
#define IH_RB_CNTL__RB_SIZE__SHIFT 0x1
|
||||
#define IH_RB_CNTL__WPTR_WRITEBACK_ENABLE__SHIFT 0x8
|
||||
#define IH_RB_CNTL__RB_FULL_DRAIN_ENABLE__SHIFT 0x9
|
||||
#define IH_RB_CNTL__FULL_DRAIN_CLEAR__SHIFT 0xa
|
||||
#define IH_RB_CNTL__PAGE_RB_CLEAR__SHIFT 0xb
|
||||
#define IH_RB_CNTL__RB_USED_INT_THRESHOLD__SHIFT 0xc
|
||||
#define IH_RB_CNTL__WPTR_OVERFLOW_ENABLE__SHIFT 0x10
|
||||
#define IH_RB_CNTL__ENABLE_INTR__SHIFT 0x11
|
||||
#define IH_RB_CNTL__MC_SWAP__SHIFT 0x12
|
||||
#define IH_RB_CNTL__MC_SNOOP__SHIFT 0x14
|
||||
#define IH_RB_CNTL__RPTR_REARM__SHIFT 0x15
|
||||
#define IH_RB_CNTL__MC_RO__SHIFT 0x16
|
||||
#define IH_RB_CNTL__MC_VMID__SHIFT 0x18
|
||||
#define IH_RB_CNTL__MC_SPACE__SHIFT 0x1c
|
||||
#define IH_RB_CNTL__WPTR_OVERFLOW_CLEAR__SHIFT 0x1f
|
||||
#define IH_RB_CNTL__RB_ENABLE_MASK 0x00000001L
|
||||
#define IH_RB_CNTL__RB_SIZE_MASK 0x0000003EL
|
||||
#define IH_RB_CNTL__WPTR_WRITEBACK_ENABLE_MASK 0x00000100L
|
||||
#define IH_RB_CNTL__RB_FULL_DRAIN_ENABLE_MASK 0x00000200L
|
||||
#define IH_RB_CNTL__FULL_DRAIN_CLEAR_MASK 0x00000400L
|
||||
#define IH_RB_CNTL__PAGE_RB_CLEAR_MASK 0x00000800L
|
||||
#define IH_RB_CNTL__RB_USED_INT_THRESHOLD_MASK 0x0000F000L
|
||||
#define IH_RB_CNTL__WPTR_OVERFLOW_ENABLE_MASK 0x00010000L
|
||||
#define IH_RB_CNTL__ENABLE_INTR_MASK 0x00020000L
|
||||
#define IH_RB_CNTL__MC_SWAP_MASK 0x000C0000L
|
||||
#define IH_RB_CNTL__MC_SNOOP_MASK 0x00100000L
|
||||
#define IH_RB_CNTL__RPTR_REARM_MASK 0x00200000L
|
||||
#define IH_RB_CNTL__MC_RO_MASK 0x00400000L
|
||||
#define IH_RB_CNTL__MC_VMID_MASK 0x0F000000L
|
||||
#define IH_RB_CNTL__MC_SPACE_MASK 0x70000000L
|
||||
#define IH_RB_CNTL__WPTR_OVERFLOW_CLEAR_MASK 0x80000000L
|
||||
//IH_RB_BASE
|
||||
#define IH_RB_BASE__ADDR__SHIFT 0x0
|
||||
#define IH_RB_BASE__ADDR_MASK 0xFFFFFFFFL
|
||||
//IH_RB_BASE_HI
|
||||
#define IH_RB_BASE_HI__ADDR__SHIFT 0x0
|
||||
#define IH_RB_BASE_HI__ADDR_MASK 0x000000FFL
|
||||
//IH_RB_RPTR
|
||||
#define IH_RB_RPTR__OFFSET__SHIFT 0x2
|
||||
#define IH_RB_RPTR__OFFSET_MASK 0x0003FFFCL
|
||||
//IH_RB_WPTR
|
||||
#define IH_RB_WPTR__RB_OVERFLOW__SHIFT 0x0
|
||||
#define IH_RB_WPTR__OFFSET__SHIFT 0x2
|
||||
#define IH_RB_WPTR__RB_LEFT_NONE__SHIFT 0x12
|
||||
#define IH_RB_WPTR__RB_MAY_OVERFLOW__SHIFT 0x13
|
||||
#define IH_RB_WPTR__RB_OVERFLOW_MASK 0x00000001L
|
||||
#define IH_RB_WPTR__OFFSET_MASK 0x0003FFFCL
|
||||
#define IH_RB_WPTR__RB_LEFT_NONE_MASK 0x00040000L
|
||||
#define IH_RB_WPTR__RB_MAY_OVERFLOW_MASK 0x00080000L
|
||||
//IH_RB_WPTR_ADDR_HI
|
||||
#define IH_RB_WPTR_ADDR_HI__ADDR__SHIFT 0x0
|
||||
#define IH_RB_WPTR_ADDR_HI__ADDR_MASK 0x0000FFFFL
|
||||
//IH_RB_WPTR_ADDR_LO
|
||||
#define IH_RB_WPTR_ADDR_LO__ADDR__SHIFT 0x2
|
||||
#define IH_RB_WPTR_ADDR_LO__ADDR_MASK 0xFFFFFFFCL
|
||||
//IH_DOORBELL_RPTR
|
||||
#define IH_DOORBELL_RPTR__OFFSET__SHIFT 0x0
|
||||
#define IH_DOORBELL_RPTR__ENABLE__SHIFT 0x1c
|
||||
#define IH_DOORBELL_RPTR__OFFSET_MASK 0x03FFFFFFL
|
||||
#define IH_DOORBELL_RPTR__ENABLE_MASK 0x10000000L
|
||||
//IH_DOORBELL_RETRY_CAM
|
||||
#define IH_DOORBELL_RETRY_CAM__OFFSET__SHIFT 0x0
|
||||
#define IH_DOORBELL_RETRY_CAM__ENABLE__SHIFT 0x1c
|
||||
#define IH_DOORBELL_RETRY_CAM__OFFSET_MASK 0x03FFFFFFL
|
||||
#define IH_DOORBELL_RETRY_CAM__ENABLE_MASK 0x10000000L
|
||||
//IH_RB_CNTL_RING1
|
||||
#define IH_RB_CNTL_RING1__RB_ENABLE__SHIFT 0x0
|
||||
#define IH_RB_CNTL_RING1__RB_SIZE__SHIFT 0x1
|
||||
#define IH_RB_CNTL_RING1__RB_FULL_DRAIN_ENABLE__SHIFT 0x9
|
||||
#define IH_RB_CNTL_RING1__FULL_DRAIN_CLEAR__SHIFT 0xa
|
||||
#define IH_RB_CNTL_RING1__PAGE_RB_CLEAR__SHIFT 0xb
|
||||
#define IH_RB_CNTL_RING1__RB_USED_INT_THRESHOLD__SHIFT 0xc
|
||||
#define IH_RB_CNTL_RING1__WPTR_OVERFLOW_ENABLE__SHIFT 0x10
|
||||
#define IH_RB_CNTL_RING1__MC_SWAP__SHIFT 0x12
|
||||
#define IH_RB_CNTL_RING1__MC_SNOOP__SHIFT 0x14
|
||||
#define IH_RB_CNTL_RING1__MC_RO__SHIFT 0x16
|
||||
#define IH_RB_CNTL_RING1__MC_VMID__SHIFT 0x18
|
||||
#define IH_RB_CNTL_RING1__MC_SPACE__SHIFT 0x1c
|
||||
#define IH_RB_CNTL_RING1__WPTR_OVERFLOW_CLEAR__SHIFT 0x1f
|
||||
#define IH_RB_CNTL_RING1__RB_ENABLE_MASK 0x00000001L
|
||||
#define IH_RB_CNTL_RING1__RB_SIZE_MASK 0x0000003EL
|
||||
#define IH_RB_CNTL_RING1__RB_FULL_DRAIN_ENABLE_MASK 0x00000200L
|
||||
#define IH_RB_CNTL_RING1__FULL_DRAIN_CLEAR_MASK 0x00000400L
|
||||
#define IH_RB_CNTL_RING1__PAGE_RB_CLEAR_MASK 0x00000800L
|
||||
#define IH_RB_CNTL_RING1__RB_USED_INT_THRESHOLD_MASK 0x0000F000L
|
||||
#define IH_RB_CNTL_RING1__WPTR_OVERFLOW_ENABLE_MASK 0x00010000L
|
||||
#define IH_RB_CNTL_RING1__MC_SWAP_MASK 0x000C0000L
|
||||
#define IH_RB_CNTL_RING1__MC_SNOOP_MASK 0x00100000L
|
||||
#define IH_RB_CNTL_RING1__MC_RO_MASK 0x00400000L
|
||||
#define IH_RB_CNTL_RING1__MC_VMID_MASK 0x0F000000L
|
||||
#define IH_RB_CNTL_RING1__MC_SPACE_MASK 0x70000000L
|
||||
#define IH_RB_CNTL_RING1__WPTR_OVERFLOW_CLEAR_MASK 0x80000000L
|
||||
//IH_RB_BASE_RING1
|
||||
#define IH_RB_BASE_RING1__ADDR__SHIFT 0x0
|
||||
#define IH_RB_BASE_RING1__ADDR_MASK 0xFFFFFFFFL
|
||||
//IH_RB_BASE_HI_RING1
|
||||
#define IH_RB_BASE_HI_RING1__ADDR__SHIFT 0x0
|
||||
#define IH_RB_BASE_HI_RING1__ADDR_MASK 0x000000FFL
|
||||
//IH_RB_RPTR_RING1
|
||||
#define IH_RB_RPTR_RING1__OFFSET__SHIFT 0x2
|
||||
#define IH_RB_RPTR_RING1__OFFSET_MASK 0x0003FFFCL
|
||||
//IH_RB_WPTR_RING1
|
||||
#define IH_RB_WPTR_RING1__RB_OVERFLOW__SHIFT 0x0
|
||||
#define IH_RB_WPTR_RING1__OFFSET__SHIFT 0x2
|
||||
#define IH_RB_WPTR_RING1__RB_LEFT_NONE__SHIFT 0x12
|
||||
#define IH_RB_WPTR_RING1__RB_MAY_OVERFLOW__SHIFT 0x13
|
||||
#define IH_RB_WPTR_RING1__RB_OVERFLOW_MASK 0x00000001L
|
||||
#define IH_RB_WPTR_RING1__OFFSET_MASK 0x0003FFFCL
|
||||
#define IH_RB_WPTR_RING1__RB_LEFT_NONE_MASK 0x00040000L
|
||||
#define IH_RB_WPTR_RING1__RB_MAY_OVERFLOW_MASK 0x00080000L
|
||||
//IH_DOORBELL_RPTR_RING1
|
||||
#define IH_DOORBELL_RPTR_RING1__OFFSET__SHIFT 0x0
|
||||
#define IH_DOORBELL_RPTR_RING1__ENABLE__SHIFT 0x1c
|
||||
#define IH_DOORBELL_RPTR_RING1__OFFSET_MASK 0x03FFFFFFL
|
||||
#define IH_DOORBELL_RPTR_RING1__ENABLE_MASK 0x10000000L
|
||||
//IH_RETRY_CAM_ACK
|
||||
#define IH_RETRY_CAM_ACK__INDEX__SHIFT 0x0
|
||||
#define IH_RETRY_CAM_ACK__INDEX_MASK 0x000003FFL
|
||||
//IH_VERSION
|
||||
#define IH_VERSION__MINVER__SHIFT 0x0
|
||||
#define IH_VERSION__MAJVER__SHIFT 0x8
|
||||
#define IH_VERSION__REV__SHIFT 0x10
|
||||
#define IH_VERSION__MINVER_MASK 0x0000007FL
|
||||
#define IH_VERSION__MAJVER_MASK 0x00007F00L
|
||||
#define IH_VERSION__REV_MASK 0x003F0000L
|
||||
//IH_CNTL
|
||||
#define IH_CNTL__WPTR_WRITEBACK_TIMER__SHIFT 0x0
|
||||
#define IH_CNTL__IH_IDLE_HYSTERESIS_CNTL__SHIFT 0x6
|
||||
#define IH_CNTL__IH_FIFO_HIGHWATER__SHIFT 0x8
|
||||
#define IH_CNTL__MC_WR_CLEAN_CNT__SHIFT 0x14
|
||||
#define IH_CNTL__WPTR_WRITEBACK_TIMER_MASK 0x0000001FL
|
||||
#define IH_CNTL__IH_IDLE_HYSTERESIS_CNTL_MASK 0x000000C0L
|
||||
#define IH_CNTL__IH_FIFO_HIGHWATER_MASK 0x00007F00L
|
||||
#define IH_CNTL__MC_WR_CLEAN_CNT_MASK 0x01F00000L
|
||||
//IH_CNTL2
|
||||
#define IH_CNTL2__SELF_IV_FORCE_WPTR_UPDATE_TIMEOUT__SHIFT 0x0
|
||||
#define IH_CNTL2__SELF_IV_FORCE_WPTR_UPDATE_ENABLE__SHIFT 0x8
|
||||
#define IH_CNTL2__SELF_IV_FORCE_WPTR_UPDATE_TIMEOUT_MASK 0x0000001FL
|
||||
#define IH_CNTL2__SELF_IV_FORCE_WPTR_UPDATE_ENABLE_MASK 0x00000100L
|
||||
//IH_STATUS
|
||||
#define IH_STATUS__IDLE__SHIFT 0x0
|
||||
#define IH_STATUS__INPUT_IDLE__SHIFT 0x1
|
||||
#define IH_STATUS__BUFFER_IDLE__SHIFT 0x2
|
||||
#define IH_STATUS__RB_FULL__SHIFT 0x3
|
||||
#define IH_STATUS__RB_FULL_DRAIN__SHIFT 0x4
|
||||
#define IH_STATUS__RB_OVERFLOW__SHIFT 0x5
|
||||
#define IH_STATUS__MC_WR_IDLE__SHIFT 0x6
|
||||
#define IH_STATUS__MC_WR_STALL__SHIFT 0x7
|
||||
#define IH_STATUS__MC_WR_CLEAN_PENDING__SHIFT 0x8
|
||||
#define IH_STATUS__MC_WR_CLEAN_STALL__SHIFT 0x9
|
||||
#define IH_STATUS__BIF_INTERRUPT_LINE__SHIFT 0xa
|
||||
#define IH_STATUS__SWITCH_READY__SHIFT 0xb
|
||||
#define IH_STATUS__RB1_FULL__SHIFT 0xc
|
||||
#define IH_STATUS__RB1_FULL_DRAIN__SHIFT 0xd
|
||||
#define IH_STATUS__RB1_OVERFLOW__SHIFT 0xe
|
||||
#define IH_STATUS__SELF_INT_GEN_IDLE__SHIFT 0x12
|
||||
#define IH_STATUS__RETRY_INT_CAM_IDLE__SHIFT 0x13
|
||||
#define IH_STATUS__ZSTATES_FENCE__SHIFT 0x14
|
||||
#define IH_STATUS__IH_BUFFER_MEM_POWER_GATED__SHIFT 0x15
|
||||
#define IH_STATUS__IH_RETRY_INT_CAM_MEM_POWER_GATED__SHIFT 0x16
|
||||
#define IH_STATUS__IH_PASID_LUT_MEM_POWER_GATED__SHIFT 0x17
|
||||
#define IH_STATUS__IDLE_MASK 0x00000001L
|
||||
#define IH_STATUS__INPUT_IDLE_MASK 0x00000002L
|
||||
#define IH_STATUS__BUFFER_IDLE_MASK 0x00000004L
|
||||
#define IH_STATUS__RB_FULL_MASK 0x00000008L
|
||||
#define IH_STATUS__RB_FULL_DRAIN_MASK 0x00000010L
|
||||
#define IH_STATUS__RB_OVERFLOW_MASK 0x00000020L
|
||||
#define IH_STATUS__MC_WR_IDLE_MASK 0x00000040L
|
||||
#define IH_STATUS__MC_WR_STALL_MASK 0x00000080L
|
||||
#define IH_STATUS__MC_WR_CLEAN_PENDING_MASK 0x00000100L
|
||||
#define IH_STATUS__MC_WR_CLEAN_STALL_MASK 0x00000200L
|
||||
#define IH_STATUS__BIF_INTERRUPT_LINE_MASK 0x00000400L
|
||||
#define IH_STATUS__SWITCH_READY_MASK 0x00000800L
|
||||
#define IH_STATUS__RB1_FULL_MASK 0x00001000L
|
||||
#define IH_STATUS__RB1_FULL_DRAIN_MASK 0x00002000L
|
||||
#define IH_STATUS__RB1_OVERFLOW_MASK 0x00004000L
|
||||
#define IH_STATUS__SELF_INT_GEN_IDLE_MASK 0x00040000L
|
||||
#define IH_STATUS__RETRY_INT_CAM_IDLE_MASK 0x00080000L
|
||||
#define IH_STATUS__ZSTATES_FENCE_MASK 0x00100000L
|
||||
#define IH_STATUS__IH_BUFFER_MEM_POWER_GATED_MASK 0x00200000L
|
||||
#define IH_STATUS__IH_RETRY_INT_CAM_MEM_POWER_GATED_MASK 0x00400000L
|
||||
#define IH_STATUS__IH_PASID_LUT_MEM_POWER_GATED_MASK 0x00800000L
|
||||
//IH_PERFMON_CNTL
|
||||
#define IH_PERFMON_CNTL__ENABLE0__SHIFT 0x0
|
||||
#define IH_PERFMON_CNTL__CLEAR0__SHIFT 0x1
|
||||
#define IH_PERFMON_CNTL__PERF_SEL0__SHIFT 0x2
|
||||
#define IH_PERFMON_CNTL__ENABLE1__SHIFT 0x10
|
||||
#define IH_PERFMON_CNTL__CLEAR1__SHIFT 0x11
|
||||
#define IH_PERFMON_CNTL__PERF_SEL1__SHIFT 0x12
|
||||
#define IH_PERFMON_CNTL__ENABLE0_MASK 0x00000001L
|
||||
#define IH_PERFMON_CNTL__CLEAR0_MASK 0x00000002L
|
||||
#define IH_PERFMON_CNTL__PERF_SEL0_MASK 0x00000FFCL
|
||||
#define IH_PERFMON_CNTL__ENABLE1_MASK 0x00010000L
|
||||
#define IH_PERFMON_CNTL__CLEAR1_MASK 0x00020000L
|
||||
#define IH_PERFMON_CNTL__PERF_SEL1_MASK 0x0FFC0000L
|
||||
//IH_PERFCOUNTER0_RESULT
|
||||
#define IH_PERFCOUNTER0_RESULT__PERF_COUNT__SHIFT 0x0
|
||||
#define IH_PERFCOUNTER0_RESULT__PERF_COUNT_MASK 0xFFFFFFFFL
|
||||
//IH_PERFCOUNTER1_RESULT
|
||||
#define IH_PERFCOUNTER1_RESULT__PERF_COUNT__SHIFT 0x0
|
||||
#define IH_PERFCOUNTER1_RESULT__PERF_COUNT_MASK 0xFFFFFFFFL
|
||||
//IH_DSM_MATCH_VALUE_BIT_31_0
|
||||
#define IH_DSM_MATCH_VALUE_BIT_31_0__VALUE__SHIFT 0x0
|
||||
#define IH_DSM_MATCH_VALUE_BIT_31_0__VALUE_MASK 0xFFFFFFFFL
|
||||
//IH_DSM_MATCH_VALUE_BIT_63_32
|
||||
#define IH_DSM_MATCH_VALUE_BIT_63_32__VALUE__SHIFT 0x0
|
||||
#define IH_DSM_MATCH_VALUE_BIT_63_32__VALUE_MASK 0xFFFFFFFFL
|
||||
//IH_DSM_MATCH_VALUE_BIT_95_64
|
||||
#define IH_DSM_MATCH_VALUE_BIT_95_64__VALUE__SHIFT 0x0
|
||||
#define IH_DSM_MATCH_VALUE_BIT_95_64__VALUE_MASK 0xFFFFFFFFL
|
||||
//IH_DSM_MATCH_FIELD_CONTROL
|
||||
#define IH_DSM_MATCH_FIELD_CONTROL__SRC_EN__SHIFT 0x0
|
||||
#define IH_DSM_MATCH_FIELD_CONTROL__FCNID_EN__SHIFT 0x1
|
||||
#define IH_DSM_MATCH_FIELD_CONTROL__TIMESTAMP_EN__SHIFT 0x2
|
||||
#define IH_DSM_MATCH_FIELD_CONTROL__RINGID_EN__SHIFT 0x3
|
||||
#define IH_DSM_MATCH_FIELD_CONTROL__VMID_EN__SHIFT 0x4
|
||||
#define IH_DSM_MATCH_FIELD_CONTROL__PASID_EN__SHIFT 0x5
|
||||
#define IH_DSM_MATCH_FIELD_CONTROL__CLIENT_ID_EN__SHIFT 0x6
|
||||
#define IH_DSM_MATCH_FIELD_CONTROL__SRC_EN_MASK 0x00000001L
|
||||
#define IH_DSM_MATCH_FIELD_CONTROL__FCNID_EN_MASK 0x00000002L
|
||||
#define IH_DSM_MATCH_FIELD_CONTROL__TIMESTAMP_EN_MASK 0x00000004L
|
||||
#define IH_DSM_MATCH_FIELD_CONTROL__RINGID_EN_MASK 0x00000008L
|
||||
#define IH_DSM_MATCH_FIELD_CONTROL__VMID_EN_MASK 0x00000010L
|
||||
#define IH_DSM_MATCH_FIELD_CONTROL__PASID_EN_MASK 0x00000020L
|
||||
#define IH_DSM_MATCH_FIELD_CONTROL__CLIENT_ID_EN_MASK 0x00000040L
|
||||
//IH_DSM_MATCH_DATA_CONTROL
|
||||
#define IH_DSM_MATCH_DATA_CONTROL__VALUE__SHIFT 0x0
|
||||
#define IH_DSM_MATCH_DATA_CONTROL__VALUE_MASK 0x0FFFFFFFL
|
||||
//IH_DSM_MATCH_FCN_ID
|
||||
#define IH_DSM_MATCH_FCN_ID__VF_ID__SHIFT 0x0
|
||||
#define IH_DSM_MATCH_FCN_ID__PF_VF__SHIFT 0x7
|
||||
#define IH_DSM_MATCH_FCN_ID__VF_ID_MASK 0x0000000FL
|
||||
#define IH_DSM_MATCH_FCN_ID__PF_VF_MASK 0x00000080L
|
||||
//IH_LIMIT_INT_RATE_CNTL
|
||||
#define IH_LIMIT_INT_RATE_CNTL__LIMIT_ENABLE__SHIFT 0x0
|
||||
#define IH_LIMIT_INT_RATE_CNTL__PERF_INTERVAL__SHIFT 0x1
|
||||
#define IH_LIMIT_INT_RATE_CNTL__PERF_THRESHOLD__SHIFT 0x5
|
||||
#define IH_LIMIT_INT_RATE_CNTL__RETURN_DELAY__SHIFT 0x11
|
||||
#define IH_LIMIT_INT_RATE_CNTL__PERF_RESULT__SHIFT 0x15
|
||||
#define IH_LIMIT_INT_RATE_CNTL__LIMIT_ENABLE_MASK 0x00000001L
|
||||
#define IH_LIMIT_INT_RATE_CNTL__PERF_INTERVAL_MASK 0x0000001EL
|
||||
#define IH_LIMIT_INT_RATE_CNTL__PERF_THRESHOLD_MASK 0x0000FFE0L
|
||||
#define IH_LIMIT_INT_RATE_CNTL__RETURN_DELAY_MASK 0x001E0000L
|
||||
#define IH_LIMIT_INT_RATE_CNTL__PERF_RESULT_MASK 0xFFE00000L
|
||||
//IH_VF_RB_STATUS
|
||||
#define IH_VF_RB_STATUS__RB_FULL_DRAIN_VF__SHIFT 0x0
|
||||
#define IH_VF_RB_STATUS__RB_FULL_DRAIN_VF_MASK 0x0000FFFFL
|
||||
//IH_VF_RB_STATUS2
|
||||
#define IH_VF_RB_STATUS2__RB_FULL_VF__SHIFT 0x0
|
||||
#define IH_VF_RB_STATUS2__RB_FULL_VF_MASK 0x0000FFFFL
|
||||
//IH_VF_RB1_STATUS
|
||||
#define IH_VF_RB1_STATUS__RB_FULL_DRAIN_VF__SHIFT 0x0
|
||||
#define IH_VF_RB1_STATUS__RB_FULL_DRAIN_VF_MASK 0x0000FFFFL
|
||||
//IH_VF_RB1_STATUS2
|
||||
#define IH_VF_RB1_STATUS2__RB_FULL_VF__SHIFT 0x0
|
||||
#define IH_VF_RB1_STATUS2__RB_FULL_VF_MASK 0x0000FFFFL
|
||||
//IH_RB_STATUS
|
||||
#define IH_RB_STATUS__RB_FULL__SHIFT 0x0
|
||||
#define IH_RB_STATUS__RB_FULL_DRAIN__SHIFT 0x1
|
||||
#define IH_RB_STATUS__RB_OVERFLOW__SHIFT 0x2
|
||||
#define IH_RB_STATUS__RB1_FULL__SHIFT 0x4
|
||||
#define IH_RB_STATUS__RB1_FULL_DRAIN__SHIFT 0x5
|
||||
#define IH_RB_STATUS__RB1_OVERFLOW__SHIFT 0x6
|
||||
#define IH_RB_STATUS__RB_FULL_MASK 0x00000001L
|
||||
#define IH_RB_STATUS__RB_FULL_DRAIN_MASK 0x00000002L
|
||||
#define IH_RB_STATUS__RB_OVERFLOW_MASK 0x00000004L
|
||||
#define IH_RB_STATUS__RB1_FULL_MASK 0x00000010L
|
||||
#define IH_RB_STATUS__RB1_FULL_DRAIN_MASK 0x00000020L
|
||||
#define IH_RB_STATUS__RB1_OVERFLOW_MASK 0x00000040L
|
||||
//IH_INT_FLOOD_CNTL
|
||||
#define IH_INT_FLOOD_CNTL__HIGHWATER__SHIFT 0x0
|
||||
#define IH_INT_FLOOD_CNTL__FLOOD_CNTL_ENABLE__SHIFT 0x3
|
||||
#define IH_INT_FLOOD_CNTL__CLEAR_INT_FLOOD_STATUS__SHIFT 0x4
|
||||
#define IH_INT_FLOOD_CNTL__HIGHWATER_MASK 0x00000007L
|
||||
#define IH_INT_FLOOD_CNTL__FLOOD_CNTL_ENABLE_MASK 0x00000008L
|
||||
#define IH_INT_FLOOD_CNTL__CLEAR_INT_FLOOD_STATUS_MASK 0x00000010L
|
||||
//IH_RB0_INT_FLOOD_STATUS
|
||||
#define IH_RB0_INT_FLOOD_STATUS__RB_INT_DROPPED_VF__SHIFT 0x0
|
||||
#define IH_RB0_INT_FLOOD_STATUS__RB_INT_DROPPED__SHIFT 0x1f
|
||||
#define IH_RB0_INT_FLOOD_STATUS__RB_INT_DROPPED_VF_MASK 0x0000FFFFL
|
||||
#define IH_RB0_INT_FLOOD_STATUS__RB_INT_DROPPED_MASK 0x80000000L
|
||||
//IH_RB1_INT_FLOOD_STATUS
|
||||
#define IH_RB1_INT_FLOOD_STATUS__RB_INT_DROPPED_VF__SHIFT 0x0
|
||||
#define IH_RB1_INT_FLOOD_STATUS__RB_INT_DROPPED__SHIFT 0x1f
|
||||
#define IH_RB1_INT_FLOOD_STATUS__RB_INT_DROPPED_VF_MASK 0x0000FFFFL
|
||||
#define IH_RB1_INT_FLOOD_STATUS__RB_INT_DROPPED_MASK 0x80000000L
|
||||
//IH_INT_FLOOD_STATUS
|
||||
#define IH_INT_FLOOD_STATUS__INT_DROP_CNT__SHIFT 0x0
|
||||
#define IH_INT_FLOOD_STATUS__FIRST_DROP_INT_CLIENT_ID__SHIFT 0x8
|
||||
#define IH_INT_FLOOD_STATUS__FIRST_DROP_INT_SOURCE_ID__SHIFT 0x10
|
||||
#define IH_INT_FLOOD_STATUS__FIRST_DROP_INT_VF_ID__SHIFT 0x18
|
||||
#define IH_INT_FLOOD_STATUS__FIRST_DROP_INT_VF__SHIFT 0x1d
|
||||
#define IH_INT_FLOOD_STATUS__INT_DROPPED__SHIFT 0x1e
|
||||
#define IH_INT_FLOOD_STATUS__INT_DROP_CNT_MASK 0x000000FFL
|
||||
#define IH_INT_FLOOD_STATUS__FIRST_DROP_INT_CLIENT_ID_MASK 0x0000FF00L
|
||||
#define IH_INT_FLOOD_STATUS__FIRST_DROP_INT_SOURCE_ID_MASK 0x00FF0000L
|
||||
#define IH_INT_FLOOD_STATUS__FIRST_DROP_INT_VF_ID_MASK 0x0F000000L
|
||||
#define IH_INT_FLOOD_STATUS__FIRST_DROP_INT_VF_MASK 0x20000000L
|
||||
#define IH_INT_FLOOD_STATUS__INT_DROPPED_MASK 0x40000000L
|
||||
//IH_STORM_CLIENT_LIST_CNTL
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT1_IS_STORM_CLIENT__SHIFT 0x1
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT2_IS_STORM_CLIENT__SHIFT 0x2
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT3_IS_STORM_CLIENT__SHIFT 0x3
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT4_IS_STORM_CLIENT__SHIFT 0x4
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT5_IS_STORM_CLIENT__SHIFT 0x5
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT6_IS_STORM_CLIENT__SHIFT 0x6
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT7_IS_STORM_CLIENT__SHIFT 0x7
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT8_IS_STORM_CLIENT__SHIFT 0x8
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT9_IS_STORM_CLIENT__SHIFT 0x9
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT10_IS_STORM_CLIENT__SHIFT 0xa
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT11_IS_STORM_CLIENT__SHIFT 0xb
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT12_IS_STORM_CLIENT__SHIFT 0xc
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT13_IS_STORM_CLIENT__SHIFT 0xd
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT14_IS_STORM_CLIENT__SHIFT 0xe
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT15_IS_STORM_CLIENT__SHIFT 0xf
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT16_IS_STORM_CLIENT__SHIFT 0x10
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT17_IS_STORM_CLIENT__SHIFT 0x11
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT18_IS_STORM_CLIENT__SHIFT 0x12
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT19_IS_STORM_CLIENT__SHIFT 0x13
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT20_IS_STORM_CLIENT__SHIFT 0x14
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT21_IS_STORM_CLIENT__SHIFT 0x15
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT22_IS_STORM_CLIENT__SHIFT 0x16
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT23_IS_STORM_CLIENT__SHIFT 0x17
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT24_IS_STORM_CLIENT__SHIFT 0x18
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT25_IS_STORM_CLIENT__SHIFT 0x19
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT26_IS_STORM_CLIENT__SHIFT 0x1a
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT27_IS_STORM_CLIENT__SHIFT 0x1b
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT28_IS_STORM_CLIENT__SHIFT 0x1c
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT29_IS_STORM_CLIENT__SHIFT 0x1d
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT30_IS_STORM_CLIENT__SHIFT 0x1e
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT31_IS_STORM_CLIENT__SHIFT 0x1f
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT1_IS_STORM_CLIENT_MASK 0x00000002L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT2_IS_STORM_CLIENT_MASK 0x00000004L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT3_IS_STORM_CLIENT_MASK 0x00000008L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT4_IS_STORM_CLIENT_MASK 0x00000010L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT5_IS_STORM_CLIENT_MASK 0x00000020L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT6_IS_STORM_CLIENT_MASK 0x00000040L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT7_IS_STORM_CLIENT_MASK 0x00000080L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT8_IS_STORM_CLIENT_MASK 0x00000100L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT9_IS_STORM_CLIENT_MASK 0x00000200L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT10_IS_STORM_CLIENT_MASK 0x00000400L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT11_IS_STORM_CLIENT_MASK 0x00000800L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT12_IS_STORM_CLIENT_MASK 0x00001000L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT13_IS_STORM_CLIENT_MASK 0x00002000L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT14_IS_STORM_CLIENT_MASK 0x00004000L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT15_IS_STORM_CLIENT_MASK 0x00008000L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT16_IS_STORM_CLIENT_MASK 0x00010000L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT17_IS_STORM_CLIENT_MASK 0x00020000L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT18_IS_STORM_CLIENT_MASK 0x00040000L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT19_IS_STORM_CLIENT_MASK 0x00080000L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT20_IS_STORM_CLIENT_MASK 0x00100000L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT21_IS_STORM_CLIENT_MASK 0x00200000L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT22_IS_STORM_CLIENT_MASK 0x00400000L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT23_IS_STORM_CLIENT_MASK 0x00800000L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT24_IS_STORM_CLIENT_MASK 0x01000000L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT25_IS_STORM_CLIENT_MASK 0x02000000L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT26_IS_STORM_CLIENT_MASK 0x04000000L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT27_IS_STORM_CLIENT_MASK 0x08000000L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT28_IS_STORM_CLIENT_MASK 0x10000000L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT29_IS_STORM_CLIENT_MASK 0x20000000L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT30_IS_STORM_CLIENT_MASK 0x40000000L
|
||||
#define IH_STORM_CLIENT_LIST_CNTL__CLIENT31_IS_STORM_CLIENT_MASK 0x80000000L
|
||||
//IH_CLK_CTRL
|
||||
#define IH_CLK_CTRL__IH_PASID_LUT_MEM_CLK_SOFT_OVERRIDE__SHIFT 0x17
|
||||
#define IH_CLK_CTRL__MSI_STORM_COUNTER_CLK_SOFT_OVERRIDE__SHIFT 0x18
|
||||
#define IH_CLK_CTRL__IH_RETRY_INT_CAM_MEM_CLK_SOFT_OVERRIDE__SHIFT 0x19
|
||||
#define IH_CLK_CTRL__IH_BUFFER_MEM_CLK_SOFT_OVERRIDE__SHIFT 0x1a
|
||||
#define IH_CLK_CTRL__DBUS_MUX_CLK_SOFT_OVERRIDE__SHIFT 0x1b
|
||||
#define IH_CLK_CTRL__OSSSYS_SHARE_CLK_SOFT_OVERRIDE__SHIFT 0x1c
|
||||
#define IH_CLK_CTRL__LIMIT_SMN_CLK_SOFT_OVERRIDE__SHIFT 0x1d
|
||||
#define IH_CLK_CTRL__DYN_CLK_SOFT_OVERRIDE__SHIFT 0x1e
|
||||
#define IH_CLK_CTRL__REG_CLK_SOFT_OVERRIDE__SHIFT 0x1f
|
||||
#define IH_CLK_CTRL__IH_PASID_LUT_MEM_CLK_SOFT_OVERRIDE_MASK 0x00800000L
|
||||
#define IH_CLK_CTRL__MSI_STORM_COUNTER_CLK_SOFT_OVERRIDE_MASK 0x01000000L
|
||||
#define IH_CLK_CTRL__IH_RETRY_INT_CAM_MEM_CLK_SOFT_OVERRIDE_MASK 0x02000000L
|
||||
#define IH_CLK_CTRL__IH_BUFFER_MEM_CLK_SOFT_OVERRIDE_MASK 0x04000000L
|
||||
#define IH_CLK_CTRL__DBUS_MUX_CLK_SOFT_OVERRIDE_MASK 0x08000000L
|
||||
#define IH_CLK_CTRL__OSSSYS_SHARE_CLK_SOFT_OVERRIDE_MASK 0x10000000L
|
||||
#define IH_CLK_CTRL__LIMIT_SMN_CLK_SOFT_OVERRIDE_MASK 0x20000000L
|
||||
#define IH_CLK_CTRL__DYN_CLK_SOFT_OVERRIDE_MASK 0x40000000L
|
||||
#define IH_CLK_CTRL__REG_CLK_SOFT_OVERRIDE_MASK 0x80000000L
|
||||
//IH_INT_FLAGS
|
||||
#define IH_INT_FLAGS__CLIENT_0_FLAG__SHIFT 0x0
|
||||
#define IH_INT_FLAGS__CLIENT_1_FLAG__SHIFT 0x1
|
||||
#define IH_INT_FLAGS__CLIENT_2_FLAG__SHIFT 0x2
|
||||
#define IH_INT_FLAGS__CLIENT_3_FLAG__SHIFT 0x3
|
||||
#define IH_INT_FLAGS__CLIENT_4_FLAG__SHIFT 0x4
|
||||
#define IH_INT_FLAGS__CLIENT_5_FLAG__SHIFT 0x5
|
||||
#define IH_INT_FLAGS__CLIENT_6_FLAG__SHIFT 0x6
|
||||
#define IH_INT_FLAGS__CLIENT_7_FLAG__SHIFT 0x7
|
||||
#define IH_INT_FLAGS__CLIENT_8_FLAG__SHIFT 0x8
|
||||
#define IH_INT_FLAGS__CLIENT_9_FLAG__SHIFT 0x9
|
||||
#define IH_INT_FLAGS__CLIENT_10_FLAG__SHIFT 0xa
|
||||
#define IH_INT_FLAGS__CLIENT_11_FLAG__SHIFT 0xb
|
||||
#define IH_INT_FLAGS__CLIENT_12_FLAG__SHIFT 0xc
|
||||
#define IH_INT_FLAGS__CLIENT_13_FLAG__SHIFT 0xd
|
||||
#define IH_INT_FLAGS__CLIENT_14_FLAG__SHIFT 0xe
|
||||
#define IH_INT_FLAGS__CLIENT_15_FLAG__SHIFT 0xf
|
||||
#define IH_INT_FLAGS__CLIENT_16_FLAG__SHIFT 0x10
|
||||
#define IH_INT_FLAGS__CLIENT_17_FLAG__SHIFT 0x11
|
||||
#define IH_INT_FLAGS__CLIENT_18_FLAG__SHIFT 0x12
|
||||
#define IH_INT_FLAGS__CLIENT_19_FLAG__SHIFT 0x13
|
||||
#define IH_INT_FLAGS__CLIENT_20_FLAG__SHIFT 0x14
|
||||
#define IH_INT_FLAGS__CLIENT_21_FLAG__SHIFT 0x15
|
||||
#define IH_INT_FLAGS__CLIENT_22_FLAG__SHIFT 0x16
|
||||
#define IH_INT_FLAGS__CLIENT_23_FLAG__SHIFT 0x17
|
||||
#define IH_INT_FLAGS__CLIENT_24_FLAG__SHIFT 0x18
|
||||
#define IH_INT_FLAGS__CLIENT_25_FLAG__SHIFT 0x19
|
||||
#define IH_INT_FLAGS__CLIENT_26_FLAG__SHIFT 0x1a
|
||||
#define IH_INT_FLAGS__CLIENT_27_FLAG__SHIFT 0x1b
|
||||
#define IH_INT_FLAGS__CLIENT_28_FLAG__SHIFT 0x1c
|
||||
#define IH_INT_FLAGS__CLIENT_29_FLAG__SHIFT 0x1d
|
||||
#define IH_INT_FLAGS__CLIENT_30_FLAG__SHIFT 0x1e
|
||||
#define IH_INT_FLAGS__CLIENT_31_FLAG__SHIFT 0x1f
|
||||
#define IH_INT_FLAGS__CLIENT_0_FLAG_MASK 0x00000001L
|
||||
#define IH_INT_FLAGS__CLIENT_1_FLAG_MASK 0x00000002L
|
||||
#define IH_INT_FLAGS__CLIENT_2_FLAG_MASK 0x00000004L
|
||||
#define IH_INT_FLAGS__CLIENT_3_FLAG_MASK 0x00000008L
|
||||
#define IH_INT_FLAGS__CLIENT_4_FLAG_MASK 0x00000010L
|
||||
#define IH_INT_FLAGS__CLIENT_5_FLAG_MASK 0x00000020L
|
||||
#define IH_INT_FLAGS__CLIENT_6_FLAG_MASK 0x00000040L
|
||||
#define IH_INT_FLAGS__CLIENT_7_FLAG_MASK 0x00000080L
|
||||
#define IH_INT_FLAGS__CLIENT_8_FLAG_MASK 0x00000100L
|
||||
#define IH_INT_FLAGS__CLIENT_9_FLAG_MASK 0x00000200L
|
||||
#define IH_INT_FLAGS__CLIENT_10_FLAG_MASK 0x00000400L
|
||||
#define IH_INT_FLAGS__CLIENT_11_FLAG_MASK 0x00000800L
|
||||
#define IH_INT_FLAGS__CLIENT_12_FLAG_MASK 0x00001000L
|
||||
#define IH_INT_FLAGS__CLIENT_13_FLAG_MASK 0x00002000L
|
||||
#define IH_INT_FLAGS__CLIENT_14_FLAG_MASK 0x00004000L
|
||||
#define IH_INT_FLAGS__CLIENT_15_FLAG_MASK 0x00008000L
|
||||
#define IH_INT_FLAGS__CLIENT_16_FLAG_MASK 0x00010000L
|
||||
#define IH_INT_FLAGS__CLIENT_17_FLAG_MASK 0x00020000L
|
||||
#define IH_INT_FLAGS__CLIENT_18_FLAG_MASK 0x00040000L
|
||||
#define IH_INT_FLAGS__CLIENT_19_FLAG_MASK 0x00080000L
|
||||
#define IH_INT_FLAGS__CLIENT_20_FLAG_MASK 0x00100000L
|
||||
#define IH_INT_FLAGS__CLIENT_21_FLAG_MASK 0x00200000L
|
||||
#define IH_INT_FLAGS__CLIENT_22_FLAG_MASK 0x00400000L
|
||||
#define IH_INT_FLAGS__CLIENT_23_FLAG_MASK 0x00800000L
|
||||
#define IH_INT_FLAGS__CLIENT_24_FLAG_MASK 0x01000000L
|
||||
#define IH_INT_FLAGS__CLIENT_25_FLAG_MASK 0x02000000L
|
||||
#define IH_INT_FLAGS__CLIENT_26_FLAG_MASK 0x04000000L
|
||||
#define IH_INT_FLAGS__CLIENT_27_FLAG_MASK 0x08000000L
|
||||
#define IH_INT_FLAGS__CLIENT_28_FLAG_MASK 0x10000000L
|
||||
#define IH_INT_FLAGS__CLIENT_29_FLAG_MASK 0x20000000L
|
||||
#define IH_INT_FLAGS__CLIENT_30_FLAG_MASK 0x40000000L
|
||||
#define IH_INT_FLAGS__CLIENT_31_FLAG_MASK 0x80000000L
|
||||
//IH_LAST_INT_INFO0
|
||||
#define IH_LAST_INT_INFO0__CLIENT_ID__SHIFT 0x0
|
||||
#define IH_LAST_INT_INFO0__SOURCE_ID__SHIFT 0x8
|
||||
#define IH_LAST_INT_INFO0__RING_ID__SHIFT 0x10
|
||||
#define IH_LAST_INT_INFO0__VM_ID__SHIFT 0x18
|
||||
#define IH_LAST_INT_INFO0__VMID_TYPE__SHIFT 0x1f
|
||||
#define IH_LAST_INT_INFO0__CLIENT_ID_MASK 0x000000FFL
|
||||
#define IH_LAST_INT_INFO0__SOURCE_ID_MASK 0x0000FF00L
|
||||
#define IH_LAST_INT_INFO0__RING_ID_MASK 0x00FF0000L
|
||||
#define IH_LAST_INT_INFO0__VM_ID_MASK 0x0F000000L
|
||||
#define IH_LAST_INT_INFO0__VMID_TYPE_MASK 0x80000000L
|
||||
//IH_LAST_INT_INFO1
|
||||
#define IH_LAST_INT_INFO1__CONTEXT_ID__SHIFT 0x0
|
||||
#define IH_LAST_INT_INFO1__CONTEXT_ID_MASK 0xFFFFFFFFL
|
||||
//IH_LAST_INT_INFO2
|
||||
#define IH_LAST_INT_INFO2__PAS_ID__SHIFT 0x0
|
||||
#define IH_LAST_INT_INFO2__VF_ID__SHIFT 0x10
|
||||
#define IH_LAST_INT_INFO2__VF__SHIFT 0x17
|
||||
#define IH_LAST_INT_INFO2__PAS_ID_MASK 0x0000FFFFL
|
||||
#define IH_LAST_INT_INFO2__VF_ID_MASK 0x000F0000L
|
||||
#define IH_LAST_INT_INFO2__VF_MASK 0x00800000L
|
||||
//IH_SCRATCH
|
||||
#define IH_SCRATCH__DATA__SHIFT 0x0
|
||||
#define IH_SCRATCH__DATA_MASK 0xFFFFFFFFL
|
||||
//IH_CLIENT_CREDIT_ERROR
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLEAR__SHIFT 0x0
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_1_ERROR__SHIFT 0x1
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_2_ERROR__SHIFT 0x2
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_3_ERROR__SHIFT 0x3
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_4_ERROR__SHIFT 0x4
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_5_ERROR__SHIFT 0x5
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_6_ERROR__SHIFT 0x6
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_7_ERROR__SHIFT 0x7
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_8_ERROR__SHIFT 0x8
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_9_ERROR__SHIFT 0x9
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_10_ERROR__SHIFT 0xa
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_11_ERROR__SHIFT 0xb
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_12_ERROR__SHIFT 0xc
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_13_ERROR__SHIFT 0xd
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_14_ERROR__SHIFT 0xe
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_15_ERROR__SHIFT 0xf
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_16_ERROR__SHIFT 0x10
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_17_ERROR__SHIFT 0x11
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_18_ERROR__SHIFT 0x12
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_19_ERROR__SHIFT 0x13
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_20_ERROR__SHIFT 0x14
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_21_ERROR__SHIFT 0x15
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_22_ERROR__SHIFT 0x16
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_23_ERROR__SHIFT 0x17
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_24_ERROR__SHIFT 0x18
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_25_ERROR__SHIFT 0x19
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_26_ERROR__SHIFT 0x1a
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_27_ERROR__SHIFT 0x1b
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_28_ERROR__SHIFT 0x1c
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_29_ERROR__SHIFT 0x1d
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_30_ERROR__SHIFT 0x1e
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_31_ERROR__SHIFT 0x1f
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLEAR_MASK 0x00000001L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_1_ERROR_MASK 0x00000002L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_2_ERROR_MASK 0x00000004L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_3_ERROR_MASK 0x00000008L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_4_ERROR_MASK 0x00000010L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_5_ERROR_MASK 0x00000020L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_6_ERROR_MASK 0x00000040L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_7_ERROR_MASK 0x00000080L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_8_ERROR_MASK 0x00000100L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_9_ERROR_MASK 0x00000200L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_10_ERROR_MASK 0x00000400L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_11_ERROR_MASK 0x00000800L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_12_ERROR_MASK 0x00001000L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_13_ERROR_MASK 0x00002000L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_14_ERROR_MASK 0x00004000L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_15_ERROR_MASK 0x00008000L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_16_ERROR_MASK 0x00010000L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_17_ERROR_MASK 0x00020000L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_18_ERROR_MASK 0x00040000L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_19_ERROR_MASK 0x00080000L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_20_ERROR_MASK 0x00100000L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_21_ERROR_MASK 0x00200000L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_22_ERROR_MASK 0x00400000L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_23_ERROR_MASK 0x00800000L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_24_ERROR_MASK 0x01000000L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_25_ERROR_MASK 0x02000000L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_26_ERROR_MASK 0x04000000L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_27_ERROR_MASK 0x08000000L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_28_ERROR_MASK 0x10000000L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_29_ERROR_MASK 0x20000000L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_30_ERROR_MASK 0x40000000L
|
||||
#define IH_CLIENT_CREDIT_ERROR__CLIENT_31_ERROR_MASK 0x80000000L
|
||||
//IH_COOKIE_REC_VIOLATION_LOG
|
||||
#define IH_COOKIE_REC_VIOLATION_LOG__VIOLATION_STATUS__SHIFT 0x0
|
||||
#define IH_COOKIE_REC_VIOLATION_LOG__CLIENT_ID__SHIFT 0x8
|
||||
#define IH_COOKIE_REC_VIOLATION_LOG__INITIATOR_ID__SHIFT 0x10
|
||||
#define IH_COOKIE_REC_VIOLATION_LOG__VIOLATION_STATUS_MASK 0x00000001L
|
||||
#define IH_COOKIE_REC_VIOLATION_LOG__CLIENT_ID_MASK 0x0000FF00L
|
||||
#define IH_COOKIE_REC_VIOLATION_LOG__INITIATOR_ID_MASK 0x03FF0000L
|
||||
//IH_CREDIT_STATUS
|
||||
#define IH_CREDIT_STATUS__CLIENT_1_CREDIT_RETURNED__SHIFT 0x1
|
||||
#define IH_CREDIT_STATUS__CLIENT_2_CREDIT_RETURNED__SHIFT 0x2
|
||||
#define IH_CREDIT_STATUS__CLIENT_3_CREDIT_RETURNED__SHIFT 0x3
|
||||
#define IH_CREDIT_STATUS__CLIENT_4_CREDIT_RETURNED__SHIFT 0x4
|
||||
#define IH_CREDIT_STATUS__CLIENT_5_CREDIT_RETURNED__SHIFT 0x5
|
||||
#define IH_CREDIT_STATUS__CLIENT_6_CREDIT_RETURNED__SHIFT 0x6
|
||||
#define IH_CREDIT_STATUS__CLIENT_7_CREDIT_RETURNED__SHIFT 0x7
|
||||
#define IH_CREDIT_STATUS__CLIENT_8_CREDIT_RETURNED__SHIFT 0x8
|
||||
#define IH_CREDIT_STATUS__CLIENT_9_CREDIT_RETURNED__SHIFT 0x9
|
||||
#define IH_CREDIT_STATUS__CLIENT_10_CREDIT_RETURNED__SHIFT 0xa
|
||||
#define IH_CREDIT_STATUS__CLIENT_11_CREDIT_RETURNED__SHIFT 0xb
|
||||
#define IH_CREDIT_STATUS__CLIENT_12_CREDIT_RETURNED__SHIFT 0xc
|
||||
#define IH_CREDIT_STATUS__CLIENT_13_CREDIT_RETURNED__SHIFT 0xd
|
||||
#define IH_CREDIT_STATUS__CLIENT_14_CREDIT_RETURNED__SHIFT 0xe
|
||||
#define IH_CREDIT_STATUS__CLIENT_15_CREDIT_RETURNED__SHIFT 0xf
|
||||
#define IH_CREDIT_STATUS__CLIENT_16_CREDIT_RETURNED__SHIFT 0x10
|
||||
#define IH_CREDIT_STATUS__CLIENT_17_CREDIT_RETURNED__SHIFT 0x11
|
||||
#define IH_CREDIT_STATUS__CLIENT_18_CREDIT_RETURNED__SHIFT 0x12
|
||||
#define IH_CREDIT_STATUS__CLIENT_19_CREDIT_RETURNED__SHIFT 0x13
|
||||
#define IH_CREDIT_STATUS__CLIENT_20_CREDIT_RETURNED__SHIFT 0x14
|
||||
#define IH_CREDIT_STATUS__CLIENT_21_CREDIT_RETURNED__SHIFT 0x15
|
||||
#define IH_CREDIT_STATUS__CLIENT_22_CREDIT_RETURNED__SHIFT 0x16
|
||||
#define IH_CREDIT_STATUS__CLIENT_23_CREDIT_RETURNED__SHIFT 0x17
|
||||
#define IH_CREDIT_STATUS__CLIENT_24_CREDIT_RETURNED__SHIFT 0x18
|
||||
#define IH_CREDIT_STATUS__CLIENT_25_CREDIT_RETURNED__SHIFT 0x19
|
||||
#define IH_CREDIT_STATUS__CLIENT_26_CREDIT_RETURNED__SHIFT 0x1a
|
||||
#define IH_CREDIT_STATUS__CLIENT_27_CREDIT_RETURNED__SHIFT 0x1b
|
||||
#define IH_CREDIT_STATUS__CLIENT_28_CREDIT_RETURNED__SHIFT 0x1c
|
||||
#define IH_CREDIT_STATUS__CLIENT_29_CREDIT_RETURNED__SHIFT 0x1d
|
||||
#define IH_CREDIT_STATUS__CLIENT_30_CREDIT_RETURNED__SHIFT 0x1e
|
||||
#define IH_CREDIT_STATUS__CLIENT_31_CREDIT_RETURNED__SHIFT 0x1f
|
||||
#define IH_CREDIT_STATUS__CLIENT_1_CREDIT_RETURNED_MASK 0x00000002L
|
||||
#define IH_CREDIT_STATUS__CLIENT_2_CREDIT_RETURNED_MASK 0x00000004L
|
||||
#define IH_CREDIT_STATUS__CLIENT_3_CREDIT_RETURNED_MASK 0x00000008L
|
||||
#define IH_CREDIT_STATUS__CLIENT_4_CREDIT_RETURNED_MASK 0x00000010L
|
||||
#define IH_CREDIT_STATUS__CLIENT_5_CREDIT_RETURNED_MASK 0x00000020L
|
||||
#define IH_CREDIT_STATUS__CLIENT_6_CREDIT_RETURNED_MASK 0x00000040L
|
||||
#define IH_CREDIT_STATUS__CLIENT_7_CREDIT_RETURNED_MASK 0x00000080L
|
||||
#define IH_CREDIT_STATUS__CLIENT_8_CREDIT_RETURNED_MASK 0x00000100L
|
||||
#define IH_CREDIT_STATUS__CLIENT_9_CREDIT_RETURNED_MASK 0x00000200L
|
||||
#define IH_CREDIT_STATUS__CLIENT_10_CREDIT_RETURNED_MASK 0x00000400L
|
||||
#define IH_CREDIT_STATUS__CLIENT_11_CREDIT_RETURNED_MASK 0x00000800L
|
||||
#define IH_CREDIT_STATUS__CLIENT_12_CREDIT_RETURNED_MASK 0x00001000L
|
||||
#define IH_CREDIT_STATUS__CLIENT_13_CREDIT_RETURNED_MASK 0x00002000L
|
||||
#define IH_CREDIT_STATUS__CLIENT_14_CREDIT_RETURNED_MASK 0x00004000L
|
||||
#define IH_CREDIT_STATUS__CLIENT_15_CREDIT_RETURNED_MASK 0x00008000L
|
||||
#define IH_CREDIT_STATUS__CLIENT_16_CREDIT_RETURNED_MASK 0x00010000L
|
||||
#define IH_CREDIT_STATUS__CLIENT_17_CREDIT_RETURNED_MASK 0x00020000L
|
||||
#define IH_CREDIT_STATUS__CLIENT_18_CREDIT_RETURNED_MASK 0x00040000L
|
||||
#define IH_CREDIT_STATUS__CLIENT_19_CREDIT_RETURNED_MASK 0x00080000L
|
||||
#define IH_CREDIT_STATUS__CLIENT_20_CREDIT_RETURNED_MASK 0x00100000L
|
||||
#define IH_CREDIT_STATUS__CLIENT_21_CREDIT_RETURNED_MASK 0x00200000L
|
||||
#define IH_CREDIT_STATUS__CLIENT_22_CREDIT_RETURNED_MASK 0x00400000L
|
||||
#define IH_CREDIT_STATUS__CLIENT_23_CREDIT_RETURNED_MASK 0x00800000L
|
||||
#define IH_CREDIT_STATUS__CLIENT_24_CREDIT_RETURNED_MASK 0x01000000L
|
||||
#define IH_CREDIT_STATUS__CLIENT_25_CREDIT_RETURNED_MASK 0x02000000L
|
||||
#define IH_CREDIT_STATUS__CLIENT_26_CREDIT_RETURNED_MASK 0x04000000L
|
||||
#define IH_CREDIT_STATUS__CLIENT_27_CREDIT_RETURNED_MASK 0x08000000L
|
||||
#define IH_CREDIT_STATUS__CLIENT_28_CREDIT_RETURNED_MASK 0x10000000L
|
||||
#define IH_CREDIT_STATUS__CLIENT_29_CREDIT_RETURNED_MASK 0x20000000L
|
||||
#define IH_CREDIT_STATUS__CLIENT_30_CREDIT_RETURNED_MASK 0x40000000L
|
||||
#define IH_CREDIT_STATUS__CLIENT_31_CREDIT_RETURNED_MASK 0x80000000L
|
||||
//IH_MMHUB_ERROR
|
||||
#define IH_MMHUB_ERROR__IH_BRESP_01__SHIFT 0x1
|
||||
#define IH_MMHUB_ERROR__IH_BRESP_10__SHIFT 0x2
|
||||
#define IH_MMHUB_ERROR__IH_BRESP_11__SHIFT 0x3
|
||||
#define IH_MMHUB_ERROR__IH_BUSER_NACK_01__SHIFT 0x5
|
||||
#define IH_MMHUB_ERROR__IH_BUSER_NACK_10__SHIFT 0x6
|
||||
#define IH_MMHUB_ERROR__IH_BUSER_NACK_11__SHIFT 0x7
|
||||
#define IH_MMHUB_ERROR__IH_BRESP_01_MASK 0x00000002L
|
||||
#define IH_MMHUB_ERROR__IH_BRESP_10_MASK 0x00000004L
|
||||
#define IH_MMHUB_ERROR__IH_BRESP_11_MASK 0x00000008L
|
||||
#define IH_MMHUB_ERROR__IH_BUSER_NACK_01_MASK 0x00000020L
|
||||
#define IH_MMHUB_ERROR__IH_BUSER_NACK_10_MASK 0x00000040L
|
||||
#define IH_MMHUB_ERROR__IH_BUSER_NACK_11_MASK 0x00000080L
|
||||
//IH_MEM_POWER_CTRL
|
||||
#define IH_MEM_POWER_CTRL__IH_BUFFER_MEM_POWER_CTRL_EN__SHIFT 0x0
|
||||
#define IH_MEM_POWER_CTRL__IH_BUFFER_MEM_POWER_LS_EN__SHIFT 0x1
|
||||
#define IH_MEM_POWER_CTRL__IH_BUFFER_MEM_POWER_DS_EN__SHIFT 0x2
|
||||
#define IH_MEM_POWER_CTRL__IH_BUFFER_MEM_POWER_SD_EN__SHIFT 0x3
|
||||
#define IH_MEM_POWER_CTRL__IH_BUFFER_MEM_IDLE_HYSTERESIS__SHIFT 0x4
|
||||
#define IH_MEM_POWER_CTRL__IH_BUFFER_MEM_POWER_UP_RECOVER_DELAY__SHIFT 0x8
|
||||
#define IH_MEM_POWER_CTRL__IH_BUFFER_MEM_POWER_DOWN_ENTER_DELAY__SHIFT 0xe
|
||||
#define IH_MEM_POWER_CTRL__IH_RETRY_INT_CAM_MEM_POWER_CTRL_EN__SHIFT 0x10
|
||||
#define IH_MEM_POWER_CTRL__IH_RETRY_INT_CAM_MEM_POWER_LS_EN__SHIFT 0x11
|
||||
#define IH_MEM_POWER_CTRL__IH_RETRY_INT_CAM_MEM_POWER_DS_EN__SHIFT 0x12
|
||||
#define IH_MEM_POWER_CTRL__IH_RETRY_INT_CAM_MEM_POWER_SD_EN__SHIFT 0x13
|
||||
#define IH_MEM_POWER_CTRL__IH_RETRY_INT_CAM_MEM_IDLE_HYSTERESIS__SHIFT 0x14
|
||||
#define IH_MEM_POWER_CTRL__IH_RETRY_INT_CAM_MEM_POWER_UP_RECOVER_DELAY__SHIFT 0x18
|
||||
#define IH_MEM_POWER_CTRL__IH_RETRY_INT_CAM_MEM_POWER_DOWN_ENTER_DELAY__SHIFT 0x1e
|
||||
#define IH_MEM_POWER_CTRL__IH_BUFFER_MEM_POWER_CTRL_EN_MASK 0x00000001L
|
||||
#define IH_MEM_POWER_CTRL__IH_BUFFER_MEM_POWER_LS_EN_MASK 0x00000002L
|
||||
#define IH_MEM_POWER_CTRL__IH_BUFFER_MEM_POWER_DS_EN_MASK 0x00000004L
|
||||
#define IH_MEM_POWER_CTRL__IH_BUFFER_MEM_POWER_SD_EN_MASK 0x00000008L
|
||||
#define IH_MEM_POWER_CTRL__IH_BUFFER_MEM_IDLE_HYSTERESIS_MASK 0x00000070L
|
||||
#define IH_MEM_POWER_CTRL__IH_BUFFER_MEM_POWER_UP_RECOVER_DELAY_MASK 0x00003F00L
|
||||
#define IH_MEM_POWER_CTRL__IH_BUFFER_MEM_POWER_DOWN_ENTER_DELAY_MASK 0x0000C000L
|
||||
#define IH_MEM_POWER_CTRL__IH_RETRY_INT_CAM_MEM_POWER_CTRL_EN_MASK 0x00010000L
|
||||
#define IH_MEM_POWER_CTRL__IH_RETRY_INT_CAM_MEM_POWER_LS_EN_MASK 0x00020000L
|
||||
#define IH_MEM_POWER_CTRL__IH_RETRY_INT_CAM_MEM_POWER_DS_EN_MASK 0x00040000L
|
||||
#define IH_MEM_POWER_CTRL__IH_RETRY_INT_CAM_MEM_POWER_SD_EN_MASK 0x00080000L
|
||||
#define IH_MEM_POWER_CTRL__IH_RETRY_INT_CAM_MEM_IDLE_HYSTERESIS_MASK 0x00700000L
|
||||
#define IH_MEM_POWER_CTRL__IH_RETRY_INT_CAM_MEM_POWER_UP_RECOVER_DELAY_MASK 0x3F000000L
|
||||
#define IH_MEM_POWER_CTRL__IH_RETRY_INT_CAM_MEM_POWER_DOWN_ENTER_DELAY_MASK 0xC0000000L
|
||||
//IH_VF_RB_STATUS3
|
||||
#define IH_VF_RB_STATUS3__RB_OVERFLOW_VF__SHIFT 0x0
|
||||
#define IH_VF_RB_STATUS3__RB_OVERFLOW_VF_MASK 0x0000FFFFL
|
||||
//IH_VF_RB_STATUS4
|
||||
#define IH_VF_RB_STATUS4__BIF_INTERRUPT_LINE_VF__SHIFT 0x0
|
||||
#define IH_VF_RB_STATUS4__BIF_INTERRUPT_LINE_VF_MASK 0x0000FFFFL
|
||||
//IH_VF_RB1_STATUS3
|
||||
#define IH_VF_RB1_STATUS3__RB_OVERFLOW_VF__SHIFT 0x0
|
||||
#define IH_VF_RB1_STATUS3__RB_OVERFLOW_VF_MASK 0x0000FFFFL
|
||||
//IH_RETRY_INT_CAM_CNTL
|
||||
#define IH_RETRY_INT_CAM_CNTL__CAM_SIZE__SHIFT 0x0
|
||||
#define IH_RETRY_INT_CAM_CNTL__BACK_PRESSURE_SKID_VALUE__SHIFT 0x8
|
||||
#define IH_RETRY_INT_CAM_CNTL__ENABLE__SHIFT 0x10
|
||||
#define IH_RETRY_INT_CAM_CNTL__MM_BACK_PRESSURE_ENABLE__SHIFT 0x11
|
||||
#define IH_RETRY_INT_CAM_CNTL__GC_BACK_PRESSURE_ENABLE__SHIFT 0x12
|
||||
#define IH_RETRY_INT_CAM_CNTL__PER_VF_ENTRY_SIZE__SHIFT 0x14
|
||||
#define IH_RETRY_INT_CAM_CNTL__CAM_SIZE_MASK 0x0000001FL
|
||||
#define IH_RETRY_INT_CAM_CNTL__BACK_PRESSURE_SKID_VALUE_MASK 0x00003F00L
|
||||
#define IH_RETRY_INT_CAM_CNTL__ENABLE_MASK 0x00010000L
|
||||
#define IH_RETRY_INT_CAM_CNTL__MM_BACK_PRESSURE_ENABLE_MASK 0x00020000L
|
||||
#define IH_RETRY_INT_CAM_CNTL__GC_BACK_PRESSURE_ENABLE_MASK 0x00040000L
|
||||
#define IH_RETRY_INT_CAM_CNTL__PER_VF_ENTRY_SIZE_MASK 0x00300000L
|
||||
//IH_MEM_POWER_CTRL2
|
||||
#define IH_MEM_POWER_CTRL2__IH_PASID_LUT_MEM_POWER_CTRL_EN__SHIFT 0x0
|
||||
#define IH_MEM_POWER_CTRL2__IH_PASID_LUT_MEM_POWER_LS_EN__SHIFT 0x1
|
||||
#define IH_MEM_POWER_CTRL2__IH_PASID_LUT_MEM_POWER_DS_EN__SHIFT 0x2
|
||||
#define IH_MEM_POWER_CTRL2__IH_PASID_LUT_MEM_POWER_SD_EN__SHIFT 0x3
|
||||
#define IH_MEM_POWER_CTRL2__IH_PASID_LUT_MEM_IDLE_HYSTERESIS__SHIFT 0x4
|
||||
#define IH_MEM_POWER_CTRL2__IH_PASID_LUT_MEM_POWER_UP_RECOVER_DELAY__SHIFT 0x8
|
||||
#define IH_MEM_POWER_CTRL2__IH_PASID_LUT_MEM_POWER_DOWN_ENTER_DELAY__SHIFT 0xe
|
||||
#define IH_MEM_POWER_CTRL2__IH_PASID_LUT_MEM_POWER_CTRL_EN_MASK 0x00000001L
|
||||
#define IH_MEM_POWER_CTRL2__IH_PASID_LUT_MEM_POWER_LS_EN_MASK 0x00000002L
|
||||
#define IH_MEM_POWER_CTRL2__IH_PASID_LUT_MEM_POWER_DS_EN_MASK 0x00000004L
|
||||
#define IH_MEM_POWER_CTRL2__IH_PASID_LUT_MEM_POWER_SD_EN_MASK 0x00000008L
|
||||
#define IH_MEM_POWER_CTRL2__IH_PASID_LUT_MEM_IDLE_HYSTERESIS_MASK 0x00000070L
|
||||
#define IH_MEM_POWER_CTRL2__IH_PASID_LUT_MEM_POWER_UP_RECOVER_DELAY_MASK 0x00003F00L
|
||||
#define IH_MEM_POWER_CTRL2__IH_PASID_LUT_MEM_POWER_DOWN_ENTER_DELAY_MASK 0x0000C000L
|
||||
//IH_MSI_STORM_CTRL
|
||||
#define IH_MSI_STORM_CTRL__DELAY__SHIFT 0x0
|
||||
#define IH_MSI_STORM_CTRL__DELAY_MASK 0x00000FFFL
|
||||
//IH_MSI_STORM_CLIENT_INDEX
|
||||
#define IH_MSI_STORM_CLIENT_INDEX__INDEX__SHIFT 0x0
|
||||
#define IH_MSI_STORM_CLIENT_INDEX__INDEX_MASK 0x00000007L
|
||||
//IH_MSI_STORM_CLIENT_DATA
|
||||
#define IH_MSI_STORM_CLIENT_DATA__CLIENT_ID__SHIFT 0x0
|
||||
#define IH_MSI_STORM_CLIENT_DATA__SOURCE_ID__SHIFT 0x8
|
||||
#define IH_MSI_STORM_CLIENT_DATA__SOURCE_ID_MATCH_ENABLE__SHIFT 0x10
|
||||
#define IH_MSI_STORM_CLIENT_DATA__UTCL2_PAGE_FAULT_MATCH_ENABLE__SHIFT 0x11
|
||||
#define IH_MSI_STORM_CLIENT_DATA__ENTRY_VALID__SHIFT 0x1f
|
||||
#define IH_MSI_STORM_CLIENT_DATA__CLIENT_ID_MASK 0x000000FFL
|
||||
#define IH_MSI_STORM_CLIENT_DATA__SOURCE_ID_MASK 0x0000FF00L
|
||||
#define IH_MSI_STORM_CLIENT_DATA__SOURCE_ID_MATCH_ENABLE_MASK 0x00010000L
|
||||
#define IH_MSI_STORM_CLIENT_DATA__UTCL2_PAGE_FAULT_MATCH_ENABLE_MASK 0x00020000L
|
||||
#define IH_MSI_STORM_CLIENT_DATA__ENTRY_VALID_MASK 0x80000000L
|
||||
//IH_REGISTER_LAST_PART2
|
||||
#define IH_REGISTER_LAST_PART2__RESERVED__SHIFT 0x0
|
||||
#define IH_REGISTER_LAST_PART2__RESERVED_MASK 0xFFFFFFFFL
|
||||
//SEM_MAILBOX
|
||||
#define SEM_MAILBOX__HOSTPORT__SHIFT 0x0
|
||||
#define SEM_MAILBOX__RESERVED__SHIFT 0x10
|
||||
#define SEM_MAILBOX__HOSTPORT_MASK 0x0000FFFFL
|
||||
#define SEM_MAILBOX__RESERVED_MASK 0xFFFF0000L
|
||||
//SEM_MAILBOX_CLEAR
|
||||
#define SEM_MAILBOX_CLEAR__CLEAR__SHIFT 0x0
|
||||
#define SEM_MAILBOX_CLEAR__RESERVED__SHIFT 0x10
|
||||
#define SEM_MAILBOX_CLEAR__CLEAR_MASK 0x0000FFFFL
|
||||
#define SEM_MAILBOX_CLEAR__RESERVED_MASK 0xFFFF0000L
|
||||
//SEM_REGISTER_LAST_PART2
|
||||
#define SEM_REGISTER_LAST_PART2__RESERVED__SHIFT 0x0
|
||||
#define SEM_REGISTER_LAST_PART2__RESERVED_MASK 0xFFFFFFFFL
|
||||
//IH_CLIENT_CFG
|
||||
#define IH_CLIENT_CFG__TOTAL_CLIENT_NUM__SHIFT 0x0
|
||||
#define IH_CLIENT_CFG__TOTAL_CLIENT_NUM_MASK 0x0000003FL
|
||||
//IH_RING1_CLIENT_CFG_INDEX
|
||||
#define IH_RING1_CLIENT_CFG_INDEX__INDEX__SHIFT 0x0
|
||||
#define IH_RING1_CLIENT_CFG_INDEX__INDEX_MASK 0x00000007L
|
||||
//IH_RING1_CLIENT_CFG_DATA
|
||||
#define IH_RING1_CLIENT_CFG_DATA__CLIENT_ID__SHIFT 0x0
|
||||
#define IH_RING1_CLIENT_CFG_DATA__SOURCE_ID__SHIFT 0x8
|
||||
#define IH_RING1_CLIENT_CFG_DATA__SOURCE_ID_MATCH_ENABLE__SHIFT 0x10
|
||||
#define IH_RING1_CLIENT_CFG_DATA__CLIENT_ID_MASK 0x000000FFL
|
||||
#define IH_RING1_CLIENT_CFG_DATA__SOURCE_ID_MASK 0x0000FF00L
|
||||
#define IH_RING1_CLIENT_CFG_DATA__SOURCE_ID_MATCH_ENABLE_MASK 0x00010000L
|
||||
//IH_CLIENT_CFG_INDEX
|
||||
#define IH_CLIENT_CFG_INDEX__INDEX__SHIFT 0x0
|
||||
#define IH_CLIENT_CFG_INDEX__INDEX_MASK 0x0000001FL
|
||||
//IH_CLIENT_CFG_DATA
|
||||
#define IH_CLIENT_CFG_DATA__CLIENT_TYPE__SHIFT 0x12
|
||||
#define IH_CLIENT_CFG_DATA__VF_RB_SELECT__SHIFT 0x16
|
||||
#define IH_CLIENT_CFG_DATA__INTERFACE_TYPE__SHIFT 0x19
|
||||
#define IH_CLIENT_CFG_DATA__CLIENT_TYPE_MASK 0x000C0000L
|
||||
#define IH_CLIENT_CFG_DATA__VF_RB_SELECT_MASK 0x00C00000L
|
||||
#define IH_CLIENT_CFG_DATA__INTERFACE_TYPE_MASK 0x02000000L
|
||||
//IH_CID_REMAP_INDEX
|
||||
#define IH_CID_REMAP_INDEX__INDEX__SHIFT 0x0
|
||||
#define IH_CID_REMAP_INDEX__INDEX_MASK 0x00000003L
|
||||
//IH_CID_REMAP_DATA
|
||||
#define IH_CID_REMAP_DATA__CLIENT_ID__SHIFT 0x0
|
||||
#define IH_CID_REMAP_DATA__INITIATOR_ID__SHIFT 0x8
|
||||
#define IH_CID_REMAP_DATA__CLIENT_ID_REMAP__SHIFT 0x18
|
||||
#define IH_CID_REMAP_DATA__CLIENT_ID_MASK 0x000000FFL
|
||||
#define IH_CID_REMAP_DATA__INITIATOR_ID_MASK 0x0003FF00L
|
||||
#define IH_CID_REMAP_DATA__CLIENT_ID_REMAP_MASK 0xFF000000L
|
||||
//IH_CHICKEN
|
||||
#define IH_CHICKEN__CROSS_TRIGGER_ENABLE__SHIFT 0x2
|
||||
#define IH_CHICKEN__MC_SPACE_FBPA_ENABLE__SHIFT 0x3
|
||||
#define IH_CHICKEN__MC_SPACE_GPA_ENABLE__SHIFT 0x4
|
||||
#define IH_CHICKEN__CROSS_TRIGGER_ENABLE_MASK 0x00000004L
|
||||
#define IH_CHICKEN__MC_SPACE_FBPA_ENABLE_MASK 0x00000008L
|
||||
#define IH_CHICKEN__MC_SPACE_GPA_ENABLE_MASK 0x00000010L
|
||||
//IH_INT_DROP_CNTL
|
||||
#define IH_INT_DROP_CNTL__INT_DROP_EN__SHIFT 0x0
|
||||
#define IH_INT_DROP_CNTL__CLIENT_ID_MATCH_EN__SHIFT 0x1
|
||||
#define IH_INT_DROP_CNTL__SOURCE_ID_MATCH_EN__SHIFT 0x2
|
||||
#define IH_INT_DROP_CNTL__VF_ID_MATCH_EN__SHIFT 0x3
|
||||
#define IH_INT_DROP_CNTL__VF_MATCH_EN__SHIFT 0x4
|
||||
#define IH_INT_DROP_CNTL__CONTEXT_ID_MATCH_EN__SHIFT 0x5
|
||||
#define IH_INT_DROP_CNTL__INT_DROP_MODE__SHIFT 0x6
|
||||
#define IH_INT_DROP_CNTL__UTCL2_RETRY_INT_DROP_EN__SHIFT 0x8
|
||||
#define IH_INT_DROP_CNTL__INT_DROPPED__SHIFT 0x10
|
||||
#define IH_INT_DROP_CNTL__INT_DROP_EN_MASK 0x00000001L
|
||||
#define IH_INT_DROP_CNTL__CLIENT_ID_MATCH_EN_MASK 0x00000002L
|
||||
#define IH_INT_DROP_CNTL__SOURCE_ID_MATCH_EN_MASK 0x00000004L
|
||||
#define IH_INT_DROP_CNTL__VF_ID_MATCH_EN_MASK 0x00000008L
|
||||
#define IH_INT_DROP_CNTL__VF_MATCH_EN_MASK 0x00000010L
|
||||
#define IH_INT_DROP_CNTL__CONTEXT_ID_MATCH_EN_MASK 0x00000020L
|
||||
#define IH_INT_DROP_CNTL__INT_DROP_MODE_MASK 0x000000C0L
|
||||
#define IH_INT_DROP_CNTL__UTCL2_RETRY_INT_DROP_EN_MASK 0x00000100L
|
||||
#define IH_INT_DROP_CNTL__INT_DROPPED_MASK 0x00010000L
|
||||
//IH_INT_DROP_MATCH_VALUE0
|
||||
#define IH_INT_DROP_MATCH_VALUE0__CLIENT_ID_MATCH_VALUE__SHIFT 0x0
|
||||
#define IH_INT_DROP_MATCH_VALUE0__SOURCE_ID_MATCH_VALUE__SHIFT 0x8
|
||||
#define IH_INT_DROP_MATCH_VALUE0__VF_ID_MATCH_VALUE__SHIFT 0x10
|
||||
#define IH_INT_DROP_MATCH_VALUE0__VF_MATCH_VALUE__SHIFT 0x17
|
||||
#define IH_INT_DROP_MATCH_VALUE0__CONTEXT_ID_39_32_MATCH_VALUE__SHIFT 0x18
|
||||
#define IH_INT_DROP_MATCH_VALUE0__CLIENT_ID_MATCH_VALUE_MASK 0x000000FFL
|
||||
#define IH_INT_DROP_MATCH_VALUE0__SOURCE_ID_MATCH_VALUE_MASK 0x0000FF00L
|
||||
#define IH_INT_DROP_MATCH_VALUE0__VF_ID_MATCH_VALUE_MASK 0x001F0000L
|
||||
#define IH_INT_DROP_MATCH_VALUE0__VF_MATCH_VALUE_MASK 0x00800000L
|
||||
#define IH_INT_DROP_MATCH_VALUE0__CONTEXT_ID_39_32_MATCH_VALUE_MASK 0xFF000000L
|
||||
//IH_INT_DROP_MATCH_VALUE1
|
||||
#define IH_INT_DROP_MATCH_VALUE1__CONTEXT_ID_31_0_MATCH_VALUE__SHIFT 0x0
|
||||
#define IH_INT_DROP_MATCH_VALUE1__CONTEXT_ID_31_0_MATCH_VALUE_MASK 0xFFFFFFFFL
|
||||
//IH_INT_DROP_MATCH_MASK0
|
||||
#define IH_INT_DROP_MATCH_MASK0__CLIENT_ID_MATCH_MASK__SHIFT 0x0
|
||||
#define IH_INT_DROP_MATCH_MASK0__SOURCE_ID_MATCH_MASK__SHIFT 0x8
|
||||
#define IH_INT_DROP_MATCH_MASK0__VF_ID_MATCH_MASK__SHIFT 0x10
|
||||
#define IH_INT_DROP_MATCH_MASK0__VF_MATCH_MASK__SHIFT 0x17
|
||||
#define IH_INT_DROP_MATCH_MASK0__CONTEXT_ID_39_32_MATCH_MASK__SHIFT 0x18
|
||||
#define IH_INT_DROP_MATCH_MASK0__CLIENT_ID_MATCH_MASK_MASK 0x000000FFL
|
||||
#define IH_INT_DROP_MATCH_MASK0__SOURCE_ID_MATCH_MASK_MASK 0x0000FF00L
|
||||
#define IH_INT_DROP_MATCH_MASK0__VF_ID_MATCH_MASK_MASK 0x001F0000L
|
||||
#define IH_INT_DROP_MATCH_MASK0__VF_MATCH_MASK_MASK 0x00800000L
|
||||
#define IH_INT_DROP_MATCH_MASK0__CONTEXT_ID_39_32_MATCH_MASK_MASK 0xFF000000L
|
||||
//IH_INT_DROP_MATCH_MASK1
|
||||
#define IH_INT_DROP_MATCH_MASK1__CONTEXT_ID_31_0_MATCH_MASK__SHIFT 0x0
|
||||
#define IH_INT_DROP_MATCH_MASK1__CONTEXT_ID_31_0_MATCH_MASK_MASK 0xFFFFFFFFL
|
||||
//IH_REGISTER_LAST_PART1
|
||||
#define IH_REGISTER_LAST_PART1__RESERVED__SHIFT 0x0
|
||||
#define IH_REGISTER_LAST_PART1__RESERVED_MASK 0xFFFFFFFFL
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,471 @@
|
||||
/*
|
||||
* Copyright 2017 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _PSP_TEE_GFX_IF_H_
|
||||
#define _PSP_TEE_GFX_IF_H_
|
||||
|
||||
#define PSP_GFX_CMD_BUF_VERSION 0x00000001
|
||||
|
||||
#define GFX_CMD_STATUS_MASK 0x0000FFFF
|
||||
#define GFX_CMD_ID_MASK 0x000F0000
|
||||
#define GFX_CMD_RESERVED_MASK 0x7FF00000
|
||||
#define GFX_CMD_RESPONSE_MASK 0x80000000
|
||||
|
||||
/* USBC PD FW version retrieval command */
|
||||
#define C2PMSG_CMD_GFX_USB_PD_FW_VER 0x2000000
|
||||
|
||||
/* TEE Gfx Command IDs for the register interface.
|
||||
* Command ID must be between 0x00010000 and 0x000F0000.
|
||||
*/
|
||||
enum psp_gfx_crtl_cmd_id
|
||||
{
|
||||
GFX_CTRL_CMD_ID_INIT_RBI_RING = 0x00010000, /* initialize RBI ring */
|
||||
GFX_CTRL_CMD_ID_INIT_GPCOM_RING = 0x00020000, /* initialize GPCOM ring */
|
||||
GFX_CTRL_CMD_ID_DESTROY_RINGS = 0x00030000, /* destroy rings */
|
||||
GFX_CTRL_CMD_ID_CAN_INIT_RINGS = 0x00040000, /* is it allowed to initialized the rings */
|
||||
GFX_CTRL_CMD_ID_ENABLE_INT = 0x00050000, /* enable PSP-to-Gfx interrupt */
|
||||
GFX_CTRL_CMD_ID_DISABLE_INT = 0x00060000, /* disable PSP-to-Gfx interrupt */
|
||||
GFX_CTRL_CMD_ID_MODE1_RST = 0x00070000, /* trigger the Mode 1 reset */
|
||||
GFX_CTRL_CMD_ID_GBR_IH_SET = 0x00080000, /* set Gbr IH_RB_CNTL registers */
|
||||
GFX_CTRL_CMD_ID_CONSUME_CMD = 0x00090000, /* send interrupt to psp for updating write pointer of vf */
|
||||
GFX_CTRL_CMD_ID_DESTROY_GPCOM_RING = 0x000C0000, /* destroy GPCOM ring */
|
||||
|
||||
GFX_CTRL_CMD_ID_MAX = 0x000F0000, /* max command ID */
|
||||
};
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
NOTE: All physical addresses used in this interface are actually
|
||||
GPU Virtual Addresses.
|
||||
*/
|
||||
|
||||
|
||||
/* Control registers of the TEE Gfx interface. These are located in
|
||||
* SRBM-to-PSP mailbox registers (total 8 registers).
|
||||
*/
|
||||
struct psp_gfx_ctrl
|
||||
{
|
||||
volatile unsigned int cmd_resp; /* +0 Command/Response register for Gfx commands */
|
||||
volatile unsigned int rbi_wptr; /* +4 Write pointer (index) of RBI ring */
|
||||
volatile unsigned int rbi_rptr; /* +8 Read pointer (index) of RBI ring */
|
||||
volatile unsigned int gpcom_wptr; /* +12 Write pointer (index) of GPCOM ring */
|
||||
volatile unsigned int gpcom_rptr; /* +16 Read pointer (index) of GPCOM ring */
|
||||
volatile unsigned int ring_addr_lo; /* +20 bits [31:0] of GPU Virtual of ring buffer (VMID=0)*/
|
||||
volatile unsigned int ring_addr_hi; /* +24 bits [63:32] of GPU Virtual of ring buffer (VMID=0) */
|
||||
volatile unsigned int ring_buf_size; /* +28 Ring buffer size (in bytes) */
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* Response flag is set in the command when command is completed by PSP.
|
||||
* Used in the GFX_CTRL.CmdResp.
|
||||
* When PSP GFX I/F is initialized, the flag is set.
|
||||
*/
|
||||
#define GFX_FLAG_RESPONSE 0x80000000
|
||||
|
||||
/* TEE Gfx Command IDs for the ring buffer interface. */
|
||||
enum psp_gfx_cmd_id
|
||||
{
|
||||
GFX_CMD_ID_LOAD_TA = 0x00000001, /* load TA */
|
||||
GFX_CMD_ID_UNLOAD_TA = 0x00000002, /* unload TA */
|
||||
GFX_CMD_ID_INVOKE_CMD = 0x00000003, /* send command to TA */
|
||||
GFX_CMD_ID_LOAD_ASD = 0x00000004, /* load ASD Driver */
|
||||
GFX_CMD_ID_SETUP_TMR = 0x00000005, /* setup TMR region */
|
||||
GFX_CMD_ID_LOAD_IP_FW = 0x00000006, /* load HW IP FW */
|
||||
GFX_CMD_ID_DESTROY_TMR = 0x00000007, /* destroy TMR region */
|
||||
GFX_CMD_ID_SAVE_RESTORE = 0x00000008, /* save/restore HW IP FW */
|
||||
GFX_CMD_ID_SETUP_VMR = 0x00000009, /* setup VMR region */
|
||||
GFX_CMD_ID_DESTROY_VMR = 0x0000000A, /* destroy VMR region */
|
||||
GFX_CMD_ID_PROG_REG = 0x0000000B, /* program regs */
|
||||
GFX_CMD_ID_GET_FW_ATTESTATION = 0x0000000F, /* Query GPUVA of the Fw Attestation DB */
|
||||
/* IDs upto 0x1F are reserved for older programs (Raven, Vega 10/12/20) */
|
||||
GFX_CMD_ID_LOAD_TOC = 0x00000020, /* Load TOC and obtain TMR size */
|
||||
GFX_CMD_ID_AUTOLOAD_RLC = 0x00000021, /* Indicates all graphics fw loaded, start RLC autoload */
|
||||
GFX_CMD_ID_BOOT_CFG = 0x00000022, /* Boot Config */
|
||||
GFX_CMD_ID_SRIOV_SPATIAL_PART = 0x00000027, /* Configure spatial partitioning mode */
|
||||
};
|
||||
|
||||
/* PSP boot config sub-commands */
|
||||
enum psp_gfx_boot_config_cmd
|
||||
{
|
||||
BOOTCFG_CMD_SET = 1, /* Set boot configuration settings */
|
||||
BOOTCFG_CMD_GET = 2, /* Get boot configuration settings */
|
||||
BOOTCFG_CMD_INVALIDATE = 3 /* Reset current boot configuration settings to VBIOS defaults */
|
||||
};
|
||||
|
||||
/* PSP boot config bitmask values */
|
||||
enum psp_gfx_boot_config
|
||||
{
|
||||
BOOT_CONFIG_GECC = 0x1,
|
||||
};
|
||||
|
||||
/* Command to load Trusted Application binary into PSP OS. */
|
||||
struct psp_gfx_cmd_load_ta
|
||||
{
|
||||
unsigned int app_phy_addr_lo; /* bits [31:0] of the GPU Virtual address of the TA binary (must be 4 KB aligned) */
|
||||
unsigned int app_phy_addr_hi; /* bits [63:32] of the GPU Virtual address of the TA binary */
|
||||
unsigned int app_len; /* length of the TA binary in bytes */
|
||||
unsigned int cmd_buf_phy_addr_lo; /* bits [31:0] of the GPU Virtual address of CMD buffer (must be 4 KB aligned) */
|
||||
unsigned int cmd_buf_phy_addr_hi; /* bits [63:32] of the GPU Virtual address of CMD buffer */
|
||||
unsigned int cmd_buf_len; /* length of the CMD buffer in bytes; must be multiple of 4 KB */
|
||||
|
||||
/* Note: CmdBufLen can be set to 0. In this case no persistent CMD buffer is provided
|
||||
* for the TA. Each InvokeCommand can have dinamically mapped CMD buffer instead
|
||||
* of using global persistent buffer.
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
/* Command to Unload Trusted Application binary from PSP OS. */
|
||||
struct psp_gfx_cmd_unload_ta
|
||||
{
|
||||
unsigned int session_id; /* Session ID of the loaded TA to be unloaded */
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* Shared buffers for InvokeCommand.
|
||||
*/
|
||||
struct psp_gfx_buf_desc
|
||||
{
|
||||
unsigned int buf_phy_addr_lo; /* bits [31:0] of GPU Virtual address of the buffer (must be 4 KB aligned) */
|
||||
unsigned int buf_phy_addr_hi; /* bits [63:32] of GPU Virtual address of the buffer */
|
||||
unsigned int buf_size; /* buffer size in bytes (must be multiple of 4 KB and no bigger than 64 MB) */
|
||||
|
||||
};
|
||||
|
||||
/* Max number of descriptors for one shared buffer (in how many different
|
||||
* physical locations one shared buffer can be stored). If buffer is too much
|
||||
* fragmented, error will be returned.
|
||||
*/
|
||||
#define GFX_BUF_MAX_DESC 64
|
||||
|
||||
struct psp_gfx_buf_list
|
||||
{
|
||||
unsigned int num_desc; /* number of buffer descriptors in the list */
|
||||
unsigned int total_size; /* total size of all buffers in the list in bytes (must be multiple of 4 KB) */
|
||||
struct psp_gfx_buf_desc buf_desc[GFX_BUF_MAX_DESC]; /* list of buffer descriptors */
|
||||
|
||||
/* total 776 bytes */
|
||||
};
|
||||
|
||||
/* Command to execute InvokeCommand entry point of the TA. */
|
||||
struct psp_gfx_cmd_invoke_cmd
|
||||
{
|
||||
unsigned int session_id; /* Session ID of the TA to be executed */
|
||||
unsigned int ta_cmd_id; /* Command ID to be sent to TA */
|
||||
struct psp_gfx_buf_list buf; /* one indirect buffer (scatter/gather list) */
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* Command to setup TMR region. */
|
||||
struct psp_gfx_cmd_setup_tmr
|
||||
{
|
||||
unsigned int buf_phy_addr_lo; /* bits [31:0] of GPU Virtual address of TMR buffer (must be 4 KB aligned) */
|
||||
unsigned int buf_phy_addr_hi; /* bits [63:32] of GPU Virtual address of TMR buffer */
|
||||
unsigned int buf_size; /* buffer size in bytes (must be multiple of 4 KB) */
|
||||
union {
|
||||
struct {
|
||||
unsigned int sriov_enabled:1; /* whether the device runs under SR-IOV*/
|
||||
unsigned int virt_phy_addr:1; /* driver passes both virtual and physical address to PSP*/
|
||||
unsigned int reserved:30;
|
||||
} bitfield;
|
||||
unsigned int tmr_flags;
|
||||
};
|
||||
unsigned int system_phy_addr_lo; /* bits [31:0] of system physical address of TMR buffer (must be 4 KB aligned) */
|
||||
unsigned int system_phy_addr_hi; /* bits [63:32] of system physical address of TMR buffer */
|
||||
|
||||
};
|
||||
|
||||
/* FW types for GFX_CMD_ID_LOAD_IP_FW command. Limit 31. */
|
||||
enum psp_gfx_fw_type {
|
||||
GFX_FW_TYPE_NONE = 0, /* */
|
||||
GFX_FW_TYPE_CP_ME = 1, /* CP-ME VG + RV */
|
||||
GFX_FW_TYPE_CP_PFP = 2, /* CP-PFP VG + RV */
|
||||
GFX_FW_TYPE_CP_CE = 3, /* CP-CE VG + RV */
|
||||
GFX_FW_TYPE_CP_MEC = 4, /* CP-MEC FW VG + RV */
|
||||
GFX_FW_TYPE_CP_MEC_ME1 = 5, /* CP-MEC Jump Table 1 VG + RV */
|
||||
GFX_FW_TYPE_CP_MEC_ME2 = 6, /* CP-MEC Jump Table 2 VG */
|
||||
GFX_FW_TYPE_RLC_V = 7, /* RLC-V VG */
|
||||
GFX_FW_TYPE_RLC_G = 8, /* RLC-G VG + RV */
|
||||
GFX_FW_TYPE_SDMA0 = 9, /* SDMA0 VG + RV */
|
||||
GFX_FW_TYPE_SDMA1 = 10, /* SDMA1 VG */
|
||||
GFX_FW_TYPE_DMCU_ERAM = 11, /* DMCU-ERAM VG + RV */
|
||||
GFX_FW_TYPE_DMCU_ISR = 12, /* DMCU-ISR VG + RV */
|
||||
GFX_FW_TYPE_VCN = 13, /* VCN RV */
|
||||
GFX_FW_TYPE_UVD = 14, /* UVD VG */
|
||||
GFX_FW_TYPE_VCE = 15, /* VCE VG */
|
||||
GFX_FW_TYPE_ISP = 16, /* ISP RV */
|
||||
GFX_FW_TYPE_ACP = 17, /* ACP RV */
|
||||
GFX_FW_TYPE_SMU = 18, /* SMU VG */
|
||||
GFX_FW_TYPE_MMSCH = 19, /* MMSCH VG */
|
||||
GFX_FW_TYPE_RLC_RESTORE_LIST_GPM_MEM = 20, /* RLC GPM VG + RV */
|
||||
GFX_FW_TYPE_RLC_RESTORE_LIST_SRM_MEM = 21, /* RLC SRM VG + RV */
|
||||
GFX_FW_TYPE_RLC_RESTORE_LIST_SRM_CNTL = 22, /* RLC CNTL VG + RV */
|
||||
GFX_FW_TYPE_UVD1 = 23, /* UVD1 VG-20 */
|
||||
GFX_FW_TYPE_TOC = 24, /* TOC NV-10 */
|
||||
GFX_FW_TYPE_RLC_P = 25, /* RLC P NV */
|
||||
GFX_FW_TYPE_RLC_IRAM = 26, /* RLC_IRAM NV */
|
||||
GFX_FW_TYPE_GLOBAL_TAP_DELAYS = 27, /* GLOBAL TAP DELAYS NV */
|
||||
GFX_FW_TYPE_SE0_TAP_DELAYS = 28, /* SE0 TAP DELAYS NV */
|
||||
GFX_FW_TYPE_SE1_TAP_DELAYS = 29, /* SE1 TAP DELAYS NV */
|
||||
GFX_FW_TYPE_GLOBAL_SE0_SE1_SKEW_DELAYS = 30, /* GLOBAL SE0/1 SKEW DELAYS NV */
|
||||
GFX_FW_TYPE_SDMA0_JT = 31, /* SDMA0 JT NV */
|
||||
GFX_FW_TYPE_SDMA1_JT = 32, /* SDNA1 JT NV */
|
||||
GFX_FW_TYPE_CP_MES = 33, /* CP MES NV */
|
||||
GFX_FW_TYPE_MES_STACK = 34, /* MES STACK NV */
|
||||
GFX_FW_TYPE_RLC_SRM_DRAM_SR = 35, /* RLC SRM DRAM NV */
|
||||
GFX_FW_TYPE_RLCG_SCRATCH_SR = 36, /* RLCG SCRATCH NV */
|
||||
GFX_FW_TYPE_RLCP_SCRATCH_SR = 37, /* RLCP SCRATCH NV */
|
||||
GFX_FW_TYPE_RLCV_SCRATCH_SR = 38, /* RLCV SCRATCH NV */
|
||||
GFX_FW_TYPE_RLX6_DRAM_SR = 39, /* RLX6 DRAM NV */
|
||||
GFX_FW_TYPE_SDMA0_PG_CONTEXT = 40, /* SDMA0 PG CONTEXT NV */
|
||||
GFX_FW_TYPE_SDMA1_PG_CONTEXT = 41, /* SDMA1 PG CONTEXT NV */
|
||||
GFX_FW_TYPE_GLOBAL_MUX_SELECT_RAM = 42, /* GLOBAL MUX SEL RAM NV */
|
||||
GFX_FW_TYPE_SE0_MUX_SELECT_RAM = 43, /* SE0 MUX SEL RAM NV */
|
||||
GFX_FW_TYPE_SE1_MUX_SELECT_RAM = 44, /* SE1 MUX SEL RAM NV */
|
||||
GFX_FW_TYPE_ACCUM_CTRL_RAM = 45, /* ACCUM CTRL RAM NV */
|
||||
GFX_FW_TYPE_RLCP_CAM = 46, /* RLCP CAM NV */
|
||||
GFX_FW_TYPE_RLC_SPP_CAM_EXT = 47, /* RLC SPP CAM EXT NV */
|
||||
GFX_FW_TYPE_RLC_DRAM_BOOT = 48, /* RLC DRAM BOOT NV */
|
||||
GFX_FW_TYPE_VCN0_RAM = 49, /* VCN_RAM NV + RN */
|
||||
GFX_FW_TYPE_VCN1_RAM = 50, /* VCN_RAM NV + RN */
|
||||
GFX_FW_TYPE_DMUB = 51, /* DMUB RN */
|
||||
GFX_FW_TYPE_SDMA2 = 52, /* SDMA2 MI */
|
||||
GFX_FW_TYPE_SDMA3 = 53, /* SDMA3 MI */
|
||||
GFX_FW_TYPE_SDMA4 = 54, /* SDMA4 MI */
|
||||
GFX_FW_TYPE_SDMA5 = 55, /* SDMA5 MI */
|
||||
GFX_FW_TYPE_SDMA6 = 56, /* SDMA6 MI */
|
||||
GFX_FW_TYPE_SDMA7 = 57, /* SDMA7 MI */
|
||||
GFX_FW_TYPE_VCN1 = 58, /* VCN1 MI */
|
||||
GFX_FW_TYPE_CAP = 62, /* CAP_FW */
|
||||
GFX_FW_TYPE_SE2_TAP_DELAYS = 65, /* SE2 TAP DELAYS NV */
|
||||
GFX_FW_TYPE_SE3_TAP_DELAYS = 66, /* SE3 TAP DELAYS NV */
|
||||
GFX_FW_TYPE_REG_LIST = 67, /* REG_LIST MI */
|
||||
GFX_FW_TYPE_IMU_I = 68, /* IMU Instruction FW SOC21 */
|
||||
GFX_FW_TYPE_IMU_D = 69, /* IMU Data FW SOC21 */
|
||||
GFX_FW_TYPE_LSDMA = 70, /* LSDMA FW SOC21 */
|
||||
GFX_FW_TYPE_SDMA_UCODE_TH0 = 71, /* SDMA Thread 0/CTX SOC21 */
|
||||
GFX_FW_TYPE_SDMA_UCODE_TH1 = 72, /* SDMA Thread 1/CTL SOC21 */
|
||||
GFX_FW_TYPE_PPTABLE = 73, /* PPTABLE SOC21 */
|
||||
GFX_FW_TYPE_DISCRETE_USB4 = 74, /* dUSB4 FW SOC21 */
|
||||
GFX_FW_TYPE_TA = 75, /* SRIOV TA FW UUID SOC21 */
|
||||
GFX_FW_TYPE_RS64_MES = 76, /* RS64 MES ucode SOC21 */
|
||||
GFX_FW_TYPE_RS64_MES_STACK = 77, /* RS64 MES stack ucode SOC21 */
|
||||
GFX_FW_TYPE_RS64_KIQ = 78, /* RS64 KIQ ucode SOC21 */
|
||||
GFX_FW_TYPE_RS64_KIQ_STACK = 79, /* RS64 KIQ Heap stack SOC21 */
|
||||
GFX_FW_TYPE_ISP_DATA = 80, /* ISP DATA SOC21 */
|
||||
GFX_FW_TYPE_CP_MES_KIQ = 81, /* MES KIQ ucode SOC21 */
|
||||
GFX_FW_TYPE_MES_KIQ_STACK = 82, /* MES KIQ stack SOC21 */
|
||||
GFX_FW_TYPE_UMSCH_DATA = 83, /* User Mode Scheduler Data SOC21 */
|
||||
GFX_FW_TYPE_UMSCH_UCODE = 84, /* User Mode Scheduler Ucode SOC21 */
|
||||
GFX_FW_TYPE_UMSCH_CMD_BUFFER = 85, /* User Mode Scheduler Command Buffer SOC21 */
|
||||
GFX_FW_TYPE_USB_DP_COMBO_PHY = 86, /* USB-Display port Combo SOC21 */
|
||||
GFX_FW_TYPE_RS64_PFP = 87, /* RS64 PFP SOC21 */
|
||||
GFX_FW_TYPE_RS64_ME = 88, /* RS64 ME SOC21 */
|
||||
GFX_FW_TYPE_RS64_MEC = 89, /* RS64 MEC SOC21 */
|
||||
GFX_FW_TYPE_RS64_PFP_P0_STACK = 90, /* RS64 PFP stack P0 SOC21 */
|
||||
GFX_FW_TYPE_RS64_PFP_P1_STACK = 91, /* RS64 PFP stack P1 SOC21 */
|
||||
GFX_FW_TYPE_RS64_ME_P0_STACK = 92, /* RS64 ME stack P0 SOC21 */
|
||||
GFX_FW_TYPE_RS64_ME_P1_STACK = 93, /* RS64 ME stack P1 SOC21 */
|
||||
GFX_FW_TYPE_RS64_MEC_P0_STACK = 94, /* RS64 MEC stack P0 SOC21 */
|
||||
GFX_FW_TYPE_RS64_MEC_P1_STACK = 95, /* RS64 MEC stack P1 SOC21 */
|
||||
GFX_FW_TYPE_RS64_MEC_P2_STACK = 96, /* RS64 MEC stack P2 SOC21 */
|
||||
GFX_FW_TYPE_RS64_MEC_P3_STACK = 97, /* RS64 MEC stack P3 SOC21 */
|
||||
GFX_FW_TYPE_VPEC_FW1 = 100, /* VPEC FW1 To Save VPE */
|
||||
GFX_FW_TYPE_VPEC_FW2 = 101, /* VPEC FW2 To Save VPE */
|
||||
GFX_FW_TYPE_VPE = 102,
|
||||
GFX_FW_TYPE_JPEG_RAM = 128, /**< JPEG Command buffer */
|
||||
GFX_FW_TYPE_P2S_TABLE = 129,
|
||||
GFX_FW_TYPE_MAX
|
||||
};
|
||||
|
||||
/* Command to load HW IP FW. */
|
||||
struct psp_gfx_cmd_load_ip_fw
|
||||
{
|
||||
unsigned int fw_phy_addr_lo; /* bits [31:0] of GPU Virtual address of FW location (must be 4 KB aligned) */
|
||||
unsigned int fw_phy_addr_hi; /* bits [63:32] of GPU Virtual address of FW location */
|
||||
unsigned int fw_size; /* FW buffer size in bytes */
|
||||
enum psp_gfx_fw_type fw_type; /* FW type */
|
||||
|
||||
};
|
||||
|
||||
/* Command to save/restore HW IP FW. */
|
||||
struct psp_gfx_cmd_save_restore_ip_fw
|
||||
{
|
||||
unsigned int save_fw; /* if set, command is used for saving fw otherwise for resetoring*/
|
||||
unsigned int save_restore_addr_lo; /* bits [31:0] of FB address of GART memory used as save/restore buffer (must be 4 KB aligned) */
|
||||
unsigned int save_restore_addr_hi; /* bits [63:32] of FB address of GART memory used as save/restore buffer */
|
||||
unsigned int buf_size; /* Size of the save/restore buffer in bytes */
|
||||
enum psp_gfx_fw_type fw_type; /* FW type */
|
||||
};
|
||||
|
||||
/* Command to setup register program */
|
||||
struct psp_gfx_cmd_reg_prog {
|
||||
unsigned int reg_value;
|
||||
unsigned int reg_id;
|
||||
};
|
||||
|
||||
/* Command to load TOC */
|
||||
struct psp_gfx_cmd_load_toc
|
||||
{
|
||||
unsigned int toc_phy_addr_lo; /* bits [31:0] of GPU Virtual address of FW location (must be 4 KB aligned) */
|
||||
unsigned int toc_phy_addr_hi; /* bits [63:32] of GPU Virtual address of FW location */
|
||||
unsigned int toc_size; /* FW buffer size in bytes */
|
||||
};
|
||||
|
||||
/* Dynamic boot configuration */
|
||||
struct psp_gfx_cmd_boot_cfg
|
||||
{
|
||||
unsigned int timestamp; /* calendar time as number of seconds */
|
||||
enum psp_gfx_boot_config_cmd sub_cmd; /* sub-command indicating how to process command data */
|
||||
unsigned int boot_config; /* dynamic boot configuration bitmask */
|
||||
unsigned int boot_config_valid; /* dynamic boot configuration valid bits bitmask */
|
||||
};
|
||||
|
||||
struct psp_gfx_cmd_sriov_spatial_part {
|
||||
unsigned int mode;
|
||||
unsigned int override_ips;
|
||||
unsigned int override_xcds_avail;
|
||||
unsigned int override_this_aid;
|
||||
};
|
||||
|
||||
/* All GFX ring buffer commands. */
|
||||
union psp_gfx_commands
|
||||
{
|
||||
struct psp_gfx_cmd_load_ta cmd_load_ta;
|
||||
struct psp_gfx_cmd_unload_ta cmd_unload_ta;
|
||||
struct psp_gfx_cmd_invoke_cmd cmd_invoke_cmd;
|
||||
struct psp_gfx_cmd_setup_tmr cmd_setup_tmr;
|
||||
struct psp_gfx_cmd_load_ip_fw cmd_load_ip_fw;
|
||||
struct psp_gfx_cmd_save_restore_ip_fw cmd_save_restore_ip_fw;
|
||||
struct psp_gfx_cmd_reg_prog cmd_setup_reg_prog;
|
||||
struct psp_gfx_cmd_setup_tmr cmd_setup_vmr;
|
||||
struct psp_gfx_cmd_load_toc cmd_load_toc;
|
||||
struct psp_gfx_cmd_boot_cfg boot_cfg;
|
||||
struct psp_gfx_cmd_sriov_spatial_part cmd_spatial_part;
|
||||
};
|
||||
|
||||
struct psp_gfx_uresp_reserved
|
||||
{
|
||||
unsigned int reserved[8];
|
||||
};
|
||||
|
||||
/* Command-specific response for Fw Attestation Db */
|
||||
struct psp_gfx_uresp_fwar_db_info
|
||||
{
|
||||
unsigned int fwar_db_addr_lo;
|
||||
unsigned int fwar_db_addr_hi;
|
||||
};
|
||||
|
||||
/* Command-specific response for boot config. */
|
||||
struct psp_gfx_uresp_bootcfg {
|
||||
unsigned int boot_cfg; /* boot config data */
|
||||
};
|
||||
|
||||
/* Union of command-specific responses for GPCOM ring. */
|
||||
union psp_gfx_uresp {
|
||||
struct psp_gfx_uresp_reserved reserved;
|
||||
struct psp_gfx_uresp_bootcfg boot_cfg;
|
||||
struct psp_gfx_uresp_fwar_db_info fwar_db_info;
|
||||
};
|
||||
|
||||
/* Structure of GFX Response buffer.
|
||||
* For GPCOM I/F it is part of GFX_CMD_RESP buffer, for RBI
|
||||
* it is separate buffer.
|
||||
*/
|
||||
struct psp_gfx_resp
|
||||
{
|
||||
unsigned int status; /* +0 status of command execution */
|
||||
unsigned int session_id; /* +4 session ID in response to LoadTa command */
|
||||
unsigned int fw_addr_lo; /* +8 bits [31:0] of FW address within TMR (in response to cmd_load_ip_fw command) */
|
||||
unsigned int fw_addr_hi; /* +12 bits [63:32] of FW address within TMR (in response to cmd_load_ip_fw command) */
|
||||
unsigned int tmr_size; /* +16 size of the TMR to be reserved including MM fw and Gfx fw in response to cmd_load_toc command */
|
||||
|
||||
unsigned int reserved[11];
|
||||
|
||||
union psp_gfx_uresp uresp; /* +64 response union containing command-specific responses */
|
||||
|
||||
/* total 96 bytes */
|
||||
};
|
||||
|
||||
/* Structure of Command buffer pointed by psp_gfx_rb_frame.cmd_buf_addr_hi
|
||||
* and psp_gfx_rb_frame.cmd_buf_addr_lo.
|
||||
*/
|
||||
struct psp_gfx_cmd_resp
|
||||
{
|
||||
unsigned int buf_size; /* +0 total size of the buffer in bytes */
|
||||
unsigned int buf_version; /* +4 version of the buffer strusture; must be PSP_GFX_CMD_BUF_VERSION */
|
||||
unsigned int cmd_id; /* +8 command ID */
|
||||
|
||||
/* These fields are used for RBI only. They are all 0 in GPCOM commands
|
||||
*/
|
||||
unsigned int resp_buf_addr_lo; /* +12 bits [31:0] of GPU Virtual address of response buffer (must be 4 KB aligned) */
|
||||
unsigned int resp_buf_addr_hi; /* +16 bits [63:32] of GPU Virtual address of response buffer */
|
||||
unsigned int resp_offset; /* +20 offset within response buffer */
|
||||
unsigned int resp_buf_size; /* +24 total size of the response buffer in bytes */
|
||||
|
||||
union psp_gfx_commands cmd; /* +28 command specific structures */
|
||||
|
||||
unsigned char reserved_1[864 - sizeof(union psp_gfx_commands) - 28];
|
||||
|
||||
/* Note: Resp is part of this buffer for GPCOM ring. For RBI ring the response
|
||||
* is separate buffer pointed by resp_buf_addr_hi and resp_buf_addr_lo.
|
||||
*/
|
||||
struct psp_gfx_resp resp; /* +864 response */
|
||||
|
||||
unsigned char reserved_2[1024 - 864 - sizeof(struct psp_gfx_resp)];
|
||||
|
||||
/* total size 1024 bytes */
|
||||
};
|
||||
|
||||
|
||||
#define FRAME_TYPE_DESTROY 1 /* frame sent by KMD driver when UMD Scheduler context is destroyed*/
|
||||
|
||||
/* Structure of the Ring Buffer Frame */
|
||||
struct psp_gfx_rb_frame
|
||||
{
|
||||
unsigned int cmd_buf_addr_lo; /* +0 bits [31:0] of GPU Virtual address of command buffer (must be 4 KB aligned) */
|
||||
unsigned int cmd_buf_addr_hi; /* +4 bits [63:32] of GPU Virtual address of command buffer */
|
||||
unsigned int cmd_buf_size; /* +8 command buffer size in bytes */
|
||||
unsigned int fence_addr_lo; /* +12 bits [31:0] of GPU Virtual address of Fence for this frame */
|
||||
unsigned int fence_addr_hi; /* +16 bits [63:32] of GPU Virtual address of Fence for this frame */
|
||||
unsigned int fence_value; /* +20 Fence value */
|
||||
unsigned int sid_lo; /* +24 bits [31:0] of SID value (used only for RBI frames) */
|
||||
unsigned int sid_hi; /* +28 bits [63:32] of SID value (used only for RBI frames) */
|
||||
unsigned char vmid; /* +32 VMID value used for mapping of all addresses for this frame */
|
||||
unsigned char frame_type; /* +33 1: destory context frame, 0: all other frames; used only for RBI frames */
|
||||
unsigned char reserved1[2]; /* +34 reserved, must be 0 */
|
||||
unsigned int reserved2[7]; /* +36 reserved, must be 0 */
|
||||
/* total 64 bytes */
|
||||
};
|
||||
|
||||
#define PSP_ERR_UNKNOWN_COMMAND 0x00000100
|
||||
|
||||
enum tee_error_code {
|
||||
TEE_SUCCESS = 0x00000000,
|
||||
TEE_ERROR_NOT_SUPPORTED = 0xFFFF000A,
|
||||
};
|
||||
|
||||
#endif /* _PSP_TEE_GFX_IF_H_ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Copyright 2021 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SMU_V13_0_0_PPSMC_H
|
||||
#define SMU_V13_0_0_PPSMC_H
|
||||
|
||||
#define PPSMC_VERSION 0x1
|
||||
#define DEBUGSMC_VERSION 0x1
|
||||
|
||||
// SMU Response Codes:
|
||||
#define PPSMC_Result_OK 0x1
|
||||
#define PPSMC_Result_Failed 0xFF
|
||||
#define PPSMC_Result_UnknownCmd 0xFE
|
||||
#define PPSMC_Result_CmdRejectedPrereq 0xFD
|
||||
#define PPSMC_Result_CmdRejectedBusy 0xFC
|
||||
|
||||
// Message Definitions:
|
||||
// BASIC
|
||||
#define PPSMC_MSG_TestMessage 0x1
|
||||
#define PPSMC_MSG_GetSmuVersion 0x2
|
||||
#define PPSMC_MSG_GetDriverIfVersion 0x3
|
||||
#define PPSMC_MSG_SetAllowedFeaturesMaskLow 0x4
|
||||
#define PPSMC_MSG_SetAllowedFeaturesMaskHigh 0x5
|
||||
#define PPSMC_MSG_EnableAllSmuFeatures 0x6
|
||||
#define PPSMC_MSG_DisableAllSmuFeatures 0x7
|
||||
#define PPSMC_MSG_EnableSmuFeaturesLow 0x8
|
||||
#define PPSMC_MSG_EnableSmuFeaturesHigh 0x9
|
||||
#define PPSMC_MSG_DisableSmuFeaturesLow 0xA
|
||||
#define PPSMC_MSG_DisableSmuFeaturesHigh 0xB
|
||||
#define PPSMC_MSG_GetRunningSmuFeaturesLow 0xC
|
||||
#define PPSMC_MSG_GetRunningSmuFeaturesHigh 0xD
|
||||
#define PPSMC_MSG_SetDriverDramAddrHigh 0xE
|
||||
#define PPSMC_MSG_SetDriverDramAddrLow 0xF
|
||||
#define PPSMC_MSG_SetToolsDramAddrHigh 0x10
|
||||
#define PPSMC_MSG_SetToolsDramAddrLow 0x11
|
||||
#define PPSMC_MSG_TransferTableSmu2Dram 0x12
|
||||
#define PPSMC_MSG_TransferTableDram2Smu 0x13
|
||||
#define PPSMC_MSG_UseDefaultPPTable 0x14
|
||||
|
||||
//BACO/BAMACO/BOMACO
|
||||
#define PPSMC_MSG_EnterBaco 0x15
|
||||
#define PPSMC_MSG_ExitBaco 0x16
|
||||
#define PPSMC_MSG_ArmD3 0x17
|
||||
#define PPSMC_MSG_BacoAudioD3PME 0x18
|
||||
|
||||
//DPM
|
||||
#define PPSMC_MSG_SetSoftMinByFreq 0x19
|
||||
#define PPSMC_MSG_SetSoftMaxByFreq 0x1A
|
||||
#define PPSMC_MSG_SetHardMinByFreq 0x1B
|
||||
#define PPSMC_MSG_SetHardMaxByFreq 0x1C
|
||||
#define PPSMC_MSG_GetMinDpmFreq 0x1D
|
||||
#define PPSMC_MSG_GetMaxDpmFreq 0x1E
|
||||
#define PPSMC_MSG_GetDpmFreqByIndex 0x1F
|
||||
#define PPSMC_MSG_OverridePcieParameters 0x20
|
||||
|
||||
//DramLog Set DramAddr
|
||||
#define PPSMC_MSG_DramLogSetDramAddrHigh 0x21
|
||||
#define PPSMC_MSG_DramLogSetDramAddrLow 0x22
|
||||
#define PPSMC_MSG_DramLogSetDramSize 0x23
|
||||
#define PPSMC_MSG_SetWorkloadMask 0x24
|
||||
|
||||
#define PPSMC_MSG_GetVoltageByDpm 0x25
|
||||
#define PPSMC_MSG_SetVideoFps 0x26
|
||||
#define PPSMC_MSG_GetDcModeMaxDpmFreq 0x27
|
||||
|
||||
//Power Gating
|
||||
#define PPSMC_MSG_AllowGfxOff 0x28
|
||||
#define PPSMC_MSG_DisallowGfxOff 0x29
|
||||
#define PPSMC_MSG_PowerUpVcn 0x2A
|
||||
#define PPSMC_MSG_PowerDownVcn 0x2B
|
||||
#define PPSMC_MSG_PowerUpJpeg 0x2C
|
||||
#define PPSMC_MSG_PowerDownJpeg 0x2D
|
||||
|
||||
//Resets
|
||||
#define PPSMC_MSG_PrepareMp1ForUnload 0x2E
|
||||
#define PPSMC_MSG_Mode1Reset 0x2F
|
||||
#define PPSMC_MSG_Mode2Reset 0x4F
|
||||
|
||||
//Set SystemVirtual DramAddrHigh
|
||||
#define PPSMC_MSG_SetSystemVirtualDramAddrHigh 0x30
|
||||
#define PPSMC_MSG_SetSystemVirtualDramAddrLow 0x31
|
||||
//ACDC Power Source
|
||||
#define PPSMC_MSG_SetPptLimit 0x32
|
||||
#define PPSMC_MSG_GetPptLimit 0x33
|
||||
#define PPSMC_MSG_ReenableAcDcInterrupt 0x34
|
||||
#define PPSMC_MSG_NotifyPowerSource 0x35
|
||||
|
||||
//BTC
|
||||
#define PPSMC_MSG_RunDcBtc 0x36
|
||||
|
||||
//Debug
|
||||
#define PPSMC_MSG_GetDebugData 0x37
|
||||
|
||||
//Others
|
||||
#define PPSMC_MSG_SetTemperatureInputSelect 0x38
|
||||
#define PPSMC_MSG_SetFwDstatesMask 0x39
|
||||
#define PPSMC_MSG_SetThrottlerMask 0x3A
|
||||
|
||||
#define PPSMC_MSG_SetExternalClientDfCstateAllow 0x3B
|
||||
|
||||
#define PPSMC_MSG_SetMGpuFanBoostLimitRpm 0x3C
|
||||
|
||||
//STB to dram log
|
||||
#define PPSMC_MSG_DumpSTBtoDram 0x3D
|
||||
#define PPSMC_MSG_STBtoDramLogSetDramAddrHigh 0x3E
|
||||
#define PPSMC_MSG_STBtoDramLogSetDramAddrLow 0x3F
|
||||
#define PPSMC_MSG_STBtoDramLogSetDramSize 0x40
|
||||
|
||||
#define PPSMC_MSG_SetGpoAllow 0x41
|
||||
#define PPSMC_MSG_AllowGfxDcs 0x42
|
||||
#define PPSMC_MSG_DisallowGfxDcs 0x43
|
||||
#define PPSMC_MSG_EnableAudioStutterWA 0x44
|
||||
#define PPSMC_MSG_PowerUpUmsch 0x45
|
||||
#define PPSMC_MSG_PowerDownUmsch 0x46
|
||||
#define PPSMC_MSG_SetDcsArch 0x47
|
||||
#define PPSMC_MSG_TriggerVFFLR 0x48
|
||||
#define PPSMC_MSG_SetNumBadMemoryPagesRetired 0x49
|
||||
#define PPSMC_MSG_SetBadMemoryPagesRetiredFlagsPerChannel 0x4A
|
||||
#define PPSMC_MSG_SetPriorityDeltaGain 0x4B
|
||||
#define PPSMC_MSG_AllowIHHostInterrupt 0x4C
|
||||
#define PPSMC_MSG_DALNotPresent 0x4E
|
||||
#define PPSMC_MSG_EnableUCLKShadow 0x51
|
||||
#define PPSMC_Message_Count 0x52
|
||||
|
||||
//Debug Dump Message
|
||||
#define DEBUGSMC_MSG_TestMessage 0x1
|
||||
#define DEBUGSMC_MSG_GetDebugData 0x2
|
||||
#define DEBUGSMC_MSG_DebugDumpExit 0x3
|
||||
#define DEBUGSMC_Message_Count 0x4
|
||||
#endif
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright 2018 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __SOC15_IH_CLIENTID_H__
|
||||
#define __SOC15_IH_CLIENTID_H__
|
||||
|
||||
/*
|
||||
* Vega10+ IH clients
|
||||
* Whenever this structure is updated, which should not happen, make sure
|
||||
* soc15_ih_clientid_name in the below is also updated accordingly.
|
||||
*/
|
||||
enum soc15_ih_clientid {
|
||||
SOC15_IH_CLIENTID_IH = 0x00,
|
||||
SOC15_IH_CLIENTID_ACP = 0x01,
|
||||
SOC15_IH_CLIENTID_ATHUB = 0x02,
|
||||
SOC15_IH_CLIENTID_BIF = 0x03,
|
||||
SOC15_IH_CLIENTID_DCE = 0x04,
|
||||
SOC15_IH_CLIENTID_ISP = 0x05,
|
||||
SOC15_IH_CLIENTID_PCIE0 = 0x06,
|
||||
SOC15_IH_CLIENTID_RLC = 0x07,
|
||||
SOC15_IH_CLIENTID_SDMA0 = 0x08,
|
||||
SOC15_IH_CLIENTID_SDMA1 = 0x09,
|
||||
SOC15_IH_CLIENTID_SE0SH = 0x0a,
|
||||
SOC15_IH_CLIENTID_SE1SH = 0x0b,
|
||||
SOC15_IH_CLIENTID_SE2SH = 0x0c,
|
||||
SOC15_IH_CLIENTID_SE3SH = 0x0d,
|
||||
SOC15_IH_CLIENTID_UVD1 = 0x0e,
|
||||
SOC15_IH_CLIENTID_THM = 0x0f,
|
||||
SOC15_IH_CLIENTID_UVD = 0x10,
|
||||
SOC15_IH_CLIENTID_VCE0 = 0x11,
|
||||
SOC15_IH_CLIENTID_VMC = 0x12,
|
||||
SOC15_IH_CLIENTID_XDMA = 0x13,
|
||||
SOC15_IH_CLIENTID_GRBM_CP = 0x14,
|
||||
SOC15_IH_CLIENTID_ATS = 0x15,
|
||||
SOC15_IH_CLIENTID_ROM_SMUIO = 0x16,
|
||||
SOC15_IH_CLIENTID_DF = 0x17,
|
||||
SOC15_IH_CLIENTID_VCE1 = 0x18,
|
||||
SOC15_IH_CLIENTID_PWR = 0x19,
|
||||
SOC15_IH_CLIENTID_RESERVED = 0x1a,
|
||||
SOC15_IH_CLIENTID_UTCL2 = 0x1b,
|
||||
SOC15_IH_CLIENTID_EA = 0x1c,
|
||||
SOC15_IH_CLIENTID_UTCL2LOG = 0x1d,
|
||||
SOC15_IH_CLIENTID_MP0 = 0x1e,
|
||||
SOC15_IH_CLIENTID_MP1 = 0x1f,
|
||||
|
||||
SOC15_IH_CLIENTID_MAX,
|
||||
|
||||
SOC15_IH_CLIENTID_VCN = SOC15_IH_CLIENTID_UVD,
|
||||
SOC15_IH_CLIENTID_VCN1 = SOC15_IH_CLIENTID_UVD1,
|
||||
SOC15_IH_CLIENTID_SDMA2 = SOC15_IH_CLIENTID_ACP,
|
||||
SOC15_IH_CLIENTID_SDMA3 = SOC15_IH_CLIENTID_DCE,
|
||||
SOC15_IH_CLIENTID_SDMA3_Sienna_Cichlid = SOC15_IH_CLIENTID_ISP,
|
||||
SOC15_IH_CLIENTID_SDMA4 = SOC15_IH_CLIENTID_ISP,
|
||||
SOC15_IH_CLIENTID_SDMA5 = SOC15_IH_CLIENTID_VCE0,
|
||||
SOC15_IH_CLIENTID_SDMA6 = SOC15_IH_CLIENTID_XDMA,
|
||||
SOC15_IH_CLIENTID_SDMA7 = SOC15_IH_CLIENTID_VCE1,
|
||||
SOC15_IH_CLIENTID_VMC1 = SOC15_IH_CLIENTID_PCIE0,
|
||||
};
|
||||
|
||||
extern const char *soc15_ih_clientid_name[];
|
||||
|
||||
/*
|
||||
* soc21 IH clients
|
||||
*/
|
||||
enum soc21_ih_clientid {
|
||||
SOC21_IH_CLIENTID_IH = 0x00,
|
||||
SOC21_IH_CLIENTID_ATHUB = 0x02,
|
||||
SOC21_IH_CLIENTID_BIF = 0x03,
|
||||
SOC21_IH_CLIENTID_DCN = 0x04,
|
||||
SOC21_IH_CLIENTID_ISP = 0x05,
|
||||
SOC21_IH_CLIENTID_MP3 = 0x06,
|
||||
SOC21_IH_CLIENTID_RLC = 0x07,
|
||||
SOC21_IH_CLIENTID_GFX = 0x0a,
|
||||
SOC21_IH_CLIENTID_IMU = 0x0b,
|
||||
SOC21_IH_CLIENTID_VCN1 = 0x0e,
|
||||
SOC21_IH_CLIENTID_THM = 0x0f,
|
||||
SOC21_IH_CLIENTID_VCN = 0x10,
|
||||
SOC21_IH_CLIENTID_VPE1 = 0x11,
|
||||
SOC21_IH_CLIENTID_VMC = 0x12,
|
||||
SOC21_IH_CLIENTID_GRBM_CP = 0x14,
|
||||
SOC21_IH_CLIENTID_ROM_SMUIO = 0x16,
|
||||
SOC21_IH_CLIENTID_DF = 0x17,
|
||||
SOC21_IH_CLIENTID_VPE = 0x18,
|
||||
SOC21_IH_CLIENTID_PWR = 0x19,
|
||||
SOC21_IH_CLIENTID_LSDMA = 0x1a,
|
||||
SOC21_IH_CLIENTID_MP0 = 0x1e,
|
||||
SOC21_IH_CLIENTID_MP1 = 0x1f,
|
||||
SOC21_IH_CLIENTID_MAX,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,56 @@
|
||||
import re, ctypes, sys
|
||||
|
||||
from tinygrad.runtime.autogen import libpciaccess
|
||||
from tinygrad.runtime.autogen.am import am, mp_11_0, mp_13_0_0, nbio_4_3_0, mmhub_3_0_0, gc_11_0_0, osssys_6_0_0
|
||||
|
||||
def parse_amdgpu_logs(log_content, register_names=None):
|
||||
register_map = register_names or REGISTER_NAMES
|
||||
|
||||
final = ""
|
||||
def replace_register(match):
|
||||
register = match.group(1)
|
||||
return f"Reading register {register_map.get(int(register, base=16), register)}"
|
||||
|
||||
pattern = r'Reading register (0x[0-9a-fA-F]+)'
|
||||
|
||||
processed_log = re.sub(pattern, replace_register, log_content)
|
||||
|
||||
def replace_register_2(match):
|
||||
register = match.group(1)
|
||||
return f"Writing register {register_map.get(int(register, base=16), register)}"
|
||||
|
||||
pattern = r'Writing register (0x[0-9a-fA-F]+)'
|
||||
processed_log = re.sub(pattern, replace_register_2, processed_log)
|
||||
|
||||
lines = processed_log.split('\n')
|
||||
|
||||
in_trace = False
|
||||
cleaned_lines = []
|
||||
|
||||
return '\n'.join(cleaned_lines)
|
||||
|
||||
def main():
|
||||
regs_offset = {13: {0: [3072, 37784576]}, 28: {0: [93184, 37754880], 1: [201327616, 201461760], 2: [209716224, 209850368], 3: [218104832, 218238976], 4: [226493440, 226627584], 5: [234882048, 235016192], 6: [243270656, 243404800]}, 21: {0: [28672, 12582912, 37795840, 130023424, 306184192], 1: [201326592, 201463808, 201465856, 204210176, 204472320], 2: [209715200, 209852416, 209854464, 212598784, 212860928], 3: [218103808, 218241024, 218243072, 220987392, 221249536], 4: [226492416, 226629632, 226631680, 229376000, 229638144], 5: [234881024, 235018240, 235020288, 237764608, 238026752], 6: [243269632, 243406848, 243408896, 246153216, 246415360]}, 22: {0: [18, 192, 13504, 36864, 37764096]}, 1: {0: [4704, 40960, 114688, 37760000]}, 2: {0: [3872, 37790720]}, 11: {0: [70656, 38103040]}, 12: {0: [106496, 37783552]}, 15: {0: [90112, 14417920, 14680064, 14942208, 38009856]}, 16: {0: [90112, 14417920, 14680064, 14942208, 38009856]}, 14: {0: [0, 20, 3360, 66560, 37859328, 67371008]}, 26: {0: [0, 20, 3360, 66560, 37859328, 67371008]}, 23: {0: [4256, 37789696]}, 33: {0: [0, 20, 3360, 66560, 37859328, 67371008]}, 25: {0: []}, 3: {0: [4704, 40960, 114688, 37760000]}, 4: {0: [4704, 40960, 114688, 37760000]}, 24: {0: [92160, 92672, 37752832, 54788096]}, 27: {0: [91648, 37751808], 1: [201339904, 201458176], 2: [209728512, 209846784], 3: [218117120, 218235392], 4: [226505728, 226624000], 5: [234894336, 235012608], 6: [243282944, 243401216]}, 29: {0: [201342976, 201344000, 205520896, 205537280], 1: [209731584, 209732608, 213909504, 213925888], 2: [218120192, 218121216, 222298112, 222314496], 3: [226508800, 226509824, 230686720, 230703104], 4: [234897408, 234898432, 239075328, 239091712], 5: [243286016, 243287040, 247463936, 247480320]}, 17: {0: [30720, 32256], 1: [31488, 73728]}}
|
||||
|
||||
def _prepare_registers(modules):
|
||||
for base, m in modules:
|
||||
for k, regval in m.__dict__.items():
|
||||
if k.startswith("reg") and not k.endswith("_BASE_IDX") and (base_idx:=getattr(m, f"{k}_BASE_IDX", None)) is not None:
|
||||
REGISTER_NAMES[regs_offset[am.__dict__.get(f"{base}_HWIP")][0][base_idx] + regval] = k
|
||||
|
||||
_prepare_registers([("MP0", mp_13_0_0), ("NBIO", nbio_4_3_0), ("MMHUB", mmhub_3_0_0), ("GC", gc_11_0_0), ("OSSSYS", osssys_6_0_0)])
|
||||
|
||||
with open(sys.argv[1], 'r') as f:
|
||||
log_content = log_content_them = f.read()
|
||||
|
||||
processed_log = parse_amdgpu_logs(log_content)
|
||||
|
||||
with open(sys.argv[2], 'w') as f:
|
||||
f.write(processed_log)
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) != 3:
|
||||
print("Usage: <input_file_path> <output_file_path>")
|
||||
sys.exit(1)
|
||||
|
||||
main()
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
PYTHON_PATH=$(readlink -f $(which python3))
|
||||
sudo setcap 'cap_dac_override,cap_sys_rawio,cap_sys_admin=ep' $PYTHON_PATH
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
sudo modprobe vfio-pci disable_idle_d3=1
|
||||
@@ -70,7 +70,7 @@ def export_to_coco(class_map, annotations, image_list, dataset_path, output_path
|
||||
cats = [{"id": i, "name": c, "supercategory": None} for i, c in enumerate(classes)]
|
||||
categories_map = pd.DataFrame([(i, c) for i, c in enumerate(classes)], columns=["category_id", "category_name"])
|
||||
class_map = class_map.merge(categories_map, left_on="DisplayName", right_on="category_name", how="inner")
|
||||
annotations = annotations[np.isin(annotations["ImageID"], image_list)]
|
||||
annotations = annotations[annotations["ImageID"].isin(image_list)]
|
||||
annotations = annotations.merge(class_map, on="LabelName", how="inner")
|
||||
annotations["image_id"] = pd.factorize(annotations["ImageID"].tolist())[0]
|
||||
annotations[["height", "width"]] = annotations.apply(lambda x: extract_dims(dataset_path / f"{x['ImageID']}.jpg"), axis=1, result_type="expand")
|
||||
@@ -96,8 +96,8 @@ def export_to_coco(class_map, annotations, image_list, dataset_path, output_path
|
||||
json.dump(coco_annotations, fp)
|
||||
|
||||
def get_image_list(class_map, annotations, classes=MLPERF_CLASSES):
|
||||
labels = class_map[np.isin(class_map["DisplayName"], classes)]["LabelName"]
|
||||
image_ids = annotations[np.isin(annotations["LabelName"], labels)]["ImageID"].unique()
|
||||
labels = class_map[class_map["DisplayName"].isin(classes)]["LabelName"]
|
||||
image_ids = annotations[annotations["LabelName"].isin(labels)]["ImageID"].unique()
|
||||
return image_ids
|
||||
|
||||
def download_image(bucket, subset, image_id, data_dir):
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,38 @@
|
||||
# Use a recent Ubuntu base image.
|
||||
FROM ubuntu:22.04
|
||||
|
||||
# Install required packages.
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git \
|
||||
build-essential \
|
||||
python3 \
|
||||
python3-pip \
|
||||
python3-tomli \
|
||||
pkg-config \
|
||||
libglib2.0-dev \
|
||||
libfdt-dev \
|
||||
libpixman-1-dev \
|
||||
zlib1g-dev \
|
||||
ninja-build \
|
||||
meson \
|
||||
wget
|
||||
|
||||
# Clone QEMU source (you can pin a specific version if desired)
|
||||
RUN wget https://download.qemu.org/qemu-9.2.0.tar.xz && tar xvJf qemu-9.2.0.tar.xz
|
||||
|
||||
WORKDIR /qemu-9.2.0
|
||||
|
||||
RUN apt-get install -y flex bison
|
||||
|
||||
# Configure QEMU to build the hexagon user-mode emulator.
|
||||
RUN ./configure --target-list=hexagon-linux-user && make -j$(nproc)
|
||||
|
||||
# Optionally, install QEMU into /usr/local (or leave it in place).
|
||||
RUN make install
|
||||
|
||||
# delete the source (for space)
|
||||
RUN cd .. && rm -rf /qemu-9.2.0
|
||||
|
||||
# The QEMU binaries will be in /usr/local/bin.
|
||||
# Set the entrypoint to bash so you can interact with the container.
|
||||
ENTRYPOINT ["/bin/bash"]
|
||||
@@ -37,7 +37,7 @@ if __name__ == "__main__":
|
||||
print("mmapped", hex(res))
|
||||
to_mv(res, 0x10)[1] = 0xaa
|
||||
|
||||
from tinygrad.runtime.ops_clang import ClangCompiler
|
||||
from tinygrad.runtime.ops_dsp import ClangCompiler
|
||||
cc = ClangCompiler(args=["--target=hexagon", "-mcpu=hexagonv65", "-fuse-ld=lld", "-nostdlib"])
|
||||
|
||||
obj = cc.compile("""
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
from tinygrad import Device
|
||||
|
||||
# PATH=/opt/homebrew/opt/llvm/bin:$PATH python3 extra/dsp/opt.py
|
||||
|
||||
if __name__ == "__main__":
|
||||
compiler = Device["DSP"].compiler
|
||||
|
||||
lib = compiler.compile("""
|
||||
typedef long HVX_Vector __attribute__((__vector_size__(128))) __attribute__ ((aligned(128)));
|
||||
typedef long HVX_VectorPair __attribute__((__vector_size__(256))) __attribute__ ((aligned(256)));
|
||||
|
||||
void test(unsigned char *c, unsigned char *a, unsigned char *b) {
|
||||
HVX_Vector t0 = *(HVX_Vector*)a;
|
||||
//HVX_VectorPair t1 = *((HVX_VectorPair*)b);
|
||||
HVX_Vector acc = __builtin_HEXAGON_V6_vd0_128B();
|
||||
for (int i = 0; i < 128; i++) {
|
||||
//__builtin_HEXAGON_V6_lvsplatb_128B(t0[i])
|
||||
//acc += __builtin_HEXAGON_V6_lvsplatb_128B(t0[i]) * t1;
|
||||
//acc += t0[i] * t1;
|
||||
unsigned int t1 = ((unsigned int *)b)[i];
|
||||
//acc = __builtin_HEXAGON_V6_vrmpyub_acc_128B(acc, t0, t1);
|
||||
acc = __builtin_HEXAGON_V6_vrmpybus_acc_128B(acc, t0, t1);
|
||||
}
|
||||
*((HVX_Vector*)c) = acc;
|
||||
}""")
|
||||
|
||||
compiler.disassemble(lib)
|
||||
@@ -1,3 +1,4 @@
|
||||
# mypy: ignore-errors
|
||||
#!/usr/bin/env python3
|
||||
import os, ctypes, ctypes.util, struct, platform, time
|
||||
from tinygrad.runtime.autogen import libc, qcom_dsp
|
||||
|
||||
@@ -94,7 +94,6 @@ def export_model_webgpu(functions, statements, bufs, weight_names, input_names,
|
||||
output_return = '[{}]'.format(",".join([f'resultBuffer{i}' for i in range(len(output_names))]))
|
||||
return f"""
|
||||
const {exported_name} = (() => {{
|
||||
let weights = null;
|
||||
const getTensorBuffer = (safetensorBuffer, tensorMetadata) => {{
|
||||
return safetensorBuffer.subarray(...tensorMetadata.data_offsets);
|
||||
}};
|
||||
@@ -147,8 +146,7 @@ const addComputePass = (device, commandEncoder, pipeline, layout, infinityUnifor
|
||||
{kernel_code}
|
||||
|
||||
const setupNet = async (device, safetensor) => {{
|
||||
weights = safetensor;
|
||||
const metadata = safetensor ? getTensorMetadata(safetensor) : null;
|
||||
const metadata = getTensorMetadata(safetensor);
|
||||
const infinityBuf = createInfinityUniformBuf(device);
|
||||
|
||||
{layouts}
|
||||
@@ -186,12 +184,8 @@ const setupNet = async (device, safetensor) => {{
|
||||
return {output_return};
|
||||
}}
|
||||
}}
|
||||
const load = async (device, weight_path) =>
|
||||
{{
|
||||
const buffer = weight_path ? await fetch(weight_path).then(x => x.arrayBuffer()) : null;
|
||||
return setupNet(device, buffer ? new Uint8Array(buffer) : null);
|
||||
}}
|
||||
return {{ load, getWeights: () => weights }};
|
||||
const load = async (device, weight_path) => {{ return await fetch(weight_path).then(x => x.arrayBuffer()).then(x => setupNet(device, new Uint8Array(x))); }}
|
||||
return {{ load }};
|
||||
}})();
|
||||
export default {exported_name};
|
||||
"""
|
||||
|
||||
+20
-15
@@ -1,11 +1,12 @@
|
||||
import numpy as np
|
||||
from tinygrad.helpers import getenv
|
||||
from tinygrad import dtypes, Tensor
|
||||
|
||||
dtype_in = dtypes.half if getenv("HALF") else dtypes.bfloat16 if getenv("BFLOAT16") else dtypes.float
|
||||
acc_dtype = dtypes.half if getenv("ACC_HALF") else dtypes.bfloat16 if getenv("ACC_BFLOAT16") else None
|
||||
if getenv("INT"):
|
||||
dtype_in = dtypes.int8
|
||||
acc_dtype = dtypes.int32
|
||||
if getenv("INT"): dtype_in, acc_dtype = dtypes.int8, dtypes.int32
|
||||
if getenv("UINT"): dtype_in, acc_dtype = dtypes.uint8, dtypes.int32
|
||||
|
||||
N = getenv("N", 4096)
|
||||
M = getenv("M", N)
|
||||
K = getenv("K", N)
|
||||
@@ -14,21 +15,25 @@ ATOL = getenv("ATOL", 1e-4)
|
||||
RTOL = getenv("RTOL", 3e-2)
|
||||
|
||||
if __name__ == "__main__":
|
||||
a, b = Tensor.rand(M, K, dtype=dtype_in).realize(), Tensor.rand(K, N, dtype=dtype_in).realize()
|
||||
def init_matrix(rows, cols):
|
||||
if dtype_in in dtypes.ints:
|
||||
return Tensor.randint((rows, cols), dtype=dtype_in).realize()
|
||||
return Tensor.rand(rows, cols, dtype=dtype_in).realize()
|
||||
|
||||
a, b = init_matrix(M, K), init_matrix(K, N)
|
||||
for i in range(CNT):
|
||||
if i > 0 and getenv("RAND", 0) != 0:
|
||||
a, b = Tensor.rand(M, K, dtype=dtype_in).realize(), Tensor.rand(K, N, dtype=dtype_in).realize()
|
||||
a, b = init_matrix(M, K), init_matrix(K, N)
|
||||
c = a.matmul(b, acc_dtype=acc_dtype).realize()
|
||||
comp = a.numpy().astype(np.float32) @ b.numpy().astype(np.float32)
|
||||
nc = c.numpy()
|
||||
|
||||
ref = a.numpy().astype(np.float32) @ b.numpy().astype(np.float32)
|
||||
res = c.numpy()
|
||||
try:
|
||||
np.testing.assert_allclose(nc, comp, atol=ATOL, rtol=RTOL)
|
||||
np.testing.assert_allclose(res, ref, rtol=RTOL, atol=ATOL)
|
||||
except AssertionError as e:
|
||||
if getenv("DEBUG_VALUES") > 0:
|
||||
indices = np.where(~np.isclose(nc, comp, rtol=RTOL, atol=ATOL))
|
||||
non_matching_elements_nc = nc[indices]
|
||||
non_matching_elements_comp = comp[indices]
|
||||
print(indices)
|
||||
print("result :", non_matching_elements_nc)
|
||||
print("ground truth:", non_matching_elements_comp)
|
||||
if getenv("DEBUG_VALUES", 0) > 0:
|
||||
mismatch = np.where(~np.isclose(res, ref, rtol=RTOL, atol=ATOL))
|
||||
print("Mismatch indices:", mismatch)
|
||||
print("Result :", res[mismatch])
|
||||
print("Ground truth :", ref[mismatch])
|
||||
raise e
|
||||
|
||||
@@ -30,14 +30,13 @@ except ImportError:
|
||||
|
||||
import os
|
||||
from tinygrad.tensor import Tensor
|
||||
from tinygrad.engine.schedule import create_schedule
|
||||
|
||||
# define the compute
|
||||
A = Tensor.rand(M, K, device="clang")
|
||||
B = Tensor.rand(K, N, device="clang")
|
||||
C = (A.reshape(M, 1, K) * B.permute(1,0).reshape(1, N, K)).sum(axis=2)
|
||||
|
||||
sched = create_schedule([C.lazydata])
|
||||
sched = C.schedule()
|
||||
from tinygrad.codegen.kernel import Kernel
|
||||
from tinygrad.device import CompilerOptions
|
||||
lin = Kernel(sched[-1].ast, CompilerOptions(has_local=False, supports_float4=False))
|
||||
|
||||
+5
-4
@@ -1,8 +1,8 @@
|
||||
import numpy as np
|
||||
from tinygrad.tensor import Tensor
|
||||
from tinygrad.tensor import Tensor, _to_np_dtype
|
||||
|
||||
def mask_like(like, mask_inx, mask_value = 1.0):
|
||||
mask = np.zeros_like(like).reshape(-1)
|
||||
mask = np.zeros(like.shape, dtype=_to_np_dtype(like.dtype)).reshape(-1)
|
||||
mask[mask_inx] = mask_value
|
||||
return mask.reshape(like.shape)
|
||||
|
||||
@@ -19,7 +19,8 @@ def jacobian(func, input):
|
||||
|
||||
# tinygrad doesn't support slicing, tiny-hack to select
|
||||
# the needed scalar an backpropagate only through it
|
||||
o_scalar = Tensor(mask_like(output.numpy(), o, 1.)).mul(output).sum()
|
||||
o_scalar = Tensor(mask_like(output, o, 1.)).mul(output).sum()
|
||||
o_scalar = Tensor(mask_like(output, o, 1.)).mul(output).sum()
|
||||
o_scalar.backward()
|
||||
|
||||
for i, grad in enumerate(input.grad.numpy().reshape(-1)):
|
||||
@@ -34,7 +35,7 @@ def numerical_jacobian(func, input, eps = 1e-3):
|
||||
NJ = np.zeros((jo, ji), dtype=np.float32)
|
||||
|
||||
for i in range(ji):
|
||||
eps_perturb = mask_like(input.numpy(), i, mask_value = eps)
|
||||
eps_perturb = mask_like(input, i, mask_value = eps)
|
||||
|
||||
output_perturb_add = func(Tensor(input.numpy() + eps_perturb)).numpy().reshape(-1)
|
||||
output_perturb_sub = func(Tensor(input.numpy() - eps_perturb)).numpy().reshape(-1)
|
||||
|
||||
@@ -4,7 +4,6 @@ from tinygrad import Tensor, Device
|
||||
import tinygrad.runtime.autogen.amd_gpu as amd_gpu
|
||||
import tinygrad.runtime.autogen.kfd as kfd
|
||||
import tinygrad.runtime.autogen.hsa as hsa
|
||||
from tinygrad.engine.schedule import create_schedule
|
||||
from tinygrad.runtime.ops_amd import kio, AMDProgram
|
||||
from tinygrad.helpers import to_mv
|
||||
|
||||
@@ -49,7 +48,7 @@ if __name__ == "__main__":
|
||||
a = Tensor([0.,1.,2.], device="KFD").realize()
|
||||
b = a + 7
|
||||
b.lazydata.buffer.allocate()
|
||||
si = create_schedule([b.lazydata])[-1]
|
||||
si = b.schedule()[-1]
|
||||
runner = dev.get_runner(*si.ast)
|
||||
prg: AMDProgram = runner.clprg
|
||||
print("device initted")
|
||||
|
||||
@@ -162,7 +162,7 @@ def mcts_search(lin:Kernel, rawbufs:List[Buffer], amt:int) -> Kernel:
|
||||
if node.n == 0: return
|
||||
for parent in node.parents: G.add_edge(parent, node)
|
||||
gopts = node.kernel.applied_opts
|
||||
edge_lbl = f"{str(gopts[-1].op)[7:]} {gopts[-1].axis} {gopts[-1].amt}" if len(gopts) else "ROOT"
|
||||
edge_lbl = f"{str(gopts[-1].op)[7:]} {gopts[-1].axis} {gopts[-1].arg}" if len(gopts) else "ROOT"
|
||||
G.add_node(node, label=f"{node.i+1}\n{node.tm:.2f} us\n{edge_lbl}\nt {node.t:.2f}\nn {node.n}",
|
||||
fillcolor="#80ff8080" if node.tm == best_tm else "#ffff8080", style='filled' if node.t == best_tm else '')
|
||||
if node.children is not None:
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
import ctypes, struct, os
|
||||
from typing import Any
|
||||
from dataclasses import dataclass
|
||||
from tinygrad.helpers import round_up
|
||||
|
||||
class VirtFileDesc:
|
||||
def __init__(self, fd): self.fd, self.off = fd, 0
|
||||
def read(self, fd, buf, sz): raise NotImplementedError()
|
||||
def ioctl(self, fd, req, argp): raise NotImplementedError()
|
||||
def mmap(self, st, sz, prot, flags, fd, off): raise NotImplementedError()
|
||||
def write(self, fd, buf, sz): raise NotImplementedError()
|
||||
def lseek(self, fd, off, whence): raise NotImplementedError()
|
||||
def fstat(self, fd, buf): raise NotImplementedError()
|
||||
def getdents(self, fd, buf, sz): return -1
|
||||
def close(self, fd): return 0
|
||||
|
||||
class TextFileDesc(VirtFileDesc):
|
||||
def __init__(self, fd, text):
|
||||
super().__init__(fd)
|
||||
self.content = ctypes.create_string_buffer(text.encode())
|
||||
self.sz = len(self.content) - 1
|
||||
|
||||
def ioctl(self, fd, req, argp): return 0
|
||||
def write(self, fd, buf, sz): return -1
|
||||
def read(self, fd, buf, sz):
|
||||
ctypes.memmove(buf, ctypes.addressof(self.content) + self.off, rdsz:=min(sz, self.sz - self.off))
|
||||
self.off += rdsz
|
||||
return rdsz
|
||||
def lseek(self, fd, off, whence):
|
||||
if whence == os.SEEK_SET: self.off = off
|
||||
elif whence == os.SEEK_CUR: self.off += off
|
||||
elif whence == os.SEEK_END: self.off = self.sz + off
|
||||
else: return -1
|
||||
return 0
|
||||
def fstat(self, fd, buf):
|
||||
ctypes.memmove(buf, VirtFile.build_fstat(st_size=self.sz), 88)
|
||||
return 0
|
||||
|
||||
class DirFileDesc(VirtFileDesc):
|
||||
def __init__(self, fd, child_names):
|
||||
super().__init__(fd)
|
||||
child_names = ['.', '..'] + child_names
|
||||
|
||||
tmp = b''
|
||||
for ino, name in enumerate(child_names):
|
||||
tmp += VirtFile.build_dirent(ino + 1, 0, name)
|
||||
self.content = ctypes.create_string_buffer(tmp)
|
||||
self.sz = len(self.content) - 1
|
||||
|
||||
def ioctl(self, fd, req, argp): return 0
|
||||
def write(self, fd, buf, sz): return -1
|
||||
def read(self, fd, buf, sz): return -1
|
||||
def lseek(self, fd, off, whence):
|
||||
if whence == os.SEEK_SET: self.off = off
|
||||
elif whence == os.SEEK_CUR: self.off += off
|
||||
elif whence == os.SEEK_END: self.off = self.sz + off
|
||||
else: return -1
|
||||
return 0
|
||||
|
||||
def getdents(self, fd, buf, sz):
|
||||
if self.sz == self.off: return 0
|
||||
if sz < self.sz: return -1
|
||||
ctypes.memmove(buf, ctypes.addressof(self.content) + self.off, self.sz)
|
||||
self.off = self.sz
|
||||
return self.sz
|
||||
|
||||
def fstat(self, fd, buf):
|
||||
ctypes.memmove(buf, VirtFile.build_fstat(st_mode=0o40755), 96)
|
||||
return 0
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class VirtFile():
|
||||
path: str
|
||||
fdcls: Any # TODO: fix this Union[VirtFileDesc, functools.partial[VirtFileDesc]]
|
||||
|
||||
@staticmethod
|
||||
def build_fstat(st_dev=0x20, st_ino=0x100000, st_mode=0o100777, st_nlink=1, st_uid=0, st_gid=0, st_rdev=0, st_size=0,
|
||||
st_blksize=4096, st_blocks=0, st_atime=0, st_mtime=0, st_ctime=0):
|
||||
assert (ssz:=struct.calcsize(fmt_string:='QQQIIIQQiQqqq')) == 96, f"{ssz} != 96"
|
||||
return struct.pack(fmt_string, st_dev, st_ino, st_nlink, st_mode, st_uid, st_gid,
|
||||
st_rdev, st_size, st_blksize, st_blocks, st_atime, st_mtime, st_ctime)
|
||||
|
||||
@staticmethod
|
||||
def build_dirent(d_ino, d_off, d_name, d_type=None):
|
||||
# Start with packing inode number, offset, and record length
|
||||
d_reclen = round_up(19 + len(d_name) + 1, 8)
|
||||
packed_data = struct.pack('QQHc', d_ino, d_off, d_reclen, b'\x04')
|
||||
d_name_bytes = d_name.encode()
|
||||
return packed_data + d_name_bytes + b'\x00' + b'\x00' * (d_reclen - (19 + len(d_name) + 1))
|
||||
|
||||
class VirtDriver:
|
||||
def __init__(self):
|
||||
self.tracked_files = []
|
||||
self.tracked_addresses = []
|
||||
def track_address(self, staddr, enaddr, rcb, wcb): self.tracked_addresses.append((staddr, enaddr, rcb, wcb))
|
||||
def open(self, name, flags, mode, fdcls): raise NotImplementedError()
|
||||
@@ -1,204 +0,0 @@
|
||||
import ctypes, ctypes.util, struct, platform, pathlib, re, time, os, builtins, atexit
|
||||
from extra.mockgpu.nv.nvdriver import NVDriver
|
||||
from extra.mockgpu.amd.amddriver import AMDDriver
|
||||
from tinygrad.helpers import from_mv, to_mv
|
||||
start = time.perf_counter()
|
||||
|
||||
# *** ioctl lib ***
|
||||
libc = ctypes.CDLL(ctypes.util.find_library("c"))
|
||||
libc.mmap.argtypes = [ctypes.c_void_p, ctypes.c_size_t, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_long]
|
||||
libc.mmap.restype = ctypes.c_void_p
|
||||
libc.munmap.argtypes = [ctypes.c_void_p, ctypes.c_size_t]
|
||||
libc.munmap.restype = ctypes.c_int
|
||||
libc.fdopendir.argtypes = [ctypes.c_int]
|
||||
libc.fdopendir.restype = ctypes.c_void_p
|
||||
|
||||
# platform.processor calls `uname -p` which can return `unknown` on some systems
|
||||
processor = os.getenv("IOCTL_PROCESSOR") or platform.processor()
|
||||
OPEN_SYSCALL = {"aarch64": None, "x86_64": 2}[processor]
|
||||
CLOSE_SYSCALL = {"aarch64": 57, "x86_64": 3}[processor]
|
||||
READ_SYSCALL = {"aarch64": 63, "x86_64": 0}[processor]
|
||||
IOCTL_SYSCALL = {"aarch64": 29, "x86_64": 16}[processor]
|
||||
MMAP_SYSCALL = {"aarch64": 222, "x86_64": 9}[processor]
|
||||
LSEEK_SYSCALL = {"aarch64": 62, "x86_64": 8}[processor]
|
||||
NEWFSTATAT_SYSCALL = {"aarch64": 79, "x86_64": 262}[processor]
|
||||
GETDENTS64_SYSCALL = {"aarch64": 61, "x86_64": 217}[processor]
|
||||
|
||||
def install_hook(c_function, python_function):
|
||||
python_function_addr = ctypes.cast(ctypes.byref(python_function), ctypes.POINTER(ctypes.c_ulong)).contents.value
|
||||
if processor == "x86_64":
|
||||
# tramp = b"\x49\xB8" + struct.pack("Q", python_function_addr) + b"\x41\xFF\xE0"
|
||||
# push r9
|
||||
# push r9
|
||||
# mov r9, 0x1122334455667788
|
||||
# mov [rsp+8], r9
|
||||
# pop r9
|
||||
# ret
|
||||
tramp = b"\x41\x51\x41\x51\x49\xB9" + struct.pack("Q", python_function_addr) + b"\x4C\x89\x4C\x24\x08\x41\x59\xC3"
|
||||
else:
|
||||
raise Exception(f"processor {processor} not supported")
|
||||
|
||||
original_bc = (ctypes.c_char * 64)()
|
||||
|
||||
# get real ioctl address
|
||||
ioctl_address = ctypes.cast(ctypes.byref(c_function), ctypes.POINTER(ctypes.c_ulong))
|
||||
|
||||
# hook ioctl
|
||||
ret = libc.mprotect(ctypes.c_ulong((ioctl_address.contents.value//0x1000)*0x1000), 0x2000, 7)
|
||||
assert ret == 0
|
||||
libc.memcpy(original_bc, ioctl_address.contents, len(tramp))
|
||||
libc.memcpy(ioctl_address.contents, ctypes.create_string_buffer(tramp), len(tramp))
|
||||
|
||||
# Restore correct functions to close libs after python exits
|
||||
def __restore(): libc.memcpy(ioctl_address.contents, original_bc, len(tramp))
|
||||
atexit.register(__restore)
|
||||
|
||||
drivers = [AMDDriver(), NVDriver()]
|
||||
tracked_fds = {}
|
||||
|
||||
@ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_char_p, ctypes.c_int, ctypes.c_ulong)
|
||||
def _open(name, flags, mode):
|
||||
for d in drivers:
|
||||
pyname = name.decode()
|
||||
for x in d.tracked_files:
|
||||
if pyname == x.path:
|
||||
virtfd = d.open(pyname, flags, mode, x)
|
||||
tracked_fds[virtfd.fd] = virtfd
|
||||
return virtfd.fd
|
||||
|
||||
libc.syscall.argtypes = [ctypes.c_ulong, ctypes.c_char_p, ctypes.c_int, ctypes.c_ulong]
|
||||
libc.syscall.restype = ctypes.c_int
|
||||
return libc.syscall(OPEN_SYSCALL, name, flags, mode)
|
||||
|
||||
@ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_char_p)
|
||||
def _opendir(name):
|
||||
fd = _open(name, os.O_RDONLY| os.O_DIRECTORY, 0)
|
||||
if fd >= 0x80:
|
||||
fake_dirfd = _open(".".encode(), os.O_RDONLY| os.O_DIRECTORY, 0)
|
||||
st = libc.fdopendir(fake_dirfd)
|
||||
to_mv(st, 8).cast('Q')[0] = fd
|
||||
return st
|
||||
else: return libc.fdopendir(fd)
|
||||
|
||||
@ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int)
|
||||
def _close(fd):
|
||||
if fd in tracked_fds:
|
||||
tracked_fds[fd].close(fd)
|
||||
tracked_fds.pop(fd)
|
||||
return 0
|
||||
|
||||
libc.syscall.argtypes = [ctypes.c_ulong, ctypes.c_int]
|
||||
libc.syscall.restype = ctypes.c_int
|
||||
return libc.syscall(CLOSE_SYSCALL, fd)
|
||||
|
||||
@ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p)
|
||||
def _closedir(st): return _close(to_mv(st, 8).cast('Q')[0])
|
||||
|
||||
@ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int, ctypes.c_ulong, ctypes.c_void_p)
|
||||
def _ioctl(fd, request, argp):
|
||||
if fd in tracked_fds: return tracked_fds[fd].ioctl(fd, request, argp)
|
||||
|
||||
libc.syscall.argtypes = [ctypes.c_ulong, ctypes.c_int, ctypes.c_ulong, ctypes.c_void_p]
|
||||
libc.syscall.restype = ctypes.c_int
|
||||
return libc.syscall(IOCTL_SYSCALL, ctypes.c_int(fd), ctypes.c_ulong(request), ctypes.c_void_p(argp))
|
||||
|
||||
@ctypes.CFUNCTYPE(ctypes.c_long, ctypes.c_int, ctypes.c_void_p, ctypes.c_size_t)
|
||||
def _read(fd, buf, sz):
|
||||
if fd in tracked_fds: return tracked_fds[fd].read(fd, buf, sz)
|
||||
|
||||
libc.syscall.argtypes = [ctypes.c_ulong, ctypes.c_int, ctypes.c_void_p, ctypes.c_size_t]
|
||||
libc.syscall.restype = ctypes.c_int
|
||||
return libc.syscall(READ_SYSCALL, ctypes.c_int(fd), ctypes.c_void_p(buf), ctypes.c_size_t(sz))
|
||||
|
||||
@ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int, ctypes.c_ulong, ctypes.c_int)
|
||||
def _lseek64(fd, off, whence):
|
||||
if fd in tracked_fds: return tracked_fds[fd].lseek(fd, off, whence)
|
||||
|
||||
libc.syscall.argtypes = [ctypes.c_ulong, ctypes.c_int, ctypes.c_ulong, ctypes.c_int]
|
||||
libc.syscall.restype = ctypes.c_int
|
||||
return libc.syscall(LSEEK_SYSCALL, fd, off, whence)
|
||||
|
||||
@ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_char_p, ctypes.c_void_p)
|
||||
def _stat64(name, buf):
|
||||
for d in drivers:
|
||||
pyname = name.decode()
|
||||
for x in d.tracked_files:
|
||||
if pyname == x.path:
|
||||
virtfd = d.open(pyname, 0, 0, x)
|
||||
return virtfd.fstat(virtfd.fd, buf)
|
||||
|
||||
libc.syscall.argtypes = [ctypes.c_ulong, ctypes.c_int, ctypes.c_char_p, ctypes.c_void_p, ctypes.c_ulong]
|
||||
libc.syscall.restype = ctypes.c_int
|
||||
return libc.syscall(NEWFSTATAT_SYSCALL, -100, name, ctypes.c_void_p(buf), 0)
|
||||
|
||||
@ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int, ctypes.c_void_p)
|
||||
def _fstat64(fd, buf):
|
||||
if fd in tracked_fds: return tracked_fds[fd].fstat(fd, buf)
|
||||
|
||||
empty_str = (ctypes.c_char*1)()
|
||||
libc.syscall.argtypes = [ctypes.c_ulong, ctypes.c_int, ctypes.c_char_p, ctypes.c_void_p, ctypes.c_ulong]
|
||||
libc.syscall.restype = ctypes.c_int
|
||||
return libc.syscall(NEWFSTATAT_SYSCALL, ctypes.c_int(fd), empty_str, ctypes.c_void_p(buf), 0x1000)
|
||||
|
||||
@ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int, ctypes.c_void_p, ctypes.c_ulong)
|
||||
def _getdents64(fd, buf, sz):
|
||||
if fd in tracked_fds: return tracked_fds[fd].getdents(fd, buf, sz)
|
||||
|
||||
libc.syscall.argtypes = [ctypes.c_ulong, ctypes.c_int, ctypes.c_void_p, ctypes.c_ulong]
|
||||
libc.syscall.restype = ctypes.c_int
|
||||
return libc.syscall(GETDENTS64_SYSCALL, fd, buf, sz)
|
||||
|
||||
def _mmap(start, sz, prot, flags, fd, offset):
|
||||
if fd in tracked_fds: return tracked_fds[fd].mmap(start, sz, prot, flags, fd, offset)
|
||||
return libc.mmap(start, sz, prot, flags, fd, offset)
|
||||
|
||||
def _munmap(buf, sz):
|
||||
return libc.munmap(buf, sz)
|
||||
|
||||
orignal_memoryview = builtins.memoryview
|
||||
class TrackedMemoryView:
|
||||
def __init__(self, data, rcb, wcb):
|
||||
self.mv = orignal_memoryview(data)
|
||||
self.rcb, self.wcb = rcb, wcb
|
||||
|
||||
def __getitem__(self, index):
|
||||
self.rcb(self.mv, index)
|
||||
return self.mv[index]
|
||||
|
||||
def __setitem__(self, index, value):
|
||||
self.mv[index] = value
|
||||
self.wcb(self.mv, index)
|
||||
|
||||
def cast(self, new_type, **kwargs):
|
||||
self.mv = self.mv.cast(new_type, **kwargs)
|
||||
return self
|
||||
|
||||
@property
|
||||
def nbytes(self): return self.mv.nbytes
|
||||
def __len__(self): return len(self.mv)
|
||||
def __repr__(self): return repr(self.mv)
|
||||
|
||||
def _memoryview(cls, mem):
|
||||
if isinstance(mem, int) or isinstance(mem, ctypes.Array):
|
||||
addr = ctypes.addressof(mem) if isinstance(mem, ctypes.Array) else mem
|
||||
for d in drivers:
|
||||
for st,en,rcb,wcb in d.tracked_addresses:
|
||||
if st <= addr <= en: return TrackedMemoryView(mem, rcb, wcb)
|
||||
return orignal_memoryview(mem)
|
||||
|
||||
install_hook(libc.open, _open)
|
||||
install_hook(libc.opendir, _opendir)
|
||||
install_hook(libc.close, _close)
|
||||
install_hook(libc.closedir, _closedir)
|
||||
install_hook(libc.ioctl, _ioctl)
|
||||
install_hook(libc.read, _read)
|
||||
install_hook(libc.lseek64, _lseek64)
|
||||
install_hook(libc.stat64, _stat64)
|
||||
install_hook(libc.fstat64, _fstat64)
|
||||
install_hook(libc.getdents64, _getdents64)
|
||||
builtins.memoryview = type("memoryview", (), {'__new__': _memoryview}) # type: ignore
|
||||
|
||||
# rewrite autogen's libc mmaps functions.
|
||||
import tinygrad.runtime.autogen.libc as autogen_libc
|
||||
autogen_libc.mmap = _mmap # type: ignore
|
||||
autogen_libc.munmap = _munmap # type: ignore
|
||||
@@ -63,15 +63,15 @@ class BertForPretraining:
|
||||
|
||||
def accuracy(self, prediction_logits:Tensor, seq_relationship_logits:Tensor, masked_lm_ids:Tensor, masked_lm_weights:Tensor, next_sentence_labels:Tensor):
|
||||
valid = masked_lm_ids != 0
|
||||
masked_lm_predictions = prediction_logits.log_softmax(dtype=dtypes.float).argmax(-1)
|
||||
masked_lm_accuracy = (masked_lm_predictions == masked_lm_ids) * valid
|
||||
masked_lm_predictions = prediction_logits.argmax(-1)
|
||||
masked_lm_correct = (masked_lm_predictions == masked_lm_ids) * valid
|
||||
masked_lm_loss = self.sparse_categorical_crossentropy(prediction_logits, masked_lm_ids, ignore_index=masked_lm_weights)
|
||||
|
||||
seq_relationship_predictions = seq_relationship_logits.log_softmax(dtype=dtypes.float).argmax(-1)
|
||||
seq_relationship_accuracy = (seq_relationship_predictions == next_sentence_labels)
|
||||
seq_relationship_predictions = seq_relationship_logits.argmax(-1)
|
||||
seq_relationship_correct = (seq_relationship_predictions == next_sentence_labels)
|
||||
next_sentence_loss = seq_relationship_logits.binary_crossentropy_logits(next_sentence_labels)
|
||||
|
||||
return masked_lm_accuracy.sum() / valid.sum(), seq_relationship_accuracy.mean(), masked_lm_loss, next_sentence_loss
|
||||
return masked_lm_correct.sum() / valid.sum(), seq_relationship_correct.mean(), masked_lm_loss, next_sentence_loss
|
||||
|
||||
def load_from_pretrained(self, tf_weight_path:str=Path(__file__).parent.parent / "datasets" / "wiki"):
|
||||
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Mute tf flag info
|
||||
|
||||
@@ -1166,7 +1166,7 @@ class Mask:
|
||||
|
||||
def __call__(self, features, proposals, targets=None):
|
||||
x = self.feature_extractor(features, proposals)
|
||||
if x:
|
||||
if x is not None:
|
||||
mask_logits = self.predictor(x)
|
||||
if not Tensor.training:
|
||||
result = self.post_processor(mask_logits, proposals)
|
||||
|
||||
@@ -137,7 +137,13 @@ class ResNet:
|
||||
|
||||
self.url = model_urls[(self.num, self.groups, self.base_width)]
|
||||
for k, dat in torch_load(fetch(self.url)).items():
|
||||
obj: Tensor = get_child(self, k)
|
||||
try:
|
||||
obj: Tensor = get_child(self, k)
|
||||
except AttributeError as e:
|
||||
if 'fc.' in k and self.fc is None:
|
||||
continue
|
||||
|
||||
raise e
|
||||
|
||||
if 'fc.' in k and obj.shape != dat.shape:
|
||||
print("skipping fully connected layer")
|
||||
|
||||
+773
-149
@@ -1,18 +1,92 @@
|
||||
from __future__ import annotations
|
||||
from typing import List, Dict, Union, Callable, Any, Sequence
|
||||
import importlib, functools
|
||||
import numpy as np
|
||||
from tinygrad import Tensor, dtypes
|
||||
from tinygrad.helpers import getenv, DEBUG, all_same
|
||||
from tinygrad.dtype import DType, ConstType
|
||||
from typing import Any, Sequence, cast, Literal, Callable
|
||||
import dataclasses, functools, io, math, types
|
||||
from tinygrad.tensor import Tensor, _broadcast_shape, ReductionStr
|
||||
from tinygrad.helpers import getenv, DEBUG, all_same, prod, flatten, make_tuple
|
||||
from tinygrad.dtype import DType, ConstType, dtypes, ImageDType
|
||||
from tinygrad.device import is_dtype_supported
|
||||
from onnx import AttributeProto, ModelProto, TensorProto, ValueInfoProto
|
||||
try:
|
||||
from onnx.helper import tensor_dtype_to_np_dtype
|
||||
except ImportError:
|
||||
# for onnx < 1.13
|
||||
from onnx.mapping import TENSOR_TYPE_TO_NP_TYPE
|
||||
def tensor_dtype_to_np_dtype(tensor_dtype:int) -> np.dtype: return TENSOR_TYPE_TO_NP_TYPE[tensor_dtype]
|
||||
|
||||
# ***** protobuf parsing ******
|
||||
from onnx import AttributeProto, ModelProto, TensorProto, TypeProto, helper
|
||||
import numpy as np
|
||||
|
||||
def dtype_parse(onnx_dtype: int) -> DType:
|
||||
supported: dict[int, DType] = {
|
||||
TensorProto.FLOAT:dtypes.float32, TensorProto.UINT8:dtypes.uint8, TensorProto.INT8:dtypes.int8,
|
||||
TensorProto.UINT16:dtypes.uint16, TensorProto.INT16:dtypes.int16, TensorProto.INT32:dtypes.int32, TensorProto.INT64:dtypes.int64,
|
||||
TensorProto.BOOL:dtypes.bool, TensorProto.FLOAT16:dtypes.float32, TensorProto.DOUBLE:dtypes.double, TensorProto.UINT32:dtypes.uint32,
|
||||
TensorProto.UINT64:dtypes.uint64, TensorProto.BFLOAT16:dtypes.bfloat16,
|
||||
}
|
||||
unsupported = {
|
||||
TensorProto.UNDEFINED, TensorProto.STRING, TensorProto.COMPLEX64, TensorProto.COMPLEX128, TensorProto.FLOAT8E4M3FN, TensorProto.FLOAT8E4M3FNUZ,
|
||||
TensorProto.FLOAT8E5M2, TensorProto.FLOAT8E5M2FNUZ, TensorProto.UINT4, TensorProto.INT4
|
||||
}
|
||||
if onnx_dtype in unsupported: raise NotImplementedError(f"onnx dtype {TensorProto.DataType.Name(onnx_dtype)} is not supported")
|
||||
return supported[onnx_dtype] if is_dtype_supported(supported[onnx_dtype]) else dtypes.float
|
||||
|
||||
def attribute_parse(onnx_attribute: AttributeProto):
|
||||
supported: dict[AttributeProto.AttributeType, Callable[[AttributeProto], Any]] = {
|
||||
AttributeProto.FLOAT: lambda a: float(a.f), AttributeProto.INT: lambda a: int(a.i),
|
||||
AttributeProto.STRING: lambda a: a.s.decode("utf-8"), AttributeProto.TENSOR: lambda a: buffer_parse(a.t),
|
||||
AttributeProto.FLOATS: lambda a: tuple(float(x) for x in a.floats), AttributeProto.INTS: lambda a: tuple(int(x) for x in a.ints),
|
||||
AttributeProto.STRINGS: lambda a: tuple(x.decode("utf-8") for x in a.strings)
|
||||
}
|
||||
unsupported = {
|
||||
AttributeProto.UNDEFINED, AttributeProto.GRAPH, AttributeProto.SPARSE_TENSOR, AttributeProto.TYPE_PROTO, AttributeProto.TENSORS,
|
||||
AttributeProto.GRAPHS, AttributeProto.SPARSE_TENSORS, AttributeProto.TYPE_PROTOS
|
||||
}
|
||||
if onnx_attribute.type in unsupported:
|
||||
raise NotImplementedError(f"attribute with type {AttributeProto.AttributeType.Name(onnx_attribute.type)} is not supported")
|
||||
return supported[onnx_attribute.type](onnx_attribute)
|
||||
|
||||
def buffer_parse(onnx_tensor: TensorProto) -> Tensor:
|
||||
if onnx_tensor.string_data: raise NotImplementedError("Parsing for buffer with string data is not implemented.")
|
||||
dtype, shape = dtype_parse(onnx_tensor.data_type), tuple(onnx_tensor.dims)
|
||||
if data := list(onnx_tensor.float_data) or list(onnx_tensor.int32_data) or list(onnx_tensor.int64_data) or list(onnx_tensor.double_data) or \
|
||||
list(onnx_tensor.uint64_data):
|
||||
if len(data) == 1: return Tensor(data[0], dtype=dtype).reshape(shape)
|
||||
return Tensor(data, dtype=dtype).reshape(shape).realize()
|
||||
if onnx_tensor.HasField("raw_data"):
|
||||
np_buffer = np.frombuffer(onnx_tensor.raw_data, dtype=helper.tensor_dtype_to_np_dtype(onnx_tensor.data_type)).copy().reshape(shape)
|
||||
if np_buffer.size == 1: return Tensor(np_buffer.item(), dtype=dtype).reshape(shape)
|
||||
return Tensor(np_buffer, dtype=dtype)
|
||||
return Tensor(None)
|
||||
|
||||
def type_parse(onnx_type: TypeProto):
|
||||
elem_type = onnx_type
|
||||
if elem_type.HasField("map_type") or elem_type.HasField("sparse_tensor_type") or elem_type.HasField("opaque_type"):
|
||||
raise NotImplementedError("parsing for map_type, sparse_tensor_type and opaque_type are not implemented")
|
||||
if is_optional := elem_type.HasField("optional_type"): elem_type = elem_type.optional_type.elem_type
|
||||
if is_sequence := elem_type.HasField("sequence_type"): elem_type = elem_type.sequence_type.elem_type
|
||||
if elem_type.HasField("tensor_type"):
|
||||
shape = tuple(d.dim_param or d.dim_value for d in elem_type.tensor_type.shape.dim)
|
||||
dtype = dtype_parse(elem_type.tensor_type.elem_type)
|
||||
return OnnxValue(shape, dtype, is_optional, is_sequence)
|
||||
raise RuntimeError(f"TypeProto was not parsed properly: {onnx_type=}")
|
||||
|
||||
# ***** onnx spec *****
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class OnnxValue:
|
||||
shape: tuple[str|int]
|
||||
dtype: DType
|
||||
is_optional: bool
|
||||
is_sequence: bool
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class OnnxNode:
|
||||
num: int
|
||||
op: str
|
||||
inputs: tuple[str]
|
||||
outputs: tuple[str]
|
||||
opts: dict[str, Any]
|
||||
|
||||
# ***** python const *****
|
||||
required_input_python_consts: dict[str, tuple[int, ...]] = {
|
||||
"Tile": (1,), "Range": (0,1,2), "Expand": (1,), "Reshape": (1,), "Squeeze": (1,), "Unsqueeze": (1,), "Trilu": (1,), "ConstantOfShape": (0,),
|
||||
"CumSum": (1,), "Pad": (1,2,3), "MaxUnpool": (2,), "Dropout": (1,2), "CenterCropPad": (1,), "OneHot": (1,), "Compress": (1,),
|
||||
"ImageDecoder": (0,), "AffineGrid": (1,), "Resize": (1,2,3), "Upsample": (1,), "Split": (1,), "Slice": (1,2,3,4),
|
||||
**{"Reduce"+r: (1,) for r in ("Max", "Min", "Sum", "Mean", "SumSquare", "Prod", "L1", "L2", "LogSum", "LogSumExp")},
|
||||
**{optim: (1,) for optim in ("Adam", "Adagrad", "Momentum")}
|
||||
}
|
||||
|
||||
cache_misses = 0
|
||||
@functools.lru_cache(None)
|
||||
@@ -22,8 +96,8 @@ def _cached_to_python_const(t:Tensor):
|
||||
return t.tolist()
|
||||
|
||||
# Tensor -> python value cache for parameters
|
||||
def to_python_const(t) -> Union[List[ConstType], List[bytes], Union[ConstType, bytes]]:
|
||||
if not isinstance(t, Tensor): return t
|
||||
def to_python_const(t:Any, op:str, idx:int) -> list[ConstType]|ConstType|bytes:
|
||||
if idx not in required_input_python_consts.get(op, ()) or not isinstance(t, Tensor): return t
|
||||
global cache_misses
|
||||
ret = _cached_to_python_const(t)
|
||||
if (info := _cached_to_python_const.cache_info()).misses > cache_misses and DEBUG >= 3:
|
||||
@@ -31,144 +105,694 @@ def to_python_const(t) -> Union[List[ConstType], List[bytes], Union[ConstType, b
|
||||
cache_misses = info.misses
|
||||
return ret
|
||||
|
||||
# TODO: use real float16
|
||||
# src: onnx/mapping.py
|
||||
DTYPE_MAP: Dict[TensorProto.DataType | int, DType] = {
|
||||
TensorProto.FLOAT:dtypes.float32, TensorProto.UINT8:dtypes.uint8, TensorProto.INT8:dtypes.int8,
|
||||
TensorProto.UINT16:dtypes.uint16, TensorProto.INT16:dtypes.int16, TensorProto.INT32:dtypes.int32, TensorProto.INT64:dtypes.int64,
|
||||
TensorProto.BOOL:dtypes.bool, TensorProto.FLOAT16:dtypes.float32, TensorProto.DOUBLE:dtypes.double, TensorProto.UINT32:dtypes.uint32,
|
||||
TensorProto.UINT64:dtypes.uint64, TensorProto.BFLOAT16:dtypes.bfloat16, TensorProto.FLOAT8E4M3FN:dtypes.float,
|
||||
TensorProto.FLOAT8E4M3FNUZ:dtypes.float, TensorProto.FLOAT8E5M2:dtypes.float, TensorProto.FLOAT8E5M2FNUZ:dtypes.float
|
||||
}
|
||||
def dtype_parse(onnx_dtype: TensorProto.DataType | int) -> DType:
|
||||
if onnx_dtype not in DTYPE_MAP: raise NotImplementedError(f"onnx dtype {TensorProto.DataType.Name(onnx_dtype)} is not supported")
|
||||
return DTYPE_MAP[onnx_dtype] if is_dtype_supported(DTYPE_MAP[onnx_dtype]) else dtypes.float
|
||||
# ***** runner ******
|
||||
debug = int(getenv("DEBUGONNX", "0"))
|
||||
limit = int(getenv("ONNXLIMIT", "-1"))
|
||||
class OnnxRunner:
|
||||
def __init__(self, model: ModelProto):
|
||||
# parse model protobuf
|
||||
self.is_training = any(n.domain in {"ai.onnx.training", "ai.onnx.preview.training"} for n in model.graph.node)
|
||||
self.old_training, self.old_no_grad = Tensor.training, Tensor.no_grad
|
||||
Tensor.training = True if self.is_training else False
|
||||
Tensor.no_grad = False if self.is_training else True
|
||||
self.graph_values = {"": None, **{x.name:buffer_parse(x) for x in model.graph.initializer}}
|
||||
self.graph_inputs = {x.name:type_parse(x.type) for x in model.graph.input if x.name not in self.graph_values}
|
||||
self.graph_outputs = {x.name:type_parse(x.type) for x in model.graph.output}
|
||||
self.graph_nodes = tuple(OnnxNode(num, n.op_type, tuple(n.input), tuple(n.output), {x.name:attribute_parse(x) for x in n.attribute})
|
||||
for num,n in enumerate(model.graph.node))
|
||||
self.opset_version = model.opset_import[0].version
|
||||
self.variable_dims: dict[str, int] = {}
|
||||
|
||||
# src: onnx/onnx_ml_pb2.pyi
|
||||
ATTRIBUTE_MAP: Dict[AttributeProto.AttributeType, Callable[[AttributeProto], Any]] = {
|
||||
AttributeProto.FLOAT: lambda a: float(a.f), AttributeProto.INT: lambda a: int(a.i),
|
||||
AttributeProto.STRING: lambda a: a.s.decode("utf-8"), AttributeProto.TENSOR: lambda a: buffer_parse(a.t),
|
||||
AttributeProto.FLOATS: lambda a: tuple(float(x) for x in a.floats), AttributeProto.INTS: lambda a: tuple(int(x) for x in a.ints),
|
||||
AttributeProto.STRINGS: lambda a: tuple(x.decode("utf-8") for x in a.strings)
|
||||
}
|
||||
def attribute_parse(onnx_attribute: AttributeProto):
|
||||
if onnx_attribute.type not in ATTRIBUTE_MAP:
|
||||
raise NotImplementedError(f"attribute with type {AttributeProto.AttributeType.Name(onnx_attribute.type)} is not supported")
|
||||
return ATTRIBUTE_MAP[onnx_attribute.type](onnx_attribute)
|
||||
self.onnx_ops = onnx_ops
|
||||
|
||||
def buffer_parse(inp: TensorProto) -> Tensor:
|
||||
if dat := list(inp.float_data) or list(inp.int32_data) or list(inp.int64_data):
|
||||
return Tensor(dat, dtype=dtype_parse(inp.data_type), requires_grad=False).reshape(tuple(inp.dims))
|
||||
if len(inp.raw_data) > 0:
|
||||
return Tensor(np.frombuffer(inp.raw_data, dtype=tensor_dtype_to_np_dtype(inp.data_type)).copy().reshape(tuple(inp.dims)),
|
||||
dtype=dtype_parse(inp.data_type), requires_grad=False)
|
||||
raise NotImplementedError(f"buffer with data type {TensorProto.DataType.Name(inp.data_type)} is not supported")
|
||||
def _parse_input(self, name: str, value: Any, spec: OnnxValue):
|
||||
if spec.is_optional and value is None: return None
|
||||
# TODO: need true float16 for dtype checking
|
||||
if spec.is_sequence:
|
||||
if not isinstance(value, Sequence): raise RuntimeError(f"{name} received {value}, expected a sequence type")
|
||||
sequence = [Tensor(v, dtype=spec.dtype, requires_grad=self.is_training) if not isinstance(v, Tensor) else v for v in value]
|
||||
if not all_same(tuple(t.shape for t in sequence)): raise RuntimeError(f"Shapes for {name} sequence must be homogeneous")
|
||||
return sequence
|
||||
tensor = Tensor(value, dtype=spec.dtype, requires_grad=self.is_training) if not isinstance(value, Tensor) else value
|
||||
for dim, (onnx_dim, user_dim_input) in enumerate(zip(spec.shape, tensor.shape, strict=True)):
|
||||
if isinstance(onnx_dim, str):
|
||||
onnx_dim = self.variable_dims[onnx_dim] if onnx_dim in self.variable_dims else self.variable_dims.setdefault(onnx_dim, int(user_dim_input))
|
||||
if user_dim_input != onnx_dim: raise RuntimeError(f"{name} has mismatch on {dim=}. Expected {onnx_dim}, received {user_dim_input}.")
|
||||
return tensor
|
||||
|
||||
onnx_ops = importlib.import_module('extra.onnx_ops')
|
||||
ONNXLIMIT = getenv("ONNXLIMIT", -1)
|
||||
def _dispatch_op(self, op, inps, opts):
|
||||
if op in self.onnx_ops:
|
||||
fxn = self.onnx_ops[op]
|
||||
if isinstance(fxn, dict):
|
||||
for k in sorted(fxn.keys()):
|
||||
if k <= self.opset_version:
|
||||
real_fxn = fxn[k]
|
||||
else: real_fxn = fxn
|
||||
return real_fxn(*inps, **opts)
|
||||
raise NotImplementedError(f"{op=} not supported")
|
||||
|
||||
def get_run_onnx(onnx_model: ModelProto):
|
||||
# model initialization data
|
||||
model_parameters = {inp.name:buffer_parse(inp) for inp in onnx_model.graph.initializer}
|
||||
model_attributes = {num:{x.name:attribute_parse(x) for x in n.attribute} for num,n in enumerate(onnx_model.graph.node)}
|
||||
def __call__(self, inputs:dict[str, Any], debug=debug):
|
||||
for name, input_spec in self.graph_inputs.items():
|
||||
if name not in inputs: raise RuntimeError(f"Please provide input data for {name}")
|
||||
self.graph_values[name] = self._parse_input(name, inputs[name], input_spec)
|
||||
|
||||
# model descriptions
|
||||
# TODO: need a better way of controlling training vs non-training
|
||||
is_onnx_preview_training = any(n.HasField("domain") and n.domain == "ai.onnx.preview.training" for n in onnx_model.graph.node)
|
||||
onnx_model_version = onnx_model.opset_import[0].version
|
||||
for node in self.graph_nodes:
|
||||
inps = [to_python_const(self.graph_values[name], node.op, i) for i,name in enumerate(node.inputs)]
|
||||
opts = node.opts
|
||||
|
||||
# mapping from onnx ops to tensor.py ops
|
||||
tensor_methods = {
|
||||
op:op.lower() for op in ("Neg", "Reciprocal", "Pow", "Sqrt", "Sign", "Abs", "Exp", "Log", "Mish", "Sin", "Cos", "Tan", "Asin", "Acos", "Atan",
|
||||
"Relu", "Sigmoid", "MatMul", "Floor", "Ceil", "IsInf", "IsNaN", "Softplus", "HardSwish", "Where", "Mul", "Sinh", "Cosh", "Tanh",
|
||||
"Softsign", "Asinh", "Acosh", "Atanh", "Elu", "Celu", "Selu", "Xor", "Round", "Erf")
|
||||
# provide additional opts
|
||||
if node.op == "Split" and 'num_outputs' not in opts: opts['num_outputs'] = len(node.outputs)
|
||||
if node.op == "Gradient": opts['intermediate_tensors'] = self.graph_values
|
||||
|
||||
if debug >= 1: print(f"{node.num}: op '{node.op}' opt {opts}")
|
||||
if debug >= 2 and node.inputs: print("\tinputs:\n" + "\n".join(f"\t\t{x} - {i!r}" for x,i in zip(node.inputs, inps)))
|
||||
ret = self._dispatch_op(node.op, inps, opts)
|
||||
ret = ret if isinstance(ret, tuple) else (ret,)
|
||||
if debug >= 2: print("\toutputs:\n" + "\n".join(f"\t\t{x} - {o!r}" for x,o in zip(node.outputs, ret)))
|
||||
|
||||
self.graph_values.update(dict(zip(node.outputs, ret[:len(node.outputs)], strict=True)))
|
||||
|
||||
if node.num == limit:
|
||||
Tensor.training, Tensor.no_grad = self.old_training, self.old_no_grad
|
||||
return {name:self.graph_values[name] for name in node.outputs}
|
||||
Tensor.training, Tensor.no_grad = self.old_training, self.old_no_grad
|
||||
return {name:self.graph_values[name] for name in self.graph_outputs}
|
||||
|
||||
####################
|
||||
##### ONNX OPS #####
|
||||
####################
|
||||
def get_onnx_ops():
|
||||
# ***** helper functions *****
|
||||
def _axes(axes, noop_with_empty_axes): return axes or ([] if noop_with_empty_axes else None)
|
||||
|
||||
# (padding_top, padding_left, ..., padding_bottom, padding_right, ...) -> (padding_left, padding_right, padding_top, padding_bottom, ...)
|
||||
def _onnx_pads_to_tiny_pads(pads): return tuple(flatten(reversed(list(zip(pads, pads[len(pads)//2:])))))
|
||||
|
||||
AUTO_PAD_OPTIONS = Literal["NOTSET", "SAME_UPPER", "SAME_LOWER", "VALID"]
|
||||
# (padding_height, padding_width) -> (padding_top, padding_left, padding_bottom, padding_right)
|
||||
def _auto_pad(pads, auto_pad: AUTO_PAD_OPTIONS):
|
||||
if auto_pad == "SAME_UPPER": return [pads[i]//2 for i in range(len(pads))] + [pads[i]-pads[i]//2 for i in range(len(pads))]
|
||||
return [pads[i]-pads[i]//2 for i in range(len(pads))] + [pads[i]//2 for i in range(len(pads))]
|
||||
|
||||
def _resolve_pool_pads(x:Tensor, p_, k_, d_, s_, auto_pad:AUTO_PAD_OPTIONS):
|
||||
i_, (s_,d_,p_) = x.shape[-len(k_):], (make_tuple(x, len(k_)*2) for x in (s_, d_, p_))
|
||||
if auto_pad == "NOTSET": return _onnx_pads_to_tiny_pads(p_ if len(p_)==len(k_)*2 else p_*2)
|
||||
o_ = [((i - (1 if auto_pad in ("SAME_UPPER", "SAME_LOWER") else k)) // s + 1) for i,k,s in zip(i_, k_, s_)]
|
||||
return _onnx_pads_to_tiny_pads(_auto_pad([(o-1)*s+k-i for o,i,k,s in zip(o_, i_, k_, s_)], auto_pad))
|
||||
|
||||
def _clamp_cast(x:Tensor, dtype:DType): return x.clamp(dtypes.min(dtype), dtypes.max(dtype)).cast(dtype)
|
||||
|
||||
def _prepare_quantize(x, scale, zero_point, axis=1, block_size=0):
|
||||
if axis < 0: axis += x.ndim
|
||||
if not isinstance(zero_point, Tensor): zero_point = Tensor(zero_point, dtype=dtypes.uint8)._broadcast_to(scale.shape)
|
||||
if block_size == 0:
|
||||
shape = (*[1]*axis, *scale.shape, *[1]*(x.ndim - axis - scale.ndim))
|
||||
return scale.reshape(shape), zero_point.reshape(shape)
|
||||
return scale.repeat_interleave(block_size, dim=axis), zero_point.repeat_interleave(block_size, dim=axis)
|
||||
|
||||
def _op_integer(op, inputs:list[Tensor], zero_points:list[Tensor], **opts):
|
||||
adjusted_inputs = [inp.int() - zp for inp, zp in zip(inputs, zero_points)]
|
||||
return op(*adjusted_inputs, **opts)
|
||||
|
||||
def _qlinearop_quantized(op, inputs:list[Tensor], zero_points:list[Tensor], scales:list[Tensor], out_scale:Tensor, out_zero_point:Tensor, **opts):
|
||||
# op execution is done in quantized int
|
||||
out = _op_integer(op, inputs, zero_points, **opts)
|
||||
assert dtypes.is_int(out.dtype), "quantized op should've done math in int"
|
||||
out_quantized = (out * prod(scales) / out_scale).round() + out_zero_point
|
||||
return _clamp_cast(out_quantized, out_zero_point.dtype)
|
||||
|
||||
def _qlinearop_float(op, inputs:list[Tensor], zero_points:list[Tensor], scales:list[Tensor], out_scale:Tensor, out_zero_point:Tensor, **opts):
|
||||
# op execution is done in float32
|
||||
dequantized_inputs = [(inp.int() - zp) * scale for inp, zp, scale in zip(inputs, zero_points, scales)]
|
||||
out = op(*dequantized_inputs, **opts)
|
||||
assert dtypes.is_float(out.dtype), "op should've done math in float"
|
||||
out_quantized = (out / out_scale).round() + out_zero_point
|
||||
return _clamp_cast(out_quantized, out_zero_point.dtype)
|
||||
|
||||
def _onnx_training(input_group_size):
|
||||
def __decorator(func):
|
||||
def ___wrapper(R:Tensor, T:int, *inputs:Tensor, **kwargs):
|
||||
R = R.detach()
|
||||
groups = len(inputs) // input_group_size
|
||||
ret = [func(R, T, *inps, **kwargs) for inps in (inputs[i::groups] for i in range(groups))]
|
||||
return tuple(flatten(zip(*ret)))
|
||||
return ___wrapper
|
||||
return __decorator
|
||||
|
||||
# ***** Property/Graph Ops *****
|
||||
def Identity(x:Tensor): return x
|
||||
def Constant(sparse_value:Tensor|None=None, value:Tensor|None=None, value_float:float|None=None, value_floats:list[float]|None=None,
|
||||
value_int:int|None=None, value_ints:list[int]|None=None, value_string:str|None=None, value_strings:list[str]|None=None):
|
||||
if value is not None: return value
|
||||
if value_float is not None: return Tensor(value_float, dtype=dtypes.float32, requires_grad=False)
|
||||
if value_floats is not None: return Tensor(list(value_floats), dtype=dtypes.float32, requires_grad=False)
|
||||
if value_int is not None: return Tensor(value_int, dtype=dtypes.int64, requires_grad=False)
|
||||
if value_ints is not None: return Tensor(list(value_ints), dtype=dtypes.int64, requires_grad=False)
|
||||
if value_string is not None or value_strings is not None and sparse_value is not None:
|
||||
raise NotImplementedError('Constant OP not implemented for value_string, value_strings and sparse_value')
|
||||
|
||||
def Range(start:float|int, limit:float|int, delta:float|int): return Tensor.arange(start=start, stop=limit, step=delta)
|
||||
|
||||
def ImageDecoder(encoded_stream:bytes, pixel_format="RGB"):
|
||||
try: import PIL.Image
|
||||
except ImportError as e: raise ImportError("Pillow must be installed for the ImageDecoder operator") from e
|
||||
img = PIL.Image.open(io.BytesIO(encoded_stream))
|
||||
if pixel_format == "BGR": return Tensor(np.array(img))[:, :, ::-1]
|
||||
if pixel_format == "RGB": return Tensor(np.array(img))
|
||||
if pixel_format == "Grayscale": return Tensor(np.array(img.convert("L"))).unsqueeze(-1) # (H, W) to (H, W, 1)
|
||||
raise ValueError(f"pixel_format={pixel_format!r} is not supported.")
|
||||
|
||||
def EyeLike(x:Tensor, dtype:int|None=None, k:int=0):
|
||||
ret = Tensor.eye(cast(int, min(x.shape)), dtype=dtype_parse(dtype) if dtype is not None else x.dtype)
|
||||
return ret if x.size(0) == x.size(1) else ret.pad(tuple(None if d == ret.size(0) else (k, d-ret.shape[0]-k) for d in x.shape))
|
||||
|
||||
def OptionalHasElement(x:Tensor|None=None): return Tensor(x is not None and x.numel() > 0)
|
||||
def OptionalGetElement(x:Tensor|None=None): return x if x is not None else Tensor([])
|
||||
def ConstantOfShape(shape:list[int], value:Tensor|None=None):
|
||||
if value is None: value = Tensor(0, dtype=dtypes.float32)
|
||||
return Tensor.ones(*shape, dtype=value.dtype) * (value if shape != [0] else 1)
|
||||
|
||||
def Size(data:Tensor): return data.numel()
|
||||
def Shape(data:Tensor, end:int|None=None, start:int=0): return Tensor(data.shape[start:end], dtype=dtypes.int64)
|
||||
|
||||
# ***** Unary Ops (math) *****
|
||||
def Not(x:Tensor): return x.logical_not()
|
||||
def Clip(x: Tensor, min:Tensor|None=None, max:Tensor|None=None):
|
||||
return x.clip(float('-inf') if min is None else min, float('inf') if max is None else max).cast(x.dtype)
|
||||
|
||||
# ***** Unary Ops (activation) *****
|
||||
def Softmax_1(x:Tensor, axis:int=1): return x.softmax(axis)
|
||||
def Softmax_13(x:Tensor, axis:int=-1): return x.softmax(axis)
|
||||
Softmax = {1:Softmax_1, 13:Softmax_13}
|
||||
def HardSigmoid(x:Tensor, alpha:float=0.2, beta:float=0.5): return (alpha*x + beta).clip(0, 1)
|
||||
def Gelu(x:Tensor, approximate:str|None=None): return x.gelu() if approximate == "tanh" else 0.5 * x * (1 + (x/math.sqrt(2)).erf())
|
||||
def FastGelu(x:Tensor, bias:Tensor|None=None):
|
||||
# this is tanh approximated
|
||||
return (x + bias).gelu() if bias is not None else x.gelu()
|
||||
# TODO: fix this
|
||||
def PRelu(X:Tensor, slope:Tensor):
|
||||
slope = slope[0] if slope.shape[-1] != X.shape[-1] else slope
|
||||
return (X > 0).where(X, X * slope)
|
||||
def LeakyRelu(X:Tensor, alpha:float=0.01): return X.leakyrelu(alpha)
|
||||
def ThresholdedRelu(X:Tensor, alpha:float=1.0): return (X > alpha).where(X, 0)
|
||||
def LogSoftmax(x: Tensor, axis:int=-1): return x.log_softmax(axis)
|
||||
def Binarizer(x:Tensor, threshold:float=0.0): return (x > threshold).float()
|
||||
|
||||
# ***** Unary Ops (broadcasted) *****
|
||||
def Add(x:Tensor,y:Tensor, broadcast=None, axis=None): return x + y if x.dtype == dtypes.float or isinstance(x.dtype, ImageDType) else (x + y).cast(x.dtype)
|
||||
def Sub(x:Tensor|int,y:Tensor): return x - y # some test has input as int
|
||||
def Div(x:Tensor,y:Tensor): return (x/y).cast(x.dtype)
|
||||
def Less(x:Tensor,y:Tensor): return x < y
|
||||
def LessOrEqual(x:Tensor,y:Tensor): return x <= y
|
||||
def Greater(x:Tensor,y:Tensor): return x > y
|
||||
def GreaterOrEqual(x:Tensor,y:Tensor): return x >= y
|
||||
def Equal(x:Tensor,y:Tensor): return x == y
|
||||
def And(x:Tensor,y:Tensor): return (x==y).where(x, False)
|
||||
def Or(x:Tensor,y:Tensor): return (x==y).where(x, True)
|
||||
def BitwiseAnd(x:Tensor,y:Tensor): return x & y
|
||||
def BitwiseOr(x:Tensor,y:Tensor): return x | y
|
||||
def BitwiseXor(x:Tensor,y:Tensor): return x ^ y
|
||||
def BitwiseNot(x:Tensor): return ~x
|
||||
|
||||
# ***** Casting Ops *****
|
||||
# TODO: saturate
|
||||
def Cast(x:Tensor, to:int, saturate:int=1): return x.cast(dtype_parse(to))
|
||||
def CastLike(x:Tensor, target_type:Tensor, saturate:int=1): return x.cast(target_type.dtype)
|
||||
|
||||
# ***** Reduce Ops *****
|
||||
def Max(*data_0:Tensor): return functools.reduce(Tensor.maximum, data_0)
|
||||
def Min(*data_0:Tensor): return functools.reduce(Tensor.minimum, data_0)
|
||||
def Sum(*data_0:Tensor): return functools.reduce(Tensor.add, data_0)
|
||||
def Mean(*data_0:Tensor): return Sum(*data_0) / len(data_0)
|
||||
def ReduceMax(data:Tensor, axes:list[int]|None=None, keepdims:int=1, noop_with_empty_axes:int=0):
|
||||
return data.max(_axes(axes, noop_with_empty_axes), keepdim=keepdims)
|
||||
def ReduceMin(data:Tensor, axes:list[int]|None=None, keepdims:int=1, noop_with_empty_axes:int=0):
|
||||
return data.min(_axes(axes, noop_with_empty_axes), keepdim=keepdims)
|
||||
def ReduceSum(data:Tensor, axes:list[int]|None=None, keepdims:int=1, noop_with_empty_axes:int=0):
|
||||
return data.sum(_axes(axes, noop_with_empty_axes), keepdim=keepdims)
|
||||
def ReduceMean(data:Tensor, axes:list[int]|None=None, keepdims:int=1, noop_with_empty_axes:int=0):
|
||||
return data.mean(_axes(axes, noop_with_empty_axes), keepdim=keepdims)
|
||||
def ReduceSumSquare(data:Tensor, axes:list[int]|None=None, keepdims:int=1, noop_with_empty_axes:int=0):
|
||||
return ReduceSum(data.square(), axes, keepdims, noop_with_empty_axes)
|
||||
def ReduceProd(data:Tensor, axes:list[int]|None=None, keepdims:int=1, noop_with_empty_axes:int=0):
|
||||
return data.prod(_axes(axes, noop_with_empty_axes), keepdim=keepdims)
|
||||
def ReduceL1(data:Tensor, axes:list[int]|None=None, keepdims:int=1, noop_with_empty_axes:int=0):
|
||||
return ReduceSum(data.abs(), axes, keepdims, noop_with_empty_axes)
|
||||
def ReduceL2(data:Tensor, axes:list[int]|None=None, keepdims:int=1, noop_with_empty_axes:int=0):
|
||||
return ReduceSumSquare(data, axes, keepdims, noop_with_empty_axes).sqrt()
|
||||
def ReduceLogSum(data:Tensor, axes:list[int]|None=None, keepdims:int=1, noop_with_empty_axes:int=0):
|
||||
return ReduceSum(data, axes, keepdims, noop_with_empty_axes).log()
|
||||
def ReduceLogSumExp(data:Tensor, axes:list[int]|None=None, keepdims:int=1, noop_with_empty_axes:int=0):
|
||||
return ReduceSum(data.exp(), axes, keepdims, noop_with_empty_axes).log()
|
||||
def ArgMax(x:Tensor, axis:int=0, keepdims:int=1, select_last_index:int=0):
|
||||
if select_last_index: return ((x.shape[axis]-1) - x.flip(axis).argmax(axis, keepdim=keepdims)).cast(dtypes.int64)
|
||||
return x.argmax(axis, keepdim=keepdims).cast(dtypes.int64)
|
||||
def ArgMin(x, axis:int=0, keepdims:int=1, select_last_index:int=0):
|
||||
return ArgMax(-x, axis=axis, keepdims=keepdims, select_last_index=select_last_index)
|
||||
|
||||
# ***** Movement Ops *****
|
||||
def Reshape(data:Tensor, shape:list[int], allowzero:int=0):
|
||||
return data.reshape([x if x != 0 else (0 if allowzero else data.shape[i]) for i,x in enumerate(shape)])
|
||||
def Flatten(x:Tensor, axis:int=1): return x.reshape(prod(x.shape[0:axis]), -1)
|
||||
def Expand(x:Tensor, shape:list[int]): return x.expand(_broadcast_shape(x.shape, tuple(shape)))
|
||||
def Shrink(x:Tensor, bias:float=0.0, lambd:float=0.5): return (x < -lambd)*(x+bias) + (x > lambd)*(x-bias)
|
||||
def Transpose(x:Tensor, perm:list[int]|None=None): return x.permute(order=list(range(x.ndim)[::-1]) if perm is None else perm)
|
||||
|
||||
# TODO: add test for when axes is None
|
||||
def Squeeze(data:Tensor, axes:list[int]|None=None):
|
||||
return data.squeeze() if axes is None else functools.reduce(lambda d, dim: d.squeeze(dim), sorted(axes, reverse=True), data)
|
||||
def Unsqueeze(data:Tensor, axes:list[int]): return functools.reduce(lambda d, dim: d.unsqueeze(dim), sorted(axes), data)
|
||||
|
||||
def Tile(x:Tensor, repeats:list[int]): return x.repeat(repeats)
|
||||
def Concat(*xs:Tensor, axis:int): return Tensor.cat(*xs, dim=axis)
|
||||
def Slice(data:Tensor, starts:list[int], ends:list[int], axes:list[int]|None=None, steps:list[int]|None=None):
|
||||
axes = axes or list(range(data.ndim))
|
||||
steps = steps or [1]*data.ndim
|
||||
slices = [slice(0,x,1) for x in data.shape]
|
||||
for i, axis in enumerate(axes): slices[axis] = slice(starts[i], ends[i], steps[i])
|
||||
return data[tuple(slices)]
|
||||
|
||||
def Split(data:Tensor, split:list[int]|None=None, num_outputs:int=0, axis:int=0):
|
||||
sz = data.shape[axis]
|
||||
if split is None: split = [sz // num_outputs + (1 if i < sz % num_outputs else 0) for i in range(num_outputs)]
|
||||
return data.split(split, axis)
|
||||
|
||||
def Pad(x:Tensor, pads:list[int], constant_value:ConstType|None=None, axes:list[int]|None=None,
|
||||
mode:Literal["constant", "reflect", "edge", "wrap"]="constant", value=0):
|
||||
value = constant_value or value
|
||||
axes = axes or list(range(x.ndim))
|
||||
real_pads = [0] * (x.ndim*2)
|
||||
for i,axis in enumerate(axes): real_pads[axis%x.ndim], real_pads[axis%x.ndim+x.ndim] = pads[i], pads[i+len(axes)]
|
||||
return x.pad(padding=_onnx_pads_to_tiny_pads(real_pads), mode={"edge":"replicate", "wrap":"circular"}.get(mode, mode), value=value)
|
||||
|
||||
def CenterCropPad(t:Tensor, shape:list[int], axes:list[int]|None=None):
|
||||
shrink_arg:list[None|tuple[int,int]] = [None] * t.ndim
|
||||
pad_arg:list[None|tuple[int,int]] = [None] * t.ndim
|
||||
for s, x in zip(shape, axes or range(t.ndim)):
|
||||
tx = t.shape[x]
|
||||
if s < tx: shrink_arg[x] = (tx//2 - (s+1)//2, tx//2 + s//2)
|
||||
elif s > tx: pad_arg[x] = ((s-tx)//2, (s-tx+1)//2)
|
||||
return t.shrink(tuple(shrink_arg)).pad(tuple(pad_arg))
|
||||
|
||||
# ***** Processing Ops *****
|
||||
def AveragePool(X: Tensor, kernel_shape:list[int], auto_pad:AUTO_PAD_OPTIONS="NOTSET", ceil_mode:int=0, count_include_pad:int=0,
|
||||
dilations:list[int]|int=1, pads:list[int]|int=0, strides:list[int]|int=1):
|
||||
return X.avg_pool2d(kernel_shape, strides, dilations, _resolve_pool_pads(X, pads, kernel_shape, dilations, strides, auto_pad),
|
||||
ceil_mode=ceil_mode, count_include_pad=count_include_pad)
|
||||
|
||||
def MaxPool(X: Tensor, kernel_shape:list[int], auto_pad:AUTO_PAD_OPTIONS="NOTSET", ceil_mode:int=0, dilations:list[int]|int=1, pads:list[int]|int=0,
|
||||
storage_order:int=0, strides:list[int]|int=1):
|
||||
ret = X.max_pool2d(kernel_shape, strides, dilations, _resolve_pool_pads(X, pads, kernel_shape, dilations, strides, auto_pad), ceil_mode=ceil_mode)
|
||||
# tests expect indices with int64 dtype
|
||||
# TODO: if there are repeated values, this is wrong
|
||||
indices = ((ret.reshape(-1, 1) == X.reshape(1, -1)) * Tensor.arange(X.numel(), dtype=dtypes.int64).unsqueeze(0)).sum(1).reshape(ret.shape)
|
||||
return ret.cast(X.dtype), indices.transpose(-2, -1) if storage_order else indices
|
||||
|
||||
def Conv(X: Tensor, W: Tensor, B:Tensor|None=None, auto_pad:AUTO_PAD_OPTIONS="NOTSET", dilations:list[int]|int=1, group:int=1,
|
||||
kernel_shape:list[int]|None=None, pads:list[int]|int=0, strides:list[int]|int=1):
|
||||
return X.conv2d(W, B, stride=strides, groups=group, dilation=dilations,
|
||||
padding=_resolve_pool_pads(X, pads, kernel_shape or W.shape[2:], dilations, strides, auto_pad))
|
||||
|
||||
def ConvTranspose(X: Tensor, W: Tensor, B:Tensor|None=None, auto_pad:AUTO_PAD_OPTIONS="NOTSET", dilations:list[int]|int=1, group:int=1,
|
||||
kernel_shape:list[int]|None=None, pads:list[int]|None=None, output_shape:list[int]|None=None, output_padding:list[int]|int=0,
|
||||
strides:list[int]|int=1):
|
||||
input_shape, kernel_shape = X.shape[2:], (kernel_shape or W.shape[2:])
|
||||
strides, dilations, output_padding = (make_tuple(x, len(input_shape)) for x in (strides, dilations, output_padding))
|
||||
if output_shape is not None: # we pad according to output_shape
|
||||
pads = _auto_pad([s*(i-1) + op + ((k-1)*d+1) - os for s,i,op,k,d,os in
|
||||
zip(strides, input_shape, output_padding, kernel_shape, dilations, output_shape)], auto_pad)
|
||||
if pads is None: # we generate pads
|
||||
output_shape = output_shape or [X.shape[i+2] * strides[i] for i in range(len(strides))]
|
||||
pads = [strides[i]*(input_shape[i]-1) + output_padding[i] + ((kernel_shape[i]-1)*dilations[i]+1)-output_shape[i] for i in range(len(input_shape))]
|
||||
pads = _auto_pad(pads, auto_pad) if auto_pad != "NOTSET" else [0] * len(input_shape) * 2
|
||||
pads = _onnx_pads_to_tiny_pads(pads)
|
||||
return X.conv_transpose2d(W, B, stride=strides, groups=group, dilation=dilations, padding=pads, output_padding=output_padding)
|
||||
|
||||
def MaxUnpool(xT: Tensor, xI: Tensor, outshape: list[int]|None=None, kernel_shape:list[int]=None, pads:list[int]|int=0, strides:list[int]|int=1):
|
||||
pads, strides = (make_tuple(x, len(xI.shape)) for x in (pads, strides))
|
||||
out_sh = [(ks//2)*2 + st * inps for inps, st, ks in zip(xI.shape, strides, kernel_shape)]
|
||||
ret = (xI.reshape(-1, 1)._one_hot_along_dim(prod(out_sh)) * xT.reshape(-1, 1)).sum(0).reshape(1, 1, *out_sh)
|
||||
if outshape is not None and outshape != ret.shape: pads = _auto_pad([outshape[-2] - ret.shape[-2], outshape[-1] - ret.shape[-1]], "SAME_UPPER")
|
||||
return ret.pad(_onnx_pads_to_tiny_pads(pads))
|
||||
|
||||
def GlobalAveragePool(X:Tensor): return X.mean(axis=tuple(range(2, X.ndim)), keepdim=True)
|
||||
def GlobalMaxPool(X:Tensor): return X.max(axis=tuple(range(2, X.ndim)), keepdim=True)
|
||||
|
||||
def Gemm(A:Tensor, B:Tensor, C:Tensor|None=None, alpha:float=1.0, beta:float=1.0, transA:int=0, transB:int=0, broadcast=0):
|
||||
ret = alpha * (A.transpose(transA) @ B.transpose(transB))
|
||||
if C is not None: ret = ret + beta * (C if broadcast == 0 else C.reshape([-1 if i < len(C.shape) else 1 for i in range(ret.ndim)][::-1]))
|
||||
return ret
|
||||
|
||||
def Einsum(*Inputs:list[Tensor], equation:str): return Tensor.einsum(equation, *Inputs)
|
||||
|
||||
def CumSum(X:Tensor, axis:int|list, exclusive:int=0, reverse:int=0):
|
||||
axis = X._resolve_dim(axis[0] if isinstance(axis, list) else axis)
|
||||
if reverse: X = X.flip(axis)
|
||||
if exclusive: X = X.pad(tuple((1,0) if i == axis else None for i in range(X.ndim)))\
|
||||
.shrink(tuple((0,X.shape[axis]) if i == axis else None for i in range(X.ndim)))
|
||||
return X.cumsum(axis).flip(axis) if reverse else X.cumsum(axis)
|
||||
|
||||
def Trilu(x:Tensor, k:int=0, upper:int=1): return x.triu(k) if upper else x.tril(k)
|
||||
|
||||
def Resize(X:Tensor, roi:list[float]|None=None, scales:list[float]|None=None, sizes:list[int]|None=None, antialias:int=0,
|
||||
axes:list[int]|None=None, coordinate_transformation_mode:str='half_pixel', cubic_coeff_a:float=-0.75, exclude_outside:int=0,
|
||||
extrapolation_value:float=0.0, keep_aspect_ratio_policy:str='stretch', mode:str='nearest', nearest_mode:str='round_prefer_floor'):
|
||||
def _apply_nearest_mode(index: Tensor, input_dim, mode: str):
|
||||
if mode == "round_prefer_floor": index = (index - 0.5).ceil()
|
||||
elif mode == "round_prefer_ceil": index = (index + 0.5).floor()
|
||||
elif mode in ["floor", "ceil"]: index = getattr(index, mode)()
|
||||
else: raise ValueError(f"invalid {nearest_mode=}")
|
||||
return index.cast(dtypes.int32).clip(0, input_dim-1)
|
||||
def _apply_transformation(index: Tensor, input_dim, scale_dim, roi_dim, mode):
|
||||
# TODO: needs more testing, not confident in this
|
||||
# NOTE: their reference implementation differ from the implementation in their reference docs
|
||||
# https://github.com/onnx/onnx/blob/main/onnx/reference/ops/op_resize.py
|
||||
# https://github.com/onnx/onnx/blob/main/docs/Operators.md#Resize
|
||||
output_dim = scale_dim * input_dim
|
||||
if mode == "half_pixel": index = (index + 0.5) / scale_dim - 0.5
|
||||
elif mode == "align_corners": index = index * (input_dim - 1) / (output_dim - 1) if output_dim != 1 else Tensor([0])
|
||||
elif mode == "asymmetric": index = index / scale_dim
|
||||
elif mode == "pytorch_half_pixel": index = (index + 0.5) / scale_dim - 0.5 if output_dim != 1 else Tensor([-0.5])
|
||||
elif mode == "half_pixel_symmetric": index = input_dim / 2 * (1 - int(output_dim) / output_dim) + (index + 0.5) / scale_dim - 0.5
|
||||
elif mode == "tf_crop_and_resize": index = roi_dim[0] * (input_dim - 1) + index * ((roi_dim[1] - roi_dim[0]) * (input_dim - 1) / (output_dim - 1))
|
||||
else: raise ValueError(f"invalid {coordinate_transformation_mode=}")
|
||||
return index.clip(0, input_dim-1)
|
||||
|
||||
scales, sizes = (None if scales is None else scales[2-(X.ndim-len(scales)):]), (None if sizes is None else sizes[2-(X.ndim-len(sizes)):])
|
||||
# we pre permute the axes and permute back after resize
|
||||
axes, input_shape, = (axes or list(range(X.ndim))), cast(tuple[int, ...], X.shape[2:]),
|
||||
perm = [a for a in range(len(X.shape)) if a not in axes] + list(axes)
|
||||
X = X.permute(*perm)
|
||||
|
||||
if sizes is not None:
|
||||
if keep_aspect_ratio_policy in ["not_larger", "not_smaller"]:
|
||||
scale_fxn = min if keep_aspect_ratio_policy == "not_larger" else max
|
||||
scales = [scale_fxn([sizes[i] / input_shape[i] for i in range(len(input_shape)) if i+2 in axes])] * 2
|
||||
sizes = [int((scales[0] * input_shape[i]) + 0.5) if i+2 in axes else input_shape[i] for i in range(X.ndim-2)]
|
||||
else:
|
||||
scales = [size / input_shape for size, input_shape in zip(sizes, input_shape)]
|
||||
else:
|
||||
sizes = [int(sc*sh) for sc, sh in zip(scales, input_shape)]
|
||||
regions = [[st, ed] for st, ed in zip(roi, roi[len(roi)//2:])] if isinstance(roi, list) and roi else [[0.0, 0.0]] * (X.ndim-2)
|
||||
|
||||
# NOTE: this transformation makes it so that we can't just call Tensor.interpolate
|
||||
# in Tensor.interpolate, we use indexes without any transformation
|
||||
indexes = []
|
||||
for shape, size, scale, region in zip(input_shape, sizes, scales, regions):
|
||||
indexes.append(_apply_transformation(Tensor.arange(size), shape, scale, region, coordinate_transformation_mode))
|
||||
|
||||
if mode == "nearest":
|
||||
indexes = [_apply_nearest_mode(index, shape, nearest_mode) for (index, shape) in zip(indexes, input_shape)]
|
||||
X = X[(..., *Tensor.meshgrid(*indexes))]
|
||||
if mode == "linear":
|
||||
expand = list(X.shape)
|
||||
for i in range(-len(sizes), 0):
|
||||
reshape, index = [1] * X.ndim, indexes[i]
|
||||
reshape[i] = expand[i] = sizes[i]
|
||||
low, high, perc = [y.reshape(reshape).expand(expand) for y in (index.floor(), index.ceil(), index - index.floor())]
|
||||
X = X.gather(i, low).lerp(X.gather(i, high), perc)
|
||||
if mode == "cubic": raise NotImplementedError("cubic interpolation is not implemented")
|
||||
return X.permute(*[perm.index(i) for i in range(len(perm))]) if perm else X
|
||||
def Upsample(X, scales, mode): return Resize(X=X, scales=scales, mode=mode) # deprecated
|
||||
|
||||
# ***** Neural Network Ops *****
|
||||
# TODO: try to factor out common implementations for these ops
|
||||
# https://medium.com/@zljdanceholic/groupnorm-then-batchnorm-instancenorm-layernorm-e2b2a1d350a0
|
||||
def BatchNormalization(X:Tensor, scale:Tensor, B:Tensor, input_mean:Tensor, input_var:Tensor, epsilon:float=1e-05, momentum:float=0.9,
|
||||
training_mode:int=0, spatial=1, is_test=0):
|
||||
if training_mode:
|
||||
x_detached = X.detach()
|
||||
current_mean = x_detached.mean(axis=(0,2,3))
|
||||
y = (x_detached - current_mean.reshape(shape=[1, -1, 1, 1]))
|
||||
current_var = (y*y).mean(axis=(0,2,3))
|
||||
current_invstd = current_var.add(epsilon).rsqrt()
|
||||
|
||||
running_mean = input_mean * momentum + current_mean * (1 - momentum)
|
||||
running_var = input_var * momentum + current_var * (1 - momentum)
|
||||
|
||||
return X.batchnorm(scale, B, current_mean, current_invstd), running_mean, running_var
|
||||
invstd = (input_var + epsilon).rsqrt()
|
||||
return X.batchnorm(scale, B, input_mean, invstd)
|
||||
def InstanceNormalization(x:Tensor, scale:Tensor, bias:Tensor, epsilon:float=1e-05):
|
||||
axis = tuple(range(2, x.ndim))
|
||||
mean = x.mean(axis=axis, keepdim=True)
|
||||
invstd = x.sub(mean).square().mean(axis=axis, keepdim=True).add(epsilon).rsqrt()
|
||||
return x.sub(mean).mul(scale.reshape(shape=[-1, 1, 1])).mul(invstd).add(bias.reshape(shape=[-1, 1, 1]))
|
||||
def LayerNormalization(x:Tensor, scale:Tensor, bias:Tensor, axis:int=-1, epsilon:float=1e-05, stash_type:int=1):
|
||||
assert stash_type == 1, "only float32 is supported"
|
||||
axes = tuple(i for i in range(axis if axis >= 0 else x.ndim + axis, x.ndim))
|
||||
mean = x.mean(axis=axes, keepdim=True)
|
||||
return x.layernorm(axes, epsilon).mul(scale).add(bias), mean, (x.sub(mean)).square().mean(axis=axes, keepdim=True).add(epsilon).rsqrt()
|
||||
def GroupNormalization(x:Tensor, scale:Tensor, bias:Tensor, num_groups:int, epsilon:float=1e-05):
|
||||
return x.reshape(x.shape[0], num_groups, -1).layernorm(axis=-1, eps=epsilon).mul(scale.unsqueeze(-1)).add(bias.unsqueeze(-1)).reshape(x.shape)
|
||||
def MeanVarianceNormalization(x:Tensor, axis:list[int]=[0,2,3]):
|
||||
return (x - x.mean(axis, keepdim=True)) / (x.std(axis, keepdim=True, correction=0) + 1e-9)
|
||||
def SkipLayerNormalization(x:Tensor, skip:Tensor, gamma:Tensor, beta:Tensor|None=None, bias:Tensor|None=None, epsilon:float=1e-12):
|
||||
x = x + skip + bias
|
||||
return x.layernorm(eps=epsilon) * gamma + beta, None, None, x
|
||||
def EmbedLayerNormalization(input_ids: Tensor, segment_ids:Tensor, word_embedding:Tensor, position_embedding:Tensor,
|
||||
segment_embedding:Tensor, gamma=None, beta=None, mask:Tensor|None=None,
|
||||
position_ids:Tensor|None=None, epsilon=1e-12, mask_index_type=0):
|
||||
# https://github.com/microsoft/onnxruntime/blob/main/docs/ContribOperators.md#com.microsoft.EmbedLayerNormalization
|
||||
assert (segment_ids is None) is (segment_embedding is None)
|
||||
assert mask is None and not mask_index_type, "functionality not supported yet" # TODO
|
||||
input_shape = input_ids.shape
|
||||
seq_length = input_shape[1]
|
||||
compute_seg_emb = (segment_embedding is not None and segment_ids is not None)
|
||||
vocab_size, max_position_embeddings = word_embedding.shape[0], position_embedding.shape[0]
|
||||
type_vocab_size = (segment_embedding.shape[0] if compute_seg_emb else None)
|
||||
|
||||
def embedding(x:Tensor, vocab_size, weight:Tensor) -> Tensor:
|
||||
return x.unsqueeze(-1).expand(*x.shape, vocab_size)._one_hot_along_dim(vocab_size) @ weight
|
||||
|
||||
# bert embedding layer
|
||||
if position_ids is None: position_ids = Tensor.arange(seq_length, requires_grad=False).unsqueeze(0).expand(*input_shape)
|
||||
wrd_embedding_res = embedding(input_ids, vocab_size, word_embedding)
|
||||
pos_embedding_res = embedding(position_ids, max_position_embeddings, position_embedding)
|
||||
seg_embedding_res = embedding(segment_ids, type_vocab_size, segment_embedding) if compute_seg_emb else None
|
||||
|
||||
embedding_sum = wrd_embedding_res + pos_embedding_res
|
||||
if seg_embedding_res is not None: embedding_sum = embedding_sum + seg_embedding_res
|
||||
out = embedding_sum.layernorm(eps=epsilon) * gamma + beta
|
||||
return out, None, embedding_sum
|
||||
|
||||
def OneHot(indices:Tensor, depth:float|int|list, values:Tensor, axis:int=-1):
|
||||
# Scalar or Rank 1 tensor containing exactly one element
|
||||
depth = int(depth[0] if isinstance(depth, list) else depth)
|
||||
indices = (indices < 0).where(indices+depth, indices)
|
||||
return indices[:, None]._one_hot_along_dim(depth, dim=axis).where(values[1], values[0])
|
||||
|
||||
def DepthToSpace(X:Tensor, blocksize:int, mode:str="DCR"):
|
||||
return X.rearrange("b (c h1 w1) h w -> b c (h h1) (w w1)" if mode=="CRD" else "b (h1 w1 c) h w -> b c (h h1) (w w1)", h1=blocksize, w1=blocksize)
|
||||
def SpaceToDepth(X:Tensor, blocksize:int):
|
||||
return X.rearrange("b c (h h1) (w w1) -> b (h1 w1 c) h w", h1=blocksize, w1=blocksize)
|
||||
|
||||
# Reimplemented here because you need legacy RNG for passing ONNX tests.
|
||||
def Dropout_7(data:Tensor, ratio:float=0.5, training_mode:bool=False, seed:int|None=None):
|
||||
if not training_mode: return data, Tensor.ones(data.shape, dtype=dtypes.bool) # if mask is requested as output it will contain all True's.
|
||||
mask = Tensor(np.random.RandomState(seed).random(cast(tuple[int,...], data.shape)) >= ratio, requires_grad=False, device=data.device)
|
||||
return data * mask * (1/(1.0 - ratio)), mask
|
||||
# 6 with 'is_test' needed for https://github.com/MTlab/onnx2caffe/raw/refs/heads/master/model/MobileNetV2.onnx
|
||||
def Dropout_6(data:Tensor, ratio:float=0.5, is_test=0): return Dropout_7(data, ratio, training_mode=not is_test)
|
||||
Dropout = {6:Dropout_6, 7:Dropout_7}
|
||||
|
||||
def LRN(x:Tensor, size:int, alpha:float=1e-4, beta:float=0.75, bias:float=1.0):
|
||||
pooled_x = (x**2).rearrange('b c h w -> b 1 c (h w)').pad((0,0,(size-1)//2, size//2)).avg_pool2d((size, 1), 1)
|
||||
return x / (pooled_x.reshape(x.shape) * alpha + bias).pow(beta)
|
||||
|
||||
def NegativeLogLikelihoodLoss(x:Tensor, target:Tensor, weight:Tensor|None=None, ignore_index:int|None=None, reduction:ReductionStr="mean"):
|
||||
return x.nll_loss(target, weight, ignore_index, reduction)
|
||||
def SoftmaxCrossEntropyLoss(scores:Tensor, labels:Tensor, weights:Tensor|None=None, ignore_index:int|None=None, reduction:ReductionStr="mean"):
|
||||
log_probs = scores.log_softmax(1)
|
||||
return log_probs.nll_loss(labels, weights, ignore_index, reduction), log_probs
|
||||
|
||||
def AffineGrid(theta:Tensor, size:list[int], align_corners:int=0):
|
||||
N, _, *spatial_dims = size
|
||||
def generate_grid(steps):
|
||||
return Tensor.linspace(-1, 1, steps, device=theta.device) if align_corners else Tensor.linspace(-1+1/steps, 1-1/steps, steps, device=theta.device)
|
||||
grids = Tensor.meshgrid(*(generate_grid(d) for d in spatial_dims))
|
||||
base_grid = Tensor.stack(*reversed(grids), Tensor.ones_like(grids[0], device=theta.device), dim=-1)
|
||||
base_grid = base_grid.reshape(1, prod(spatial_dims), len(grids)+1).expand(N, -1, -1)
|
||||
return (base_grid @ theta.transpose(1, 2)).reshape(N, *spatial_dims, -1)
|
||||
|
||||
def Attention(x:Tensor, weights, bias:Tensor, mask_index:Tensor|None=None, past:Tensor|None=None,
|
||||
relative_position_bias:Tensor|None=None, past_sequence_length:Tensor|None=None, do_rotary:int|None=None,
|
||||
mask_filter_value:float|None=None, num_heads:int|None=None, past_present_share_buffer:int|None=None,
|
||||
qkv_hidden_sizes:list[int]|None=None, scale:float|None=None, unidirectional:int|None=None):
|
||||
# https://github.com/microsoft/onnxruntime/blob/main/docs/ContribOperators.md#com.microsoft.Attention
|
||||
assert num_heads is not None # required
|
||||
assert (qkv_hidden_sizes is None and past is not None) or (qkv_hidden_sizes is not None)
|
||||
assert relative_position_bias is do_rotary is past_sequence_length is mask_filter_value is past_present_share_buffer is scale is None, \
|
||||
"functionality not supported yet" # TODO strange params
|
||||
hidden_size, v_hidden_size = qkv_hidden_sizes[1:] if qkv_hidden_sizes is not None else 2*(weights.shape[1] // 3,)
|
||||
|
||||
if unidirectional: # gpt-style
|
||||
assert hidden_size == v_hidden_size
|
||||
xqkv = x.linear(weights, bias)
|
||||
xq, xk, xv = [xqkv.shrink([None, None, (i*hidden_size, (i+1)*hidden_size)]) for i in range(3)]
|
||||
else: # bert-style
|
||||
wq, wk, wv = weights[:,:hidden_size], weights[:,hidden_size:hidden_size+v_hidden_size], weights[:,hidden_size+v_hidden_size:]
|
||||
bq, bk, bv = (bias[:hidden_size], bias[hidden_size:hidden_size+v_hidden_size], bias[hidden_size+v_hidden_size]) if bias is not None else None
|
||||
xq, xk, xv = [x.linear(w, b) for w, b in zip((wq, wk, wv), (bq, bk, bv))]
|
||||
xq, xk, xv = [x.reshape(x.shape[0], x.shape[1], num_heads, -1).transpose(1, 2) for x in (xq, xk, xv)]
|
||||
|
||||
if past is not None:
|
||||
xk, xv = Tensor.cat(past[0], xk, dim=-2), Tensor.cat(past[1], xv, dim=-2)
|
||||
present = Tensor.cat(xk.unsqueeze(0), xv.unsqueeze(0))
|
||||
|
||||
def attn(query, key, value, attn_mask):
|
||||
query_length, key_length = query.shape[-2], key.shape[-2]
|
||||
cdim = max(query_length, key_length) + 1
|
||||
attn_weights = query @ key.transpose(-1, -2) / math.sqrt(value.shape[-1])
|
||||
# This is where Tensor.scaled_dot_product_attention differs:
|
||||
causal_mask = Tensor.ones((cdim, cdim), requires_grad=False, dtype=dtypes.bool).tril(0)[key_length - query_length : key_length, :key_length]
|
||||
masked = Tensor.where(causal_mask, attn_weights, -math.inf)
|
||||
if attn_mask is not None: masked = masked + attn_mask
|
||||
return masked.softmax(-1) @ value
|
||||
|
||||
bsz, _, seq_len, _ = xq.shape
|
||||
out = attn(xq, xk, xv, mask_index).transpose(1, 2).reshape(bsz, seq_len, -1)
|
||||
return out, present if past is not None else out
|
||||
|
||||
# ***** Indexing Ops *****
|
||||
def ArrayFeatureExtractor(x:Tensor, indices:Tensor): return x[..., indices]
|
||||
|
||||
def Gather(x:Tensor, indices:Tensor, axis:int=0):
|
||||
if indices.numel() < 9: # NOTE lessor kernels for smaller indices but kernel number increases depending on size of indices
|
||||
x_sh = list(x.shape)
|
||||
ret_shape = x_sh[:axis] + list(indices.shape) + x_sh[axis+1:]
|
||||
if indices.ndim > 1: indices = indices.flatten()
|
||||
indices = [_cached_to_python_const(indices)] if indices.shape == () else [x_sh[axis]+x if x<0 else x for x in _cached_to_python_const(indices)]
|
||||
args = [[(0,x) if j != axis else (i,i+1) for j, x in enumerate(x_sh)] for i in indices] # type: ignore
|
||||
return x.shrink(arg=tuple(args[0])).cat(*[x.shrink(arg=tuple(arg)) for arg in args[1:]], dim=axis).reshape(ret_shape)
|
||||
# NOTE faster gather, fixed number of kernels, but exceeds limited kernels for openpilot
|
||||
return x[tuple([slice(None) if i != axis else indices for i in range(x.ndim)])]
|
||||
def Scatter(*args, **kwargs): return ScatterElements(*args, **kwargs) # deprecated
|
||||
|
||||
def GatherND(x:Tensor, indices:Tensor, batch_dims:int=0):
|
||||
if batch_dims == 0: return x[tuple(i.squeeze(-1) for i in indices.split(1, -1))]
|
||||
x_shape, i_shape = x.shape, indices.shape
|
||||
b = math.prod(x.shape[dim] for dim in range(batch_dims))
|
||||
# NOTE: each batched dim of both input and indices are equal
|
||||
x = x.reshape(b, *x.shape[batch_dims:])
|
||||
indices = indices.reshape(b, *indices.shape[batch_dims:])
|
||||
b_idx = Tensor.arange(b, device=x.device).reshape(b, *(1,)*(indices.ndim - 2)).expand(*indices.shape[:-1])
|
||||
ret = x[(b_idx,) + tuple(i.squeeze(-1) for i in indices.split(1, -1))]
|
||||
return ret.reshape(*x_shape[:batch_dims], *i_shape[batch_dims:-1], *ret.shape[indices.ndim-1:])
|
||||
def ScatterND(x:Tensor, indices:Tensor, updates:Tensor, reduction:Literal["none", "add", "mul"]='none'):
|
||||
assert updates.shape == indices.shape[:-1] + x.shape[cast(int, indices.shape[-1]):]
|
||||
x = x.contiguous()
|
||||
for index, u in zip(indices.split(1, 0), updates.split(1, 0)):
|
||||
i = tuple(idx.squeeze(-1) for idx in index.squeeze(0).split(1, -1))
|
||||
u = u.squeeze(0)
|
||||
if reduction == "none": x[i] = u
|
||||
elif reduction == "add": x[i] += u
|
||||
elif reduction == "mul": x[i] *= u
|
||||
else: raise NotImplementedError("reduction doesn't support max or min")
|
||||
return x
|
||||
|
||||
def ScatterElements(x: Tensor, indices: Tensor, updates: Tensor, axis=0, reduction:Literal["none", "add", "mul"]="none"):
|
||||
indices = (indices < 0).where(x.shape[axis], 0) + indices
|
||||
return x.scatter(axis, indices, updates, {"none":None, "mul": "multiply"}.get(reduction, reduction))
|
||||
def GatherElements(x:Tensor, indices:Tensor, axis:int):
|
||||
indices = (indices < 0).where(x.shape[axis], 0) + indices
|
||||
return x.gather(axis, indices)
|
||||
|
||||
def Compress(inp:Tensor, condition:list[bool], axis:int|None=None):
|
||||
if axis is None:
|
||||
inp = inp.flatten()
|
||||
axis = 0
|
||||
if axis < 0: axis += inp.ndim
|
||||
con = Tensor(np.arange(len(condition))[condition]) # no boolean indexing in Tensor
|
||||
return inp[tuple(con if i == axis else slice(None) for i in range(inp.ndim))]
|
||||
|
||||
# ***** Quantization Ops *****
|
||||
def QuantizeLinear(x:Tensor, y_scale:Tensor, y_zero_point:Tensor|int=0, axis:int=1, block_size:int=0, output_dtype:int=0, saturate=1):
|
||||
out_dtype = y_zero_point.dtype if isinstance(y_zero_point, Tensor) else dtype_parse(output_dtype) if output_dtype else dtypes.uint8
|
||||
y_scale, y_zero_point = _prepare_quantize(x, y_scale, y_zero_point, axis, block_size)
|
||||
return _clamp_cast(((x / y_scale).round() + y_zero_point), out_dtype).contiguous()
|
||||
|
||||
def DequantizeLinear(x:Tensor, x_scale:Tensor, x_zero_point:Tensor|int=0, axis:int=1, block_size:int=0):
|
||||
x_scale, x_zero_point = _prepare_quantize(x, x_scale, x_zero_point, axis, block_size)
|
||||
return ((x.int() - x_zero_point) * x_scale).cast(x_scale.dtype)
|
||||
|
||||
def QLinearConv(x:Tensor, x_scale:Tensor, x_zero_point:Tensor|int, w:Tensor, w_scale:Tensor, w_zero_point:Tensor|int, y_scale:Tensor,
|
||||
y_zero_point: Tensor|int, B:Tensor|None=None, **opts):
|
||||
return _qlinearop_quantized(Conv, [x,w], [x_zero_point,w_zero_point], [x_scale,w_scale], y_scale, y_zero_point, **{"B":B, **opts})
|
||||
|
||||
def QLinearMatMul(a:Tensor, a_scale:Tensor, a_zero_point:Tensor|int, b:Tensor, b_scale:Tensor, b_zero_point:Tensor|int, y_scale:Tensor,
|
||||
y_zero_point:Tensor|int) -> Tensor:
|
||||
return _qlinearop_quantized(Tensor.matmul, [a,b], [a_zero_point,b_zero_point], [a_scale,b_scale], y_scale, y_zero_point)
|
||||
|
||||
def QLinearAdd(a:Tensor, a_scale:Tensor, a_zero_point:Tensor, b:Tensor, b_scale:Tensor, b_zero_point:Tensor, c_scale:Tensor, c_zero_point:Tensor):
|
||||
return _qlinearop_float(Tensor.add, [a,b], [a_zero_point,b_zero_point], [a_scale,b_scale], c_scale, c_zero_point)
|
||||
|
||||
def QLinearGlobalAveragePool(X:Tensor, x_scale:Tensor, x_zero_point:Tensor, y_scale:Tensor, y_zero_point:Tensor, channels_last:int):
|
||||
assert channels_last == 0, "unsure what this does"
|
||||
return _qlinearop_float(GlobalAveragePool, [X], [x_zero_point], [x_scale], y_scale, y_zero_point)
|
||||
|
||||
def ConvInteger(x: Tensor, w: Tensor, x_zero_point: Tensor | int = 0, w_zero_point: Tensor | int = 0, B: Tensor | None = None, **opts) -> Tensor:
|
||||
return _op_integer(Conv, [x,w], [x_zero_point,w_zero_point], **{"B":B, **opts})
|
||||
|
||||
def MatMulInteger(A: Tensor, B: Tensor, a_zero_point: Tensor | int = 0, b_zero_point: Tensor | int = 0) -> Tensor:
|
||||
return _op_integer(Tensor.matmul, [A,B], [a_zero_point,b_zero_point])
|
||||
|
||||
# ***** Training Ops *****
|
||||
# NOTE: onnx test coverage only covers `T==0` cases, so for all `T>0` this isn't tested
|
||||
# NOTE: onnx training ops actually don't need the state for optim, all the ops work in a functional way, but we still can reuse optim.py code
|
||||
@_onnx_training(3)
|
||||
def Adagrad(R:Tensor, T:int, *inputs:Tensor, decay_factor:float=0.0, epsilon:float=0.0, norm_coefficient:float=0.0):
|
||||
X, G, H = (i.detach() for i in inputs)
|
||||
grad = norm_coefficient * X + G
|
||||
H.assign(H + grad.square())
|
||||
up = grad / (H.sqrt() + epsilon)
|
||||
r = R / (1 + T * decay_factor)
|
||||
X.assign(X.detach() - r * up)
|
||||
return [X, H]
|
||||
|
||||
@_onnx_training(4)
|
||||
def Adam(R:Tensor, T:int, *inputs:Tensor, alpha:float=0.9, beta:float=0.999, epsilon:float=0.0, norm_coefficient:float=0.0,
|
||||
norm_coefficient_post:float=0.0):
|
||||
from tinygrad.nn.optim import Adam as TinyAdam
|
||||
X, G, V, H = inputs
|
||||
G, V, H = G.detach(), V.detach(), H.detach() # TODO we shouldn't need these detaches
|
||||
X.grad = norm_coefficient * X.detach() + G
|
||||
opt = TinyAdam([X], b1=alpha, b2=beta, eps=epsilon)
|
||||
opt.m, opt.v, opt.lr = [V], [H], R
|
||||
# need no-op for m_hat and v_hat if T == 0
|
||||
if T == 0: opt.b1_t, opt.b2_t = opt.b1_t.zeros_like(), opt.b2_t.zeros_like()
|
||||
else:
|
||||
# `T-1` since it's applied again at the start of `_step`
|
||||
opt.b1_t = Tensor([alpha**(T-1)], dtype=dtypes.float32, device=X.device, requires_grad=False)
|
||||
opt.b2_t = Tensor([beta**(T-1)], dtype=dtypes.float32, device=X.device, requires_grad=False)
|
||||
opt.step()
|
||||
X = (1 - norm_coefficient_post) * X
|
||||
return [X, V, H]
|
||||
|
||||
@_onnx_training(3)
|
||||
def Momentum(R:Tensor, T:int, *inputs:Tensor, alpha:float, beta:float, mode:str, norm_coefficient:float):
|
||||
from tinygrad.nn.optim import SGD
|
||||
X, G, V = inputs
|
||||
G, V = G.detach(), V.detach()
|
||||
X.grad = (norm_coefficient * X.detach() + G) * (beta if T > 0 else 1)
|
||||
opt = SGD([X], momentum=alpha, nesterov=(mode=="nesterov"))
|
||||
opt.b, opt.lr = [V], R
|
||||
opt.step()
|
||||
return [X, V]
|
||||
|
||||
def Gradient(*inputs:Tensor, y:str, intermediate_tensors:dict[str, Tensor], **_):
|
||||
intermediate_tensors[y].backward()
|
||||
return tuple([t.grad for t in inputs])
|
||||
|
||||
return {
|
||||
# Tensor ops
|
||||
**{op: getattr(Tensor, op.lower()) for op in ("Neg", "Reciprocal", "Pow", "Sqrt", "Sign", "Abs", "Exp", "Log", "Mish", "Sin", "Cos", "Tan",
|
||||
"Asin", "Acos", "Atan", "Relu", "Sigmoid", "MatMul", "Floor", "Ceil", "IsInf", "IsNaN", "Softplus", "HardSwish", "Where", "Mul", "Sinh", "Cosh",
|
||||
"Tanh", "Softsign", "Asinh", "Acosh", "Atanh", "Elu", "Celu", "Selu", "Xor", "Round", "Erf", "Mod")},
|
||||
# Implemented ops
|
||||
**{name:obj for name,obj in locals().items() if isinstance(obj, types.FunctionType) and not name.startswith("_") and name[0].isupper()},
|
||||
# Version ops
|
||||
**{name:obj for name,obj in locals().items() if isinstance(obj, dict)},
|
||||
}
|
||||
|
||||
# src: https://onnx.ai/onnx/repo-docs/IR.html#input-output-data-types
|
||||
# parses and validates inputs based on their shape and dtype specified by model
|
||||
def prepare_input(user_input:Any, model_input:ValueInfoProto):
|
||||
type_proto = model_input.type
|
||||
if type_proto.HasField("optional_type"):
|
||||
if user_input is None: return Tensor(None)
|
||||
type_proto = type_proto.optional_type.elem_type
|
||||
if type_proto.HasField("sequence_type"):
|
||||
if not isinstance(user_input, Sequence): raise RuntimeError(f"{model_input.name} received {user_input}, expected sequence type")
|
||||
dtype = dtype_parse(type_proto.sequence_type.elem_type.tensor_type.elem_type)
|
||||
sequence = [Tensor(i, dtype=dtype, requires_grad=is_onnx_preview_training) if not isinstance(i, Tensor) else i for i in user_input]
|
||||
if not all_same(tuple(t.shape for t in sequence)): raise RuntimeError(f"shapes for {model_input.name} must be homogeneous")
|
||||
# TODO: need true float16 for dtype checking
|
||||
# if not all(t.dtype is dtype for t in sequence): raise RuntimeError(f"{model_input.name} received wrong dtype, expected {dtype}")
|
||||
return sequence
|
||||
if type_proto.HasField("tensor_type"):
|
||||
dtype = dtype_parse(type_proto.tensor_type.elem_type)
|
||||
tensor = Tensor(user_input, dtype=dtype, requires_grad=is_onnx_preview_training) if not isinstance(user_input, Tensor) else user_input
|
||||
# TODO: need true float16 for dtype checking
|
||||
# if dtype is not tensor.dtype: raise RuntimeError(f"{model_input.name} received dtype {inp.dtype}, expected {dtype}")
|
||||
for d,onnx_dim in enumerate(type_proto.tensor_type.shape.dim):
|
||||
# NOTE: dim is a variable dimension when `dim_param` is specified, e.g. dim {dim_param: "N"} is a variable dim
|
||||
if onnx_dim.dim_param is None and onnx_dim.dim_value != user_input.shape[d]:
|
||||
raise RuntimeError(f"{model_input.name} received value {user_input.shape[d]} on dim {d}, expected {onnx_dim.dim_value}")
|
||||
return tensor
|
||||
type_field_names = [field.name for field,_ in type_proto.ListFields()]
|
||||
raise NotImplementedError(f"{model_input.name} with {type_field_names=} is not supported")
|
||||
|
||||
def run_onnx(inputs={}, debug=0):
|
||||
debug = getenv("DEBUGONNX") or debug
|
||||
intermediate_tensors: Dict[str,Tensor] = {}
|
||||
|
||||
input_tensors: Dict[str, Tensor | List[Tensor]] = {}
|
||||
for model_input in onnx_model.graph.input:
|
||||
if model_input.name in inputs: input_tensors[model_input.name] = prepare_input(inputs[model_input.name], model_input)
|
||||
elif model_input.name not in model_parameters: raise RuntimeError(f"Please provide input data for {model_input.name}")
|
||||
|
||||
def fetch_tensor(x: str):
|
||||
if x in model_parameters: return model_parameters[x]
|
||||
if x in intermediate_tensors: return intermediate_tensors[x]
|
||||
if x != "": return input_tensors[x]
|
||||
return None
|
||||
|
||||
for num,n in enumerate(onnx_model.graph.node):
|
||||
inp = [fetch_tensor(x) for x in n.input]
|
||||
opt = model_attributes[num]
|
||||
|
||||
if debug >= 1: print(f"{num}: op \"{n.op_type}\" input shapes {[x.shape if isinstance(x, Tensor) else x for x in inp]} opt {opt}")
|
||||
if debug >= 3: print("\tinputs:\n" + "\n".join(f"\t\t{x} - {t}" for i,(x,t) in enumerate(zip(n.input, inp))))
|
||||
|
||||
if n.op_type in tensor_methods:
|
||||
ret = getattr(Tensor, tensor_methods[n.op_type])(*inp, **opt)
|
||||
|
||||
# NOTE some ops live here because they require access to some local variables
|
||||
elif n.op_type == "Split":
|
||||
axis, n_outputs = opt.get('axis', 0), opt.get('num_outputs') or len(n.output)
|
||||
sz = inp[0].shape[axis]
|
||||
sizes = to_python_const(inp[1]) if len(inp) == 2 else [sz // n_outputs + (1 if i < sz % n_outputs else 0) for i in range(n_outputs)]
|
||||
ret = inp[0].split(sizes, axis)
|
||||
elif n.op_type == "Gradient":
|
||||
assert len(opt["xs"]) == len(inp), f"len(opt['xs']):{len(opt['xs'])}, len(inp):{len(inp)} output and input has to match"
|
||||
y = opt["y"]
|
||||
intermediate_tensors[y].backward()
|
||||
ret = tuple([t.grad for t in inp])
|
||||
|
||||
# onnx_ops.py
|
||||
elif hasattr(onnx_ops, n.op_type):
|
||||
fxn = getattr(onnx_ops, n.op_type)
|
||||
if isinstance(fxn, dict):
|
||||
for k in sorted(fxn.keys()):
|
||||
if k <= onnx_model_version:
|
||||
real_fxn = fxn[k]
|
||||
else:
|
||||
real_fxn = fxn
|
||||
ret = real_fxn(*inp, **opt)
|
||||
else:
|
||||
print("UNSUPPORTED", n.op_type, n.input, n.output)
|
||||
raise NotImplementedError(f"op_type {n.op_type} not supported")
|
||||
|
||||
# finalization after running the op
|
||||
if not isinstance(ret, tuple): ret = (ret, )
|
||||
if len(n.output) > len(ret): raise RuntimeError(f"expected output size must be less than {len(ret)}, it's {n.output}")
|
||||
for i in range(len(n.output)): intermediate_tensors[n.output[i]] = ret[i]
|
||||
if debug >= 2: print("\toutputs:\n" + "\n".join(f"\t\t{n.output[i]} - {ret[i]}" for i in range(len(n.output))))
|
||||
|
||||
if num == ONNXLIMIT: return {name:intermediate_tensors[name] for name in n.output}
|
||||
return {x.name:intermediate_tensors[x.name] for x in onnx_model.graph.output}
|
||||
return run_onnx
|
||||
onnx_ops = get_onnx_ops()
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
from tinygrad import Tensor
|
||||
from tinygrad.tensor import _to_np_dtype
|
||||
from extra.onnx import OnnxRunner, OnnxValue
|
||||
import onnx
|
||||
import numpy as np
|
||||
import onnxruntime as ort
|
||||
|
||||
def get_example_inputs(graph_inputs:dict[str, OnnxValue]):
|
||||
ret: dict[str, Tensor] = {}
|
||||
for name, spec in graph_inputs.items():
|
||||
assert not spec.is_optional and not spec.is_sequence, "only allow tensor input for now"
|
||||
shape = tuple(dim if isinstance(dim, int) else 1 for dim in spec.shape)
|
||||
value = Tensor(np.random.uniform(size=shape).astype(_to_np_dtype(spec.dtype)) * 8).realize()
|
||||
ret.update({name:value})
|
||||
return ret
|
||||
|
||||
def validate(onnx_file, inputs, rtol=1e-5, atol=1e-5):
|
||||
run_onnx = OnnxRunner(onnx.load(onnx_file))
|
||||
tinygrad_out = run_onnx(inputs)
|
||||
|
||||
ort_options = ort.SessionOptions()
|
||||
ort_options.log_severity_level = 3
|
||||
ort_sess = ort.InferenceSession(onnx_file, ort_options, ["CPUExecutionProvider"])
|
||||
np_inputs = {k:v.numpy() if isinstance(v, Tensor) else v for k,v in inputs.items()}
|
||||
out_names = list(run_onnx.graph_outputs)
|
||||
out_values = ort_sess.run(out_names, np_inputs)
|
||||
ort_out = dict(zip(out_names, out_values))
|
||||
|
||||
assert len(tinygrad_out) == len(ort_out) and tinygrad_out.keys() == ort_out.keys()
|
||||
for k in tinygrad_out.keys():
|
||||
tiny_v, onnx_v = tinygrad_out[k], ort_out[k]
|
||||
if tiny_v is None: assert tiny_v == onnx_v
|
||||
else: np.testing.assert_allclose(tiny_v.numpy(), onnx_v, rtol=rtol, atol=atol, err_msg=f"For tensor '{k}' in {tinygrad_out.keys()}")
|
||||
@@ -1,575 +0,0 @@
|
||||
import functools, io, math
|
||||
from typing import Union, Tuple, Optional, List, Any, cast
|
||||
from tinygrad.tensor import Tensor, _broadcast_shape
|
||||
from tinygrad.dtype import ImageDType, dtypes
|
||||
from tinygrad.helpers import prod, flatten
|
||||
from extra.onnx import dtype_parse, to_python_const
|
||||
import numpy as np
|
||||
|
||||
# **************** Free Ops ****************
|
||||
|
||||
def Identity(x: Tensor): return x
|
||||
# TODO: fix buffer_parse
|
||||
def Add(x: Tensor, other: Tensor, broadcast=None, axis=None): return x + other if x.dtype == dtypes.float or isinstance(x.dtype, ImageDType) else (x + other).cast(x.dtype)
|
||||
def Sub(x: Union[Tensor, Any], other: Tensor): return x - other # some test has input as int
|
||||
def Less(x:Tensor,y:Tensor): return x < y
|
||||
def LessOrEqual(x:Tensor,y:Tensor): return x <= y
|
||||
def Greater(x:Tensor,y:Tensor): return x > y
|
||||
def GreaterOrEqual(x:Tensor,y:Tensor): return x >= y
|
||||
def Equal(x:Tensor,y:Tensor): return x == y
|
||||
def BitwiseNot(x:Tensor): return ~x
|
||||
def BitwiseOr(x:Tensor, y:Tensor): return x | y
|
||||
def BitwiseAnd(x:Tensor, y:Tensor): return x & y
|
||||
def BitwiseXor(x:Tensor, y:Tensor): return x ^ y
|
||||
def Max(*data_0): return functools.reduce(Tensor.maximum, data_0)
|
||||
def Min(*data_0): return functools.reduce(Tensor.minimum, data_0)
|
||||
def Sum(*data_0): return functools.reduce(Tensor.add, data_0)
|
||||
def Mean(*data_0): return Sum(*data_0) / len(data_0)
|
||||
# NOTE: does not support saturate
|
||||
def Cast(x: Tensor, to: int, saturate=1): return x.cast(dtype_parse(to))
|
||||
def CastLike(x: Tensor, target_type: Tensor, saturate=1): return x.cast(target_type.dtype)
|
||||
|
||||
# **************** Simple Ops ****************
|
||||
|
||||
# https://github.com/onnx/onnx/blob/main/onnx/reference/ops/op_div.py
|
||||
def Div(x: Tensor, other: Tensor): return (x/other).cast(x.dtype)
|
||||
|
||||
def Constant(value:Optional[Tensor]=None, value_float=None, value_floats=None, value_int=None, value_ints=None, value_string=None, value_strings=None):
|
||||
if value is not None: return value
|
||||
if value_float is not None: return Tensor(value_float, dtype=dtypes.float32, requires_grad=False)
|
||||
if value_floats is not None: return Tensor(list(value_floats), dtype=dtypes.float32, requires_grad=False)
|
||||
if value_int is not None: return Tensor(value_int, dtype=dtypes.int64, requires_grad=False)
|
||||
if value_ints is not None: return Tensor(list(value_ints), dtype=dtypes.int64, requires_grad=False)
|
||||
if value_string is not None or value_strings is not None: raise NotImplementedError('value_string or value_strings not implemented for Constant op')
|
||||
|
||||
def HardSigmoid(x: Tensor, alpha=0.2, beta=0.5): return (alpha*x + beta).clip(0, 1)
|
||||
def Gelu(x:Tensor, approximate=None): return x.gelu() if approximate == "tanh" else 0.5 * x * (1 + (x/math.sqrt(2)).erf())
|
||||
def PRelu(X:Tensor, slope:Tensor):
|
||||
slope = slope[0] if slope.shape[-1] != X.shape[-1] else slope # HACK OnnxBackendPyTorchConvertedModelTest HAS WEIRD SLOPE WHERE IT'S [0.25, 0.25, 0.25] FOR ANY X.SHAPE
|
||||
return (X > 0).where(X, X * slope)
|
||||
def LeakyRelu(X: Tensor, alpha=0.01): return X.leakyrelu(alpha)
|
||||
def ThresholdedRelu(X: Tensor, alpha=1.0): return (X > alpha).where(X, 0)
|
||||
def Softmax_1(x: Tensor, axis=1): return x.softmax(axis)
|
||||
def Softmax_13(x: Tensor, axis=-1): return x.softmax(axis)
|
||||
Softmax = {1: Softmax_1, 13: Softmax_13} # Softmax default axis changed
|
||||
def LogSoftmax(x: Tensor, axis=-1): return x.log_softmax(axis)
|
||||
def Clip(x: Tensor, min=None, max=None): return x.clip(float('-inf') if min is None else min, float('inf') if max is None else max).cast(x.dtype)
|
||||
|
||||
def _axes(axes, noop_with_empty_axes):
|
||||
if axes is not None and not (isinstance(axes, Tensor) and axes.shape == (0,)): return to_python_const(axes)
|
||||
return [] if noop_with_empty_axes else None
|
||||
def ReduceMax(data: Tensor, axes=None, keepdims=1, noop_with_empty_axes=0): return data.max(_axes(axes, noop_with_empty_axes), keepdim=keepdims)
|
||||
def ReduceMin(data: Tensor, axes=None, keepdims=1, noop_with_empty_axes=0): return data.min(_axes(axes, noop_with_empty_axes), keepdim=keepdims)
|
||||
def ReduceSum(data: Tensor, axes=None, keepdims=1, noop_with_empty_axes=0): return data.sum(_axes(axes, noop_with_empty_axes), keepdim=keepdims)
|
||||
def ReduceMean(data: Tensor, axes=None, keepdims=1, noop_with_empty_axes=0): return data.mean(_axes(axes, noop_with_empty_axes), keepdim=keepdims)
|
||||
def ReduceSumSquare(data: Tensor, axes=None, keepdims=1, noop_with_empty_axes=0): return ReduceSum(data.square(), axes, keepdims, noop_with_empty_axes)
|
||||
def ReduceProd(data: Tensor, axes=None, keepdims=1, noop_with_empty_axes=0): return data.prod(_axes(axes, noop_with_empty_axes), keepdim=keepdims)
|
||||
def ReduceL1(data: Tensor, axes=None, keepdims=1, noop_with_empty_axes=0): return ReduceSum(data.abs(), axes, keepdims, noop_with_empty_axes)
|
||||
def ReduceL2(data: Tensor, axes=None, keepdims=1, noop_with_empty_axes=0): return ReduceSumSquare(data, axes, keepdims, noop_with_empty_axes).sqrt()
|
||||
def ReduceLogSum(data: Tensor, axes=None, keepdims=1, noop_with_empty_axes=0): return ReduceSum(data, axes, keepdims, noop_with_empty_axes).log()
|
||||
def ReduceLogSumExp(data: Tensor, axes=None, keepdims=1, noop_with_empty_axes=0): return ReduceSum(data.exp(), axes, keepdims, noop_with_empty_axes).log()
|
||||
|
||||
def GlobalAveragePool(X: Tensor): return X.mean(axis=tuple(range(2, X.ndim)), keepdim=True)
|
||||
def GlobalMaxPool(X: Tensor): return X.max(axis=tuple(range(2, X.ndim)), keepdim=True)
|
||||
def OptionalHasElement(x: Optional[Tensor]=None): return Tensor(x is not None and x.numel() > 0)
|
||||
def OptionalGetElement(x: Optional[Tensor]=None): return x if x is not None else Tensor([])
|
||||
|
||||
def Tile(x: Tensor, repeats): return x.repeat(to_python_const(repeats))
|
||||
def Range(start: Tensor, limit, delta): return Tensor.arange(start=to_python_const(start), stop=to_python_const(limit), step=to_python_const(delta))
|
||||
def Shape(data: Tensor, end=None, start=0): return Tensor(data.shape[start:end], dtype=dtypes.int64)
|
||||
def Size(data: Tensor): return prod(data if isinstance(data, list) else data.shape)
|
||||
def Flatten(x: Tensor, axis=1): return x.reshape(prod(x.shape[0:axis]), -1)
|
||||
def Reshape(data: Tensor, shape: Tensor, allowzero=0):
|
||||
return data.reshape([int(x) if x != 0 else (0 if allowzero else data.shape[i]) for i,x in enumerate(to_python_const(shape))])
|
||||
def Expand(x: Tensor, shape:Tensor): return x.expand(_broadcast_shape(x.shape, tuple(to_python_const(shape))))
|
||||
def Shrink(x: Tensor, bias=0.0, lambd=0.5): return (x < -lambd)*(x+bias) + (x > lambd)*(x-bias)
|
||||
def And(x:Tensor, y:Tensor): return (x==y).where(x, False)
|
||||
def Or(x:Tensor, y:Tensor): return (x==y).where(x, True)
|
||||
def Not(x:Tensor): return x.logical_not()
|
||||
|
||||
def Trilu(x: Tensor, k: Union[Tensor, int]=0, upper=1):
|
||||
k = to_python_const(k) if isinstance(k, Tensor) else 0 # onnx passes k as a tensor int64 with one element, default is 0
|
||||
return x.triu(k) if upper else x.tril(k)
|
||||
|
||||
def Slice(data: Tensor, starts:Tensor, ends:Tensor, axes:Optional[Tensor]=None, steps:Optional[Tensor]=None):
|
||||
if axes is None: axes = list(range(data.ndim))
|
||||
if steps is None: steps = [1] * data.ndim
|
||||
starts, ends, axes, steps = (to_python_const(x) for x in (starts, ends, axes, steps))
|
||||
slices = [slice(0,x,1) for x in data.shape]
|
||||
for i, axis in enumerate(axes): slices[axis] = slice(starts[i], ends[i], steps[i])
|
||||
return data[tuple(slices)]
|
||||
|
||||
def Squeeze(data: Tensor, axes):
|
||||
if isinstance(axes, Tensor): axes = to_python_const(axes)
|
||||
axes = [data._resolve_dim(x) for x in axes]
|
||||
return data.reshape([s for i,s in enumerate(data.shape) if i not in axes])
|
||||
def Unsqueeze(data: Tensor, axes):
|
||||
axes = sorted([x + data.ndim if x < 0 else x for x in to_python_const(axes)])
|
||||
new_shape = list(data.shape)
|
||||
for axis in axes: new_shape.insert(axis, 1)
|
||||
return data.reshape(new_shape)
|
||||
|
||||
def Binarizer(x, threshold=0.0): return (x > threshold).float()
|
||||
|
||||
def ArgMax(x: Tensor, axis=0, keepdims=1, select_last_index=0):
|
||||
if select_last_index: return ((x.shape[axis]-1) - x.flip(axis).argmax(axis, keepdim=keepdims)).cast(dtypes.int64)
|
||||
return x.argmax(axis, keepdim=keepdims).cast(dtypes.int64)
|
||||
def ArgMin(x, axis=0, keepdims=1, select_last_index=0): return ArgMax(-x, axis=axis, keepdims=keepdims, select_last_index=select_last_index)
|
||||
|
||||
def Concat(*xs: List[Tensor], axis): return Tensor.cat(*xs, dim=axis)
|
||||
def Transpose(x: Tensor, perm=None): return x.permute(order=list(range(x.ndim)[::-1]) if perm is None else perm)
|
||||
|
||||
def ConstantOfShape(x, value:Tensor=None):
|
||||
if value is None: value = 0.0
|
||||
shape = to_python_const(x)
|
||||
return Tensor.ones(*shape, dtype=value.dtype) * (value if shape[0]!=0 else 1)
|
||||
|
||||
# **************** Complex Ops ****************
|
||||
|
||||
def Gemm(A: Tensor, B: Tensor, C: Tensor=None, alpha=1.0, beta=1.0, transA=0, transB=0, broadcast=0):
|
||||
ret = alpha * (A.transpose(transA) @ B.transpose(transB))
|
||||
if C is not None: ret = ret + beta * (C if broadcast == 0 else C.reshape([-1 if i < len(C.shape) else 1 for i in range(ret.ndim)][::-1]))
|
||||
return ret
|
||||
|
||||
def Einsum(*Inputs: List[Tensor], equation): return Tensor.einsum(equation, Inputs)
|
||||
|
||||
def CumSum(X:Tensor, axis:Tensor, exclusive=0, reverse=0):
|
||||
if (axis := to_python_const(axis)) < 0: axis += X.ndim
|
||||
if reverse: X = X.flip(axis)
|
||||
if exclusive: X = X.pad(tuple((1,0) if i == axis else None for i in range(X.ndim)))\
|
||||
.shrink(tuple((0,X.shape[axis]) if i == axis else None for i in range(X.ndim)))
|
||||
return X.cumsum(axis).flip(axis) if reverse else X.cumsum(axis)
|
||||
|
||||
# TODO: this is copied from tinygrad/nn/__init__.py
|
||||
# spatial is from opset 7 and has since been removed
|
||||
def BatchNormalization(X: Tensor, scale, B, input_mean, input_var, epsilon=1e-05, momentum=0.9, training_mode=0, spatial=1, is_test=0):
|
||||
if training_mode:
|
||||
x_detached = X.detach()
|
||||
current_mean = x_detached.mean(axis=(0,2,3))
|
||||
y = (x_detached - current_mean.reshape(shape=[1, -1, 1, 1]))
|
||||
current_var = (y*y).mean(axis=(0,2,3))
|
||||
current_invstd = current_var.add(epsilon).rsqrt()
|
||||
|
||||
running_mean = input_mean * momentum + current_mean * (1 - momentum)
|
||||
running_var = input_var * momentum + current_var * (1 - momentum)
|
||||
|
||||
return X.batchnorm(scale, B, current_mean, current_invstd), running_mean, running_var
|
||||
invstd = (input_var + epsilon).rsqrt()
|
||||
return X.batchnorm(scale, B, input_mean, invstd)
|
||||
|
||||
def InstanceNormalization(x: Tensor, scale: Tensor, bias: Tensor, epsilon=1e-05):
|
||||
axis = tuple(range(2, x.ndim))
|
||||
mean = x.mean(axis=axis, keepdim=True)
|
||||
invstd = x.sub(mean).square().mean(axis=axis, keepdim=True).add(epsilon).rsqrt()
|
||||
return x.sub(mean).mul(scale.reshape(shape=[-1, 1, 1])).mul(invstd).add(bias.reshape(shape=[-1, 1, 1]))
|
||||
|
||||
def LayerNormalization(x: Tensor, scale, bias, axis=-1, epsilon=1e-05, stash_type=1):
|
||||
assert stash_type == 1, "only float32 is supported"
|
||||
axis = tuple(i for i in range(axis if axis >= 0 else x.ndim + axis, x.ndim))
|
||||
mean = x.mean(axis=axis, keepdim=True)
|
||||
return x.layernorm(axis, epsilon).mul(scale).add(bias), mean, (x.sub(mean)).square().mean(axis=axis, keepdim=True).add(epsilon).rsqrt()
|
||||
|
||||
def GroupNormalization(x: Tensor, scale: Tensor, bias: Tensor, num_groups, epsilon=1e-05):
|
||||
return x.reshape(x.shape[0], num_groups, -1).layernorm(axis=-1, eps=epsilon).mul(scale.unsqueeze(-1)).add(bias.unsqueeze(-1)).reshape(x.shape)
|
||||
|
||||
# onnx: [x1_begin, x2_begin, ..., x1_end, x2_end, ...]
|
||||
# numpy.pad: ((x1_begin, x1_end), (x2_begin, x2_end), ...)
|
||||
def _format_padding(onnx_pads, ndims=None, axes=None):
|
||||
if ndims and len(onnx_pads)//2 != ndims: onnx_pads = onnx_pads * ndims # for OnnxBackendPyTorchConvertedModelTest the len(onnx_pads) == 2
|
||||
if ndims is None: ndims = len(onnx_pads) // 2
|
||||
if axes is None: axes = list(range(ndims))
|
||||
num_axes = len(axes)
|
||||
np_pads = [(0,0)] * ndims
|
||||
for i in range(num_axes):
|
||||
np_pads[axes[i]] = (onnx_pads[i], onnx_pads[i + num_axes])
|
||||
return np_pads
|
||||
|
||||
def _padded(X: Tensor, pads=None, auto_pad="NOTSET", axes=None, constant_value=0., strides=None, kernel_shape=None, dilations=None, ceil_mode=0):
|
||||
if auto_pad != "NOTSET": pads = _auto_pad(X, auto_pad, strides, kernel_shape, dilations)
|
||||
elif ceil_mode:
|
||||
if strides is not None: strides = [strides]*len(kernel_shape) if isinstance(strides, int) else strides if strides else [1]*len(kernel_shape)
|
||||
if dilations is not None: dilations = [1]*len(kernel_shape) if dilations == 1 else dilations
|
||||
out_spatial_shape = [math.ceil((sh - dil * (ker-1)-1)/st + 1) if ceil_mode else math.floor((sh - dil * (ker-1)-1)/st + 1) for sh, st, ker, dil in zip(X.shape[-len(kernel_shape):], strides, kernel_shape, dilations)]
|
||||
pad_shape = [(osh-1)*st+((ks-1)*dil+1)-ish for osh, st, ks, dil, ish in zip(out_spatial_shape, strides, kernel_shape, dilations, X.shape[-len(kernel_shape):])]
|
||||
pad_shape = [[sh//2, sh-sh//2] for sh in pad_shape]
|
||||
# ceil_mode case follows NOTE in https://pytorch.org/docs/stable/generated/torch.nn.MaxPool2d.html#torch.nn.MaxPool2d
|
||||
# so if any kernels start in right padded region, we decrease right pads to omit that kernel. Only omitting 1 kernel now.
|
||||
pad_shape = [[start,end-rpad] if (rpad := ks + st%(st-(((start+xs)%st)))) <= end else [start,end]
|
||||
for (start,end), ks, st, xs in zip(pad_shape, kernel_shape, strides, X.shape[-len(kernel_shape):])]
|
||||
pad_shape = flatten(pad_shape)
|
||||
pads = pad_shape[::2] + pad_shape[1::2]
|
||||
if pads is None: return X
|
||||
pads = _format_padding(pads, ndims=len(X.shape), axes=axes)
|
||||
return X.pad(tuple(pads), value=constant_value)
|
||||
|
||||
def _auto_pad(X: Tensor, auto_pad, strides, kernel_shape, dilations):
|
||||
strides = [strides]*len(kernel_shape) if isinstance(strides, int) else strides if strides else [1]*len(kernel_shape)
|
||||
dilations = [1]*len(kernel_shape) if dilations == 1 else dilations
|
||||
if auto_pad == "SAME_UPPER" or auto_pad == "SAME_LOWER":
|
||||
pad_shape = [(math.ceil(sh/st)-1)*st+((ks-1)*di+1)-sh for sh, st, ks, di in zip(X.shape[-len(kernel_shape):], strides, kernel_shape, dilations)]
|
||||
pad_shape = flatten([[sh//2, sh-sh//2] for sh in pad_shape])
|
||||
return pad_shape[::2] + pad_shape[1::2] if auto_pad == "SAME_UPPER" else pad_shape[1::2] + pad_shape[::2]
|
||||
raise NotImplementedError(f"auto_pad={auto_pad} not implemented")
|
||||
|
||||
# (x1_begin, x2_begin, ..., x1_end, x2_end, ...) -> (..., x2_start, x2_end, x1_start, x1_end)
|
||||
def _onnx_pads_to_pad2d_pads(pads): return flatten(reversed(list((pB, pE) for pB, pE in zip(pads, pads[len(pads)//2:]))))
|
||||
def Pad(x: Tensor, pads: Union[Tensor, Tuple[int, ...]], constant_value: Optional[Tensor]=None, axes: Optional[Tensor]=None, mode="constant", value=0):
|
||||
pads, value, axes = to_python_const(pads), to_python_const(constant_value) or value or 0, to_python_const(axes) or list(range(x.ndim))
|
||||
real_pads = [0] * (x.ndim*2)
|
||||
for i,axis in enumerate(axes): real_pads[axis%x.ndim], real_pads[axis%x.ndim+x.ndim] = pads[i], pads[i+len(axes)]
|
||||
return x.pad(padding=_onnx_pads_to_pad2d_pads(to_python_const(real_pads)), mode={"edge":"replicate", "wrap":"circular"}.get(mode, mode), value=value)
|
||||
|
||||
def AveragePool(X: Tensor, kernel_shape, auto_pad="NOTSET", ceil_mode=0, count_include_pad=0, dilations=1, pads=None, strides=1):
|
||||
pixel_axes = tuple(range(2, X.ndim))
|
||||
ret = _padded(X, pads, auto_pad, axes=pixel_axes, strides=strides, kernel_shape=kernel_shape, dilations=dilations, ceil_mode=ceil_mode)
|
||||
ret = ret.avg_pool2d(kernel_shape, stride=strides, dilation=dilations)
|
||||
if count_include_pad: return ret
|
||||
div = _padded(Tensor.ones(X.shape), pads, auto_pad, axes=pixel_axes, strides=strides, kernel_shape=kernel_shape, dilations=dilations, ceil_mode=ceil_mode).avg_pool2d(kernel_shape, stride=strides, dilation=dilations)
|
||||
return ret / div
|
||||
|
||||
def MaxPool(X: Tensor, kernel_shape, auto_pad="NOTSET", ceil_mode=0, dilations=1, pads=None, storage_order=0, strides=1):
|
||||
pixel_axes = tuple(range(2, X.ndim))
|
||||
ret = _padded(X, pads, auto_pad, constant_value=-math.inf, axes=pixel_axes, strides=strides, kernel_shape=kernel_shape, dilations=dilations, ceil_mode=ceil_mode)
|
||||
ret = ret.max_pool2d(kernel_shape, stride=strides, dilation=dilations).cast(X.dtype)
|
||||
ret_len, X_len = ret.numel(), X.numel()
|
||||
indices = ((ret.flatten().unsqueeze(1).expand(ret_len, X_len) == X.flatten().unsqueeze(0).expand(ret_len, X_len)) * \
|
||||
Tensor.arange(X_len, dtype=dtypes.int64).unsqueeze(0).expand(ret_len, X_len)).sum(1).reshape(ret.shape)
|
||||
if storage_order: indices = indices.transpose(-2, -1)
|
||||
return ret, indices
|
||||
|
||||
def MaxUnpool(xT: Tensor, xI: Tensor, outshape: Optional[Tensor]=None, kernel_shape=None, pads=None, strides=None):
|
||||
out_sh = [(ks//2)*2 + st * inps for inps, st, ks in zip(xI.shape, strides, kernel_shape)]
|
||||
outlength = prod(out_sh)
|
||||
xI = xI.flatten().unsqueeze(1).expand(None, outlength)
|
||||
arange = Tensor.arange(outlength, requires_grad=False).reshape(1, outlength).expand(xI.shape)
|
||||
xT = xT.flatten().unsqueeze(1).expand(None, outlength)
|
||||
ret = ((xI == arange) * xT).sum(0).reshape([1, 1] + out_sh)
|
||||
if outshape is not None and (outshape := to_python_const(outshape)) != ret.shape:
|
||||
diff = [outshape[2] - ret.shape[2], outshape[3] - ret.shape[3]]
|
||||
pad_args = [diff[0]//2, diff[1]//2, diff[0]-diff[0]//2, diff[1]-diff[1]//2]
|
||||
ret = ret.pad((pad_args[1], pad_args[3], pad_args[0], pad_args[2]))
|
||||
return ret
|
||||
|
||||
def Conv(X: Tensor, W: Tensor, B:Optional[Tensor]=None, auto_pad="NOTSET", dilations=1, group=1, kernel_shape=None, pads=None, strides=1):
|
||||
if auto_pad != "NOTSET":
|
||||
padding = _auto_pad(X, auto_pad, strides, kernel_shape, dilations)
|
||||
else:
|
||||
# reorder padding
|
||||
padding = [p for ps in zip(pads[:len(pads)//2][::-1], pads[len(pads)//2:][::-1]) for p in ps] if pads is not None else 0
|
||||
return X.conv2d(W, B, stride=strides, groups=group, dilation=dilations, padding=padding)
|
||||
|
||||
def ConvTranspose(X: Tensor, W: Tensor, B:Optional[Tensor]=None, auto_pad="NOTSET", dilations=1, group=1, kernel_shape=None, pads=None, output_shape=None, output_padding=0, strides=1):
|
||||
if kernel_shape is None: kernel_shape = W.shape[2:]
|
||||
if isinstance(strides, int): strides = [strides]*(W.ndim-2)
|
||||
if isinstance(dilations, int): dilations = [dilations]*(W.ndim-2)
|
||||
if isinstance(output_padding, int): output_padding = [output_padding]*(W.ndim-2)
|
||||
out_sh = [st*(xs-1) + (ks-1)*di+1 if n < 2 else st*(xs-1) + (ks-1)*di+1 - pads[n-2] - pads[n-1] for n, (st, xs, ks, di) in enumerate(zip(strides, X.shape[2:], kernel_shape, dilations))] if output_shape is not None or auto_pad != "NOTSET" else []
|
||||
if pads is None:
|
||||
if output_shape is None: output_shape = [xs*st for xs, st in zip(X.shape[2:], strides)]
|
||||
if auto_pad == "NOTSET": pads = [0,0] * (X.ndim - 2)
|
||||
else:
|
||||
total_padding = [st*(ish-1) + pad + ((ks-1)*dil+1)-osh for st, ish, pad, ks, dil, osh in zip(strides, X.shape[2:], output_padding, kernel_shape, dilations, output_shape)]
|
||||
pad_shape = flatten([[sh//2, sh-sh//2] for sh in total_padding])
|
||||
pads = pad_shape[::2] + pad_shape[1::2] if auto_pad == "SAME_UPPER" else pad_shape[1::2] + pad_shape[::2]
|
||||
else:
|
||||
if output_shape is None: output_shape = [st*(xs-1) + (ks-1)*di+1 if n < 2 else st*(xs-1) + (ks-1)*di+1 - pads[n-2] - pads[n-1] for n, (st, xs, ks, di) in enumerate(zip(strides, X.shape[2:], kernel_shape, dilations))]
|
||||
if out_sh: output_padding = [os - rs for os, rs in zip(output_shape, out_sh)]
|
||||
return X.conv_transpose2d(W, B, stride=strides, groups=group, dilation=dilations, padding=pads if pads is not None else 0, output_padding=output_padding)
|
||||
|
||||
def DepthToSpace(X:Tensor, blocksize:int, mode:str="DCR"):
|
||||
return X.rearrange("b (c h1 w1) h w -> b c (h h1) (w w1)" if mode=="CRD" else "b (h1 w1 c) h w -> b c (h h1) (w w1)", h1=blocksize, w1=blocksize)
|
||||
def SpaceToDepth(X:Tensor, blocksize:int):
|
||||
return X.rearrange("b c (h h1) (w w1) -> b (h1 w1 c) h w", h1=blocksize, w1=blocksize)
|
||||
|
||||
# Reimplemented here because you need legacy RNG for passing ONNX tests.
|
||||
def Dropout(data: Tensor, ratio=0.5, training_mode=False, seed=None):
|
||||
if isinstance(ratio, Tensor) and not ratio.shape: ratio = to_python_const(ratio) # ratio and tensor is passed in as Tensor with shape: ()
|
||||
if isinstance(training_mode, Tensor) and not training_mode.shape: training_mode = to_python_const(training_mode)
|
||||
if not training_mode: return data, Tensor.ones(data.shape, dtype=dtypes.bool) # if mask is requested as output it will contain all True's.
|
||||
rng = np.random.RandomState(seed)
|
||||
if isinstance(ratio, Tensor): ratio = ratio.item()
|
||||
mask = Tensor(rng.random(data.shape) >= ratio, requires_grad=False, device=data.device)
|
||||
return data * mask * (1/(1.0 - ratio)), mask
|
||||
|
||||
def LRN(x: Tensor, size, alpha=1e-4, beta=0.75, bias=1.0):
|
||||
pooled_x = (x**2).rearrange('b c h w -> b 1 c (h w)').pad((0,0,(size-1)//2, size//2)).avg_pool2d((size, 1), 1)
|
||||
return x / (pooled_x.reshape(x.shape) * alpha + bias).pow(beta)
|
||||
|
||||
def MeanVarianceNormalization(x: Tensor, axis=(0, 2, 3)): return (x - x.mean(axis, keepdim=True)) / (x.std(axis, keepdim=True, correction=0) + 1e-9)
|
||||
|
||||
def NegativeLogLikelihoodLoss(x: Tensor, target: Tensor, weight=None, ignore_index=None, reduction="mean"):
|
||||
return x.nll_loss(target, weight, ignore_index, reduction)
|
||||
|
||||
def SoftmaxCrossEntropyLoss(scores: Tensor, labels: Tensor, weights=None, ignore_index=None, reduction="mean"):
|
||||
log_probs = scores.log_softmax(1)
|
||||
return log_probs.nll_loss(labels, weights, ignore_index, reduction), log_probs
|
||||
|
||||
def ArrayFeatureExtractor(x: Tensor, indices: Tensor): return x[..., indices]
|
||||
|
||||
def Gather(x: Tensor, indices: Tensor, axis=0):
|
||||
if indices.numel() < 9: # NOTE lessor kernels for smaller indices but kernel number increases depending on size of indices
|
||||
x_sh = list(x.shape)
|
||||
ret_shape = x_sh[:axis] + list(indices.shape) + x_sh[axis+1:]
|
||||
if indices.ndim > 1: indices = indices.flatten()
|
||||
indices = [to_python_const(indices)] if indices.shape == () else [x_sh[axis]+x if x<0 else x for x in to_python_const(indices)]
|
||||
args = [[(0,x) if j != axis else (i,i+1) for j, x in enumerate(x_sh)] for i in indices]
|
||||
return x.shrink(arg=tuple(args[0])).cat(*[x.shrink(arg=tuple(arg)) for arg in args[1:]], dim=axis).reshape(ret_shape)
|
||||
# NOTE faster gather, fixed number of kernels, but exceeds limited kernels for openpilot
|
||||
return x[tuple([slice(None) if i != axis else indices for i in range(x.ndim)])]
|
||||
def Scatter(*args, **kwargs): return ScatterElements(*args, **kwargs) # deprecated
|
||||
|
||||
def ScatterElements(x: Tensor, indices: Tensor, updates: Tensor, axis=0, reduction:Optional[str]=None):
|
||||
if reduction in {"min", "max"}: raise NotImplementedError("min and max reduction not supported")
|
||||
indices = (indices < 0).where(x.shape[axis], 0) + indices
|
||||
return x.scatter(axis, indices, updates, reduction)
|
||||
def GatherElements(x: Tensor, indices: Tensor, axis):
|
||||
indices = (indices < 0).where(x.shape[axis], 0) + indices
|
||||
return x.gather(axis, indices)
|
||||
|
||||
def Resize(X:Tensor, roi=None, scales=None, sizes=None, antialias=0, axes=None, coordinate_transformation_mode='half_pixel',
|
||||
cubic_coeff_a=-0.75, exclude_outside=0, extrapolation_value=0.0, keep_aspect_ratio_policy='stretch',
|
||||
mode='nearest', nearest_mode='round_prefer_floor'):
|
||||
def _apply_nearest_mode(index: Tensor, input_dim, mode: str):
|
||||
if mode == "round_prefer_floor": index = (index - 0.5).ceil()
|
||||
elif mode == "round_prefer_ceil": index = (index + 0.5).floor()
|
||||
elif mode in ["floor", "ceil"]: index = getattr(index, mode)()
|
||||
else: raise ValueError(f"invalid {nearest_mode=}")
|
||||
return index.cast(dtypes.int32).clip(0, input_dim-1)
|
||||
def _apply_transformation(index: Tensor, input_dim, scale_dim, roi_dim, sizes_frac, mode):
|
||||
# TODO: needs more testing, not confident in this
|
||||
# NOTE: their reference implementation differ from the implementation in their reference docs
|
||||
# https://github.com/onnx/onnx/blob/main/onnx/reference/ops/op_resize.py
|
||||
# https://github.com/onnx/onnx/blob/main/docs/Operators.md#Resize
|
||||
output_dim = scale_dim * input_dim
|
||||
if mode == "half_pixel": index = (index + 0.5) / scale_dim - 0.5
|
||||
elif mode == "align_corners": index = index * (input_dim - 1) / (output_dim - 1) if output_dim != 1 else Tensor([0])
|
||||
elif mode == "asymmetric": index = index / scale_dim
|
||||
elif mode == "pytorch_half_pixel": index = (index + 0.5) / scale_dim - 0.5 if output_dim != 1 else Tensor([-0.5])
|
||||
elif mode == "half_pixel_symmetric": index = input_dim / 2 * (1 - int(output_dim) / sizes_frac) + (index + 0.5) / scale_dim - 0.5
|
||||
elif mode == "tf_crop_and_resize": index = roi_dim[0] * (input_dim - 1) + index * ((roi_dim[1] - roi_dim[0]) * (input_dim - 1) / (output_dim - 1)) # noqa: E501
|
||||
else: raise ValueError(f"invalid {coordinate_transformation_mode=}")
|
||||
return index.clip(0, input_dim-1)
|
||||
|
||||
roi, scales, sizes = (to_python_const(a) for a in (roi, scales, sizes))
|
||||
scales, sizes = (None if scales is None else scales[-2:]), (None if sizes is None else sizes[-2:])
|
||||
# we pre permute the axes and permute back after resize
|
||||
axes, input_shape, = (axes or list(range(X.ndim))), X.shape[2:],
|
||||
perm = [a for a in range(len(X.shape)) if a not in axes] + list(axes)
|
||||
X = X.permute(*perm)
|
||||
|
||||
if sizes is not None:
|
||||
if keep_aspect_ratio_policy in ["not_larger", "not_smaller"]:
|
||||
scale_fxn = min if keep_aspect_ratio_policy == "not_larger" else max
|
||||
scales = scale_fxn([sizes[i] / input_shape[i] for i in range(X.ndim-2) if i+2 in axes])
|
||||
sizes = [int((scales * input_shape[i]) + 0.5) if i+2 in axes else input_shape[i] for i in range(X.ndim-2)]
|
||||
else: scales = [sizes[-2] / X.size(-2), sizes[-1] / X.size(-1)]
|
||||
else: sizes = [int(sc*sh) for sc, sh in zip(scales, input_shape)]
|
||||
scales = [scales] * 2 if not isinstance(scales, list) else scales
|
||||
roi = [[st, ed] for st, ed in zip(roi, roi[len(roi)//2:])] if isinstance(roi, list) else [None] * (X.ndim-2)
|
||||
|
||||
# NOTE: this transformation makes it so that we can't just call Tensor.interpolate
|
||||
# in Tensor.interpolate, we use indexes without any transformation
|
||||
indexes = []
|
||||
for shape, size, scale, region in zip(input_shape, sizes, scales, roi):
|
||||
indexes.append(_apply_transformation(Tensor.arange(size), shape, scale, region, shape * scale, coordinate_transformation_mode))
|
||||
|
||||
if mode == "nearest":
|
||||
indexes = [_apply_nearest_mode(index, shape, nearest_mode) for (index, shape) in zip(indexes, input_shape)]
|
||||
X = X[(..., *Tensor.meshgrid(*indexes))]
|
||||
if mode == "linear":
|
||||
expand = list(X.shape)
|
||||
for i in range(-len(sizes), 0):
|
||||
reshape, index = [1] * X.ndim, indexes[i]
|
||||
reshape[i] = expand[i] = sizes[i]
|
||||
low, high, perc = [y.reshape(reshape).expand(expand) for y in (index.floor(), index.ceil(), index - index.floor())]
|
||||
X = X.gather(i, low).lerp(X.gather(i, high), perc)
|
||||
if mode == "cubic": raise NotImplementedError("cubic interpolation is not implemented")
|
||||
return X.permute(*[perm.index(i) for i in range(len(perm))]) if perm else X
|
||||
|
||||
def CenterCropPad(t: Tensor, shape: Tensor, axes=None):
|
||||
shape = to_python_const(shape)
|
||||
shrink_arg = [None] * t.ndim
|
||||
pad_arg = [None] * t.ndim
|
||||
for s, x in zip(shape, axes or range(t.ndim)):
|
||||
tx = t.shape[x]
|
||||
if s < tx: shrink_arg[x] = (tx//2 - (s+1)//2, tx//2 + s//2)
|
||||
elif s > tx: pad_arg[x] = ((s-tx)//2, (s-tx+1)//2)
|
||||
return t.shrink(tuple(shrink_arg)).pad(tuple(pad_arg))
|
||||
|
||||
def OneHot(indices: Tensor, depth: Tensor, values: Tensor, axis=-1):
|
||||
depth = int(to_python_const(depth))
|
||||
# Scalar or Rank 1 tensor containing exactly one element
|
||||
depth, indices = depth[0] if isinstance(depth, list) else depth, (indices < 0).where(indices+depth, indices),
|
||||
return indices[:, None]._one_hot_along_dim(depth, dim=axis).where(values[1], values[0])
|
||||
|
||||
def Compress(inp: Tensor, condition: Tensor, axis=None):
|
||||
if axis is None:
|
||||
inp = inp.flatten()
|
||||
axis = 0
|
||||
if axis < 0: axis += inp.ndim
|
||||
con_np = to_python_const(condition)
|
||||
con = Tensor(np.arange(condition.shape[0])[con_np]) # no boolean indexing in Tensor
|
||||
return inp[tuple(con if i == axis else slice(None) for i in range(inp.ndim))]
|
||||
|
||||
def EyeLike(x: Tensor, dtype=None, k=0):
|
||||
ret = Tensor.eye(cast(int, min(x.shape)), dtype=dtype_parse(dtype) if dtype else x.dtype)
|
||||
return ret if x.size(0) == x.size(1) else ret.pad(tuple(None if d == ret.size(0) else (k, d-ret.size(0)-k) for d in x.shape))
|
||||
|
||||
def Upsample(X, scales, mode): return Resize(X=X, scales=scales, mode=mode)
|
||||
|
||||
def DequantizeLinear(x: Tensor, x_scale: Tensor, x_zero_point: Union[Tensor, int] = 0, axis=1, block_size=0):
|
||||
if axis < 0: axis += x.ndim
|
||||
if not isinstance(x_zero_point, Tensor): x_zero_point = Tensor(x_zero_point)
|
||||
if block_size: x_zer, x_sc = x_zero_point.repeat_interleave(block_size, axis), x_scale.repeat_interleave(block_size, axis)
|
||||
else:
|
||||
shape = (*[1]*axis, *x_scale.shape, *[1]*(x.ndim - axis - x_scale.ndim))
|
||||
x_sc, x_zer = x_scale.reshape(shape), x_zero_point.reshape(shape)
|
||||
return ((x.float() - x_zer) * x_sc).cast(x_scale.dtype)
|
||||
|
||||
# copied from https://github.com/onnx/onnx/blob/main/onnx/reference/ops/op_image_decoder.py
|
||||
# without importing PIL we'll have to manually decode a bunch of image formats like PNG, JPEG, WebP, etc
|
||||
def ImageDecoder(encoded_stream: Tensor, pixel_format="RGB"):
|
||||
try: import PIL.Image
|
||||
except ImportError as e: raise ImportError("Pillow must be installed to use the reference implementation of the ImageDecoder operator") from e
|
||||
img = PIL.Image.open(io.BytesIO(to_python_const(encoded_stream)))
|
||||
if pixel_format == "BGR": return Tensor(np.array(img))[:, :, ::-1]
|
||||
if pixel_format == "RGB": return Tensor(np.array(img))
|
||||
if pixel_format == "Grayscale": return Tensor(np.array(img.convert("L"))).unsqueeze(-1) # (H, W) to (H, W, 1)
|
||||
raise ValueError(f"pixel_format={pixel_format!r} is not supported.")
|
||||
|
||||
def AffineGrid(theta: Tensor, size: Tensor, align_corners=0):
|
||||
N, _, *spatial_dims = to_python_const(size)
|
||||
def generate_grid(steps):
|
||||
return Tensor.linspace(-1, 1, steps, device=theta.device) if align_corners else Tensor.linspace(-1+1/steps, 1-1/steps, steps, device=theta.device)
|
||||
grids = Tensor.meshgrid(*(generate_grid(d) for d in spatial_dims))
|
||||
base_grid = Tensor.stack(*reversed(grids), Tensor.ones_like(grids[0], device=theta.device), dim=-1)
|
||||
base_grid = base_grid.reshape(1, prod(spatial_dims), len(grids)+1).expand(N, -1, -1)
|
||||
return (base_grid @ theta.transpose(1, 2)).reshape(N, *spatial_dims, -1)
|
||||
|
||||
# **************** com.microsoft Ops ****************
|
||||
|
||||
def SkipLayerNormalization(x:Tensor, skip:Tensor, gamma, beta:Optional[Tensor]=None, bias:Optional[Tensor]=None, epsilon=None):
|
||||
if epsilon is None: epsilon=1e-12
|
||||
x = x + skip + bias
|
||||
return x.layernorm(eps=epsilon) * gamma + beta, None, None, x
|
||||
|
||||
def FastGelu(x:Tensor, bias:Optional[Tensor]=None):
|
||||
# this is tanh approximated
|
||||
return (x + bias).gelu()
|
||||
|
||||
def EmbedLayerNormalization(input_ids: Tensor, segment_ids:Optional[Tensor]=None, word_embedding:Tensor=None, position_embedding:Tensor=None, segment_embedding:Optional[Tensor]=None, gamma=None, beta=None, mask:Optional[Tensor]=None, position_ids:Optional[Tensor]=None, epsilon=None, mask_index_type=None):
|
||||
# https://github.com/microsoft/onnxruntime/blob/main/docs/ContribOperators.md#com.microsoft.EmbedLayerNormalization
|
||||
assert (segment_ids is None) is (segment_embedding is None)
|
||||
assert (mask is None) is (mask_index_type is None)
|
||||
assert mask is None, "functionality not supported yet" # TODO
|
||||
input_shape = input_ids.shape
|
||||
seq_length = input_shape[1]
|
||||
compute_seg_emb = (segment_embedding is not None and segment_ids is not None)
|
||||
vocab_size, max_position_embeddings, type_vocab_size = word_embedding.shape[0], position_embedding.shape[0], (segment_embedding.shape[0] if compute_seg_emb else None)
|
||||
|
||||
def embedding(x:Tensor, vocab_size, weight:Tensor) -> Tensor:
|
||||
return x.unsqueeze(-1).expand(*x.shape, vocab_size)._one_hot_along_dim(vocab_size) @ weight
|
||||
|
||||
# bert embedding layer
|
||||
if epsilon is None: epsilon = 1e-12
|
||||
if position_ids is None: position_ids = Tensor.arange(seq_length, requires_grad=False).unsqueeze(0).expand(*input_shape)
|
||||
wrd_embedding_res = embedding(input_ids, vocab_size, word_embedding)
|
||||
pos_embedding_res = embedding(position_ids, max_position_embeddings, position_embedding)
|
||||
seg_embedding_res = embedding(segment_ids, type_vocab_size, segment_embedding) if compute_seg_emb else None
|
||||
|
||||
embedding_sum = wrd_embedding_res + pos_embedding_res
|
||||
if seg_embedding_res is not None: embedding_sum = embedding_sum + seg_embedding_res
|
||||
out = embedding_sum.layernorm(eps=epsilon) * gamma + beta
|
||||
return out, None, embedding_sum
|
||||
|
||||
def Attention(x:Tensor, weights, bias:Optional[Tensor]=None, mask_index:Optional[Tensor]=None, past:Optional[Tensor]=None, relative_position_bias:Optional[Tensor]=None, past_sequence_length:Optional[Tensor]=None, do_rotary=None, mask_filter_value=None, num_heads=None, past_present_share_buffer=None, qkv_hidden_sizes=None, scale=None, unidirectional=None):
|
||||
# https://github.com/microsoft/onnxruntime/blob/main/docs/ContribOperators.md#com.microsoft.Attention
|
||||
assert num_heads is not None # required
|
||||
assert (qkv_hidden_sizes is None and past is not None) or (qkv_hidden_sizes is not None)
|
||||
assert relative_position_bias==do_rotary==past_sequence_length==mask_filter_value==past_present_share_buffer==scale==None, "functionality not supported yet" # TODO strange params
|
||||
hidden_size, v_hidden_size = qkv_hidden_sizes[1:] if qkv_hidden_sizes is not None else 2*(weights.shape[1] // 3,)
|
||||
|
||||
if unidirectional: # gpt-style
|
||||
assert hidden_size == v_hidden_size
|
||||
xqkv = x.linear(weights, bias)
|
||||
xq, xk, xv = [xqkv.shrink([None, None, (i*hidden_size, (i+1)*hidden_size)]) for i in range(3)]
|
||||
else: # bert-style
|
||||
wq, wk, wv = weights[:,:hidden_size], weights[:,hidden_size:hidden_size+v_hidden_size], weights[:,hidden_size+v_hidden_size:]
|
||||
bq, bk, bv = (bias[:hidden_size], bias[hidden_size:hidden_size+v_hidden_size], bias[hidden_size+v_hidden_size]) if bias is not None else None
|
||||
xq, xk, xv = [x.linear(w, b) for w, b in zip((wq, wk, wv), (bq, bk, bv))]
|
||||
xq, xk, xv = [x.reshape(x.shape[0], x.shape[1], num_heads, -1).transpose(1, 2) for x in (xq, xk, xv)]
|
||||
|
||||
if past is not None:
|
||||
xk, xv = Tensor.cat(past[0], xk, dim=-2), Tensor.cat(past[1], xv, dim=-2)
|
||||
present = Tensor.cat(xk.unsqueeze(0), xv.unsqueeze(0))
|
||||
|
||||
def attn(query, key, value, attn_mask):
|
||||
query_length, key_length = query.shape[-2], key.shape[-2]
|
||||
cdim = max(query_length, key_length) + 1
|
||||
attn_weights = query @ key.transpose(-1, -2) / math.sqrt(value.shape[-1])
|
||||
# This is where Tensor.scaled_dot_product_attention differs:
|
||||
causal_mask = Tensor.ones((cdim, cdim), requires_grad=False, dtype=dtypes.bool).tril(0)[key_length - query_length : key_length, :key_length]
|
||||
masked = Tensor.where(causal_mask, attn_weights, -math.inf)
|
||||
if attn_mask is not None: masked = masked + attn_mask
|
||||
return masked.softmax(-1) @ value
|
||||
|
||||
bsz, _, seq_len, _ = xq.shape
|
||||
out = attn(xq, xk, xv, mask_index).transpose(1, 2).reshape(bsz, seq_len, -1)
|
||||
return out, present
|
||||
|
||||
# **************** ai.onnx.preview.training Ops ****************
|
||||
# NOTE: onnx test coverage only covers `T==0` cases, so for all `T>0` this isn't tested
|
||||
# NOTE: onnx training ops actually don't need the state for optim, all the ops work in a functional way, but we still can reuse optim.py code
|
||||
|
||||
from tinygrad.nn.optim import Adam as TinyAdam
|
||||
from tinygrad.nn.optim import SGD
|
||||
|
||||
def onnx_training(input_group_size):
|
||||
def _decorator(func):
|
||||
def __wrapper(R, T, *inputs, **kwargs):
|
||||
old_training = Tensor.training
|
||||
Tensor.training = True
|
||||
T, R = to_python_const(T), R.detach()
|
||||
groups = len(inputs) // input_group_size
|
||||
ret = [func(R, T, *inps, **kwargs) for inps in (inputs[i::groups] for i in range(groups))]
|
||||
Tensor.training = old_training
|
||||
return tuple(flatten(zip(*ret)))
|
||||
return __wrapper
|
||||
return _decorator
|
||||
|
||||
@onnx_training(3)
|
||||
def Adagrad(R, T, *inputs, decay_factor=0.0, epsilon=0.0, norm_coefficient=0.0):
|
||||
X, G, H = (i.detach() for i in inputs)
|
||||
grad = norm_coefficient * X + G
|
||||
H.assign(H + grad.square())
|
||||
up = grad / (H.sqrt() + epsilon)
|
||||
r = R / (1 + T * decay_factor)
|
||||
X.assign(X.detach() - r * up)
|
||||
return [X, H]
|
||||
|
||||
@onnx_training(4)
|
||||
def Adam(R, T, *inputs, alpha=0.9, beta=0.999, epsilon=0.0, norm_coefficient=0.0, norm_coefficient_post=0.0):
|
||||
X, G, V, H = inputs
|
||||
G, V, H = G.detach(), V.detach(), H.detach() # TODO we shouldn't need these detaches
|
||||
X.grad = norm_coefficient * X.detach() + G
|
||||
opt = TinyAdam([X], b1=alpha, b2=beta, eps=epsilon)
|
||||
opt.m, opt.v, opt.lr = [V], [H], R
|
||||
# need no-op for m_hat and v_hat if T == 0
|
||||
if T == 0: opt.b1_t, opt.b2_t = opt.b1_t.zeros_like(), opt.b2_t.zeros_like()
|
||||
else:
|
||||
# `T-1` since it's applied again at the start of `_step`
|
||||
opt.b1_t = Tensor([alpha**(T-1)], dtype=dtypes.float32, device=X.device, requires_grad=False)
|
||||
opt.b2_t = Tensor([beta**(T-1)], dtype=dtypes.float32, device=X.device, requires_grad=False)
|
||||
opt.step()
|
||||
X = (1 - norm_coefficient_post) * X
|
||||
return [X, V, H]
|
||||
|
||||
@onnx_training(3)
|
||||
def Momentum(R, T, *inputs, alpha, beta, mode, norm_coefficient):
|
||||
X, G, V = inputs
|
||||
G, V = G.detach(), V.detach()
|
||||
X.grad = (norm_coefficient * X.detach() + G) * (beta if T > 0 else 1)
|
||||
opt = SGD([X], momentum=alpha, nesterov=(mode=="nesterov"))
|
||||
opt.b, opt.lr = [V], R
|
||||
opt.step()
|
||||
return [X, V]
|
||||
@@ -2,7 +2,7 @@
|
||||
export PAGE_SIZE=1
|
||||
export PYTHONPATH=.
|
||||
export LOGOPS=/tmp/ops
|
||||
export RUN_PROCESS_REPLAY=1
|
||||
export CAPTURE_PROCESS_REPLAY=1
|
||||
rm $LOGOPS
|
||||
test/external/process_replay/reset.py
|
||||
|
||||
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
INSTALL_PATH="${1:-/opt/homebrew/lib}"
|
||||
if [ ! -d "$INSTALL_PATH" ]; then
|
||||
USER=$(whoami)
|
||||
echo "No path $INSTALL_PATH. Will create. Might need your password..."
|
||||
echo "You can stop now and provide any location as an argument where you want to save the libs (note, that not default locations should be in LD_LIBRARY_PATH, so tinygrad can find the libs)."
|
||||
echo "Press any key or symbol to continue..."
|
||||
read -n 1 -s
|
||||
|
||||
sudo mkdir -p "$INSTALL_PATH"
|
||||
sudo chown -R "$USER":staff "$INSTALL_PATH"
|
||||
fi
|
||||
|
||||
# Download libremu.dylib
|
||||
curl -s https://api.github.com/repos/Qazalin/remu/releases/latest | \
|
||||
jq -r '.assets[] | select(.name == "libremu.dylib").browser_download_url' | \
|
||||
xargs curl -L -o $INSTALL_PATH/libremu.dylib
|
||||
|
||||
# Download libamd_comgr.dylib
|
||||
curl -s https://api.github.com/repos/nimlgen/amdcomgr_dylib/releases/latest | \
|
||||
jq -r '.assets[] | select(.name == "libamd_comgr.dylib").browser_download_url' | \
|
||||
xargs curl -L -o $INSTALL_PATH/libamd_comgr.dylib
|
||||
+1
-1
@@ -22,11 +22,11 @@ nav:
|
||||
- Runtime: runtime.md
|
||||
- Developer:
|
||||
- Intro: developer/developer.md
|
||||
- Function (autodiff): developer/function.md
|
||||
- UOp: developer/uop.md
|
||||
- Runtime:
|
||||
- developer/runtime.md
|
||||
- HCQ: developer/hcq.md
|
||||
- AM Driver: developer/am.md
|
||||
- tinybox: tinybox.md
|
||||
#- tinygrad: reference/
|
||||
|
||||
|
||||
@@ -8,14 +8,14 @@ with open(directory / 'README.md', encoding='utf-8') as f:
|
||||
long_description = f.read()
|
||||
|
||||
setup(name='tinygrad',
|
||||
version='0.10.0',
|
||||
version='0.10.1',
|
||||
description='You like pytorch? You like micrograd? You love tinygrad! <3',
|
||||
author='George Hotz',
|
||||
license='MIT',
|
||||
long_description=long_description,
|
||||
long_description_content_type='text/markdown',
|
||||
packages = ['tinygrad', 'tinygrad.runtime.autogen', 'tinygrad.codegen', 'tinygrad.nn', 'tinygrad.renderer', 'tinygrad.engine',
|
||||
'tinygrad.runtime', 'tinygrad.runtime.support', 'tinygrad.runtime.graph', 'tinygrad.shape'],
|
||||
'tinygrad.runtime', 'tinygrad.runtime.support', 'tinygrad.runtime.support.am', 'tinygrad.runtime.graph', 'tinygrad.shape'],
|
||||
package_data = {'tinygrad': ['py.typed']},
|
||||
classifiers=[
|
||||
"Programming Language :: Python :: 3",
|
||||
@@ -24,7 +24,6 @@ setup(name='tinygrad',
|
||||
install_requires=[],
|
||||
python_requires='>=3.10',
|
||||
extras_require={
|
||||
'llvm': ["llvmlite"],
|
||||
'arm': ["unicorn"],
|
||||
'triton': ["triton-nightly>=2.1.0.dev20231014192330"],
|
||||
'linting': [
|
||||
@@ -39,6 +38,7 @@ setup(name='tinygrad',
|
||||
'testing': [
|
||||
"numpy",
|
||||
"torch",
|
||||
"jax",
|
||||
"pillow",
|
||||
"pytest",
|
||||
"pytest-xdist",
|
||||
@@ -57,7 +57,8 @@ setup(name='tinygrad',
|
||||
"hypothesis",
|
||||
"nibabel",
|
||||
"bottle",
|
||||
"ggml-python"
|
||||
"ggml-python",
|
||||
"capstone"
|
||||
],
|
||||
'webgpu': ["wgpu"],
|
||||
'docs': [
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user