Merged
修改混合 ub 内存排布图 #6077
wulinyuAdd on Sep 16
修改混合 ub 内存排布图 #6077
Merged
wulinyuAdd on Sep 16
Total: 5 files changed+70-47
@@ -102,7 +102,9 @@ UB是同一线程块内所有线程均可访问的内存空间,位于每个AIV
1024. Data Cache:SIMT专有的Data Cache空间,UB内扣除静态内存、动态内存以及预留空间以后,剩余内存大小为Data Cache,Data Cache最小为32KB,剩余空间超过128KB时Data Cache大小固定为128KB,具体计算公式为:1024. Data Cache:SIMT专有的Data Cache空间,UB内扣除静态内存、动态内存以及预留空间以后,剩余内存大小为Data Cache,Data Cache最小为32KB,剩余空间超过128KB时Data Cache大小固定为128KB,具体计算公式为:
103 103 
104 ```104 ```
105- DataCache = UB总大小(256KB) - 静态内存 - 动态内存 - 预留空间(8KB)105+ Data Cache空间大小 = min(UB总大小(256KB) - 静态内存 - 动态内存 - 预留空间(8KB), 128KB)
106 ```106 ```
107 107 
108 若DataCache小于32KB,会出现校验报错。108 若DataCache小于32KB,会出现校验报错。
109+ 
110+更多UB内存的排布、复用、对齐等规则,详见[SIMD与SIMT混合编程场景的UB内存划分](../../../guide/programming_guide/advanced_programming/advanced_ai_core_programming_model/simd_simt_hybrid_programming/memory_hierarchy.md#ub划分)。
Rdocs/zh/guide/figures/simt_layout.png→docs/zh/guide/figures/simt_simd_ub_layout.png+2-2
@@ -1,3 +1,3 @@
1version https://git-lfs.github.com/spec/v11version https://git-lfs.github.com/spec/v1
2-oid sha256:6bc6f484b62a9dc1939c441c328b187792450532b5d61919c689c8c223be0c182+oid sha256:ed2001d97b7376488b8b04fa6e5ac9c5bce4ea1cb2ea388e47b09cc078d60189
3-size 252533+size 237580
@@ -0,0 +1,4 @@
1+<?xml version="1.0" encoding="UTF-8"?>
2+<!-- Do not edit this file with editors other than draw.io -->
3+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4+<svg xmlns="http://www.w3.org/2000/svg" style="background: #ffffff; background-color: light-dark(#ffffff, #121212); color-scheme: light dark;" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="2680px" height="1280px" viewBox="0 0 2680 1280" id="ge-svg-fnAa1BE_CIkNll2WwqDT" content="&lt;mxfile host=&quot;app.diagrams.net&quot; compressed=&quot;false&quot; pages=&quot;2&quot;&gt;&#10; &lt;diagram id=&quot;storage_unit&quot; name=&quot;storage_unit&quot;&gt;&#10; &lt;mxGraphModel dx=&quot;5135&quot; dy=&quot;908&quot; grid=&quot;1&quot; gridSize=&quot;10&quot; guides=&quot;1&quot; tooltips=&quot;1&quot; connect=&quot;1&quot; arrows=&quot;1&quot; fold=&quot;1&quot; page=&quot;1&quot; pageScale=&quot;1&quot; pageWidth=&quot;2869&quot; pageHeight=&quot;1850&quot; background=&quot;#ffffff&quot; math=&quot;0&quot; shadow=&quot;0&quot;&gt;&#10; &lt;root&gt;&#10; &lt;mxCell id=&quot;0&quot; /&gt;&#10; &lt;mxCell id=&quot;1&quot; parent=&quot;0&quot; /&gt;&#10; &lt;mxCell id=&quot;vyCDRny16pTUmMtkMtA--1&quot; parent=&quot;1&quot; style=&quot;rounded=0;whiteSpace=wrap;html=1;strokeColor=none;&quot; value=&quot;&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;1280&quot; width=&quot;2680&quot; x=&quot;90&quot; y=&quot;1960&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;UserObject label=&quot;&quot; tags=&quot;背景&quot; id=&quot;Tz7OZV6N9ZXrq3vnHc34-88&quot;&gt;&#10; &lt;mxCell parent=&quot;1&quot; style=&quot;vsdxID=359;fillColor=#EAEAEA;gradientColor=none;strokeWidth=102;spacingTop=-3;spacingBottom=-3;spacingLeft=-3;spacingRight=-3;points=[];labelBackgroundColor=none;rounded=0;strokeColor=none;html=1;whiteSpace=wrap;&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;1100&quot; width=&quot;1260&quot; x=&quot;110&quot; y=&quot;2120&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;/UserObject&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-91&quot; parent=&quot;Tz7OZV6N9ZXrq3vnHc34-88&quot; style=&quot;text=1;html=0;align=left;verticalAlign=middle;whiteSpace=wrap;strokeColor=none;fillColor=none;fontFamily=FZLanTingHeiS, 方正兰亭黑简体;fontSize=42;spacing=0.0;&quot; value=&quot;MainScalar&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;70.95031836962814&quot; width=&quot;321.46833378643106&quot; x=&quot;37.73807417890216&quot; y=&quot;44.95356037151702&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-93&quot; parent=&quot;Tz7OZV6N9ZXrq3vnHc34-88&quot; style=&quot;text=1;html=0;align=left;verticalAlign=middle;whiteSpace=wrap;strokeColor=default;fillColor=none;fontFamily=FZLanTingHeiS, 方正兰亭黑简体;fontSize=38;spacing=0.0;&quot; value=&quot;__ubuf__ float static_buf_0[2048];&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;70.95413533834586&quot; width=&quot;790&quot; x=&quot;60&quot; y=&quot;181.9548872180451&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-94&quot; parent=&quot;Tz7OZV6N9ZXrq3vnHc34-88&quot; style=&quot;text=1;html=0;align=left;verticalAlign=middle;whiteSpace=wrap;strokeColor=default;fillColor=none;fontFamily=FZLanTingHeiS, 方正兰亭黑简体;fontSize=38;spacing=0.0;&quot; value=&quot;extern __ubuf__ char dyn_buf[];&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;70.95413533834586&quot; width=&quot;734.33&quot; x=&quot;60.36&quot; y=&quot;284.6616541353383&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-98&quot; parent=&quot;Tz7OZV6N9ZXrq3vnHc34-88&quot; style=&quot;vsdxID=392;fillColor=#aad3f5;gradientColor=none;shape=stencil(nZFLDgIhEERP01vDJxpdj+MFPAGRVjoiTBj8nl6YjgkaV8Oqq+p1OilAd6MzA4ISY07xjHey2YHeglIUHCbKZQLdg+6OMeEpxWuwrAdTSCUmBy3vyEorYdJhTy9kb7nY1LeWKw55+xJv9eqDGcHRs1U7Bj2FBpRiNvrRf+HZ6BdYhqkV7ou851Lb/LfFYvEP6P4N);strokeColor=none;spacingTop=-3;spacingBottom=-3;spacingLeft=-3;spacingRight=-3;points=[[0,0.5,0],[0.5,0,0],[1,0.5,0],[0.5,1,0]];labelBackgroundColor=none;rounded=1;html=1;whiteSpace=wrap;fontFamily=方正兰亭黑简体;&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;306.0150375939849&quot; width=&quot;1017.08&quot; x=&quot;70.63&quot; y=&quot;416.9097744360902&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-108&quot; parent=&quot;Tz7OZV6N9ZXrq3vnHc34-88&quot; style=&quot;text=1;html=0;align=left;verticalAlign=middle;whiteSpace=wrap;strokeColor=none;fillColor=none;fontFamily=FZLanTingHeiS, 方正兰亭黑简体;fontSize=42;spacing=0.0;&quot; value=&quot;VF 1&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;70.95031836962814&quot; width=&quot;321.46833378643106&quot; x=&quot;80.72072072072072&quot; y=&quot;416.9097744360902&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-109&quot; parent=&quot;Tz7OZV6N9ZXrq3vnHc34-88&quot; style=&quot;text=1;html=0;align=left;verticalAlign=middle;whiteSpace=wrap;strokeColor=default;fillColor=none;fontFamily=FZLanTingHeiS, 方正兰亭黑简体;fontSize=38;spacing=0.0;&quot; value=&quot;__ubuf__ int32_t static_buf_1[512];&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;70.95413533834586&quot; width=&quot;817.2972972972972&quot; x=&quot;131.17117117117115&quot; y=&quot;509.54135338345867&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-112&quot; parent=&quot;Tz7OZV6N9ZXrq3vnHc34-88&quot; style=&quot;text=1;html=0;align=left;verticalAlign=middle;whiteSpace=wrap;strokeColor=default;fillColor=none;fontFamily=FZLanTingHeiS, 方正兰亭黑简体;fontSize=38;spacing=0.0;&quot; value=&quot;extern __ubuf__ char dyn_buf_1[];&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;70.95413533834586&quot; width=&quot;817.2972972972972&quot; x=&quot;131.17117117117115&quot; y=&quot;601.3458646616541&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-113&quot; parent=&quot;Tz7OZV6N9ZXrq3vnHc34-88&quot; style=&quot;vsdxID=392;fillColor=#aad3f5;gradientColor=none;shape=stencil(nZFLDgIhEERP01vDJxpdj+MFPAGRVjoiTBj8nl6YjgkaV8Oqq+p1OilAd6MzA4ISY07xjHey2YHeglIUHCbKZQLdg+6OMeEpxWuwrAdTSCUmBy3vyEorYdJhTy9kb7nY1LeWKw55+xJv9eqDGcHRs1U7Bj2FBpRiNvrRf+HZ6BdYhqkV7ou851Lb/LfFYvEP6P4N);strokeColor=none;spacingTop=-3;spacingBottom=-3;spacingLeft=-3;spacingRight=-3;points=[[0,0.5,0],[0.5,0,0],[1,0.5,0],[0.5,1,0]];labelBackgroundColor=none;rounded=1;html=1;whiteSpace=wrap;fontFamily=方正兰亭黑简体;&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;206.76691729323306&quot; width=&quot;1017.08&quot; x=&quot;70.63&quot; y=&quot;773.5488721804511&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-114&quot; parent=&quot;Tz7OZV6N9ZXrq3vnHc34-88&quot; style=&quot;text=1;html=0;align=left;verticalAlign=middle;whiteSpace=wrap;strokeColor=none;fillColor=none;fontFamily=FZLanTingHeiS, 方正兰亭黑简体;fontSize=42;spacing=0.0;&quot; value=&quot;VF 2&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;70.95031836962814&quot; width=&quot;321.46833378643106&quot; x=&quot;80.72072072072072&quot; y=&quot;772.5488721804511&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-115&quot; parent=&quot;Tz7OZV6N9ZXrq3vnHc34-88&quot; style=&quot;text=1;html=0;align=left;verticalAlign=middle;whiteSpace=wrap;strokeColor=default;fillColor=none;fontFamily=FZLanTingHeiS, 方正兰亭黑简体;fontSize=38;spacing=0.0;&quot; value=&quot;__ubuf__ int32_t static_buf_1[1024];&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;70.95413533834586&quot; width=&quot;817.2972972972972&quot; x=&quot;131.17117117117115&quot; y=&quot;862.6992481203007&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-92&quot; parent=&quot;1&quot; style=&quot;text=1;html=0;align=left;verticalAlign=middle;whiteSpace=wrap;strokeColor=none;fillColor=none;fontFamily=FZLanTingHeiS, 方正兰亭黑简体;fontSize=45;spacing=0.0;&quot; value=&quot;&amp;lt;&amp;lt;&amp;lt;... , dyn_ub_size=64*1024, ....&amp;gt;&amp;gt;&amp;gt;&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;68.15&quot; width=&quot;1260&quot; x=&quot;110&quot; y=&quot;1977&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-123&quot; parent=&quot;1&quot; style=&quot;rounded=0;whiteSpace=wrap;html=1;fillColor=#25C251;fontSize=32;&quot; value=&quot;&amp;lt;span&amp;gt;static buf(&amp;lt;/span&amp;gt;&amp;lt;span&amp;gt;8KB&amp;lt;/span&amp;gt;&amp;lt;span&amp;gt;)&amp;lt;/span&amp;gt;&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;88.59&quot; width=&quot;745&quot; x=&quot;1990&quot; y=&quot;2108.15&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-124&quot; parent=&quot;1&quot; style=&quot;rounded=0;whiteSpace=wrap;html=1;fillColor=#B3D6FF;fontSize=32;&quot; value=&quot;&amp;lt;span&amp;gt;static buf(4KB)&amp;lt;/span&amp;gt;&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;60&quot; width=&quot;745&quot; x=&quot;1990&quot; y=&quot;2196.7400000000002&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-125&quot; parent=&quot;1&quot; style=&quot;rounded=0;whiteSpace=wrap;html=1;fillColor=#FCBC72;fontSize=32;&quot; value=&quot;&amp;lt;span&amp;gt;dyn buf(64KB)&amp;lt;/span&amp;gt;&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;221.41&quot; width=&quot;745&quot; x=&quot;1990&quot; y=&quot;2256.7400000000002&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-128&quot; parent=&quot;1&quot; style=&quot;rounded=0;whiteSpace=wrap;html=1;fillColor=none;fontSize=32;&quot; value=&quot;&amp;lt;span&amp;gt;&amp;lt;b&amp;gt;...&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;140&quot; width=&quot;745&quot; x=&quot;1990&quot; y=&quot;2478.15&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-129&quot; parent=&quot;1&quot; style=&quot;rounded=0;whiteSpace=wrap;html=1;fillColor=#97E8E1;fontSize=32;&quot; value=&quot;&amp;lt;span&amp;gt;预留空间(8KB)&amp;lt;/span&amp;gt;&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;88.59&quot; width=&quot;745&quot; x=&quot;1990&quot; y=&quot;2618.15&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-138&quot; parent=&quot;1&quot; style=&quot;rounded=0;whiteSpace=wrap;html=1;fillColor=#DBDBDB;fontSize=32;&quot; value=&quot;&amp;lt;span&amp;gt;Data Cache (128KB)&amp;lt;/span&amp;gt;&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;513.26&quot; width=&quot;745&quot; x=&quot;1990&quot; y=&quot;2706.74&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-139&quot; edge=&quot;1&quot; parent=&quot;1&quot; source=&quot;Tz7OZV6N9ZXrq3vnHc34-93&quot; style=&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;&quot; target=&quot;Tz7OZV6N9ZXrq3vnHc34-140&quot;&gt;&#10; &lt;mxGeometry relative=&quot;1&quot; as=&quot;geometry&quot;&gt;&#10; &lt;Array as=&quot;points&quot;&gt;&#10; &lt;mxPoint x=&quot;1140&quot; y=&quot;2337.33&quot; /&gt;&#10; &lt;mxPoint x=&quot;1140&quot; y=&quot;2105.5&quot; /&gt;&#10; &lt;mxPoint x=&quot;1900&quot; y=&quot;2105.5&quot; /&gt;&#10; &lt;/Array&gt;&#10; &lt;/mxGeometry&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-140&quot; parent=&quot;1&quot; style=&quot;text=1;html=0;align=right;verticalAlign=middle;whiteSpace=wrap;strokeColor=none;fillColor=none;fontFamily=FZLanTingHeiS, 方正兰亭黑简体;fontSize=30;spacing=0.0;fontColor=#999999;&quot; value=&quot;0x00&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;70.95&quot; width=&quot;80&quot; x=&quot;1900&quot; y=&quot;2071&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-141&quot; parent=&quot;1&quot; style=&quot;text=1;html=0;align=right;verticalAlign=middle;whiteSpace=wrap;strokeColor=none;fillColor=none;fontFamily=FZLanTingHeiS, 方正兰亭黑简体;fontSize=30;spacing=0.0;fontColor=#999999;&quot; value=&quot;0x2000&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;70.95&quot; width=&quot;110&quot; x=&quot;1870&quot; y=&quot;2160&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-142&quot; edge=&quot;1&quot; parent=&quot;1&quot; source=&quot;Tz7OZV6N9ZXrq3vnHc34-109&quot; style=&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;strokeColor=#0000FF;&quot; target=&quot;Tz7OZV6N9ZXrq3vnHc34-141&quot;&gt;&#10; &lt;mxGeometry relative=&quot;1&quot; as=&quot;geometry&quot;&gt;&#10; &lt;Array as=&quot;points&quot;&gt;&#10; &lt;mxPoint x=&quot;1310&quot; y=&quot;2665&quot; /&gt;&#10; &lt;mxPoint x=&quot;1310&quot; y=&quot;2195.5&quot; /&gt;&#10; &lt;/Array&gt;&#10; &lt;/mxGeometry&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-143&quot; edge=&quot;1&quot; parent=&quot;1&quot; source=&quot;Tz7OZV6N9ZXrq3vnHc34-115&quot; style=&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;strokeColor=#0000FF;&quot; target=&quot;Tz7OZV6N9ZXrq3vnHc34-141&quot;&gt;&#10; &lt;mxGeometry relative=&quot;1&quot; as=&quot;geometry&quot;&gt;&#10; &lt;Array as=&quot;points&quot;&gt;&#10; &lt;mxPoint x=&quot;1310&quot; y=&quot;3018.17&quot; /&gt;&#10; &lt;mxPoint x=&quot;1310&quot; y=&quot;2195.5&quot; /&gt;&#10; &lt;/Array&gt;&#10; &lt;/mxGeometry&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-145&quot; parent=&quot;1&quot; style=&quot;text=1;html=0;align=right;verticalAlign=middle;whiteSpace=wrap;strokeColor=none;fillColor=none;fontFamily=FZLanTingHeiS, 方正兰亭黑简体;fontSize=30;spacing=0.0;fontColor=#999999;&quot; value=&quot;0x3000&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;70.95&quot; width=&quot;110&quot; x=&quot;1870&quot; y=&quot;2220&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-146&quot; parent=&quot;1&quot; style=&quot;text=1;html=0;align=right;verticalAlign=middle;whiteSpace=wrap;strokeColor=none;fillColor=none;fontFamily=FZLanTingHeiS, 方正兰亭黑简体;fontSize=30;spacing=0.0;fontColor=#999999;&quot; value=&quot;0x13000&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;70.95&quot; width=&quot;130&quot; x=&quot;1850&quot; y=&quot;2440&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-147&quot; parent=&quot;1&quot; style=&quot;text=1;html=0;align=right;verticalAlign=middle;whiteSpace=wrap;strokeColor=none;fillColor=none;fontFamily=FZLanTingHeiS, 方正兰亭黑简体;fontSize=30;spacing=0.0;fontColor=#999999;&quot; value=&quot;0x1E000&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;70.95&quot; width=&quot;130&quot; x=&quot;1850&quot; y=&quot;2580&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-148&quot; parent=&quot;1&quot; style=&quot;text=1;html=0;align=right;verticalAlign=middle;whiteSpace=wrap;strokeColor=none;fillColor=none;fontFamily=FZLanTingHeiS, 方正兰亭黑简体;fontSize=30;spacing=0.0;fontColor=#999999;&quot; value=&quot;0x20000&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;70.95&quot; width=&quot;130&quot; x=&quot;1850&quot; y=&quot;2670&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-149&quot; edge=&quot;1&quot; parent=&quot;1&quot; source=&quot;Tz7OZV6N9ZXrq3vnHc34-94&quot; style=&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;strokeColor=#FF0000;&quot; target=&quot;Tz7OZV6N9ZXrq3vnHc34-145&quot;&gt;&#10; &lt;mxGeometry relative=&quot;1&quot; as=&quot;geometry&quot;&gt;&#10; &lt;Array as=&quot;points&quot;&gt;&#10; &lt;mxPoint x=&quot;1670&quot; y=&quot;2440.17&quot; /&gt;&#10; &lt;mxPoint x=&quot;1670&quot; y=&quot;2255.5&quot; /&gt;&#10; &lt;/Array&gt;&#10; &lt;/mxGeometry&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-150&quot; edge=&quot;1&quot; parent=&quot;1&quot; source=&quot;Tz7OZV6N9ZXrq3vnHc34-112&quot; style=&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;strokeColor=#FF0000;&quot; target=&quot;Tz7OZV6N9ZXrq3vnHc34-145&quot;&gt;&#10; &lt;mxGeometry relative=&quot;1&quot; as=&quot;geometry&quot;&gt;&#10; &lt;Array as=&quot;points&quot;&gt;&#10; &lt;mxPoint x=&quot;1670&quot; y=&quot;2756.83&quot; /&gt;&#10; &lt;mxPoint x=&quot;1670&quot; y=&quot;2255.5&quot; /&gt;&#10; &lt;/Array&gt;&#10; &lt;/mxGeometry&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;Tz7OZV6N9ZXrq3vnHc34-151&quot; parent=&quot;1&quot; style=&quot;text=1;html=0;align=right;verticalAlign=middle;whiteSpace=wrap;strokeColor=none;fillColor=none;fontFamily=FZLanTingHeiS, 方正兰亭黑简体;fontSize=42;spacing=0.0;&quot; value=&quot;UB&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry height=&quot;70.95&quot; width=&quot;145&quot; x=&quot;2570&quot; y=&quot;2010&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;/root&gt;&#10; &lt;/mxGraphModel&gt;&#10; &lt;/diagram&gt;&#10; &lt;diagram id=&quot;wRpVhzO6DHmiRBtP84Xx&quot; name=&quot;第 2 页&quot;&gt;&#10; &lt;mxGraphModel dx=&quot;2054&quot; dy=&quot;1103&quot; grid=&quot;1&quot; gridSize=&quot;10&quot; guides=&quot;1&quot; tooltips=&quot;1&quot; connect=&quot;1&quot; arrows=&quot;1&quot; fold=&quot;1&quot; page=&quot;1&quot; pageScale=&quot;1&quot; pageWidth=&quot;827&quot; pageHeight=&quot;1169&quot; math=&quot;0&quot; shadow=&quot;0&quot;&gt;&#10; &lt;root&gt;&#10; &lt;mxCell id=&quot;0&quot; /&gt;&#10; &lt;mxCell id=&quot;1&quot; parent=&quot;0&quot; /&gt;&#10; &lt;/root&gt;&#10; &lt;/mxGraphModel&gt;&#10; &lt;/diagram&gt;&#10;&lt;/mxfile&gt;&#10;"><style type="text/css">@supports (color: light-dark(#000, #fff)) { #ge-svg-fnAa1BE_CIkNll2WwqDT { --ge-adaptive-bg: light-dark(#ffffff, var(--ge-dark-color, #121212)); } }</style><defs/><rect fill="#ffffff" width="100%" height="100%" x="0" y="0" style="fill: light-dark(rgb(255, 255, 255), rgb(18, 18, 18));"/><g><g data-cell-id="0"><g data-cell-id="1"><g data-cell-id="vyCDRny16pTUmMtkMtA--1"><g><rect x="-0.2" y="0" width="2680" height="1280" fill="#ffffff" stroke="none" pointer-events="all" style="fill: var(--ge-adaptive-bg, #ffffff);"/></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-88"><g><rect x="19.8" y="160" width="1260" height="1100" fill="#eaeaea" stroke="none" pointer-events="all" style="fill: light-dark(rgb(234, 234, 234), rgb(36, 36, 36));"/></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-91"><g><rect x="57.54" y="204.95" width="321.47" height="70.95" fill="none" stroke="none" pointer-events="all"/></g><g><g><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe flex-start; width: 323px; height: 1px; padding-top: 240px; margin-left: 58px;"><div style="box-sizing: border-box; font-size: 0; text-align: left; color: #000000; "><div style="display: inline-block; font-size: 42px; font-family: FZLanTingHeiS, 方正兰亭黑简体; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">MainScalar</div></div></div></foreignObject><text x="58" y="253" fill="#000000" font-family="FZLanTingHeiS, 方正兰亭黑简体" font-size="42px" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));">MainScalar</text></switch></g></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-93"><g transform="translate(0.5,0.5)"><rect x="79.8" y="341.95" width="790" height="70.95" fill="none" stroke="#000000" pointer-events="all" style="stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g><g><g><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe flex-start; width: 792px; height: 1px; padding-top: 377px; margin-left: 80px;"><div style="box-sizing: border-box; font-size: 0; text-align: left; color: #000000; "><div style="display: inline-block; font-size: 38px; font-family: FZLanTingHeiS, 方正兰亭黑简体; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">__ubuf__ float static_buf_0[2048];</div></div></div></foreignObject><text x="80" y="389" fill="#000000" font-family="FZLanTingHeiS, 方正兰亭黑简体" font-size="38px" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));">__ubuf__ float static_buf_0[2048];</text></switch></g></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-94"><g transform="translate(0.5,0.5)"><rect x="80.16" y="444.66" width="734.33" height="70.95" fill="none" stroke="#000000" pointer-events="all" style="stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g><g><g><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe flex-start; width: 736px; height: 1px; padding-top: 480px; margin-left: 80px;"><div style="box-sizing: border-box; font-size: 0; text-align: left; color: #000000; "><div style="display: inline-block; font-size: 38px; font-family: FZLanTingHeiS, 方正兰亭黑简体; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">extern __ubuf__ char dyn_buf[];</div></div></div></foreignObject><text x="80" y="492" fill="#000000" font-family="FZLanTingHeiS, 方正兰亭黑简体" font-size="38px" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));">extern __ubuf__ char dyn_buf[];</text></switch></g></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-98"><g><path d="M 90.43 729.92 L 90.43 582.91 Q 90.43 576.91 96.43 576.91 L 1101.51 576.91 Q 1107.51 576.91 1107.51 582.91 L 1107.51 876.92 Q 1107.51 882.92 1101.51 882.92 L 96.43 882.92 Q 90.43 882.92 90.43 876.92 Z" fill="#aad3f5" stroke="none" pointer-events="all" style="fill: light-dark(rgb(170, 211, 245), rgb(32, 67, 97));"/></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-108"><g><rect x="100.52" y="576.91" width="321.47" height="70.95" fill="none" stroke="none" pointer-events="all"/></g><g><g><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe flex-start; width: 323px; height: 1px; padding-top: 612px; margin-left: 101px;"><div style="box-sizing: border-box; font-size: 0; text-align: left; color: #000000; "><div style="display: inline-block; font-size: 42px; font-family: FZLanTingHeiS, 方正兰亭黑简体; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">VF 1</div></div></div></foreignObject><text x="101" y="625" fill="#000000" font-family="FZLanTingHeiS, 方正兰亭黑简体" font-size="42px" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));">VF 1</text></switch></g></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-109"><g transform="translate(0.5,0.5)"><rect x="150.97" y="669.54" width="817.3" height="70.95" fill="none" stroke="#000000" pointer-events="all" style="stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g><g><g><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe flex-start; width: 819px; height: 1px; padding-top: 705px; margin-left: 151px;"><div style="box-sizing: border-box; font-size: 0; text-align: left; color: #000000; "><div style="display: inline-block; font-size: 38px; font-family: FZLanTingHeiS, 方正兰亭黑简体; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">__ubuf__ int32_t static_buf_1[512];</div></div></div></foreignObject><text x="151" y="716" fill="#000000" font-family="FZLanTingHeiS, 方正兰亭黑简体" font-size="38px" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));">__ubuf__ int32_t static_buf_1[512];</text></switch></g></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-112"><g transform="translate(0.5,0.5)"><rect x="150.97" y="761.35" width="817.3" height="70.95" fill="none" stroke="#000000" pointer-events="all" style="stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g><g><g><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe flex-start; width: 819px; height: 1px; padding-top: 797px; margin-left: 151px;"><div style="box-sizing: border-box; font-size: 0; text-align: left; color: #000000; "><div style="display: inline-block; font-size: 38px; font-family: FZLanTingHeiS, 方正兰亭黑简体; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">extern __ubuf__ char dyn_buf_1[];</div></div></div></foreignObject><text x="151" y="808" fill="#000000" font-family="FZLanTingHeiS, 方正兰亭黑简体" font-size="38px" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));">extern __ubuf__ char dyn_buf_1[];</text></switch></g></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-113"><g><path d="M 90.43 1036.93 L 90.43 939.55 Q 90.43 933.55 96.43 933.55 L 1101.51 933.55 Q 1107.51 933.55 1107.51 939.55 L 1107.51 1134.32 Q 1107.51 1140.32 1101.51 1140.32 L 96.43 1140.32 Q 90.43 1140.32 90.43 1134.32 Z" fill="#aad3f5" stroke="none" pointer-events="all" style="fill: light-dark(rgb(170, 211, 245), rgb(32, 67, 97));"/></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-114"><g><rect x="100.52" y="932.55" width="321.47" height="70.95" fill="none" stroke="none" pointer-events="all"/></g><g><g><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe flex-start; width: 323px; height: 1px; padding-top: 968px; margin-left: 101px;"><div style="box-sizing: border-box; font-size: 0; text-align: left; color: #000000; "><div style="display: inline-block; font-size: 42px; font-family: FZLanTingHeiS, 方正兰亭黑简体; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">VF 2</div></div></div></foreignObject><text x="101" y="981" fill="#000000" font-family="FZLanTingHeiS, 方正兰亭黑简体" font-size="42px" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));">VF 2</text></switch></g></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-115"><g transform="translate(0.5,0.5)"><rect x="150.97" y="1022.7" width="817.3" height="70.95" fill="none" stroke="#000000" pointer-events="all" style="stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g><g><g><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe flex-start; width: 819px; height: 1px; padding-top: 1058px; margin-left: 151px;"><div style="box-sizing: border-box; font-size: 0; text-align: left; color: #000000; "><div style="display: inline-block; font-size: 38px; font-family: FZLanTingHeiS, 方正兰亭黑简体; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">__ubuf__ int32_t static_buf_1[1024];</div></div></div></foreignObject><text x="151" y="1070" fill="#000000" font-family="FZLanTingHeiS, 方正兰亭黑简体" font-size="38px" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));">__ubuf__ int32_t static_buf_1[1024];</text></switch></g></g></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-92"><g><rect x="19.8" y="17" width="1260" height="68.15" fill="none" stroke="none" pointer-events="all"/></g><g><g><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe flex-start; width: 1262px; height: 1px; padding-top: 51px; margin-left: 20px;"><div style="box-sizing: border-box; font-size: 0; text-align: left; color: #000000; "><div style="display: inline-block; font-size: 45px; font-family: FZLanTingHeiS, 方正兰亭黑简体; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">&lt;&lt;&lt;... , dyn_ub_size=64*1024, ....&gt;&gt;&gt;</div></div></div></foreignObject><text x="20" y="65" fill="#000000" font-family="FZLanTingHeiS, 方正兰亭黑简体" font-size="45px" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));">&lt;&lt;&lt;... , dyn_ub_size=64*1024, ....&gt;&gt;&gt;</text></switch></g></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-123"><g transform="translate(0.5,0.5)"><rect x="1899.8" y="148.15" width="745" height="88.59" fill="#25c251" stroke="#000000" pointer-events="all" style="fill: light-dark(rgb(37, 194, 81), rgb(6, 141, 44)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g><g><g><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 743px; height: 1px; padding-top: 192px; margin-left: 1901px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; color: #000000; "><div style="display: inline-block; font-size: 32px; font-family: Helvetica; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "><span>static buf(</span><span>8KB</span><span>)</span></div></div></div></foreignObject><text x="2272" y="202" fill="#000000" font-family="Helvetica" font-size="32px" text-anchor="middle" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));">static buf(8KB)</text></switch></g></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-124"><g transform="translate(0.5,0.5)"><rect x="1899.8" y="236.74" width="745" height="60" fill="#b3d6ff" stroke="#000000" pointer-events="all" style="fill: light-dark(rgb(179, 214, 255), rgb(31, 61, 96)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g><g><g><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 743px; height: 1px; padding-top: 267px; margin-left: 1901px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; color: #000000; "><div style="display: inline-block; font-size: 32px; font-family: Helvetica; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "><span>static buf(4KB)</span></div></div></div></foreignObject><text x="2272" y="276" fill="#000000" font-family="Helvetica" font-size="32px" text-anchor="middle" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));">static buf(4KB)</text></switch></g></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-125"><g transform="translate(0.5,0.5)"><rect x="1899.8" y="296.74" width="745" height="221.41" fill="#fcbc72" stroke="#000000" pointer-events="all" style="fill: light-dark(rgb(252, 188, 114), rgb(116, 61, 0)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g><g><g><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 743px; height: 1px; padding-top: 407px; margin-left: 1901px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; color: #000000; "><div style="display: inline-block; font-size: 32px; font-family: Helvetica; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "><span>dyn buf(64KB)</span></div></div></div></foreignObject><text x="2272" y="417" fill="#000000" font-family="Helvetica" font-size="32px" text-anchor="middle" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));">dyn buf(64KB)</text></switch></g></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-128"><g transform="translate(0.5,0.5)"><rect x="1899.8" y="518.15" width="745" height="140" fill="none" stroke="#000000" pointer-events="all" style="stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g><g><g><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 743px; height: 1px; padding-top: 588px; margin-left: 1901px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; color: #000000; "><div style="display: inline-block; font-size: 32px; font-family: Helvetica; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "><span><b>...</b></span></div></div></div></foreignObject><text x="2272" y="598" fill="#000000" font-family="Helvetica" font-size="32px" text-anchor="middle" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));">...</text></switch></g></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-129"><g transform="translate(0.5,0.5)"><rect x="1899.8" y="658.15" width="745" height="88.59" fill="#97e8e1" stroke="#000000" pointer-events="all" style="fill: light-dark(rgb(151, 232, 225), rgb(0, 68, 62)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g><g><g><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 743px; height: 1px; padding-top: 702px; margin-left: 1901px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; color: #000000; "><div style="display: inline-block; font-size: 32px; font-family: Helvetica; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "><span>预留空间(8KB)</span></div></div></div></foreignObject><text x="2272" y="712" fill="#000000" font-family="Helvetica" font-size="32px" text-anchor="middle" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));">预留空间(8KB)</text></switch></g></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-138"><g transform="translate(0.5,0.5)"><rect x="1899.8" y="746.74" width="745" height="513.26" fill="#dbdbdb" stroke="#000000" pointer-events="all" style="fill: light-dark(rgb(219, 219, 219), rgb(49, 49, 49)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g><g><g><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 743px; height: 1px; padding-top: 1003px; margin-left: 1901px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; color: #000000; "><div style="display: inline-block; font-size: 32px; font-family: Helvetica; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "><span>Data Cache (128KB)</span></div></div></div></foreignObject><text x="2272" y="1013" fill="#000000" font-family="Helvetica" font-size="32px" text-anchor="middle" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));">Data Cache (128KB)</text></switch></g></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-139"><g transform="translate(0.5,0.5)"><path d="M 869.8 377.43 L 1049.8 377.5 L 1049.8 145.5 L 1803.43 145.5" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke" style="stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/><path d="M 1808.68 145.5 L 1801.68 149 L 1803.43 145.5 L 1801.68 142 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255)); stroke: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));"/></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-140"><g><rect x="1809.8" y="111" width="80" height="70.95" fill="none" stroke="none" pointer-events="all"/></g><g><g><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe flex-end; width: 82px; height: 1px; padding-top: 146px; margin-left: 1808px;"><div style="box-sizing: border-box; font-size: 0; text-align: right; color: #999999; "><div style="display: inline-block; font-size: 30px; font-family: FZLanTingHeiS, 方正兰亭黑简体; color: light-dark(#999999, #6a6a6a); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">0x00</div></div></div></foreignObject><text x="1890" y="155" fill="#999999" font-family="FZLanTingHeiS, 方正兰亭黑简体" font-size="30px" text-anchor="end" style="fill: light-dark(rgb(153, 153, 153), rgb(106, 106, 106));">0x00</text></switch></g></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-141"><g><rect x="1779.8" y="200" width="110" height="70.95" fill="none" stroke="none" pointer-events="all"/></g><g><g><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe flex-end; width: 112px; height: 1px; padding-top: 235px; margin-left: 1778px;"><div style="box-sizing: border-box; font-size: 0; text-align: right; color: #999999; "><div style="display: inline-block; font-size: 30px; font-family: FZLanTingHeiS, 方正兰亭黑简体; color: light-dark(#999999, #6a6a6a); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">0x2000</div></div></div></foreignObject><text x="1890" y="244" fill="#999999" font-family="FZLanTingHeiS, 方正兰亭黑简体" font-size="30px" text-anchor="end" style="fill: light-dark(rgb(153, 153, 153), rgb(106, 106, 106));">0x2000</text></switch></g></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-142"><g transform="translate(0.5,0.5)"><path d="M 968.27 705.02 L 1219.8 705 L 1219.8 235.5 L 1773.43 235.48" fill="none" stroke="#0000ff" stroke-miterlimit="10" pointer-events="stroke" style="stroke: light-dark(rgb(0, 0, 255), rgb(205, 205, 255));"/><path d="M 1778.68 235.48 L 1771.68 238.98 L 1773.43 235.48 L 1771.68 231.98 Z" fill="#0000ff" stroke="#0000ff" stroke-miterlimit="10" pointer-events="all" style="fill: light-dark(rgb(0, 0, 255), rgb(205, 205, 255)); stroke: light-dark(rgb(0, 0, 255), rgb(205, 205, 255));"/></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-143"><g transform="translate(0.5,0.5)"><path d="M 968.27 1058.18 L 1219.8 1058.25 L 1219.8 235.5 L 1773.43 235.48" fill="none" stroke="#0000ff" stroke-miterlimit="10" pointer-events="stroke" style="stroke: light-dark(rgb(0, 0, 255), rgb(205, 205, 255));"/><path d="M 1778.68 235.48 L 1771.68 238.98 L 1773.43 235.48 L 1771.68 231.98 Z" fill="#0000ff" stroke="#0000ff" stroke-miterlimit="10" pointer-events="all" style="fill: light-dark(rgb(0, 0, 255), rgb(205, 205, 255)); stroke: light-dark(rgb(0, 0, 255), rgb(205, 205, 255));"/></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-145"><g><rect x="1779.8" y="260" width="110" height="70.95" fill="none" stroke="none" pointer-events="all"/></g><g><g><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe flex-end; width: 112px; height: 1px; padding-top: 295px; margin-left: 1778px;"><div style="box-sizing: border-box; font-size: 0; text-align: right; color: #999999; "><div style="display: inline-block; font-size: 30px; font-family: FZLanTingHeiS, 方正兰亭黑简体; color: light-dark(#999999, #6a6a6a); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">0x3000</div></div></div></foreignObject><text x="1890" y="304" fill="#999999" font-family="FZLanTingHeiS, 方正兰亭黑简体" font-size="30px" text-anchor="end" style="fill: light-dark(rgb(153, 153, 153), rgb(106, 106, 106));">0x3000</text></switch></g></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-146"><g><rect x="1759.8" y="480" width="130" height="70.95" fill="none" stroke="none" pointer-events="all"/></g><g><g><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe flex-end; width: 132px; height: 1px; padding-top: 515px; margin-left: 1758px;"><div style="box-sizing: border-box; font-size: 0; text-align: right; color: #999999; "><div style="display: inline-block; font-size: 30px; font-family: FZLanTingHeiS, 方正兰亭黑简体; color: light-dark(#999999, #6a6a6a); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">0x13000</div></div></div></foreignObject><text x="1890" y="524" fill="#999999" font-family="FZLanTingHeiS, 方正兰亭黑简体" font-size="30px" text-anchor="end" style="fill: light-dark(rgb(153, 153, 153), rgb(106, 106, 106));">0x13000</text></switch></g></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-147"><g><rect x="1759.8" y="620" width="130" height="70.95" fill="none" stroke="none" pointer-events="all"/></g><g><g><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe flex-end; width: 132px; height: 1px; padding-top: 655px; margin-left: 1758px;"><div style="box-sizing: border-box; font-size: 0; text-align: right; color: #999999; "><div style="display: inline-block; font-size: 30px; font-family: FZLanTingHeiS, 方正兰亭黑简体; color: light-dark(#999999, #6a6a6a); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">0x1E000</div></div></div></foreignObject><text x="1890" y="664" fill="#999999" font-family="FZLanTingHeiS, 方正兰亭黑简体" font-size="30px" text-anchor="end" style="fill: light-dark(rgb(153, 153, 153), rgb(106, 106, 106));">0x1E000</text></switch></g></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-148"><g><rect x="1759.8" y="710" width="130" height="70.95" fill="none" stroke="none" pointer-events="all"/></g><g><g><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe flex-end; width: 132px; height: 1px; padding-top: 745px; margin-left: 1758px;"><div style="box-sizing: border-box; font-size: 0; text-align: right; color: #999999; "><div style="display: inline-block; font-size: 30px; font-family: FZLanTingHeiS, 方正兰亭黑简体; color: light-dark(#999999, #6a6a6a); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">0x20000</div></div></div></foreignObject><text x="1890" y="754" fill="#999999" font-family="FZLanTingHeiS, 方正兰亭黑简体" font-size="30px" text-anchor="end" style="fill: light-dark(rgb(153, 153, 153), rgb(106, 106, 106));">0x20000</text></switch></g></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-149"><g transform="translate(0.5,0.5)"><path d="M 814.49 480.14 L 1579.8 480 L 1579.8 295.5 L 1773.43 295.48" fill="none" stroke="#ff0000" stroke-miterlimit="10" pointer-events="stroke" style="stroke: light-dark(rgb(255, 0, 0), rgb(255, 144, 144));"/><path d="M 1778.68 295.48 L 1771.68 298.98 L 1773.43 295.48 L 1771.68 291.98 Z" fill="#ff0000" stroke="#ff0000" stroke-miterlimit="10" pointer-events="all" style="fill: light-dark(rgb(255, 0, 0), rgb(255, 144, 144)); stroke: light-dark(rgb(255, 0, 0), rgb(255, 144, 144));"/></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-150"><g transform="translate(0.5,0.5)"><path d="M 968.27 796.82 L 1579.8 796.75 L 1579.8 295.5 L 1773.43 295.48" fill="none" stroke="#ff0000" stroke-miterlimit="10" pointer-events="stroke" style="stroke: light-dark(rgb(255, 0, 0), rgb(255, 144, 144));"/><path d="M 1778.68 295.48 L 1771.68 298.98 L 1773.43 295.48 L 1771.68 291.98 Z" fill="#ff0000" stroke="#ff0000" stroke-miterlimit="10" pointer-events="all" style="fill: light-dark(rgb(255, 0, 0), rgb(255, 144, 144)); stroke: light-dark(rgb(255, 0, 0), rgb(255, 144, 144));"/></g></g><g data-cell-id="Tz7OZV6N9ZXrq3vnHc34-151"><g><rect x="2479.8" y="50" width="145" height="70.95" fill="none" stroke="none" pointer-events="all"/></g><g><g><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe flex-end; width: 147px; height: 1px; padding-top: 85px; margin-left: 2478px;"><div style="box-sizing: border-box; font-size: 0; text-align: right; color: #000000; "><div style="display: inline-block; font-size: 42px; font-family: FZLanTingHeiS, 方正兰亭黑简体; color: light-dark(#000000, #ffffff); line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">UB</div></div></div></foreignObject><text x="2625" y="98" fill="#000000" font-family="FZLanTingHeiS, 方正兰亭黑简体" font-size="42px" text-anchor="end" style="fill: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));">UB</text></switch></g></g></g></g></g></g><switch><g requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"/><a transform="translate(0,-5)" xlink:href="https://www.drawio.com/doc/faq/svg-export-text-problems" target="_blank"><text text-anchor="middle" font-size="10px" x="50%" y="100%">Text is not SVG - cannot display</text></a></switch></svg>
@@ -11,13 +11,11 @@
11 11 
12## UB划分<a name="ZH-CN_TOPIC_0000002563309890"></a>12## UB划分<a name="ZH-CN_TOPIC_0000002563309890"></a>
13 13 
14-UB内存空间总大小为256KB。UB按功能划分为四个主要区域,从低地址到高地址依次为静态内存、动态内存、预留空间和Data Cache,如下图所示。14+UB内存空间总大小为256KB。除了用户申请的动静态内存,UB还需要预留一定的空间供内部使用,因此用户在配置动静态内存大小时,并不能用满全部UB空间。UB按功能划分为四个主要区域,从低地址到高地址依次为静态内存、动态内存、预留空间和Data Cache,如下图所示。
15 15 
16**图2** SIMD与SIMT混合编程UB内存分配 16**图2** SIMD与SIMT混合编程UB内存分配
17![](../../../../figures/simt_ub.png "UB内存分配图")17![](../../../../figures/simt_ub.png "UB内存分配图")
18 18 
19-### 内存空间说明<a name="zh-cn_topic_0000002571697985_section19291134194"></a>
20- 
211. 静态内存:从内存的起始地址分配一段指定大小的内存空间,其大小在编译时确定,不可动态修改。191. 静态内存:从内存的起始地址分配一段指定大小的内存空间,其大小在编译时确定,不可动态修改。
22 20 
23 ```cpp21 ```cpp
@@ -37,38 +35,47 @@ UB内存空间总大小为256KB。UB按功能划分为四个主要区域,从
37 35 
38 由于动态内存均从静态内存结束位置之后开始分配,因此只能选择其中一种方式申请动态内存,否则可能导致地址空间重叠,从而引发未定义行为。36 由于动态内存均从静态内存结束位置之后开始分配,因此只能选择其中一种方式申请动态内存,否则可能导致地址空间重叠,从而引发未定义行为。
39 37 
40-3. 预留空间:编译器和Ascend C的预留空间,大小固定为8KB。38+3. 预留空间:编译器和Ascend C的预留空间,大小为8KB,其中6KB作为SIMD与SIMT各类寄存器溢出栈空间,2KB为Ascend C接口内部预留空间。
41-4. Data Cache:SIMT专有的Data Cache空间,可分配的内存大小范围为32KB到128KB,具体计算公式如下:39+4. Data Cache:SIMT专有的Data Cache空间,用于SIMT线程访问全局内存时的数据缓存,Data Cache的空间可配置范围为**最小32KB、最大128KB**,实际内存大小受用户配置的静态和动态内存大小影响,具体计算公式如下:
42 40 
43 ```41 ```
44- Data Cache空间大小 = min(UB总大小(256KB) - 静态内存 - 动态内存 - 预留空间(8KB), 128KB)42+ Data Cache空间大小 = min(UB总大小(256KB) - 静态内存 - 动态内存 - 预留空间(默认8KB), 128KB)
45 ```43 ```
44+ Data Cache空间上限为**128KB**,即使静态与动态内存申请较少,Data Cache实际分配大小也不会超出该上限。
46 45 
47- Data Cache作为访问GM内存的缓存,其大小会影响算子的访存效率。若Data Cache小于32KB,执行时会出现校验报错并退出,因此申请内存时需确保预留足够的Data Cache空间。46+混合编程场景下,可在SIMT VF、SIMD VF和MainScalar执行空间中使用动静态内存。MainScalar是指Device侧在VF函数外部的执行空间。下图为不同执行空间申请内存时对应的UB内存排布示意图。
48- 
49-由于Data Cache、预留空间与用户申请的UB内存共用同一块UB,因此开发者无法使用全部UB空间,应确保SIMT和SIMD各个执行空间中的实际UB访问范围都不超过已申请的静态内存和动态内存大小。
50- 
51-静态内存和动态内存的声明或配置限定了用户使用UB内存的有效范围。若用户配置的内存大小不足,甚至未申请内存即直接访问UB地址,访问地址可能越过用户动、静态内存边界并落入Data Cache区域。由于Data Cache容量由UB总量扣除静态内存、动态内存和预留空间后确定,所以用户共享内存配置偏小会扩大可分配给Data Cache的剩余空间。当程序执行越过已申请的动、静态内存边界,发生越界写入行为时,未必立即表现为内存分配失败,但可能破坏SIMT全局内存访问的数据缓存,导致计算结果不稳定或算子精度异常。
52- 
53-> [!NOTE]说明
54->
55-> 用户可选择禁用预留空间,禁用方法为:编译时增加[--cce-disable-vf-stack-reserved-ubuf](../../../compilation_and_execution/operator_compilation/ai_core_operator_compilation.md#ZH-CN_TOPIC_0000002462746461)选项。开启该选项后,编译器不再预留该部分UB空间,该空间可作为普通UB空间使用,Data Cache空间可按如下公式估算:
56-> ```
57-> Data Cache空间大小 = min(UB总大小(256KB) - 静态内存 - 动态内存 - 预留空间(8KB), 128KB)
58-> ```
59-> 使用该选项时,仍需保证Data Cache空间不小于32KB,且Data Cache空间上限仍为128KB。开启该选项后,编译器将无法使用预留UB空间作为寄存器溢出的缓存空间,开发者需保证不会发生寄存器溢出。
60- 
61-混合编程模式下,可在SIMT VF、SIMD VF和MainScalar执行空间申请静态内存和动态内存。MainScalar是指Device侧在VF函数外部的执行空间。下图为不同执行空间申请内存时对应的UB内存排布示意图。
62 47 
63**图3** 不同执行空间的UB内存排布 48**图3** 不同执行空间的UB内存排布
64-<img src="../../../../figures/simt_layout.png" alt="内存排布" style="width:80%; height:auto;">49+<img src="../../../../figures/simt_simd_ub_layout.png" alt="内存排布">
65 50 
66-用户在申请静态内存和动态内存时需要注意:51+UB内存的排布遵循以下规则:
67 52 
68-- 多次申请的静态内存在UB上按一定的首地址对齐规则排布:53+- 全局仅有一份动态内存。不同执行空间获取到的动态内存均位于同一地址空间,动态内存的大小由kernel launch时配置的动态内存大小决定。
54+- 由于AIV上VF是串行执行的,为提升UB资源利用率,VF之间复用同一份静态内存,该内存大小取决于各个VF所需静态内存最大值。
55+- 用户在一个Kernel内申请的动态内存首地址固定按照32B对齐,静态内存按如下首地址对齐规则排布:
69 - 默认情况下,申请到的静态内存首地址按照32B对齐;56 - 默认情况下,申请到的静态内存首地址按照32B对齐;
70- - 支持用户使用`__align__(N)`手动指定对齐,优先级高于默认对齐。57+ - 用户可以通过`alignas(N)`手动指定对齐方式,该配置的优先级高于默认对齐方式。
71-- 动态内存大小在`<<<...>>>`执行时动态配置,全局只有一份,因此不同执行位置申请的动态内存返回的首地址均相同。58+- 预留空间和Data Cache位于UB地址空间的高地址区域。Data Cache的实际大小取决于动静态内存实际占用的空间。
59+ 
60+### Data Cache内存空间说明<a name="zh-cn_topic_0000002571697985_section19291134194"></a>
61+ 
62+Data Cache作为访问GM内存的缓存,其大小会影响算子的访存效率。若Data Cache小于32KB,执行时会出现校验报错并退出,因此申请内存时需确保预留足够的Data Cache空间。
63+ 
64+由于Data Cache、预留空间与用户申请的动静态内存共用同一块UB,开发者无法使用全部UB空间。Data Cache的容量由UB总量扣除动静态内存和预留空间计算所得,用户配置的共享内存越小,留给Data Cache的空间就越大,即共享内存大小实际上隐式决定了Data Cache的容量,直至其达到128KB上限。
65+ 
66+若用户配置的内存大小不足,甚至未申请内存即直接访问UB地址,访问地址可能越过动、静态内存边界并落入Data Cache区域,属于未定义行为,非常危险。此类越界写入可能破坏SIMT全局内存访问的数据缓存,导致算子功能异常。
67+ 
68+### 禁用预留空间
69+ 
70+若用户需要使用更多UB内存,可通过禁用预留空间来扩大可用UB空间。禁用方法为编译时增加如下编译选项:
71+ 
72+- [--cce-disable-vf-stack-reserved-ubuf](../../../compilation_and_execution/operator_compilation/ai_core_operator_compilation.md#ZH-CN_TOPIC_0000002462746461):关闭6KB的SIMD与SIMT各类寄存器溢出栈空间。
73+- [--cce-disable-asc-reserved-ubuf](../../../compilation_and_execution/operator_compilation/ai_core_operator_compilation.md#ZH-CN_TOPIC_0000002462746461):关闭2KB的Ascend C接口内部预留空间。
74+ 
75+以上编译选项可独立使用,也可同时使用。开启后,编译器不再预留对应部分UB空间,该空间可作为普通UB空间使用。但开发者需要自行确认禁用预留空间的影响:
76+ 
77+- 开启`--cce-disable-vf-stack-reserved-ubuf`后,编译器将无法使用预留UB空间作为寄存器溢出的缓存空间,开发者需保证不会发生相关寄存器溢出,否则将会编译报错。
78+- 开启`--cce-disable-asc-reserved-ubuf`后,[使用预留UB空间的API](../../../programming_model/ai_core_simd_programming/cpp_tensor_programming/static_tensor_programming.md#section_reserved_ubuf_api)无法正常使用,需要手动调整API调用方式或替换为不依赖预留UB空间的实现。
72 79 
73## 数据通路80## 数据通路
74 81 
@@ -89,7 +96,7 @@ UB内存空间总大小为256KB。UB按功能划分为四个主要区域,从
89 - 写数据时,底层会确保数据立即写出到GM,从而确保其他通路读取到最新数据;96 - 写数据时,底层会确保数据立即写出到GM,从而确保其他通路读取到最新数据;
90 - 读数据时,默认访存的底层实现与[asc\_ldca](../../../../../api/SIMT-API/memory_access_functions/asc_ldca.md)的实现一致。若访问的内存数据在SIMT Data Cache中命中,默认会读取Cache数据,可能导致读取到的数据与GM中的最新数据不一致。97 - 读数据时,默认访存的底层实现与[asc\_ldca](../../../../../api/SIMT-API/memory_access_functions/asc_ldca.md)的实现一致。若访问的内存数据在SIMT Data Cache中命中,默认会读取Cache数据,可能导致读取到的数据与GM中的最新数据不一致。
91- 在MainScalar执行空间通过Cache读写GM上的数据时,读写均可能存在一致性问题:98- 在MainScalar执行空间通过Cache读写GM上的数据时,读写均可能存在一致性问题:
92- - 写数据时,数据会先写入Cache,底层无法保证数据立即刷新到GM上,此时其他通路读取到的可能是旧数据。可使用缓存控制使数据立即刷新到GM上,保证其它通路读到的是最新数据,具体详见[asc\_dcci](../../../../../api/SIMD-API/c_api/cache_ctrl/asc_dcci.md)中的内容;99+ - 写数据时,数据会先写入Cache,底层无法保证数据立即刷新到GM上,此时其他通路读取到的可能是旧数据。可使用缓存控制使数据立即刷新到GM上,保证其他通路读到的是最新数据,具体详见[asc\_dcci](../../../../../api/SIMD-API/c_api/cache_ctrl/asc_dcci.md)中的内容;
93 - 读数据时,若访问的内存在Cache中命中,将不会读取GM中的最新数据,可能导致读取到的数据失效。100 - 读数据时,若访问的内存在Cache中命中,将不会读取GM中的最新数据,可能导致读取到的数据失效。
94 101 
95在SIMT VF执行空间读GM上的数据时,对于上述缓存数据与GM数据不一致的问题,可以通过以下的方式解决:102在SIMT VF执行空间读GM上的数据时,对于上述缓存数据与GM数据不一致的问题,可以通过以下的方式解决:
@@ -75,42 +75,52 @@ __global__ void add_custom(float* x, float* y, float* z, uint64_t total_length)
75 }75 }
76 ```76 ```
77 77 
78-### 共享内存大小的限制78+### UB内存划分排布
79 79 
80-如下图所示,UB内存空间总大小为256KB。默认编译模式下,UB按功能划分为四个主要区域,从低地址到高地址依次为静态内存、动态内存、预留空间和Data Cache。由于这四类区域共享同一块UB内存,因此用户在配置共享内存大小时,应确保为Data Cache保留足够的空间(至少32KB),避免因可用空间不足导致校验报错。80+如下图所示,UB内存空间总大小为256KB。除了用户申请的动静态内存,UB还需要预留一定的空间供内部使用,因此用户在配置动静态内存大小时,并不能用满全部UB空间:
81 81 
82![](../../../figures/ub_alloc.png)82![](../../../figures/ub_alloc.png)
83 83 
84-具体结构如下:84+UB按功能划分为四个主要区域,从低地址到高地址依次为静态内存、动态内存、预留空间和Data Cache,具体结构如下:
85 85 
86-1. 静态内存和动态内存对应用户静态、动态申请方式分配的内存。86+1. 静态内存和动态内存对应用户静态、动态申请方式分配的内存。用户在UB上申请的动态内存首地址固定按照32B对齐,静态内存按如下首地址对齐规则排布:
87-2. 预留空间:编译器和Ascend C预留空间,大小固定为8KB。87+ - 默认情况下,申请到的静态内存首地址按照数据类型大小进行对齐;
88+ - 用户可以通过`alignas(N)`手动指定对齐方式,该配置的优先级高于默认对齐方式。
89+2. 预留空间:编译器和Ascend C预留空间,大小为8KB,其中6KB作为SIMT传参寄存器溢出栈空间,2KB为Ascend C接口内部预留空间。
883. Data Cache:SIMT专有的Data Cache空间,用于SIMT线程访问全局内存时的数据缓存,Data Cache的空间可配置范围为**最小32KB、最大128KB**,实际内存大小受用户配置的静态和动态内存大小影响,具体计算公式为:903. Data Cache:SIMT专有的Data Cache空间,用于SIMT线程访问全局内存时的数据缓存,Data Cache的空间可配置范围为**最小32KB、最大128KB**,实际内存大小受用户配置的静态和动态内存大小影响,具体计算公式为:
89 91 
90 ```92 ```
91- Data Cache空间大小 = min(UB总大小(256KB) - 静态内存 - 动态内存 - 预留空间(8KB), 128KB)93+ Data Cache空间大小 = min(UB总大小(256KB) - 静态内存 - 动态内存 - 预留空间(默认8KB), 128KB)
92 ```94 ```
93 95 
94 Data Cache空间上限为**128KB**,即使静态与动态内存申请较少,Data Cache实际分配大小也不会超出该上限。96 Data Cache空间上限为**128KB**,即使静态与动态内存申请较少,Data Cache实际分配大小也不会超出该上限。
95 97 
96-由于Data Cache、预留空间与用户申请的UB内存共用同一块UB,因此开发者无法使用全部UB空间,应确保实际访问范围不超过已申请的静态内存和动态内存大小。98+#### Data Cache内存空间说明
97 99 
98-静态内存和动态内存的声明或配置限定了用户使用UB内存的有效范围。若用户配置的内存大小不足,甚至未申请内存即直接访问UB地址,访问地址可能越过用户动、静态内存边界并落入Data Cache区域。由于Data Cache容量由UB总量扣除静态内存、动态内存和预留空间后确定,所以用户共享内存配置偏小会扩大可分配给Data Cache的剩余空间。当程序执行越过已申请的动、静态内存边界,发生越界写入行为时,未必立即表现为内存分配失败,但可能破坏SIMT全局内存访问的数据缓存,导致计算结果不稳定或算子精度异常。100+Data Cache作为访问GM内存的缓存,其大小会影响算子的访存效率。若Data Cache小于32KB,执行时会出现校验报错并退出,因此申请内存时需确保预留足够的Data Cache空间。
99 101 
100-> [!NOTE]说明102+由于Data Cache、预留空间与用户申请的动静态内存共用同一块UB,开发者无法使用全部UB空间。Data Cache的容量由UB总量扣除动静态内存和预留空间计算所得,用户配置的共享内存越小,留给Data Cache的空间就越大,即共享内存大小实际上隐式决定了Data Cache的容量,直至其达到128KB上限。
101->103+ 
102-> 用户可选择禁用预留空间,禁用方法为:编译时增加[--cce-disable-vf-stack-reserved-ubuf](../../compilation_and_execution/operator_compilation/ai_core_operator_compilation.md#ZH-CN_TOPIC_0000002462746461)选项。开启该选项后,编译器不再预留该部分UB空间,该空间可作为普通UB空间使用,Data Cache空间可按如下公式估算:104+若用户配置的内存大小不足,甚至未申请内存即直接访问UB地址,访问地址可能越过动、静态内存边界并落入Data Cache区域,属于未定义行为,非常危险。此类越界写入可能破坏SIMT全局内存访问的数据缓存,导致算子功能异常。
103-> ```105+ 
104-> Data Cache空间大小 = min(UB总大小(256KB) - 静态内存 - 动态内存, 128KB)106+#### 禁用预留空间
105-> ```107+ 
106-> 使用该选项时,仍需保证Data Cache空间不小于32KB,且Data Cache空间上限仍为128KB。开启该选项后,编译器将无法使用预留UB空间作为寄存器溢出的缓存空间,开发者需保证不会发生寄存器溢出。108+若用户需要使用更多UB内存,可通过禁用预留空间来扩大可用UB空间。禁用方法为编译时增加如下编译选项:
109+ 
110+- [--cce-disable-vf-stack-reserved-ubuf](../../compilation_and_execution/operator_compilation/ai_core_operator_compilation.md#ZH-CN_TOPIC_0000002462746461):关闭6KB的SIMT传参寄存器溢出栈空间。
111+- [--cce-disable-asc-reserved-ubuf](../../compilation_and_execution/operator_compilation/ai_core_operator_compilation.md#ZH-CN_TOPIC_0000002462746461):关闭2KB的Ascend C接口内部预留空间。
112+ 
113+以上编译选项可独立使用,也可同时使用。开启后,编译器不再预留对应部分UB空间,该空间可作为普通UB空间使用。但开发者需要自行确认禁用预留空间的影响:
114+ 
115+- 开启`--cce-disable-vf-stack-reserved-ubuf`后,编译器将无法使用预留UB空间作为传参寄存器溢出的栈空间,若用户函数参数过大,将会编译报错。
116+- 开启`--cce-disable-asc-reserved-ubuf`暂无影响,当前SIMT编程场景内部暂未使用该空间。
107 117 
108## 栈空间118## 栈空间
109 119 
110SIMT编程中的栈空间由编译器管理,生命周期与核函数(Kernel)一致,包括以下两部分:120SIMT编程中的栈空间由编译器管理,生命周期与核函数(Kernel)一致,包括以下两部分:
111 121 
112- 位于Global Memory(GM)上的SIMT栈空间。122- 位于Global Memory(GM)上的SIMT栈空间。
113-- 位于UB上用于SIMT函数调用参数传递的中转栈空间(UB上8KB预留空间的一部分)。123+- 位于UB上用于SIMT函数调用参数传递的中转栈空间(UB上8KB预留空间的一部分)。
114 124 
115下文分别说明这两类栈空间。125下文分别说明这两类栈空间。
116 126 
@@ -136,7 +146,7 @@ GM上的SIMT栈空间用于保存线程私有运行时状态,按用途分为SI
136 146 
137### UB上的SIMT函数调用中转栈空间147### UB上的SIMT函数调用中转栈空间
138 148 
139-如上文[共享内存大小的限制](#共享内存大小的限制)所述,UB中有8KB大小的预留空间,其中6KB内存是用于SIMT函数调用参数传递的中转栈。如[传参寄存器](#传参寄存器)章节所述,硬件原生支持的函数间传参寄存器容量有限,当参数总大小超出该容量时,编译器会使用该中转栈空间完成参数传递,由此产生额外的访存开销,降低函数调用性能。因此,开发者应关注Device侧函数调用的参数规模,避免传递过大的参数对象。149+如上文[UB内存划分排布](#ub内存划分排布)所述,UB中有8KB大小的预留空间,其中6KB内存是用于SIMT函数调用参数传递的中转栈。如[传参寄存器](#传参寄存器)章节所述,硬件原生支持的函数间传参寄存器容量有限,当参数总大小超出该容量时,编译器会使用该中转栈空间完成参数传递,由此产生额外的访存开销,降低函数调用性能。因此,开发者应关注Device侧函数调用的参数规模,避免传递过大的参数对象。
140 150 
141## 寄存器<a name="section1137715201010"></a>151## 寄存器<a name="section1137715201010"></a>
142 152