Debian Codegraph @

tensilelite/Tensile/Components/MAC_F32C.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_F32C_Plain(MAC):
31 kernel = {"ProblemType": {"DataType": DataType(DataTypeEnum.ComplexFloat)}}
32
33 def __call__(self, writer, m, innerUnroll):
34 kernel = writer.states.kernel
35 module = Module("MAC_F32C_Plain")
36 module.addComment(self.commentHeader())
37 priority = Component.Priority.find(writer)
38
39 vars = {}
40 vars["m"] = m
41 vars["ThreadTile0"] = kernel["ThreadTile0"]
42
43 for b in range(0, kernel["ThreadTile1"]):
44 for a in range(0, kernel["ThreadTile0"]):
45 for iui in range(0, innerUnroll):
46 vars["a"] = a
47 vars["b"] = b
48 vars["iui"] = iui
49
50 cStr = "v[vgprValuC+({a}+{b}*{ThreadTile0})*2]".format_map(vars)
51 aStr = "v[vgprValuA_X{m}_I{iui}+{a}*2]".format_map(vars)
52 bStr = "v[vgprValuB_X{m}_I{iui}+{b}*2]".format_map(vars)
53 module.addInst("_v_mac_f32", cStr, aStr, bStr, "")
54
55 cStr = "v[vgprValuC+({a}+{b}*{ThreadTile0})*2]".format_map(vars)
56 aStr = "v[vgprValuA_X{m}_I{iui}+{a}*2+1]".format_map(vars)
57 bStr = "v[vgprValuB_X{m}_I{iui}+{b}*2+1]".format_map(vars)
58 sign = "-" if (not kernel["ProblemType"]["ComplexConjugateA"] and not kernel["ProblemType"]["ComplexConjugateB"]) or \
59 (kernel["ProblemType"]["ComplexConjugateA"] and kernel["ProblemType"]["ComplexConjugateB"]) else ""
60 module.addInst("_v_mac_f32", cStr, sign + aStr, bStr, "")
61
62 cStr = "v[vgprValuC+({a}+{b}*{ThreadTile0})*2+1]".format_map(vars)
63 aStr = "v[vgprValuA_X{m}_I{iui}+{a}*2]".format_map(vars)
64 bStr = "v[vgprValuB_X{m}_I{iui}+{b}*2+1]".format_map(vars)
65 sign = "-" if kernel["ProblemType"]["ComplexConjugateB"] else ""
66 module.addInst("_v_mac_f32", cStr, aStr, sign + bStr, "")
67
68 cStr = "v[vgprValuC+({a}+{b}*{ThreadTile0})*2+1]".format_map(vars)
69 aStr = "v[vgprValuA_X{m}_I{iui}+{a}*2+1]".format_map(vars)
70 bStr = "v[vgprValuB_X{m}_I{iui}+{b}*2]".format_map(vars)
71 sign = "-" if kernel["ProblemType"]["ComplexConjugateA"] else ""
72 module.addInst("_v_mac_f32", cStr, sign + aStr, bStr, "")
73
74 module.add(priority(writer, 1, "Raise priority while processing macs"))
75 module.add(priority(writer, 0, "Reset priority after macs"))
76 return module