Debian Codegraph @

tensilelite/Tensile/Components/MAC_I8X4.py

raw symbols SCIP
1 ################################################################################
2 #
3 # Copyright (C) 2022-2025 Advanced Micro Devices, Inc. All rights reserved.
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining a copy
6 # of this software and associated documentation files (the "Software"), to deal
7 # in the Software without restriction, including without limitation the rights
8 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 # copies of the Software, and to permit persons to whom the Software is
10 # furnished to do so, subject to the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be included in
13 # all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 # SOFTWARE.
22 #
23 ################################################################################
24
25 from rocisa.code import Module
26 from rocisa.enum import DataTypeEnum
27 from ..Common.DataType import DataType
28 from ..Component import Component, MAC
29
30 class MAC_I8X4_Plain(MAC):
31 asmCaps = {"VOP3v_dot4_i32_i8": True}
32 kernel = {"ProblemType": {"DataType": DataType(DataTypeEnum.Int8x4)}}
33
34 def __call__(self, writer, m, innerUnroll):
35 kernel = writer.states.kernel
36 module = Module("MAC_I8X4_Plain")
37 module.addComment(self.commentHeader())
38 priority = Component.Priority.find(writer)
39
40 vars = {}
41 vars["m"] = m
42 vars["ThreadTile0"] = kernel["ThreadTile0"]
43
44 for b in range(0, kernel["ThreadTile1"]):
45 vars["b"] = b
46 for a in range(0, kernel["ThreadTile0"]):
47 vars["a"] = a
48 for iui in range(0, innerUnroll):
49 vars["iui"] = iui
50 cidx = a + b*kernel["ThreadTile0"] + 0
51 cStr = "v[vgprValuC+{a}+{b}*{ThreadTile0}]".format_map(vars)
52 aStr = "v[vgprValuA_X{m}_I{iui}+{a}]".format_map(vars)
53 bStr = "v[vgprValuB_X{m}_I{iui}+{b}]".format_map(vars)
54 module.addInst("v_dot4_i32_i8", cStr, aStr, bStr, cStr, "op_sel:[0,0]", "op_sel_hi:[1,1]", "valuC[%u]" % cidx)
55 module.add(priority(writer, 1, "Raise priority while processing macs"))
56
57 module.add(priority(writer, 0, "Reset priority after macs"))
58 return module