Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : /*!
12 : * \file kernel_check_vec_padding_util.h
13 : * \brief
14 : */
15 : #ifndef ASCENDC_CHECK_VEC_PADDING_UTIL_H
16 : #define ASCENDC_CHECK_VEC_PADDING_UTIL_H
17 : #if ASCENDC_CPU_DEBUG
18 : #include <string>
19 : #include "kernel_utils.h"
20 : namespace AscendC {
21 : namespace check {
22 : struct VectorPaddingApiParams {
23 : VectorPaddingApiParams() {}
24 : VectorPaddingApiParams(
25 : uint64_t dstAddrIn, uint64_t srcAddrIn, uint8_t repeatIn, uint16_t dstBlockStrideIn, uint16_t srcBlockStrideIn,
26 : uint16_t dstRepeatStrideIn, uint16_t srcRepeatStrideIn, uint32_t dstDtypeBytesIn, uint32_t srcDtypeBytesIn,
27 : uint64_t dstSizeIn, uint64_t srcSizeIn, uint8_t dstPosIn, uint8_t srcPosIn, uint8_t padModeIn, bool padSideIn)
28 : {
29 : dstAddr = dstAddrIn;
30 : srcAddr = srcAddrIn;
31 : repeatTimes = repeatIn;
32 : dstBlockStride = dstBlockStrideIn;
33 : srcBlockStride = srcBlockStrideIn;
34 : dstRepeatStride = dstRepeatStrideIn;
35 : srcRepeatStride = srcRepeatStrideIn;
36 : dstDtypeBytes = dstDtypeBytesIn;
37 : srcDtypeBytes = srcDtypeBytesIn;
38 : dstSize = dstSizeIn;
39 : srcSize = srcSizeIn;
40 : dstLogicPos = dstPosIn;
41 : srcLogicPos = srcPosIn;
42 : dstPos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(dstPosIn)));
43 : srcPos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(srcPosIn)));
44 : padMode = padModeIn;
45 : padSide = padSideIn;
46 : }
47 : VectorPaddingApiParams(
48 : uint64_t dstAddrIn, uint64_t srcAddrIn, uint32_t dstDtypeBytesIn, uint32_t srcDtypeBytesIn, uint64_t dstSizeIn,
49 : uint64_t srcSizeIn, uint8_t dstPosIn, uint8_t srcPosIn, uint32_t count, uint8_t padModeIn, bool padSideIn)
50 : {
51 : dstAddr = dstAddrIn;
52 : srcAddr = srcAddrIn;
53 : dstDtypeBytes = dstDtypeBytesIn;
54 : srcDtypeBytes = srcDtypeBytesIn;
55 : dstSize = dstSizeIn;
56 : srcSize = srcSizeIn;
57 : dstLogicPos = dstPosIn;
58 : srcLogicPos = srcPosIn;
59 : dstPos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(dstPosIn)));
60 : srcPos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(srcPosIn)));
61 : calCount = count;
62 : padMode = padModeIn;
63 : padSide = padSideIn;
64 : }
65 : uint64_t dstAddr = 0;
66 : uint64_t srcAddr = 0;
67 : uint8_t repeatTimes = 0;
68 : uint16_t dstBlockStride = 0;
69 : uint16_t srcBlockStride = 0;
70 : uint16_t dstRepeatStride = 0;
71 : uint16_t srcRepeatStride = 0;
72 : uint32_t dstDtypeBytes = 0;
73 : uint32_t srcDtypeBytes = 0;
74 : uint64_t dstSize = 0;
75 : uint64_t srcSize = 0;
76 : uint8_t dstLogicPos = 0;
77 : uint8_t srcLogicPos = 0;
78 : uint8_t dstPos = 0;
79 : uint8_t srcPos = 0;
80 : uint32_t calCount = 0;
81 : uint8_t padMode = 0;
82 : bool padSide = false;
83 : };
84 :
85 : struct VecBroadCastToMMApiParams {
86 : VecBroadCastToMMApiParams() {}
87 20 : VecBroadCastToMMApiParams(
88 : uint64_t dstAddrIn, uint64_t srcAddrIn, uint32_t dstDtypeBytesIn, uint32_t srcDtypeBytesIn, uint64_t dstSizeIn,
89 : uint64_t srcSizeIn, uint8_t dstPosIn, uint8_t srcPosIn, uint32_t blockCountIn, uint8_t blockLenIn,
90 : uint8_t srcGapIn, uint8_t dstGapIn)
91 20 : {
92 20 : dstAddr = dstAddrIn;
93 20 : srcAddr = srcAddrIn;
94 20 : dstDtypeBytes = dstDtypeBytesIn;
95 20 : srcDtypeBytes = srcDtypeBytesIn;
96 20 : dstSize = dstSizeIn;
97 20 : srcSize = srcSizeIn;
98 20 : dstLogicPos = dstPosIn;
99 20 : srcLogicPos = srcPosIn;
100 20 : dstPos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(dstPosIn)));
101 20 : srcPos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(srcPosIn)));
102 20 : blockCount = blockCountIn;
103 20 : blockLen = blockLenIn;
104 20 : srcGap = srcGapIn;
105 20 : dstGap = dstGapIn;
106 20 : }
107 : uint64_t dstAddr = 0;
108 : uint64_t srcAddr = 0;
109 : uint32_t dstDtypeBytes = 0;
110 : uint32_t srcDtypeBytes = 0;
111 : uint64_t dstSize = 0;
112 : uint64_t srcSize = 0;
113 : uint8_t dstLogicPos = 0;
114 : uint8_t srcLogicPos = 0;
115 : uint8_t dstPos = 0;
116 : uint8_t srcPos = 0;
117 : uint32_t calCount = 0;
118 : uint32_t blockCount = 0;
119 : uint8_t blockLen = 0;
120 : uint8_t srcGap = 0;
121 : uint8_t dstGap = 0;
122 : };
123 :
124 : struct VecBroadCastApiParams {
125 : VecBroadCastApiParams() {}
126 20 : VecBroadCastApiParams(
127 : uint64_t dstAddrIn, uint64_t srcAddrIn, uint8_t repeatIn, uint16_t dstBlockStrideIn, uint16_t dstRepeatStrideIn,
128 : uint32_t dstDtypeBytesIn, uint32_t srcDtypeBytesIn, uint64_t dstSizeIn, uint64_t srcSizeIn, uint8_t dstPosIn,
129 : uint8_t srcPosIn)
130 20 : {
131 20 : dstAddr = dstAddrIn;
132 20 : srcAddr = srcAddrIn;
133 20 : repeatTimes = repeatIn;
134 20 : dstBlockStride = dstBlockStrideIn;
135 20 : dstRepeatStride = dstRepeatStrideIn;
136 20 : dstDtypeBytes = dstDtypeBytesIn;
137 20 : srcDtypeBytes = srcDtypeBytesIn;
138 20 : dstSize = dstSizeIn;
139 20 : srcSize = srcSizeIn;
140 20 : dstLogicPos = dstPosIn;
141 20 : srcLogicPos = srcPosIn;
142 20 : dstPos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(dstPosIn)));
143 20 : srcPos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(srcPosIn)));
144 20 : }
145 : uint64_t dstAddr = 0;
146 : uint64_t srcAddr = 0;
147 : uint8_t repeatTimes = 0;
148 : uint16_t dstBlockStride = 0;
149 : uint16_t dstRepeatStride = 0;
150 : uint32_t dstDtypeBytes = 0;
151 : uint32_t srcDtypeBytes = 0;
152 : uint64_t dstSize = 0;
153 : uint64_t srcSize = 0;
154 : uint8_t dstLogicPos = 0;
155 : uint8_t srcLogicPos = 0;
156 : uint8_t dstPos = 0;
157 : uint8_t srcPos = 0;
158 : };
159 :
160 : bool CheckVectorPaddingForMaskArray(VectorPaddingApiParams& chkParams, const uint64_t mask[], const char* intriName);
161 : bool CheckVectorPadding(VectorPaddingApiParams& chkParams, const uint64_t mask, const char* intriName);
162 : bool CheckVectorPadding(VectorPaddingApiParams& chkParams, const char* intriName);
163 : bool CheckFuncBroadCastToMMImpl(VecBroadCastToMMApiParams& chkParams, const char* intriName);
164 : bool CheckFunBcBImpl(VecBroadCastApiParams& chkParams, uint32_t dtypeSize, const char* intriName);
165 : } // namespace check
166 : } // namespace AscendC
167 : #endif
168 : #endif
|