Merged
同步 CheckerL2 最新代码到 hccl_vm #5659
git_qkAdd on Sep 23
同步 CheckerL2 最新代码到 hccl_vm #5659
Merged
Merged fromgit_qk/hcommmasterintocann/hcommmaster
Total: 702 files changed+83338-74451
| @@ -0,0 +1,13 @@ | |||
| 1 | +# ----------------------------------------------------------------------------------------------------------- | ||
| 2 | +# Copyright (c) 2026 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 | +BasedOnStyle: LLVM | ||
| 12 | +IndentWidth: 4 | ||
| 13 | +UseTab: Never | ||
| @@ -67,7 +67,7 @@ bash build_pkg.sh | |||
| 67 | 67 | ||
| 68 | #### 3.2.1 环境配置 | 68 | #### 3.2.1 环境配置 |
| 69 | 69 | ||
| 70 | -请参照[hccl_rootinfo文件内容](#47-hccl_rootinfojson文件),创建并配置hccl_rootinfo.json文件。 | 70 | +若/etc路径下已存在hccl_rootinfo.json文件,请手动删除该文件。 |
| 71 | 71 | ||
| 72 | #### 3.2.2 CCU模式 | 72 | #### 3.2.2 CCU模式 |
| 73 | 73 | ||
| @@ -107,8 +107,8 @@ cd /home/workspace/hcomm/test/hccl_vm/hccl_vm_install/bin | |||
| 107 | ``` | 107 | ``` |
| 108 | 108 | ||
| 109 | 3. 验证hccl_test用例运行结果 | 109 | 3. 验证hccl_test用例运行结果 |
| 110 | -[Runner结果查看](#491-runner插件结果) | 110 | +[Runner结果查看](#481-runner插件结果) |
| 111 | -[Checker结果查看](#492-checker插件结果) | 111 | +[Checker结果查看](#482-checker插件结果) |
| 112 | 112 | ||
| 113 | #### 3.2.3 AICPU模式 | 113 | #### 3.2.3 AICPU模式 |
| 114 | 114 | ||
| @@ -148,7 +148,7 @@ cd /home/workspace/hcomm/test/hccl_vm/hccl_vm_install/bin | |||
| 148 | (hvm)$> exit | 148 | (hvm)$> exit |
| 149 | ``` | 149 | ``` |
| 150 | 150 | ||
| 151 | -3. 验证hccl_test用例运行结果 [Runner结果查看](#491-runner插件结果) [Checker结果查看](#492-checker插件结果) | 151 | +3. 验证hccl_test用例运行结果 [Runner结果查看](#481-runner插件结果) [Checker结果查看](#482-checker插件结果) |
| 152 | 152 | ||
| 153 | #### 3.2.4 HostDPU模式 | 153 | #### 3.2.4 HostDPU模式 |
| 154 | 154 | ||
| @@ -193,7 +193,7 @@ cd /home/workspace/hcomm/test/hccl_vm/hccl_vm_install/bin | |||
| 193 | (hvm)$> exit | 193 | (hvm)$> exit |
| 194 | ``` | 194 | ``` |
| 195 | 195 | ||
| 196 | -3. 验证hccl_test用例运行结果 [Runner结果查看](#491-runner插件结果) [Checker结果查看](#492-checker插件结果) | 196 | +3. 验证hccl_test用例运行结果 [Runner结果查看](#481-runner插件结果) [Checker结果查看](#482-checker插件结果) |
| 197 | 197 | ||
| 198 | ### 3.3 Pytorch用例示例 | 198 | ### 3.3 Pytorch用例示例 |
| 199 | 199 | ||
| @@ -229,11 +229,11 @@ export HCOMM_CODE_HOME=/home/workspace/hcomm | |||
| 229 | | ------------------------- | --------------------------------------------------------------------------------------------------------- | --------------------- | | 229 | | ------------------------- | --------------------------------------------------------------------------------------------------------- | --------------------- | |
| 230 | | `HCCL_CODE_HOME` | HCCL-VM编译指定HCCL源码路径。默认未配置。 | `export HCCL_CODE_HOME=/home/workspace/hccl` | | 230 | | `HCCL_CODE_HOME` | HCCL-VM编译指定HCCL源码路径。默认未配置。 | `export HCCL_CODE_HOME=/home/workspace/hccl` | |
| 231 | | `HCOMM_CODE_HOME` | HCCL-VM编译指定HCOMM源码路径。默认未配置。 | `export HCOMM_CODE_HOME=/home/workspace/hcomm` | | 231 | | `HCOMM_CODE_HOME` | HCCL-VM编译指定HCOMM源码路径。默认未配置。 | `export HCOMM_CODE_HOME=/home/workspace/hcomm` | |
| 232 | -| `HCCLVM_ENABLE_DUMP_DATA` | 使能Runner插件dump input\&output数据。若使能,则在测试用例执行过程中,会将每个算子的input\&output数据dump到all\_rank\_input\_output.txt文件中 | `export HCCLVM_ENABLE_DUMP_DATA=1 使能,export HCCLVM_ENABLE_DUMP_DATA=0 禁用` | | 232 | +| `HCCLVM_ENABLE_DUMP_DATA` | 1. 使能性能仿真文件输出落盘。若使能,则在测试用例执行过程中输出3个runner_hcclvm_*_data.bin文件和1个ccu_channel_jetty_config.xml文件供性能仿真使用. <br> 2.使能Runner插件dump input\&output数据。若使能,则在测试用例执行过程中,会将每个算子的input\&output数据dump到all\_rank\_input\_output.txt文件中 | `export HCCLVM_ENABLE_DUMP_DATA=1 使能,export HCCLVM_ENABLE_DUMP_DATA=0 或不配置该环境变量 禁用` | |
| 233 | 233 | ||
| 234 | ### 4.2 HCCL-Test用例构建 | 234 | ### 4.2 HCCL-Test用例构建 |
| 235 | 235 | ||
| 236 | -hccl_test用例源码在CANN包安装目录下,支持OpenMPI和MPICH两种环境编译、运行,运行时差异详见[OpenMPI和MPICH环境用例执行差异](#48-openmpi和mpich环境用例运行差异),本用例指导中以OpenMPI环境为例。 | 236 | +hccl_test用例源码在CANN包安装目录下,支持OpenMPI和MPICH两种环境编译、运行,运行时差异详见[OpenMPI和MPICH环境用例执行差异](#47-openmpi和mpich环境用例运行差异),本用例指导中以OpenMPI环境为例。 |
| 237 | 237 | ||
| 238 | #### 4.2.1 OpenMPI环境编译 | 238 | #### 4.2.1 OpenMPI环境编译 |
| 239 | 239 | ||
| @@ -711,23 +711,11 @@ Checker 插件当前使用 Checker V3 执行单算子校验。Checker V3 大图 | |||
| 711 | } | 711 | } |
| 712 | ``` | 712 | ``` |
| 713 | 713 | ||
| 714 | -### 4.7 hccl_rootinfo.json文件 | 714 | +### 4.7 OpenMPI和MPICH环境用例运行差异 |
| 715 | - | ||
| 716 | -目前工具初始化通信域使用的是ranktable.json文件,因此hccl_rootinfo.json文件的作用仅限于提供topo.json文件的路径。 | ||
| 717 | -若/etc路径下没有hccl_rootinfo.json文件,则用户需自行创建该文件,内容如下: | ||
| 718 | - | ||
| 719 | -```json | ||
| 720 | -{ | ||
| 721 | - "version": "2.0", | ||
| 722 | - "topo_file_path": "/home/workspace/hcomm/test/hccl_vm/hccl_vm_install/data/topo.json" | ||
| 723 | -} | ||
| 724 | -``` | ||
| 725 | - | ||
| 726 | -### 4.8 OpenMPI和MPICH环境用例运行差异 | ||
| 727 | 715 | ||
| 728 | 运行hccl_test用例前,用户可以通过which命令判断当前环境使用的是哪个mpirun。 | 716 | 运行hccl_test用例前,用户可以通过which命令判断当前环境使用的是哪个mpirun。 |
| 729 | 717 | ||
| 730 | -#### 4.8.1 环境变量配置差异 | 718 | +#### 4.7.1 环境变量配置差异 |
| 731 | 719 | ||
| 732 | 环境中一般默认配置的是OpenMPI,若用户使用OpenMPI运行用例,一般不需要额外配置环境变量。 | 720 | 环境中一般默认配置的是OpenMPI,若用户使用OpenMPI运行用例,一般不需要额外配置环境变量。 |
| 733 | 若用户使用MPICH环境运行用例,需要按照如下方式配置环境变量: | 721 | 若用户使用MPICH环境运行用例,需要按照如下方式配置环境变量: |
| @@ -738,7 +726,7 @@ export LD_LIBRARY_PATH=/usr/lib/mpich/lib/:${ASCEND_HOME_PATH}/lib64/:${ASCEND_H | |||
| 738 | export PATH=/usr/lib/mpich/bin:$PATH | 726 | export PATH=/usr/lib/mpich/bin:$PATH |
| 739 | ``` | 727 | ``` |
| 740 | 728 | ||
| 741 | -#### 4.8.2 mpirun命令参数差异 | 729 | +#### 4.7.2 mpirun命令参数差异 |
| 742 | 730 | ||
| 743 | OpenMPI环境,用户按照如下命令运行hccl_test用例: | 731 | OpenMPI环境,用户按照如下命令运行hccl_test用例: |
| 744 | 732 | ||
| @@ -764,9 +752,9 @@ mpirun -np 2 ${HCCL_TEST_PATH}/bin/reduce_scatter_test -b 64 -e 64 -d int32 -o s | |||
| 764 | 752 | ||
| 765 | - -np 2:指定进程数为2,与节点数一致。 | 753 | - -np 2:指定进程数为2,与节点数一致。 |
| 766 | 754 | ||
| 767 | -### 4.9 结果查看 | 755 | +### 4.8 结果查看 |
| 768 | 756 | ||
| 769 | -#### 4.9.1 Runner插件结果 | 757 | +#### 4.8.1 Runner插件结果 |
| 770 | 758 | ||
| 771 | 如果在hccl-vm终端执行hccl-vm plugin install @runner安装插件后,算子流程执行完成后会自动触发runner插件的执行,最终结果依赖hccl_test进行校验,用户需关注在重定向的日志文件中是否存在[error]级别日志和最终校验结果: | 759 | 如果在hccl-vm终端执行hccl-vm plugin install @runner安装插件后,算子流程执行完成后会自动触发runner插件的执行,最终结果依赖hccl_test进行校验,用户需关注在重定向的日志文件中是否存在[error]级别日志和最终校验结果: |
| 772 | 760 | ||
| @@ -775,7 +763,7 @@ data_size(Bytes): | aveg_time(us): | alg_bandwidth(GB/s): | check_result: | |||
| 775 | 64 | 1000.00 | 0.00006 | success | 763 | 64 | 1000.00 | 0.00006 | success |
| 776 | ``` | 764 | ``` |
| 777 | 765 | ||
| 778 | -#### 4.9.2 Checker插件结果 | 766 | +#### 4.8.2 Checker插件结果 |
| 779 | 767 | ||
| 780 | 在hccl-vm终端内执行hccl-vm plugin run @checker后,Checker校验流程及结果会打印在终端内,用于需关注是否存在[error]级别日志和最终校验结果: | 768 | 在hccl-vm终端内执行hccl-vm plugin run @checker后,Checker校验流程及结果会打印在终端内,用于需关注是否存在[error]级别日志和最终校验结果: |
| 781 | 769 | ||
| @@ -786,7 +774,7 @@ data_size(Bytes): | aveg_time(us): | alg_bandwidth(GB/s): | check_result: | |||
| 786 | ``` | 774 | ``` |
| 787 | 775 | ||
| 788 | --- | 776 | --- |
| 789 | -### 4.10 大块内存复用(仅校验模式) | 777 | +### 4.9 大块内存复用(仅校验模式) |
| 790 | 778 | ||
| 791 | 仅校验模式用于大规模集群仅运行 Checker 校验的场景。开启后,单块 200MB 到 4GB 的大内存申请复用同一块 4GB 共享区 `HcclCommPool`,各 rank 共享、允许互相覆盖,以此大幅降低 `/dev/shm` 占用。此时大块内容不保证正确,仅适用于不读取缓冲区数据的 Checker V3 校验链路,需要数值正确的结果时请勿开启。 | 779 | 仅校验模式用于大规模集群仅运行 Checker 校验的场景。开启后,单块 200MB 到 4GB 的大内存申请复用同一块 4GB 共享区 `HcclCommPool`,各 rank 共享、允许互相覆盖,以此大幅降低 `/dev/shm` 占用。此时大块内容不保证正确,仅适用于不读取缓冲区数据的 Checker V3 校验链路,需要数值正确的结果时请勿开启。 |
| 792 | 780 | ||
| @@ -8,14 +8,6 @@ | |||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ----------------------------------------------------------------------------------------------------------- | 9 | # ----------------------------------------------------------------------------------------------------------- |
| 10 | 10 | ||
| 11 | -# You may not use this file except in compliance with the License. | ||
| 12 | -# You may obtain a copy of the License at | ||
| 13 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 14 | -# Unless required by applicable law or agreed to in writing, software | ||
| 15 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | -# See the License for the specific language governing permissions and limitations under the License. | ||
| 18 | - | ||
| 19 | name: "ascend950_cluster_32_server_normal" | 11 | name: "ascend950_cluster_32_server_normal" |
| 20 | description: "昇腾950 normal组网:32个超级节点,每个超级节点1个服务器" | 12 | description: "昇腾950 normal组网:32个超级节点,每个超级节点1个服务器" |
| 21 | 13 | ||
| @@ -8,14 +8,6 @@ | |||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ----------------------------------------------------------------------------------------------------------- | 9 | # ----------------------------------------------------------------------------------------------------------- |
| 10 | 10 | ||
| 11 | -# You may not use this file except in compliance with the License. | ||
| 12 | -# You may obtain a copy of the License at | ||
| 13 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 14 | -# Unless required by applicable law or agreed to in writing, software | ||
| 15 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | -# See the License for the specific language governing permissions and limitations under the License. | ||
| 18 | - | ||
| 19 | name: "ascend950_cluster_32_server_normal" | 11 | name: "ascend950_cluster_32_server_normal" |
| 20 | description: "昇腾950 normal组网:32个超级节点,每个超级节点1个服务器" | 12 | description: "昇腾950 normal组网:32个超级节点,每个超级节点1个服务器" |
| 21 | 13 | ||
| @@ -8,14 +8,6 @@ | |||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ----------------------------------------------------------------------------------------------------------- | 9 | # ----------------------------------------------------------------------------------------------------------- |
| 10 | 10 | ||
| 11 | -# You may not use this file except in compliance with the License. | ||
| 12 | -# You may obtain a copy of the License at | ||
| 13 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 14 | -# Unless required by applicable law or agreed to in writing, software | ||
| 15 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | -# See the License for the specific language governing permissions and limitations under the License. | ||
| 18 | - | ||
| 19 | name: "ascend950_cluster_32_server_normal" | 11 | name: "ascend950_cluster_32_server_normal" |
| 20 | description: "昇腾950 normal组网:32个超级节点,每个超级节点1个服务器" | 12 | description: "昇腾950 normal组网:32个超级节点,每个超级节点1个服务器" |
| 21 | 13 | ||
| @@ -8,14 +8,6 @@ | |||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ----------------------------------------------------------------------------------------------------------- | 9 | # ----------------------------------------------------------------------------------------------------------- |
| 10 | 10 | ||
| 11 | -# You may not use this file except in compliance with the License. | ||
| 12 | -# You may obtain a copy of the License at | ||
| 13 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 14 | -# Unless required by applicable law or agreed to in writing, software | ||
| 15 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | -# See the License for the specific language governing permissions and limitations under the License. | ||
| 18 | - | ||
| 19 | name: "ascend950_cluster_32_server_normal" | 11 | name: "ascend950_cluster_32_server_normal" |
| 20 | description: "昇腾950 normal组网:32个超级节点,每个超级节点1个服务器" | 12 | description: "昇腾950 normal组网:32个超级节点,每个超级节点1个服务器" |
| 21 | 13 | ||
| @@ -8,14 +8,6 @@ | |||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ----------------------------------------------------------------------------------------------------------- | 9 | # ----------------------------------------------------------------------------------------------------------- |
| 10 | 10 | ||
| 11 | -# You may not use this file except in compliance with the License. | ||
| 12 | -# You may obtain a copy of the License at | ||
| 13 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 14 | -# Unless required by applicable law or agreed to in writing, software | ||
| 15 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | -# See the License for the specific language governing permissions and limitations under the License. | ||
| 18 | - | ||
| 19 | name: "ascend960_cluster_32_server_normal" | 11 | name: "ascend960_cluster_32_server_normal" |
| 20 | description: "昇腾960 normal组网:32个超级节点,每个超级节点1个服务器" | 12 | description: "昇腾960 normal组网:32个超级节点,每个超级节点1个服务器" |
| 21 | 13 | ||
| @@ -8,14 +8,6 @@ | |||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ----------------------------------------------------------------------------------------------------------- | 9 | # ----------------------------------------------------------------------------------------------------------- |
| 10 | 10 | ||
| 11 | -# You may not use this file except in compliance with the License. | ||
| 12 | -# You may obtain a copy of the License at | ||
| 13 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 14 | -# Unless required by applicable law or agreed to in writing, software | ||
| 15 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | -# See the License for the specific language governing permissions and limitations under the License. | ||
| 18 | - | ||
| 19 | type: "server_intra_links" | 11 | type: "server_intra_links" |
| 20 | name: "ascend950_links_topo_normal" | 12 | name: "ascend950_links_topo_normal" |
| 21 | description: "ascend950芯片NORMAL类型拓扑连接关系描述文件" | 13 | description: "ascend950芯片NORMAL类型拓扑连接关系描述文件" |
| @@ -8,14 +8,6 @@ | |||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ----------------------------------------------------------------------------------------------------------- | 9 | # ----------------------------------------------------------------------------------------------------------- |
| 10 | 10 | ||
| 11 | -# You may not use this file except in compliance with the License. | ||
| 12 | -# You may obtain a copy of the License at | ||
| 13 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 14 | -# Unless required by applicable law or agreed to in writing, software | ||
| 15 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | -# See the License for the specific language governing permissions and limitations under the License. | ||
| 18 | - | ||
| 19 | type: "server_intra_links" | 11 | type: "server_intra_links" |
| 20 | name: "ascend960_links_topo_normal" | 12 | name: "ascend960_links_topo_normal" |
| 21 | description: "ascend960芯片NORMAL类型拓扑连接关系描述文件" | 13 | description: "ascend960芯片NORMAL类型拓扑连接关系描述文件" |
| @@ -8,14 +8,6 @@ | |||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ----------------------------------------------------------------------------------------------------------- | 9 | # ----------------------------------------------------------------------------------------------------------- |
| 10 | 10 | ||
| 11 | -# You may not use this file except in compliance with the License. | ||
| 12 | -# You may obtain a copy of the License at | ||
| 13 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 14 | -# Unless required by applicable law or agreed to in writing, software | ||
| 15 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | -# See the License for the specific language governing permissions and limitations under the License. | ||
| 18 | - | ||
| 19 | # 1. 全局统计信息 podNum, serNum, rankNum 都小于 1024 | 11 | # 1. 全局统计信息 podNum, serNum, rankNum 都小于 1024 |
| 20 | meta: | 12 | meta: |
| 21 | podNum: 1 | 13 | podNum: 1 |
| @@ -8,15 +8,7 @@ | |||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ----------------------------------------------------------------------------------------------------------- | 9 | # ----------------------------------------------------------------------------------------------------------- |
| 10 | 10 | ||
| 11 | -# You may not use this file except in compliance with the License. | ||
| 12 | -# You may obtain a copy of the License at | ||
| 13 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 14 | -# Unless required by applicable law or agreed to in writing, software | ||
| 15 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | -# See the License for the specific language governing permissions and limitations under the License. | ||
| 18 | # 1. 全局统计信息 podNum, serNum, rankNum 都小于 1024 | 11 | # 1. 全局统计信息 podNum, serNum, rankNum 都小于 1024 |
| 19 | - | ||
| 20 | meta: | 12 | meta: |
| 21 | podNum: 1 | 13 | podNum: 1 |
| 22 | serNum: 1 | 14 | serNum: 1 |
| @@ -8,14 +8,6 @@ | |||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ----------------------------------------------------------------------------------------------------------- | 9 | # ----------------------------------------------------------------------------------------------------------- |
| 10 | 10 | ||
| 11 | -# You may not use this file except in compliance with the License. | ||
| 12 | -# You may obtain a copy of the License at | ||
| 13 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 14 | -# Unless required by applicable law or agreed to in writing, software | ||
| 15 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | -# See the License for the specific language governing permissions and limitations under the License. | ||
| 18 | - | ||
| 19 | # 1. 全局统计信息 podNum, serNum, rankNum 都小于 1024 | 11 | # 1. 全局统计信息 podNum, serNum, rankNum 都小于 1024 |
| 20 | meta: | 12 | meta: |
| 21 | podNum: 1 | 13 | podNum: 1 |
| @@ -8,14 +8,6 @@ | |||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ----------------------------------------------------------------------------------------------------------- | 9 | # ----------------------------------------------------------------------------------------------------------- |
| 10 | 10 | ||
| 11 | -# You may not use this file except in compliance with the License. | ||
| 12 | -# You may obtain a copy of the License at | ||
| 13 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 14 | -# Unless required by applicable law or agreed to in writing, software | ||
| 15 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | -# See the License for the specific language governing permissions and limitations under the License. | ||
| 18 | - | ||
| 19 | # 1. 全局统计信息 podNum, serNum, rankNum 都小于 1024 | 11 | # 1. 全局统计信息 podNum, serNum, rankNum 都小于 1024 |
| 20 | meta: | 12 | meta: |
| 21 | podNum: 1 | 13 | podNum: 1 |
| @@ -8,14 +8,6 @@ | |||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ----------------------------------------------------------------------------------------------------------- | 9 | # ----------------------------------------------------------------------------------------------------------- |
| 10 | 10 | ||
| 11 | -# You may not use this file except in compliance with the License. | ||
| 12 | -# You may obtain a copy of the License at | ||
| 13 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 14 | -# Unless required by applicable law or agreed to in writing, software | ||
| 15 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | -# See the License for the specific language governing permissions and limitations under the License. | ||
| 18 | - | ||
| 19 | # 1. 全局统计信息 podNum, serNum, rankNum 都小于 1024 | 11 | # 1. 全局统计信息 podNum, serNum, rankNum 都小于 1024 |
| 20 | meta: | 12 | meta: |
| 21 | podNum: 1 | 13 | podNum: 1 |
| @@ -8,14 +8,6 @@ | |||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ----------------------------------------------------------------------------------------------------------- | 9 | # ----------------------------------------------------------------------------------------------------------- |
| 10 | 10 | ||
| 11 | -# You may not use this file except in compliance with the License. | ||
| 12 | -# You may obtain a copy of the License at | ||
| 13 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 14 | -# Unless required by applicable law or agreed to in writing, software | ||
| 15 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | -# See the License for the specific language governing permissions and limitations under the License. | ||
| 18 | - | ||
| 19 | # 1. 全局统计信息 podNum, serNum, rankNum 都小于 1024 | 11 | # 1. 全局统计信息 podNum, serNum, rankNum 都小于 1024 |
| 20 | meta: | 12 | meta: |
| 21 | podNum: 1 | 13 | podNum: 1 |
| @@ -8,14 +8,6 @@ | |||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ----------------------------------------------------------------------------------------------------------- | 9 | # ----------------------------------------------------------------------------------------------------------- |
| 10 | 10 | ||
| 11 | -# You may not use this file except in compliance with the License. | ||
| 12 | -# You may obtain a copy of the License at | ||
| 13 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 14 | -# Unless required by applicable law or agreed to in writing, software | ||
| 15 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | -# See the License for the specific language governing permissions and limitations under the License. | ||
| 18 | - | ||
| 19 | # 1. 全局统计信息 podNum, serNum, rankNum 都小于 1024 | 11 | # 1. 全局统计信息 podNum, serNum, rankNum 都小于 1024 |
| 20 | meta: | 12 | meta: |
| 21 | podNum: 1 | 13 | podNum: 1 |
| @@ -8,14 +8,6 @@ | |||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ----------------------------------------------------------------------------------------------------------- | 9 | # ----------------------------------------------------------------------------------------------------------- |
| 10 | 10 | ||
| 11 | -# You may not use this file except in compliance with the License. | ||
| 12 | -# You may obtain a copy of the License at | ||
| 13 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 14 | -# Unless required by applicable law or agreed to in writing, software | ||
| 15 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | -# See the License for the specific language governing permissions and limitations under the License. | ||
| 18 | - | ||
| 19 | # 1. 全局统计信息 podNum, serNum, rankNum 都小于 1024 | 11 | # 1. 全局统计信息 podNum, serNum, rankNum 都小于 1024 |
| 20 | meta: | 12 | meta: |
| 21 | podNum: 1 | 13 | podNum: 1 |
| @@ -8,14 +8,6 @@ | |||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ----------------------------------------------------------------------------------------------------------- | 9 | # ----------------------------------------------------------------------------------------------------------- |
| 10 | 10 | ||
| 11 | -# You may not use this file except in compliance with the License. | ||
| 12 | -# You may obtain a copy of the License at | ||
| 13 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 14 | -# Unless required by applicable law or agreed to in writing, software | ||
| 15 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | -# See the License for the specific language governing permissions and limitations under the License. | ||
| 18 | - | ||
| 19 | # 1. 全局统计信息 podNum, serNum, rankNum 都小于 1024 | 11 | # 1. 全局统计信息 podNum, serNum, rankNum 都小于 1024 |
| 20 | meta: | 12 | meta: |
| 21 | podNum: 1 | 13 | podNum: 1 |
| @@ -8,14 +8,6 @@ | |||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ----------------------------------------------------------------------------------------------------------- | 9 | # ----------------------------------------------------------------------------------------------------------- |
| 10 | 10 | ||
| 11 | -# You may not use this file except in compliance with the License. | ||
| 12 | -# You may obtain a copy of the License at | ||
| 13 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 14 | -# Unless required by applicable law or agreed to in writing, software | ||
| 15 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | -# See the License for the specific language governing permissions and limitations under the License. | ||
| 18 | - | ||
| 19 | # 1. 全局统计信息 podNum, serNum, rankNum 都小于 1024 | 11 | # 1. 全局统计信息 podNum, serNum, rankNum 都小于 1024 |
| 20 | meta: | 12 | meta: |
| 21 | podNum: 1 | 13 | podNum: 1 |
| @@ -8,14 +8,6 @@ | |||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ----------------------------------------------------------------------------------------------------------- | 9 | # ----------------------------------------------------------------------------------------------------------- |
| 10 | 10 | ||
| 11 | -# You may not use this file except in compliance with the License. | ||
| 12 | -# You may obtain a copy of the License at | ||
| 13 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 14 | -# Unless required by applicable law or agreed to in writing, software | ||
| 15 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | -# See the License for the specific language governing permissions and limitations under the License. | ||
| 18 | - | ||
| 19 | # 1. 全局统计信息 podNum, serNum, rankNum 都小于 1024 | 11 | # 1. 全局统计信息 podNum, serNum, rankNum 都小于 1024 |
| 20 | meta: | 12 | meta: |
| 21 | podNum: 1 | 13 | podNum: 1 |
| @@ -8,14 +8,6 @@ | |||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ----------------------------------------------------------------------------------------------------------- | 9 | # ----------------------------------------------------------------------------------------------------------- |
| 10 | 10 | ||
| 11 | -# You may not use this file except in compliance with the License. | ||
| 12 | -# You may obtain a copy of the License at | ||
| 13 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 14 | -# Unless required by applicable law or agreed to in writing, software | ||
| 15 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | -# See the License for the specific language governing permissions and limitations under the License. | ||
| 18 | - | ||
| 19 | hccl_vm: | 11 | hccl_vm: |
| 20 | console_level: 2 | 12 | console_level: 2 |
| 21 | file_level: 1 | 13 | file_level: 1 |
| @@ -10,15 +10,6 @@ | |||
| 10 | # See LICENSE in the root of the software repository for the full text of the License. | 10 | # See LICENSE in the root of the software repository for the full text of the License. |
| 11 | # ----------------------------------------------------------------------------------------------------------- | 11 | # ----------------------------------------------------------------------------------------------------------- |
| 12 | 12 | ||
| 13 | -# You may not use this file except in compliance with the License. | ||
| 14 | -# You may obtain a copy of the License at | ||
| 15 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 16 | -# Unless required by applicable law or agreed to in writing, software | ||
| 17 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 18 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 19 | -# See the License for the specific language governing permissions and limitations under the License. | ||
| 20 | - | ||
| 21 | -#!/usr/bin/env python3 | ||
| 22 | """ | 13 | """ |
| 23 | FAQ Markdown 转 HTML 转换脚本 | 14 | FAQ Markdown 转 HTML 转换脚本 |
| 24 | 15 | ||
| @@ -10,15 +10,6 @@ | |||
| 10 | # See LICENSE in the root of the software repository for the full text of the License. | 10 | # See LICENSE in the root of the software repository for the full text of the License. |
| 11 | # ----------------------------------------------------------------------------------------------------------- | 11 | # ----------------------------------------------------------------------------------------------------------- |
| 12 | 12 | ||
| 13 | -# You may not use this file except in compliance with the License. | ||
| 14 | -# You may obtain a copy of the License at | ||
| 15 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 16 | -# Unless required by applicable law or agreed to in writing, software | ||
| 17 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 18 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 19 | -# See the License for the specific language governing permissions and limitations under the License. | ||
| 20 | - | ||
| 21 | -#!/usr/bin/env python3 | ||
| 22 | """ | 13 | """ |
| 23 | FAQ Markdown 转 HTML 转换脚本 | 14 | FAQ Markdown 转 HTML 转换脚本 |
| 24 | 15 | ||
| @@ -4,11 +4,19 @@ | |||
| 4 | 4 | ||
| 5 | | 项目 | 内容 | | 5 | | 项目 | 内容 | |
| 6 | |----------|--------------------------------| | 6 | |----------|--------------------------------| |
| 7 | -| 版本 | v1.0 | | 7 | +| 版本 | v2.0 | |
| 8 | -| 更新日期 | 2025-01-16 | | 8 | +| 更新日期 | 2026-09-17 | |
| 9 | | 适用场景 | HCCL VM 仿真数据导出与读取 | | 9 | | 适用场景 | HCCL VM 仿真数据导出与读取 | |
| 10 | | 作者 | HCCL VM Team | | 10 | | 作者 | HCCL VM Team | |
| 11 | 11 | ||
| 12 | +> **v2.0 变更说明**:综合数据文件(`*_hcclvm_syn_data.bin`)**version 保持 1,文件头不做版本变更** | ||
| 13 | +> (本特性不做新旧文件兼容性区分)。`ChannelData` 二进制布局与历史版本**一致(未新增字段,176 字节)**, | ||
| 14 | +> 但 AICPU 模式 dump **语义**变更以支持多 channel(`HCCL_UB_MULTI_CHANNEL_NUM`)特性: | ||
| 15 | +> jetty 精确归属到(本端 eid, 对端 eid)链路 + **每 eid 对一条聚合记录** | ||
| 16 | +> (`jettyNum` 为该 eid 对的 jetty 个数,`jettyId[0..jettyNum)` 携带全部本端 jetty, | ||
| 17 | +> 读取方需在数组内查找 `task.jettyId`,不能再假定 `jettyNum` 恒为 1 或直接取 `jettyId[0]`)。 | ||
| 18 | +> 任务/微码/flag 文件格式不变。 | ||
| 19 | + | ||
| 12 | --- | 20 | --- |
| 13 | 21 | ||
| 14 | ## 1. 概述 | 22 | ## 1. 概述 |
| @@ -34,7 +42,7 @@ | |||
| 34 | | 偏移量 | 字节数 | 类型 | 字段名 | 说明 | | 42 | | 偏移量 | 字节数 | 类型 | 字段名 | 说明 | |
| 35 | |:------:|:------:|---------|-------------|----------------------------| | 43 | |:------:|:------:|---------|-------------|----------------------------| |
| 36 | | 0 | 4 | uint32 | magic | 魔数,标识文件类型 | | 44 | | 0 | 4 | uint32 | magic | 魔数,标识文件类型 | |
| 37 | -| 4 | 2 | uint16 | version | 版本号(当前为 1) | | 45 | +| 4 | 2 | uint16 | version | 版本号(当前为 1) | |
| 38 | | 6 | 2 | uint16 | header_size | 文件头大小(20 字节) | | 46 | | 6 | 2 | uint16 | header_size | 文件头大小(20 字节) | |
| 39 | | 8 | 4 | uint32 | flags | 标志位(保留) | | 47 | | 8 | 4 | uint32 | flags | 标志位(保留) | |
| 40 | | 12 | 4 | uint32 | count | 数据条目数量 | | 48 | | 12 | 4 | uint32 | count | 数据条目数量 | |
| @@ -65,7 +73,7 @@ struct FileHeader { | |||
| 65 | |:----:|----------------------------------|----------|----------------------------------------------| | 73 | |:----:|----------------------------------|----------|----------------------------------------------| |
| 66 | | 1 | FileHeader | 20 Bytes | 文件头 | | 74 | | 1 | FileHeader | 20 Bytes | 文件头 | |
| 67 | | 2 | ModelInfo | 变长 | 模型信息(含 ModelInfoCommInner、VDataDesTag、All2AllDataDesTag) | | 75 | | 2 | ModelInfo | 变长 | 模型信息(含 ModelInfoCommInner、VDataDesTag、All2AllDataDesTag) | |
| 68 | -| 3 | ChannelInfo 或 JettyInfo | 变长 | 二选一,由 `op_expansion_mode` 决定 | | 76 | +| 3 | ChannelInfo(CCU/AICPU 共用) | 变长 | AIV 模式无此数据块 | |
| 69 | | 4 | MemLayoutInfo | 变长 | 内存布局信息 | | 77 | | 4 | MemLayoutInfo | 变长 | 内存布局信息 | |
| 70 | 78 | ||
| 71 | **op_expansion_mode 取值说明:** | 79 | **op_expansion_mode 取值说明:** |
| @@ -73,7 +81,7 @@ struct FileHeader { | |||
| 73 | | 值 | 模式 | 使用的数据结构 | | 81 | | 值 | 模式 | 使用的数据结构 | |
| 74 | |:--:|---------|----------------| | 82 | |:--:|---------|----------------| |
| 75 | | 0 | CCU | ChannelInfo | | 83 | | 0 | CCU | ChannelInfo | |
| 76 | -| 1 | AICPU | JettyInfo | | 84 | +| 1 | AICPU | ChannelInfo(多 channel 语义见 3.3.3) | |
| 77 | 85 | ||
| 78 | ### 3.2 ModelInfo 结构 | 86 | ### 3.2 ModelInfo 结构 |
| 79 | 87 | ||
| @@ -126,7 +134,7 @@ struct FileHeader { | |||
| 126 | 134 | ||
| 127 | ### 3.3 ChannelInfo 结构 | 135 | ### 3.3 ChannelInfo 结构 |
| 128 | 136 | ||
| 129 | -**适用条件**:`op_expansion_mode = 0`(CCU 模式) | 137 | +**适用条件**:`op_expansion_mode = 0`(CCU 模式)或 `1`(AICPU 模式)——两种模式均使用 ChannelData 定长结构;AIV 模式不写。 |
| 130 | 138 | ||
| 131 | #### 3.3.1 ChannelInfo 头部 | 139 | #### 3.3.1 ChannelInfo 头部 |
| 132 | 140 | ||
| @@ -137,24 +145,40 @@ struct FileHeader { | |||
| 137 | 145 | ||
| 138 | #### 3.3.2 ChannelData | 146 | #### 3.3.2 ChannelData |
| 139 | 147 | ||
| 140 | -**大小**:152 字节。 | 148 | +**大小**:176 字节(布局与历史版本一致)。 |
| 141 | 149 | ||
| 142 | -| 偏移量 | 字节数 | 类型 | 字段名 | 说明 | | 150 | +| 偏移量 | 字节数 | 类型 | 字段名 | 说明 | |
| 143 | |:------:|:------:|------------|-----------|---------------| | 151 | |:------:|:------:|------------|-----------|---------------| |
| 144 | -| 0 | 2 | uint16 | channelId | 通道 ID | | 152 | +| 0 | 2 | uint16 | channelId | CCU 模式: 通道 ID;AICPU 模式: EndPointPair 主键(eid 对标识) | |
| 145 | | 2 | 1 | uint8 | srcDieId | 源 Die ID | | 153 | | 2 | 1 | uint8 | srcDieId | 源 Die ID | |
| 146 | | 3 | 1 | uint8 | dstDieId | 目标 Die ID | | 154 | | 3 | 1 | uint8 | dstDieId | 目标 Die ID | |
| 147 | | 4 | 4 | uint32 | srcRank | 源 Rank ID | | 155 | | 4 | 4 | uint32 | srcRank | 源 Rank ID | |
| 148 | | 8 | 4 | uint32 | dstRank | 目标 Rank ID | | 156 | | 8 | 4 | uint32 | dstRank | 目标 Rank ID | |
| 149 | -| 12 | 16 | uint8[16] | leid | 本端 EID | | 157 | +| 12 | 16 | uint8[16] | leid | 本端 EID | |
| 150 | -| 28 | 16 | uint8[16] | reid | 远端 EID | | 158 | +| 28 | 16 | uint8[16] | reid | 远端 EID | |
| 151 | | 44 | 2 | uint16 | protocol | 协议类型 | | 159 | | 44 | 2 | uint16 | protocol | 协议类型 | |
| 152 | | 46 | 2 | uint16 | jettyNum | Jetty 数量 | | 160 | | 46 | 2 | uint16 | jettyNum | Jetty 数量 | |
| 153 | -| 48 | 128 | uint32[32] | jettyId | Jetty ID 数组 | | 161 | +| 48 | 128 | uint32[32] | jettyId | Jetty ID 数组 | |
| 154 | 162 | ||
| 155 | -### 3.4 JettyInfo 结构 | 163 | +#### 3.3.3 多 channel 语义(AICPU 模式) |
| 156 | 164 | ||
| 157 | -**适用条件**:`op_expansion_mode = 1`(AICPU 模式) | 165 | +`HCCL_UB_MULTI_CHANNEL_NUM=N` 特性下,同一对 rank(同一对 eid)之间存在 N 条并行 channel, |
| 166 | +AICPU 模式 dump 规则: | ||
| 167 | + | ||
| 168 | +1. **每 eid 对一条聚合 ChannelData 记录**:同一 `channelId`(eid 对)的 N 条 channel 输出 **1 条**记录, | ||
| 169 | + `jettyNum=N`,`jettyId[0..jettyNum)` 为该 eid 对上**全部本端(发送侧)jetty**, | ||
| 170 | + 按**本端 jetty 创建序**排列(数组下标即 pair 内 channel 序号); | ||
| 171 | +2. 读取方将任务元数据中的 `task.jettyId` 在 `jettyId[0..jettyNum)` **数组内查找**, | ||
| 172 | + 即得任务经由哪个 jetty 从本端哪个 eid(`leid`)发往对端哪个 eid(`reid`); | ||
| 173 | +3. `jettyId[0..jettyNum)` **精确归属**到该 eid 对(由 RA 层 `RaCtxQpImport` 回填归属信息), | ||
| 174 | + 不含该本端 eid 上通往其它对端的 jetty。 | ||
| 175 | + | ||
| 176 | +CCU 模式维持"每 channel 一条记录、`jettyId[]` 携带该 channel 的 jetty 列表"的既有语义。 | ||
| 177 | + | ||
| 178 | +### 3.4 JettyInfo 结构(未使用,保留历史说明) | ||
| 179 | + | ||
| 180 | +`JettyData` 为早期设计中 AICPU 模式的独立结构,**当前实现未使用**:AICPU 模式实际同样写 | ||
| 181 | +ChannelData(见 3.3)。本节保留仅作历史格式参考,读取方不应按 JettyData 解析 AICPU 数据。 | ||
| 158 | 182 | ||
| 159 | #### 3.4.1 JettyInfo 头部 | 183 | #### 3.4.1 JettyInfo 头部 |
| 160 | 184 | ||
| @@ -346,7 +370,7 @@ struct FileHeader { | |||
| 346 | | 值 | 名称 | 说明 | | 370 | | 值 | 名称 | 说明 | |
| 347 | |:--:|---------------------------------|---------------------------| | 371 | |:--:|---------------------------------|---------------------------| |
| 348 | | 0 | SIM_OP_EXPANSION_MODE_CCU | CCU 模式,使用 ChannelInfo | | 372 | | 0 | SIM_OP_EXPANSION_MODE_CCU | CCU 模式,使用 ChannelInfo | |
| 349 | -| 1 | SIM_OP_EXPANSION_MODE_AICPU | AICPU 模式,使用 JettyInfo | | 373 | +| 1 | SIM_OP_EXPANSION_MODE_AICPU | AICPU 模式,使用 ChannelInfo | |
| 350 | 374 | ||
| 351 | --- | 375 | --- |
| 352 | 376 | ||
| @@ -392,10 +416,10 @@ struct ModelInfoCommInner { | |||
| 392 | }; | 416 | }; |
| 393 | 417 | ||
| 394 | // ============================================================================ | 418 | // ============================================================================ |
| 395 | -// 通道数据 (CCU 模式) | 419 | +// 通道数据 (CCU / AICPU 模式共用) |
| 396 | // ============================================================================ | 420 | // ============================================================================ |
| 397 | struct ChannelData { | 421 | struct ChannelData { |
| 398 | - uint16_t channelId; | 422 | + uint16_t channelId; // CCU: 通道ID; AICPU: EndPointPair主键(eid对标识) |
| 399 | uint8_t srcDieId; | 423 | uint8_t srcDieId; |
| 400 | uint8_t dstDieId; | 424 | uint8_t dstDieId; |
| 401 | uint32_t srcRank; | 425 | uint32_t srcRank; |
| @@ -403,12 +427,12 @@ struct ChannelData { | |||
| 403 | uint8_t leid[16]; | 427 | uint8_t leid[16]; |
| 404 | uint8_t reid[16]; | 428 | uint8_t reid[16]; |
| 405 | uint16_t protocol; | 429 | uint16_t protocol; |
| 406 | - uint16_t jettyNum; | 430 | + uint16_t jettyNum; // AICPU: 该eid对的本端jetty个数(多channel时可大于1); CCU: 该channel的jetty个数 |
| 407 | - uint32_t jettyId[32]; | 431 | + uint32_t jettyId[32]; // AICPU: 该eid对全部本端(发送)jetty, 按创建序排列, task.jettyId在数组内查找 |
| 408 | }; | 432 | }; |
| 409 | 433 | ||
| 410 | // ============================================================================ | 434 | // ============================================================================ |
| 411 | -// Jetty 数据 (AICPU 模式) | 435 | +// Jetty 数据(未使用的历史结构;AICPU 实际使用 ChannelData,见上方) |
| 412 | // ============================================================================ | 436 | // ============================================================================ |
| 413 | struct JettyData { | 437 | struct JettyData { |
| 414 | uint32_t jettyId; | 438 | uint32_t jettyId; |
| @@ -572,9 +596,8 @@ bool ReadSynthesisData(const char* filename) { | |||
| 572 | std::cout << "\n[All2All] Matrix Count: " << matrixCount << std::endl; | 596 | std::cout << "\n[All2All] Matrix Count: " << matrixCount << std::endl; |
| 573 | } | 597 | } |
| 574 | 598 | ||
| 575 | - // ===== Step 5: 根据 op_expansion_mode 读取通道或 Jetty 信息 ===== | 599 | + // ===== Step 5: 读取 ChannelInfo(CCU 与 AICPU 模式均为 ChannelData 定长结构;AIV 模式无此段) ===== |
| 576 | - if (modelComm.op_expansion_mode == 0) { | 600 | + if (modelComm.op_expansion_mode != 2) { |
| 577 | - // CCU 模式 - 读取 ChannelInfo | ||
| 578 | uint32_t channelCount; | 601 | uint32_t channelCount; |
| 579 | fread(&channelCount, sizeof(uint32_t), 1, fp); | 602 | fread(&channelCount, sizeof(uint32_t), 1, fp); |
| 580 | 603 | ||
| @@ -585,21 +608,12 @@ bool ReadSynthesisData(const char* filename) { | |||
| 585 | for (size_t i = 0; i < channels.size() && i < 3; ++i) { | 608 | for (size_t i = 0; i < channels.size() && i < 3; ++i) { |
| 586 | std::cout << " Channel[" << i << "]: ID=" << channels[i].channelId | 609 | std::cout << " Channel[" << i << "]: ID=" << channels[i].channelId |
| 587 | << ", srcRank=" << channels[i].srcRank | 610 | << ", srcRank=" << channels[i].srcRank |
| 588 | - << ", dstRank=" << channels[i].dstRank << std::endl; | 611 | + << ", dstRank=" << channels[i].dstRank |
| 589 | - } | 612 | + << ", jettyNum=" << channels[i].jettyNum; |
| 590 | - } else { | 613 | + for (uint16_t j = 0; j < channels[i].jettyNum; ++j) { |
| 591 | - // AICPU 模式 - 读取 JettyInfo | 614 | + std::cout << ", jetty[" << j << "]=" << channels[i].jettyId[j]; |
| 592 | - uint32_t jettyCount; | 615 | + } |
| 593 | - fread(&jettyCount, sizeof(uint32_t), 1, fp); | 616 | + std::cout << std::endl; |
| 594 | - | ||
| 595 | - std::vector<JettyData> jetties(jettyCount); | ||
| 596 | - fread(jetties.data(), sizeof(JettyData), jettyCount, fp); | ||
| 597 | - | ||
| 598 | - std::cout << "\n[JettyInfo] Count: " << jettyCount << std::endl; | ||
| 599 | - for (size_t i = 0; i < jetties.size() && i < 3; ++i) { | ||
| 600 | - std::cout << " Jetty[" << i << "]: ID=" << jetties[i].jettyId | ||
| 601 | - << ", srcRank=" << jetties[i].srcRank | ||
| 602 | - << ", dstRank=" << jetties[i].dstRank << std::endl; | ||
| 603 | } | 617 | } |
| 604 | } | 618 | } |
| 605 | 619 | ||
| @@ -704,7 +718,7 @@ bool ReadTaskMetaData(const char* filename) { | |||
| 704 | | 1 | 字节序 | 所有多字节字段均采用**小端序**(Little-Endian) | | 718 | | 1 | 字节序 | 所有多字节字段均采用**小端序**(Little-Endian) | |
| 705 | | 2 | 内存对齐 | 结构体使用 `#pragma pack(1)` 进行 **1 字节对齐** | | 719 | | 2 | 内存对齐 | 结构体使用 `#pragma pack(1)` 进行 **1 字节对齐** | |
| 706 | | 3 | 变长字段读取 | 先读取 `count` 字段,再根据 count 值读取相应数量的数据 | | 720 | | 3 | 变长字段读取 | 先读取 `count` 字段,再根据 count 值读取相应数量的数据 | |
| 707 | -| 4 | 模式判断 | 根据 `op_expansion_mode` 判断读取 ChannelInfo 还是 JettyInfo | | 721 | +| 4 | 模式判断 | CCU 与 AICPU 模式均读取 ChannelInfo(ChannelData 定长结构);AIV 模式无此段;JettyData 为未使用的历史结构 | |
| 708 | | 5 | 联合体解析 | 任务元数据中的 `taskData` 需根据 `taskType` 选择正确的结构体 | | 722 | | 5 | 联合体解析 | 任务元数据中的 `taskData` 需根据 `taskType` 选择正确的结构体 | |
| 709 | | 6 | 魔数验证 | 读取文件时务必先验证魔数,确保文件类型正确 | | 723 | | 6 | 魔数验证 | 读取文件时务必先验证魔数,确保文件类型正确 | |
| 710 | 724 | ||
| @@ -1,355 +0,0 @@ | |||
| 1 | -# CheckerL2 Third-Party Header File Dependency List | ||
| 2 | - | ||
| 3 | -> This list is based on the `CheckerL2` version and covers all third-party header file dependencies. | ||
| 4 | - | ||
| 5 | -## Description | ||
| 6 | - | ||
| 7 | -This document lists all third-party header files that the project references through `#include`. Each entry marks its origin (CANN / HCCL / HCOMM) and its actual path on disk. | ||
| 8 | - | ||
| 9 | -**Path Conventions**: | ||
| 10 | -- CANN root directory: `/home/teamserver/workspace/Ascend/cann-9.1.0/` (abbreviated as `CANN/` below) | ||
| 11 | -- HCOMM root directory: `/home/teamserver/workspace/hcomm/` (abbreviated as `HCOMM/` below) | ||
| 12 | -- HCCL root directory: `/home/teamserver/workspace/hccl/` (abbreviated as `HCCL/` below) | ||
| 13 | -- Project root directory: `CheckerL2/` (abbreviated as `Project/` below) | ||
| 14 | - | ||
| 15 | -**Resolution Principle**: The declaration order of `target_include_directories` in CMake determines the search priority. The compiler uses the first match found. | ||
| 16 | - | ||
| 17 | ---- | ||
| 18 | - | ||
| 19 | -## 1. Header Files from CANN | ||
| 20 | - | ||
| 21 | -### 1.1 ACL Runtime Interfaces (`CANN/include/acl/`) | ||
| 22 | - | ||
| 23 | -| #include | Actual File Path | Reference Locations | | ||
| 24 | -|----------|------------|---------| | ||
| 25 | -| `acl/acl_base.h` | `CANN/include/acl/acl_base.h` | all aclrt_*.cc under proxy, hccl_comm_stub.cc, hccp_stub.cc, hccp_ra_socket_stub.cc, ascend_hal_stub.cc, aclrt_exec_control.cc; include/runnerdb/db_sim_runner_common.h; test/proxy/ | | ||
| 26 | -| `acl/acl_rt.h` | `CANN/include/acl/acl_rt.h` | all aclrt_*.cc under proxy, hccl_op_stub.cc; test/proxy/ | | ||
| 27 | - | ||
| 28 | -### 1.2 HCCL Public Interfaces (`CANN/include/hccl/`) | ||
| 29 | - | ||
| 30 | -| #include | Actual File Path | Reference Locations | | ||
| 31 | -|----------|------------|---------| | ||
| 32 | -| `hccl/hccl_types.h` | `CANN/include/hccl/hccl_types.h` | proxy/aclrt_kernel_stub.cc, hccl_op_stub.cc, hccl_proxy_common.h; plugin/runner/ccu_executor/ccu_fp16.h; common/sim_data_dump.cc; device_arm/level2/proxy/device_sqe_parse_stub.h; test/proxy/ | | ||
| 33 | -| `hccl/hccl.h` | `CANN/include/hccl/hccl.h` | **proxy/hccl_op_stub.cc**; test/proxy/hccl_comm_stub_test.cc | | ||
| 34 | -| `hccl/hcom.h` | `CANN/include/hccl/hcom.h` | proxy/hccl_inner_stub.cc; test/proxy/hccl_inner_stub_test.cc | | ||
| 35 | -| `hccl/base.h` | `CANN/include/hccl/base.h` | proxy/aclrt_context_stub.cc; plugin/runner/ccu_executor/ccu_fp16.h; plugin/checker/header/external/task_param.h; include/sim_ip_address.h | | ||
| 36 | -| `hccl/dtype_common.h` | `CANN/include/hccl/dtype_common.h` | proxy/scatter_stub.cc; test/proxy/scatter_stub_test.cc | | ||
| 37 | -| `hccl/hccl_common.h` | `CANN/x86_64-linux/asc/include/adv_api/hccl/hccl_common.h` | test/proxy/hccl_proxy_common_test.cc | | ||
| 38 | - | ||
| 39 | -### 1.3 HCCL Internal Interfaces (`CANN/pkg_inc/hccl/`) | ||
| 40 | - | ||
| 41 | -| #include | Actual File Path | Reference Locations | | ||
| 42 | -|----------|------------|---------| | ||
| 43 | -| `"dtype_common.h"` | `CANN/pkg_inc/hccl/dtype_common.h` | proxy/aclrt_new_stub.cc, hccp_ccu_stub.cc, hccp_stub.cc, hccl_op_stub.cc, aclrt_device_stub.cc, hccl_proxy_common.cc; plugin/runner/runner_utils/storage_manager.h; plugin/checker/src/framework/task_graph_generator_v3/ccu_graph_generator_v3/ccu_all_rank_param_recorder_v3.h; plugin/checker/src/framework/task_graph_generator/ccu_all_rank_param_recorder.h; plugin/checker/src/utils/storage_manager.h | | ||
| 44 | - | ||
| 45 | -### 1.4 CANN Runtime Interfaces (`CANN/pkg_inc/runtime/`) | ||
| 46 | - | ||
| 47 | -| #include | Actual File Path | Reference Locations | | ||
| 48 | -|----------|------------|---------| | ||
| 49 | -| `"runtime/base.h"` | `CANN/pkg_inc/runtime/runtime/base.h` | proxy/hccl_comm_stub.cc, aclrt_runtime_config.cc, aclrt_notify_stub.cc, hccp_stub.cc, aclrt_device_stub.cc, hccp_ra_socket_stub.cc, aclrt_stream_stub.cc, aclrt_stub.cc; test/proxy/ | | ||
| 50 | -| `"runtime/event.h"` | `CANN/pkg_inc/runtime/runtime/event.h` | proxy/aclrt_runtime_config.cc, aclrt_notify_stub.cc | | ||
| 51 | -| `"runtime/rt.h"` | `CANN/pkg_inc/runtime/runtime/rt.h` | device_arm/level2/proxy/device_sqe_parse_stub.h | | ||
| 52 | - | ||
| 53 | -### 1.5 CANN Profiling Interfaces (`CANN/pkg_inc/profiling/`) | ||
| 54 | - | ||
| 55 | -| #include | Actual File Path | Reference Locations | | ||
| 56 | -|----------|------------|---------| | ||
| 57 | -| `"aprof_pub.h"` | `CANN/pkg_inc/profiling/aprof_pub.h` | proxy/aprofiling_stub.cc; device_arm/level2/proxy/aprofiling_stub.cc; test/proxy/aprofiling_stub_test.cc | | ||
| 58 | - | ||
| 59 | -### 1.6 CANN Trace Interfaces (`CANN/pkg_inc/trace/`) | ||
| 60 | - | ||
| 61 | -| #include | Actual File Path | Reference Locations | | ||
| 62 | -|----------|------------|---------| | ||
| 63 | -| `"atrace_pub.h"` | `CANN/pkg_inc/trace/atrace_pub.h` | proxy/adapter_rts_stub.cc | | ||
| 64 | -| `"atrace_types.h"` | `CANN/pkg_inc/trace/atrace_types.h` | proxy/aclrt_new_stub.cc, hccp_stub.cc | | ||
| 65 | - | ||
| 66 | -### 1.7 CANN Driver Interfaces (`CANN/include/driver/`) | ||
| 67 | - | ||
| 68 | -| #include | Actual File Path | Reference Locations | | ||
| 69 | -|----------|------------|---------| | ||
| 70 | -| `"ascend_hal.h"` | `CANN/include/driver/ascend_hal.h` | proxy/adapter_rts_stub.cc, aclrt_new_stub.cc, ascend_hal_stub.cc; device_arm/level2/proxy/device_sqe_parse_stub.h, ascend_hal_stub.cc; test/device_arm/ | | ||
| 71 | - | ||
| 72 | -### 1.8 CANN Base Interfaces (`CANN/pkg_inc/base/`) | ||
| 73 | - | ||
| 74 | -| #include | Actual File Path | Reference Locations | | ||
| 75 | -|----------|------------|---------| | ||
| 76 | -| `"dlog_pub.h"` | `CANN/pkg_inc/base/dlog_pub.h` | plugin/checker/header/external/log.h (as fallback) | | ||
| 77 | -| `"log_types.h"` | `CANN/pkg_inc/base/log_types.h` | plugin/checker/header/external/dlog_pub.h | | ||
| 78 | - | ||
| 79 | -### 1.9 CANN CCU Microcode Interfaces (`CANN/pkg_inc/hcomm/ccu/`) | ||
| 80 | - | ||
| 81 | -| #include | Actual File Path | Reference Locations | | ||
| 82 | -|----------|------------|---------| | ||
| 83 | -| `"ccu_microcode_v1.h"` | `CANN/pkg_inc/hcomm/ccu/ccu_microcode_v1.h` | proxy/hccp_ccu_stub.cc; plugin/runner/ccu_executor/ccu_resource_manager.cc, ccu_resource_common.h; plugin/checker/header/external/ccu_rep_base.h, ccu_instr_info.h; plugin/checker/header/internal/binary_data_type_pub.h; multiple files under plugin/checker/src/framework/task_graph_generator_v3/ccu_graph_generator_v3/; multiple files under plugin/checker/src/framework/task_graph_generator/; include/sim_binary_data_type_pub.h | | ||
| 84 | -| `"ccu_common.h"` | `CANN/pkg_inc/hcomm/ccu/ccu_common.h` | proxy/hccp_ccu_stub.cc | | ||
| 85 | - | ||
| 86 | -### 1.10 CANN RTS Device Interfaces (`CANN/pkg_inc/runtime/runtime/rts/`) | ||
| 87 | - | ||
| 88 | -| #include | Actual File Path | Reference Locations | | ||
| 89 | -|----------|------------|---------| | ||
| 90 | -| `"rts_device.h"` | `CANN/pkg_inc/runtime/runtime/rts/rts_device.h` | proxy/hccp_stub.cc, adapter_rts_stub.cc, aclrt_new_stub.cc | | ||
| 91 | - | ||
| 92 | -### 1.11 CANN Runtime Other Interfaces (`CANN/pkg_inc/runtime/`) | ||
| 93 | - | ||
| 94 | -| #include | Actual File Path | Reference Locations | | ||
| 95 | -|----------|------------|---------| | ||
| 96 | -| `"mem.h"` | `CANN/pkg_inc/runtime/mem.h` | proxy/hccp_stub.cc, aclrt_new_stub.cc | | ||
| 97 | -| `"rt_external_kernel.h"` | `CANN/pkg_inc/runtime/rt_external_kernel.h` | proxy/hccp_ccu_stub.cc | | ||
| 98 | - | ||
| 99 | ---- | ||
| 100 | - | ||
| 101 | -## 2. Header Files from HCOMM | ||
| 102 | - | ||
| 103 | -### 2.1 HCCP Network Interfaces (`HCOMM/src/base_comm/resources/hccp/inc/network/`) | ||
| 104 | - | ||
| 105 | -| #include | Actual File Path | Reference Locations | | ||
| 106 | -|----------|------------|---------| | ||
| 107 | -| `"hccp.h"` | `HCOMM/src/base_comm/resources/hccp/inc/network/hccp.h` | proxy/adapter_rts_stub.cc | | ||
| 108 | -| `"hccp_async.h"` | `HCOMM/src/base_comm/resources/hccp/inc/network/hccp_async.h` | proxy/adapter_rts_stub.cc | | ||
| 109 | -| `"hccp_ping.h"` | `HCOMM/src/base_comm/resources/hccp/inc/network/hccp_ping.h` | proxy/adapter_rts_stub.cc | | ||
| 110 | -| `"hccp_tlv.h"` | `HCOMM/src/base_comm/resources/hccp/inc/network/hccp_tlv.h` | proxy/adapter_rts_stub.cc, hccp_stub.cc, **hccp_ccu_stub.cc** | | ||
| 111 | -| `"hccp_ctx.h"` | `HCOMM/src/base_comm/resources/hccp/inc/network/hccp_ctx.h` | proxy/hccp_ccu_stub.cc, hccp_stub.cc | | ||
| 112 | -| `"hccp_common.h"` | `HCOMM/src/base_comm/resources/hccp/inc/network/hccp_common.h` | proxy/hccl_comm_stub.cc, aclrt_new_stub.cc, hccp_ccu_stub.cc, hccp_stub.cc, hccp_ra_socket_stub.cc | | ||
| 113 | - | ||
| 114 | -### 2.2 HCCP CCU External Dependencies (`HCOMM/src/base_comm/resources/hccp/external_depends/ccu/`) | ||
| 115 | - | ||
| 116 | -| #include | Actual File Path | Reference Locations | | ||
| 117 | -|----------|------------|---------| | ||
| 118 | -| `"ccu_u_comm.h"` | `HCOMM/src/base_comm/resources/hccp/external_depends/ccu/ccu_u_comm.h` | proxy/hccp_ccu_stub.cc | | ||
| 119 | - | ||
| 120 | ---- | ||
| 121 | - | ||
| 122 | -## 3. Header Files from HCCL (ARM Cross-Compilation Only) | ||
| 123 | - | ||
| 124 | -### 3.1 Operator Common Interfaces (`HCCL/src/ops/op_common/inc/`) | ||
| 125 | - | ||
| 126 | -| #include | Actual File Path | Reference Locations | | ||
| 127 | -|----------|------------|---------| | ||
| 128 | -| `"alg_param.h"` | `HCCL/src/ops/op_common/inc/alg_param.h` | device_arm/hccl_kernel_executor.cc; test/device_arm/ | | ||
| 129 | - | ||
| 130 | -### 3.2 HCCL Common Code (`HCCL/src/common/`) | ||
| 131 | - | ||
| 132 | -| #include | Actual File Path | Reference Locations | | ||
| 133 | -|----------|------------|---------| | ||
| 134 | -| (multiple headers exposed through include paths) | `HCCL/src/common/*.h` | the device_arm build module references these indirectly through include paths | | ||
| 135 | - | ||
| 136 | -### 3.3 Dynamic Symbol Loading (`HCCL/src/common/hcomm_dlsym/` and `ccu/`) | ||
| 137 | - | ||
| 138 | -| #include | Actual File Path | Reference Locations | | ||
| 139 | -|----------|------------|---------| | ||
| 140 | -| (multiple headers exposed through include paths) | `HCCL/src/common/hcomm_dlsym/*.h`, `HCCL/src/common/hcomm_dlsym/ccu/*.h`, `*.hpp` | the device_arm build module references these indirectly through include paths | | ||
| 141 | - | ||
| 142 | ---- | ||
| 143 | - | ||
| 144 | -## 4. Project Local External Header Files (Checker-Specific, HCCL Interface Definition Copies) | ||
| 145 | - | ||
| 146 | -Path: `Project/src/plugin/checker/header/external/` | ||
| 147 | - | ||
| 148 | -The project uses these local copies as a fallback when the CANN package does not contain a header file with the same name. | ||
| 149 | - | ||
| 150 | -| File Name | Description | Reference Locations | | ||
| 151 | -|-------|------|---------| | ||
| 152 | -| `hccl_types.h` | HcclResult enumeration (24 error codes including HCCL_SUCCESS) | 50+ files under plugin/checker/ reference this through `#include "hccl_types.h"`; include/sim_binary_data_type_pub.h, sim_loader.h, sim_ccu_jetty_ctx.h, sim_ccu_channel_ctx.h, and so on | | ||
| 153 | -| `base.h` | Basic type definitions | 19 references under plugin/checker/ (framework, semantics_check, checker, and so on); header/external/log.h | | ||
| 154 | -| `data_type.h` | Data type definitions | 3 references under plugin/checker/src/framework/task_graph_generator_v3/, 4 references under task_graph_generator/ | | ||
| 155 | -| `ccu_instr_info.h` | CCU instruction information | 8 references under plugin/checker/ (task_ccu.h, task_utils.cc, task_graph_generator, and so on) | | ||
| 156 | -| `ccu_task_param.h` | CCU task parameters | plugin/checker/src/utils/task_ccu.h | | ||
| 157 | -| `ccu_rep_base.h` | CCU Reporter base | the file exists; no direct `#include` reference currently | | ||
| 158 | -| `ccu_rep_type.h` | CCU Reporter types | the file exists; no direct `#include` reference currently | | ||
| 159 | -| `dlog_pub.h` | Logging public interface (CANN fallback) | plugin/checker/header/external/log.h | | ||
| 160 | -| `enum_factory.h` | Enumeration factory | 5 internal references under plugin/checker/ (sim_task.h, check_utils.h, data_slice.h, data_type.h, task_param.h) | | ||
| 161 | -| `const_val.h` | Constant value definitions | plugin/checker/header/external/task_param.h | | ||
| 162 | -| `log.h` | Logging interface | internal to plugin/checker/ | | ||
| 163 | -| `log_types.h` | Logging types (CANN fallback) | plugin/checker/header/external/dlog_pub.h | | ||
| 164 | -| `string_util.h` | String utilities | plugin/checker/header/external/enum_factory.h; header/internal/task_def.h; src/utils/check_utils.h | | ||
| 165 | -| `task_param.h` | Task parameters | the file exists; no direct `#include` reference currently (other header files include it internally) | | ||
| 166 | - | ||
| 167 | ---- | ||
| 168 | - | ||
| 169 | -## 5. AIV Dependencies (AIV Operator Simulation Only) | ||
| 170 | - | ||
| 171 | -This section describes the dependencies for AIV (AI Vector Core) operator simulation in the tool. These dependencies originate from the HCOMM repository and the AscendC programming interfaces. The tool maintains local backups of key definitions to remove strong dependencies on external repositories. | ||
| 172 | - | ||
| 173 | -### 5.1 AivOpArgs Data Structure (Local Backup in Project) | ||
| 174 | - | ||
| 175 | -**Original Source**: the `hccl_aiv_utils.h` header file from the HCOMM repository | ||
| 176 | - | ||
| 177 | -**Backup Location**: `src/proxy/level2/aclrt_kernel_stub.cc` lines 597-628 | ||
| 178 | - | ||
| 179 | -**Description**: `AivOpArgs` is the parameter structure for AIV collective communication operators. The structure passes AIV kernel execution parameters between the host side and the device side. The tool originally loaded the `ops_hccl::ExecuteKernelLaunch()` function from the HCOMM library through `dlsym` (symbol name: `_ZN8ops_hccl19ExecuteKernelLaunchERKNS_9AivOpArgsE`). That function accepts this structure as a parameter. The tool maintains a complete backup of the structure to remove the dependency on the HCOMM runtime library. | ||
| 180 | - | ||
| 181 | -**Structure Definition**: | ||
| 182 | -```cpp | ||
| 183 | -struct AivOpArgs { | ||
| 184 | - HcclCMDType cmdType = HcclCMDType::HCCL_CMD_MAX; // collective communication command type | ||
| 185 | - std::string comm = {}; // communication domain identifier | ||
| 186 | - HcclComm hcclComm = nullptr; // HCCL communicator handle | ||
| 187 | - uint32_t numBlocks = AIV_STUB_MAX_NUM_BLOCKS; // AIV core count | ||
| 188 | - void *stream = nullptr; // execution stream | ||
| 189 | - uint64_t beginTime = 0; // start timestamp | ||
| 190 | - OpCounterInfo counter = {}; // counter information | ||
| 191 | - void *buffersIn = nullptr; // input buffer address | ||
| 192 | - uint64_t input = 0; // input offset | ||
| 193 | - uint64_t output = 0; // output offset | ||
| 194 | - uint32_t rank = 0; // current rank | ||
| 195 | - uint32_t sendRecvRemoteRank = 0; // SendRecv remote rank | ||
| 196 | - uint32_t rankSize = 0; // total rank count | ||
| 197 | - uint64_t xRankSize = 0, yRankSize = 0, zRankSize = 0; // topology dimensions | ||
| 198 | - uint64_t count = 0; // element count | ||
| 199 | - HcclDataType dataType = HcclDataType::HCCL_DATA_TYPE_INT32; // data type | ||
| 200 | - HcclReduceOp op = HcclReduceOp::HCCL_REDUCE_SUM; // Reduce operation type | ||
| 201 | - uint32_t root = 0; // Root rank | ||
| 202 | - uint32_t sliceId = 0; // Slice ID | ||
| 203 | - uint64_t inputSliceStride = 0; // input slice stride | ||
| 204 | - uint64_t outputSliceStride = 0; // output slice stride | ||
| 205 | - uint64_t repeatNum = 0; // repeat count | ||
| 206 | - uint64_t inputRepeatStride = 0; // input repeat stride | ||
| 207 | - uint64_t outputRepeatStride = 0; // output repeat stride | ||
| 208 | - bool isOpBase = false; // whether this is a base operator | ||
| 209 | - ExtraArgs extraArgs = {}; // extra parameters (AllToAllV, and so on) | ||
| 210 | - uint64_t topo_[AIV_STUB_TOPO_LEN] = {0}; // topology information | ||
| 211 | - KernelArgsType argsType = KernelArgsType::ARGS_TYPE_SERVER; // parameter type | ||
| 212 | -}; | ||
| 213 | -``` | ||
| 214 | - | ||
| 215 | -**Dependency Risk**: Changes to the `AivOpArgs` structure on the HCOMM side (such as field additions, field removals, order changes, or type changes) may cause parameter misalignment during `dlsym` calls. This leads to runtime errors. | ||
| 216 | - | ||
| 217 | -### 5.2 aiv_communication_base_v2.h Header File (Local Backup in Project) | ||
| 218 | - | ||
| 219 | -**Original Source**: the header file with the same name from the HCOMM repository | ||
| 220 | - | ||
| 221 | -**Backup Location**: `src/proxy/level2/aiv_kernel/hccl_op_stub/aiv_communication_base_v2.h` | ||
| 222 | - | ||
| 223 | -**Description**: This header file defines the base class `AivCommBase` for AIV collective communication operators and the related kernel parameter macros (`KERNEL_ARGS_DEF`, `KERNEL_ARGS_CALL`, and so on). The tool originally included this file directly from the HCOMM repository. The tool maintains a complete backup to remove the dependency. | ||
| 224 | - | ||
| 225 | -**Key Definitions in the File**: | ||
| 226 | - | ||
| 227 | -| Definition | Description | | ||
| 228 | -|------|------| | ||
| 229 | -| `AivSuperKernelArgs` | SuperKernel parameter structure | | ||
| 230 | -| `ExtraArgs` | Extra parameter structure (sendCounts/recvCounts, and so on, for AllToAllV) | | ||
| 231 | -| `KERNEL_ARGS_DEF` / `KERNEL_ARGS_CALL` | AIV kernel parameter macros (approximately 25 parameters) | | ||
| 232 | -| `SUPERKERNEL_ARGS_DEF` / `SUPERKERNEL_ARGS_CALL` | SuperKernel parameter macros | | ||
| 233 | -| `AivCommBase` class | AIV communication base class that encapsulates core methods such as Barrier, Record/WaitFlag, and CpGM2GM | | ||
| 234 | -| `EXPORT_AIV_META_INFO` | AIV kernel metadata export macro | | ||
| 235 | -| `AIV_ATOMIC_DATA_TYPE_DEF` / `AIV_COPY_DATA_TYPE_DEF` | Supported data type macro definitions | | ||
| 236 | - | ||
| 237 | -**Dependency Risk**: Changes to the AIV communication interfaces or kernel parameters on the HCOMM side require a synchronized update to this backup file. | ||
| 238 | - | ||
| 239 | -### 5.3 AIV Operator Op Header Files (HCOMM / HCCL Dependencies) | ||
| 240 | - | ||
| 241 | -Each AIV kernel implementation file for a collective communication operator in the tool (`src/proxy/level2/aiv_kernel/hccl_op_stub/*/aiv_communication_v2.cc`) includes the corresponding operator op header file through `#include`. These header files **do not exist within the project**. They come from the HCOMM and HCCL repositories respectively: | ||
| 242 | - | ||
| 243 | -| #include | Source | Actual File Path | Reference Locations | | ||
| 244 | -|----------|------|------------|---------| | ||
| 245 | -| `"aiv_all_reduce_op.h"` | HCOMM | `hcomm/src/legacy/ascend910/algorithm/base/alg_aiv_template/all_reduce/` | hccl_op_stub/all_reduce/aiv_communication_v2.cc | | ||
| 246 | -| `"aiv_all_gather_op.h"` | HCOMM | `hcomm/src/legacy/ascend910/algorithm/base/alg_aiv_template/all_gather/` | hccl_op_stub/all_gather/aiv_communication_v2.cc | | ||
| 247 | -| `"aiv_reduce_scatter_op.h"` | HCOMM | `hcomm/src/legacy/ascend910/algorithm/base/alg_aiv_template/reduce_scatter/` | hccl_op_stub/reduce_scatter/aiv_communication_v2.cc | | ||
| 248 | -| `"aiv_broadcast_op.h"` | HCOMM | `hcomm/src/legacy/ascend910/algorithm/base/alg_aiv_template/broadcast/` | hccl_op_stub/broadcast/aiv_communication_v2.cc | | ||
| 249 | -| `"aiv_all_to_all_op.h"` | HCOMM | `hcomm/src/legacy/ascend910/algorithm/base/alg_aiv_template/all_to_all/` | hccl_op_stub/all_to_all_v/aiv_communication_v2.cc | | ||
| 250 | -| `"aiv_all_to_all_v_op.h"` | HCOMM | `hcomm/src/legacy/ascend910/algorithm/base/alg_aiv_template/all_to_all/` | hccl_op_stub/all_to_all_v/aiv_communication_v2.cc | | ||
| 251 | -| `"aiv_scatter_op.h"` | HCCL | `hccl/src/ops/scatter/template/aiv/kernel/` | hccl_op_stub/scatter/aiv_communication_v2.cc | | ||
| 252 | -| `"aiv_reduce_op.h"` | HCCL | `hccl/src/ops/reduce/template/aiv/kernel/` | hccl_op_stub/reduce/aiv_communication_v2.cc | | ||
| 253 | - | ||
| 254 | -**Dependency Risk**: Changes to the interface signatures, template parameters, or member functions in the operator op header files on the HCOMM or HCCL side will cause AIV kernel compilation failures or lead to inconsistent runtime behavior. | ||
| 255 | - | ||
| 256 | -### 5.4 AscendC Interface Dependencies | ||
| 257 | - | ||
| 258 | -The tool depends on the AscendC programming interfaces provided by the CANN package to simulate AIV kernel execution. All AscendC interfaces in the project use local stub files under the `src/proxy/level2/aiv_kernel/ascendc_stub/` directory. The tool does not use the AscendC header files from the CANN SDK directly. | ||
| 259 | - | ||
| 260 | -**AscendC Interfaces in Use** (implemented through stubs): | ||
| 261 | - | ||
| 262 | -| Stub Header File | Encapsulated AscendC Interfaces | Reference Locations | | ||
| 263 | -|------------|-------------------|---------| | ||
| 264 | -| `ascendc_base_stub.h` | base classes such as `GlobalTensor`, `LocalTensor`, `TPipe`, `TBuf`, `TQueBind`, `pipe_barrier`, and `GetBlockIdx` | nearly all files under aiv_kernel/ | | ||
| 265 | -| `ascendc_copy_stub.h` | data copy interfaces such as `DataCopy` and `DataCopyPad` | ascendc_stub/kernel_operator.h | | ||
| 266 | -| `ascendc_math_stub.h` | math operation interfaces such as `Add`, `Sub`, `Mul`, and `Reduce` | ascendc_stub/kernel_operator.h | | ||
| 267 | -| `ascendc_memory_stub.h` | atomic operation interfaces such as `SetAtomicAdd`, `SetAtomicMax`, and `SetAtomicMin` | ascendc_stub/kernel_operator.h | | ||
| 268 | -| `ascendc_sync_stub.h` | synchronization interfaces such as `send_flag`, `recv_flag`, and `SyncAll` | ascendc_stub/kernel_operator.h | | ||
| 269 | -| `ascendc_utils_stub.h` | utility functions such as `PipeBarrier` | ascendc_stub/kernel_operator.h | | ||
| 270 | - | ||
| 271 | -**Dependency Risks**: | ||
| 272 | - | ||
| 273 | -1. AscendC API changes (such as class member function signature changes or template parameter adjustments) may cause mismatches between stub implementations and the real interfaces | ||
| 274 | -2. New AscendC data types (such as `fp8_e4m3fn_t`, `fp8_e5m2_t`, and `hifloat8_t`) require synchronized updates to stub support | ||
| 275 | -3. The `AivCommBase` class uses AscendC template classes extensively (`GlobalTensor<T>`, `LocalTensor<T>`, `TQueBind`, and so on). Semantic changes to these types affect AIV simulation correctness | ||
| 276 | - | ||
| 277 | ---- | ||
| 278 | - | ||
| 279 | -## 6. AICPU Dependencies (AICPU Mode Only) | ||
| 280 | - | ||
| 281 | -This section describes the dependencies for simulating host-device interaction in AICPU mode. The `ExecuteAicpuKernel` function in `src/device_arm/hccl_kernel_executor.cc` implements this mode. The function simulates the process of dispatching an AICPU kernel to the device side. This involves serialization and address translation of multiple data structures. | ||
| 282 | - | ||
| 283 | -### 6.1 AICPU Interaction Data Structures | ||
| 284 | - | ||
| 285 | -The tool maintains local backups of the following data structures in `src/device_arm/common/aicpu_args_stub.h` to remove the strong dependency on the HCOMM runtime library: | ||
| 286 | - | ||
| 287 | -| Data Structure | Purpose | Corresponding Kernel Function | | ||
| 288 | -|---------|------|-----------------| | ||
| 289 | -| `CommAicpuParam` | Communication domain initialization parameters (hcomId, device ID, H2D/D2H transfer parameters) | `RunAicpuIndOpCommInit` | | ||
| 290 | -| `HDCommunicateParams` | H2D/D2H control transfer parameters (deviceAddr, readCacheAddr) | referenced by `CommAicpuParam` | | ||
| 291 | -| `ThreadMgrAicpuParam` | Thread management parameters (threadNum, serialized threadParam array, deviceHandle) | `RunAicpuIndOpThreadInit`, `RunAicpuThreadSupplementNotify` | | ||
| 292 | -| `AicpuTsThread` | AICPU thread information (streamType, notifyLoadType, devId) | referenced by `ThreadMgrAicpuParam` | | ||
| 293 | -| `InitTask` | Channel initialization task (context pointer, isCustom flag) | `RunAicpuIndOpChannelInitV2` | | ||
| 294 | -| `HcclChannelUrmaRes` | Channel URMA resource description (channelList, uniqueIdAddr, remoteRankList) | `RunAicpuIndOpChannelInitV2` | | ||
| 295 | -| `UniqueIdV2Header` | UniqueId V2 header (type, notifyNum, bufferNum, connNum) | channel link establishment serialized data parsing | | ||
| 296 | -| `ConnUniqueBlock` | Connection unique block (flexible array that contains `ConnUniqueIds`) | channel link establishment serialized data parsing | | ||
| 297 | - | ||
| 298 | -### 6.2 OpParam Data Structure (External Dependency) | ||
| 299 | - | ||
| 300 | -**Source**: the `alg_param.h` header file from the HCCL repository (`HCCL/src/ops/op_common/inc/`), in the `ops_hccl` namespace | ||
| 301 | - | ||
| 302 | -**Description**: `OpParam` is the general parameter structure for AICPU collective communication operators. The `HcclLaunchAicpuKernel` function uses this structure. Unlike the locally backed-up structures above, the tool **directly uses** the `OpParam` definition from the HCCL source code without a local backup. | ||
| 303 | - | ||
| 304 | -**Dependency Risk**: Changes to the `OpParam` structure on the HCCL side (field additions, field removals, or type changes) may cause the tool to parse parameters incorrectly or crash at runtime. | ||
| 305 | - | ||
| 306 | -### 6.3 AICPU Kernel Function Dependencies | ||
| 307 | - | ||
| 308 | -The tool dynamically loads the following kernel functions from the HCOMM runtime library through `dlopen` + `dlsym` to simulate the actual execution on the AICPU side: | ||
| 309 | - | ||
| 310 | -| dlsym Symbol Name | Library | Function | | ||
| 311 | -|-------------|-------|------| | ||
| 312 | -| `RunAicpuIndOpCommInit` | `libccl_kernel.so` | AICPU communication domain initialization | | ||
| 313 | -| `RunAicpuIndOpThreadInit` | `libccl_kernel.so` | AICPU thread initialization | | ||
| 314 | -| `RunAicpuIndOpChannelInitV2` | `libccl_kernel.so` | AICPU channel initialization V2 | | ||
| 315 | -| `RunAicpuDfxOpInfoInitV2` | `libccl_kernel.so` | AICPU DFX operator information initialization V2 | | ||
| 316 | -| `RunAicpuThreadSupplementNotify` | `libccl_kernel.so` | AICPU resource supplement notification | | ||
| 317 | -| `HcclLaunchAicpuKernel` | `libscatter_aicpu_kernel.so` | AICPU collective communication kernel launch | | ||
| 318 | - | ||
| 319 | -**Dependency Risks**: | ||
| 320 | -1. Changes to the signatures or behavior of the above kernel functions on the HCOMM side may cause `dlsym` calls to fail or produce incorrect results | ||
| 321 | -2. If `libccl_kernel.so` or `libscatter_aicpu_kernel.so` adds or removes kernel functions, the tool must update its function pointer list accordingly | ||
| 322 | -3. Inconsistencies between the locally backed-up structures (`CommAicpuParam`, `ThreadMgrAicpuParam`, `HcclChannelUrmaRes`, and so on) and the actual definitions on the HCOMM side will cause address translation errors and memory out-of-bounds access | ||
| 323 | - | ||
| 324 | -### 6.4 Kernel SO Library Name Dependencies | ||
| 325 | - | ||
| 326 | -The `InitKernelFuncHandle` function hardcodes the following SO library names to load the execution entry points for AICPU kernels: | ||
| 327 | - | ||
| 328 | -| Hardcoded SO Name | Loaded dlsym Symbols | Description | | ||
| 329 | -|--------------|-----------------|------| | ||
| 330 | -| `libccl_kernel.so` | `RunAicpuIndOpCommInit`, `RunAicpuIndOpThreadInit`, `RunAicpuIndOpChannelInitV2`, `RunAicpuDfxOpInfoInitV2`, `RunAicpuThreadSupplementNotify` | HCOMM communication framework core library | | ||
| 331 | -| `libscatter_aicpu_kernel.so` | `HcclLaunchAicpuKernel` | AICPU collective communication operator kernel library | | ||
| 332 | -| `libslog.so` | (logging library dependency) | CANN secure logging library | | ||
| 333 | -| `libc_sec.so` | (security library dependency) | CANN security function library | | ||
| 334 | - | ||
| 335 | -**Dependency Risks**: | ||
| 336 | -1. **SO Name Changes**: If the HCOMM side renames or splits the above SOs (for example, renaming `libccl_kernel.so`), the `dlopen` call in the tool will fail. This causes all AICPU kernels to become non-executable | ||
| 337 | -2. **Operator Kernel SO Name Ambiguity**: The operator kernel SO name is fixed as `libscatter_aicpu_kernel.so` regardless of the operator type (AllReduce, AllGather, ReduceScatter, and so on). The "scatter" in the name suggests applicability only to the Scatter operator, but the library actually hosts kernels for all collective communication operators. If the HCOMM side later splits SOs by operator type (for example, `liballreduce_aicpu_kernel.so`), the tool will fail to adapt | ||
| 338 | -3. **User-Defined Operator Scenarios**: The HCCL business layer does not strictly define SO names for user-defined operators. Users may compile private SOs (for example, `libcustom_alltoall_kernel.so`). The tool currently recognizes only the fixed SO names listed above. The tool cannot load or simulate private SOs for user-defined operators | ||
| 339 | - | ||
| 340 | ---- | ||
| 341 | - | ||
| 342 | -## 7. Dependency Overview | ||
| 343 | - | ||
| 344 | -| Source | Header File Count | Modules in Use | | ||
| 345 | -|------|---------|---------| | ||
| 346 | -| **CANN** | 23 distinct header files | nearly all modules (proxy, checker, runner, common, store, topo, utils, device_arm) | | ||
| 347 | -| **HCOMM** | 13 distinct header files | proxy module (hccp network interfaces + AIV operator ops) | | ||
| 348 | -| **HCCL** | 3 direct references + indirect references | device_arm module (ARM cross-compilation) + proxy (AIV scatter/reduce ops) | | ||
| 349 | -| **Project Local External** | 14 header files | checker module only (as a fallback when CANN headers are missing) | | ||
| 350 | -| **AIV Backup** | 2 key definitions | proxy/aiv_kernel module only (AIV operator simulation) | | ||
| 351 | -| **AIV Operator Ops** | 8 header files (6 from HCOMM + 2 from HCCL) | proxy/aiv_kernel module only (AIV operator simulation) | | ||
| 352 | -| **AscendC Interfaces** | 6 stub header files | proxy/aiv_kernel module only (AIV operator simulation) | | ||
| 353 | -| **AICPU Backup** | 8 local structures + 6 kernel functions + 4 SO library names | device_arm module only (AICPU mode host-device interaction) | | ||
| 354 | - | ||
| 355 | - | ||
| @@ -1,343 +0,0 @@ | |||
| 1 | -# HVRM Insight V3 User Guide | ||
| 2 | - | ||
| 3 | -## 1. Overview | ||
| 4 | - | ||
| 5 | -HVRM Insight V3 supports the `DAGView` task graph viewer. This document covers data preparation, page access, dataset selection, DAG graph browsing, and node search. | ||
| 6 | - | ||
| 7 | -Other pages and advanced linkage features are not yet available. | ||
| 8 | - | ||
| 9 | ---- | ||
| 10 | - | ||
| 11 | -## 2. Prerequisites | ||
| 12 | - | ||
| 13 | -Before using Insight V3, confirm that the Checker has completed execution and has generated Insight data. | ||
| 14 | - | ||
| 15 | -To configure Checker data output, confirm that the Checker configuration file has enabled Insight dump: | ||
| 16 | - | ||
| 17 | -```json | ||
| 18 | -# The configuration file is located at /pathto/hccl_vm_install/plugin/checker/manifest.json | ||
| 19 | - | ||
| 20 | -{ | ||
| 21 | - ... | ||
| 22 | - "setting": { // Checker plugin configuration items | ||
| 23 | - ... | ||
| 24 | - "enable_insight_dump": true, // Whether to output Checker V3 Insight data (disabled by default) | ||
| 25 | - "enable_memory_snapshot_dump": false // Whether to output memory snapshot data (not yet supported, disabled by default, requires enabling Insight data output first) | ||
| 26 | - } | ||
| 27 | -} | ||
| 28 | -``` | ||
| 29 | - | ||
| 30 | -DAGView requires at least the following data files: | ||
| 31 | - | ||
| 32 | -```text | ||
| 33 | -<dataset_name>/ | ||
| 34 | -├── manifest.json | ||
| 35 | -└── graph/ | ||
| 36 | - ├── graph.msgpack | ||
| 37 | - └── layout.msgpack | ||
| 38 | -``` | ||
| 39 | - | ||
| 40 | -The `manifest.json` file provides dataset metadata. The `graph.msgpack` and `layout.msgpack` files render the DAG task graph. | ||
| 41 | - | ||
| 42 | ---- | ||
| 43 | - | ||
| 44 | -## 3. Compile and Install the Insight Plugin | ||
| 45 | - | ||
| 46 | -The Insight V3 frontend source code is located at: | ||
| 47 | - | ||
| 48 | -```text | ||
| 49 | -{hccl_vm directory}/src/plugin/insight/frontend_v3 | ||
| 50 | -``` | ||
| 51 | - | ||
| 52 | -Before installing the Insight plugin, compile the frontend first, then run the HCCL VM build and installation process. | ||
| 53 | - | ||
| 54 | -Note: Compiling the Insight visualization frontend requires `Node.js` and `npm`. Use `Node.js 20.19.0` or later and `npm 10.x` or later. | ||
| 55 | - | ||
| 56 | -The recommended steps are as follows: | ||
| 57 | - | ||
| 58 | -1. Navigate to the frontend directory: | ||
| 59 | - | ||
| 60 | -```bash | ||
| 61 | -cd {hccl_vm directory}/src/plugin/insight/frontend_v3 | ||
| 62 | -``` | ||
| 63 | - | ||
| 64 | -2. Install frontend dependencies: | ||
| 65 | - | ||
| 66 | -```bash | ||
| 67 | -npm install | ||
| 68 | -``` | ||
| 69 | - | ||
| 70 | -3. Build the frontend output: | ||
| 71 | - | ||
| 72 | -```bash | ||
| 73 | -npm run build | ||
| 74 | -``` | ||
| 75 | - | ||
| 76 | -After the frontend compilation completes, the system generates the `src/plugin/insight/dist/` directory. | ||
| 77 | - | ||
| 78 | -4. Return to the HCCL_VM root directory, and run `build.sh` to compile and install hccl-vm: | ||
| 79 | - | ||
| 80 | -```bash | ||
| 81 | -cd {HCCL_VM directory} | ||
| 82 | -bash build.sh --package-path <ASCEND_CANN_PATH> --hcomm-path <HCOMM_CODE_PATH> | ||
| 83 | -``` | ||
| 84 | - | ||
| 85 | -To package the installation directory, append `--pkg`. If the current build scenario requires AICPU / AIV / FULL mode, append the `--aicpu`, `--aiv`, or `--full` parameter following the standard project procedure. | ||
| 86 | - | ||
| 87 | ---- | ||
| 88 | - | ||
| 89 | -## 4. Insight Plugin Configuration and Start/Stop | ||
| 90 | - | ||
| 91 | -The Insight plugin configuration file is located at: | ||
| 92 | - | ||
| 93 | -```text | ||
| 94 | -hccl_vm_install/plugin/visualization/insight/manifest.json | ||
| 95 | -``` | ||
| 96 | - | ||
| 97 | -The default configuration is as follows: | ||
| 98 | - | ||
| 99 | -```json | ||
| 100 | -{ | ||
| 101 | - "name": "insight", | ||
| 102 | - "version": "1.0.0", | ||
| 103 | - "entry": "python3 server.py", | ||
| 104 | - "dependency": { | ||
| 105 | - "min_core_version": "1.0.0" | ||
| 106 | - }, | ||
| 107 | - "setting": { | ||
| 108 | - "dist_path": "./dist", | ||
| 109 | - "data_path": "../../checker/data/insight", | ||
| 110 | - "topo_config_path": "../../../../../asset/cluster_model/config/cluster", | ||
| 111 | - "port": 8080 | ||
| 112 | - } | ||
| 113 | -} | ||
| 114 | -``` | ||
| 115 | - | ||
| 116 | -The common fields are described below: | ||
| 117 | - | ||
| 118 | -| Field | Description | | ||
| 119 | -|------|------| | ||
| 120 | -| `entry` | The Insight plugin startup command. The system starts the service using `python3 server.py`. | | ||
| 121 | -| `setting.dist_path` | The frontend static resource directory. The default value is `./dist`. | | ||
| 122 | -| `setting.data_path` | The Insight data directory. The default points to the Checker output directory `data/insight`. | | ||
| 123 | -| `setting.topo_config_path` | The cluster topology configuration directory. | | ||
| 124 | -| `setting.port` | The Insight service port. The default value is `8080`. | | ||
| 125 | - | ||
| 126 | -To modify the port or data directory, edit the `setting` field in `manifest.json` directly. | ||
| 127 | - | ||
| 128 | -> Warning: Insight binds to `127.0.0.1` by default using `python3 server.py`. To listen on a specific IP address instead of the default `localhost(127.0.0.1)`, navigate to the `hccl_vm_install/plugin/visualization/insight` directory and run the following command manually: | ||
| 129 | -> | ||
| 130 | -> ```bash | ||
| 131 | -> python3 server.py --host <ip> --port <port> | ||
| 132 | -> ``` | ||
| 133 | -> | ||
| 134 | -> For example: | ||
| 135 | -> | ||
| 136 | -> ```bash | ||
| 137 | -> cd hccl_vm_install/plugin/visualization/insight | ||
| 138 | -> python3 server.py --host 0.0.0.0 --port 8080 | ||
| 139 | -> ``` | ||
| 140 | - | ||
| 141 | -The plugin installation and uninstall commands are as follows: | ||
| 142 | - | ||
| 143 | -```bash | ||
| 144 | -# Install and start the Insight plugin | ||
| 145 | -hccl-vm plugin install @insight | ||
| 146 | - | ||
| 147 | -# Uninstall the Insight plugin | ||
| 148 | -hccl-vm plugin uninstall @insight | ||
| 149 | -``` | ||
| 150 | - | ||
| 151 | ---- | ||
| 152 | - | ||
| 153 | -## 5. Open Insight | ||
| 154 | - | ||
| 155 | -If the Insight service is running, open the service address in the browser. For example: | ||
| 156 | - | ||
| 157 | -```text | ||
| 158 | -http://localhost:8080 | ||
| 159 | -``` | ||
| 160 | - | ||
| 161 | -To start Insight through the plugin, run the following command: | ||
| 162 | - | ||
| 163 | -```bash | ||
| 164 | -hccl-vm plugin install @insight | ||
| 165 | -``` | ||
| 166 | - | ||
| 167 | -After the plugin starts, the terminal outputs the access address. Open that address in the browser to access the Insight page. | ||
| 168 | - | ||
| 169 | - | ||
| 170 | - | ||
| 171 | ---- | ||
| 172 | - | ||
| 173 | -## 6. Select a Dataset | ||
| 174 | - | ||
| 175 | -After opening Insight, the system displays the `Overview` page by default. Follow these steps to select a dataset for analysis: | ||
| 176 | - | ||
| 177 | -1. View the dataset list in the middle dataset table. | ||
| 178 | -2. Click the target dataset. | ||
| 179 | -3. Confirm the target Rank in the left Rank tree. | ||
| 180 | -4. If the DAG graph is large, reduce the Rank selection range first. | ||
| 181 | -5. Click `Enter Correlation View` on the right side. | ||
| 182 | - | ||
| 183 | - | ||
| 184 | - | ||
| 185 | -Select a small number of Ranks during the first analysis. Confirm the analysis direction, then expand the Rank range gradually. | ||
| 186 | - | ||
| 187 | ---- | ||
| 188 | - | ||
| 189 | -## 7. Enter DAGView | ||
| 190 | - | ||
| 191 | -After entering the `Correlation` page, focus on the `DAGView Task View` in the lower section. | ||
| 192 | - | ||
| 193 | -The main page areas are as follows: | ||
| 194 | - | ||
| 195 | -| Area | Function | | ||
| 196 | -|------|------| | ||
| 197 | -| Left panel | Select Ranks and search for nodes | | ||
| 198 | -| Center bottom | Display the DAG task graph | | ||
| 199 | -| Right detail panel | View the current node details | | ||
| 200 | - | ||
| 201 | -If the upper memory view is empty, the DAGView below remains fully functional. | ||
| 202 | - | ||
| 203 | ---- | ||
| 204 | - | ||
| 205 | -## 8. View the DAG Task Graph | ||
| 206 | - | ||
| 207 | -The DAG task graph consists of swim lanes, nodes, and arrows: | ||
| 208 | - | ||
| 209 | -| Element | Description | | ||
| 210 | -|------|------| | ||
| 211 | -| Swim lane | Represents an execution queue, displayed as `Rank / Stream / Queue` | | ||
| 212 | -| Node | Represents a task, for example data transfer, Reduce, Record, or Wait | | ||
| 213 | -| Arrow | Represents a dependency between tasks | | ||
| 214 | -| Loop dashed box | Represents a Loop region. A dashed box encloses the related nodes within the Loop, and a `Loop` label appears outside the box. | | ||
| 215 | - | ||
| 216 | -The common node types are as follows: | ||
| 217 | - | ||
| 218 | -| Node Type | Meaning | | ||
| 219 | -|----------|------| | ||
| 220 | -| `TRANS_MEM` | Data transfer task | | ||
| 221 | -| `REDUCE` | Reduce task | | ||
| 222 | -| `RECORD` | Notify record task | | ||
| 223 | -| `WAIT` | Notify wait task | | ||
| 224 | -| `CCU_GRAPH` | CCU graph task | | ||
| 225 | -| `AIV_GRAPH` | AIV graph task | | ||
| 226 | - | ||
| 227 | -The recommended viewing approach is as follows: | ||
| 228 | - | ||
| 229 | -1. Follow the arrow direction to review the task dependency order. | ||
| 230 | -2. Click the task node of interest. | ||
| 231 | -3. View the Rank, Stream, Queue, and detailed node information in the right detail panel. | ||
| 232 | -4. Examine the parent nodes and child nodes to trace upstream and downstream dependencies. | ||
| 233 | - | ||
| 234 | -For Loop display, pay attention to the following information: | ||
| 235 | - | ||
| 236 | -1. If the DAG contains a Loop, the page automatically overlays a Loop dashed box on the task graph. | ||
| 237 | -2. The dashed box covers the Loop start point, end point, and internal loop body nodes for quick identification of loop boundaries. | ||
| 238 | -3. Click the Loop capsule to navigate directly to the corresponding Loop Start node. | ||
| 239 | -4. After selecting a node inside a Loop, the right detail panel displays the Loop information and the nesting chain for that node. | ||
| 240 | - | ||
| 241 | - | ||
| 242 | - | ||
| 243 | ---- | ||
| 244 | - | ||
| 245 | -## 9. Canvas Operations | ||
| 246 | - | ||
| 247 | -The DAGView canvas supports the following operations: | ||
| 248 | - | ||
| 249 | -| Operation | Description | | ||
| 250 | -|------|------| | ||
| 251 | -| Pan canvas | Drag an empty area | | ||
| 252 | -| Zoom in / Zoom out | Use the mouse scroll wheel, or click `+` / `-` in the bottom-right corner | | ||
| 253 | -| Reset zoom | Click the percentage button in the bottom-right corner | | ||
| 254 | -| Select node | Click the target node | | ||
| 255 | - | ||
| 256 | -When the graph is large, reduce the Rank selection range first, then zoom into specific areas to examine dependencies. | ||
| 257 | - | ||
| 258 | ---- | ||
| 259 | - | ||
| 260 | -## 10. View Node Details | ||
| 261 | - | ||
| 262 | -After clicking a DAG node, the right detail panel displays node information. The common sections are as follows: | ||
| 263 | - | ||
| 264 | -| Section | Description | | ||
| 265 | -|------|------| | ||
| 266 | -| Node overview | Node ID, task type, Rank, Stream, Queue | | ||
| 267 | -| Loop information | The Loop that contains the current node, Loop count, instruction range, Loop boundaries | | ||
| 268 | -| Parent nodes | Upstream nodes that the current node depends on | | ||
| 269 | -| Child nodes | Downstream nodes that depend on the current node | | ||
| 270 | -| Node semantics | Notify, Task metadata, Memory Slices | | ||
| 271 | -| Raw JSON | The complete raw information of the current node | | ||
| 272 | - | ||
| 273 | -When troubleshooting dependency relationships, check `Parent nodes` and `Child nodes` first. When troubleshooting loop structures, focus on `Loop information`. When troubleshooting data transfer issues, focus on `Memory Slices`. | ||
| 274 | - | ||
| 275 | -The `Memory Slices` section follows these display rules: | ||
| 276 | - | ||
| 277 | -1. A regular memory Slice displays `rank / type / offset / size`. | ||
| 278 | -2. If the Slice belongs to `MS_CCU`, Insight V3 displays the `MSID` instead of the underlying abstract offset. | ||
| 279 | -3. For batch tasks, if multiple `MS_CCU` Slices exist, the system merges them into a single summary card automatically. | ||
| 280 | -4. The summary card displays a description such as `Total 8 MSIDs used`. | ||
| 281 | -5. After expanding `MSID Details`, inspect the `id` and `size` of each `MSID` individually. | ||
| 282 | - | ||
| 283 | ---- | ||
| 284 | - | ||
| 285 | -## 11. Search for Nodes | ||
| 286 | - | ||
| 287 | -The left `Search` panel locates DAG nodes quickly. | ||
| 288 | - | ||
| 289 | -The supported search fields are as follows: | ||
| 290 | - | ||
| 291 | -| Field | Use Case | | ||
| 292 | -|------|----------| | ||
| 293 | -| `taskId` | Use when the node ID is known | | ||
| 294 | -| `taskType` | Search by task type, for example `TRANS_MEM` | | ||
| 295 | -| `notifyId` | Search by notify id | | ||
| 296 | - | ||
| 297 | -Steps: | ||
| 298 | - | ||
| 299 | -1. Select a search field in the left search panel. | ||
| 300 | -2. Enter the complete keyword. | ||
| 301 | -3. Click the search result. | ||
| 302 | -4. DAGView locates and selects the corresponding node automatically. | ||
| 303 | - | ||
| 304 | -The current search uses exact matching. If the system finds no results, confirm that the keyword is complete and that the target Rank is selected. | ||
| 305 | - | ||
| 306 | ---- | ||
| 307 | - | ||
| 308 | -## 12. Recommended Analysis Workflow | ||
| 309 | - | ||
| 310 | -Follow this workflow for DAGView analysis: | ||
| 311 | - | ||
| 312 | -1. Select a dataset on the `Overview` page. | ||
| 313 | -2. Select a small number of Ranks in the left Rank tree. | ||
| 314 | -3. Click `Enter Correlation View`. | ||
| 315 | -4. View the overall nodes and dependency arrows in DAGView. | ||
| 316 | -5. Click the node of interest and view the details on the right. | ||
| 317 | -6. Trace upstream and downstream dependencies through parent nodes and child nodes. | ||
| 318 | -7. Use the search function to locate known nodes quickly. | ||
| 319 | - | ||
| 320 | ---- | ||
| 321 | - | ||
| 322 | -## 13. Frequently Asked Questions | ||
| 323 | - | ||
| 324 | -### 13.1 The Page Shows No Data | ||
| 325 | - | ||
| 326 | -Confirm that the Insight service address is correct, and confirm that the Checker has generated Insight data. | ||
| 327 | - | ||
| 328 | -### 13.2 The DAG Is Empty After Entering the Correlation Page | ||
| 329 | - | ||
| 330 | -Confirm that the dataset contains the following files: | ||
| 331 | - | ||
| 332 | -```text | ||
| 333 | -graph/graph.msgpack | ||
| 334 | -graph/layout.msgpack | ||
| 335 | -``` | ||
| 336 | - | ||
| 337 | -### 13.3 The DAG Graph Is Too Dense | ||
| 338 | - | ||
| 339 | -Reduce the number of selected Ranks on the left side first. View a subset of Ranks, then zoom into specific areas for analysis. | ||
| 340 | - | ||
| 341 | -### 13.4 The Search Returns No Node | ||
| 342 | - | ||
| 343 | -Confirm that the search keyword is complete, and confirm that the Rank containing the target node is selected. | ||
| @@ -1,423 +0,0 @@ | |||
| 1 | -# CCU Executor Debug Tool Design Document — Feasibility Review and Optimization Report | ||
| 2 | - | ||
| 3 | -A comprehensive review based on the code in `src/plugin/solver/virtual_runtime/ccu_executor/` and the design proposal in `runner_debug/debug_tool_design_doc.md`. | ||
| 4 | - | ||
| 5 | ---- | ||
| 6 | - | ||
| 7 | -## I. Feasibility Issues (Must Fix) | ||
| 8 | - | ||
| 9 | -### P0-1: CKE Wait Flow Does Not Match Instrumentation Design | ||
| 10 | - | ||
| 11 | -**Severity**: P0 (Approach feasibility error) | ||
| 12 | - | ||
| 13 | -**Problem Description**: | ||
| 14 | - | ||
| 15 | -The instrumentation pseudocode in Section 4.1 assumes that the `waitCKE_` flag can be detected before `ExecuteInstr()` returns, and the delta from `snapshotBefore → snapshotAfter` is computed afterward. However, the actual code flow is: | ||
| 16 | - | ||
| 17 | -``` | ||
| 18 | -WaitCkeProcess() → CKE not met → ccuSimulator_->SetWaitCKEFlag(true) → return (Process() not called) | ||
| 19 | -→ UpdateLoopStatus() returns false → ExecuteInstr() returns false → Execute() returns false | ||
| 20 | -``` | ||
| 21 | - | ||
| 22 | -Key point: When CKE is not met, `WaitCkeProcess` inside `Run()` sets the waitCKE flag and returns directly, **without calling Process() and without modifying any resources**. Therefore: | ||
| 23 | -- Pre-execution snapshot = post-execution snapshot (delta is empty) | ||
| 24 | -- snapshotAfter should not be captured and delta should not be computed | ||
| 25 | - | ||
| 26 | -**Code Evidence**: | ||
| 27 | - | ||
| 28 | -`CcuExecutorBase.cc` lines 162-172: | ||
| 29 | -```cpp | ||
| 30 | -if ((waitCKE & waitCKEMask) == waitCKEMask) { | ||
| 31 | - Process(ccuResMgr); // CKE met → execute Process | ||
| 32 | -} else { | ||
| 33 | - ccuSimulator_->SetWaitCKEFlag(true); // CKE not met → set flag, do not execute Process | ||
| 34 | - return; | ||
| 35 | -} | ||
| 36 | -``` | ||
| 37 | - | ||
| 38 | -**Fix Suggestion**: | ||
| 39 | - | ||
| 40 | -When waitCKE is not met, only record key spin fields; do not compute delta or create a full trace entry: | ||
| 41 | -```cpp | ||
| 42 | -// During waitCKE, only record spin information | ||
| 43 | -CcuTraceCollector::RecordWaitSpin(rankId_, dieId_, curInstrId, | ||
| 44 | - waitCKEId, waitCKEMask, actualCKEValue); | ||
| 45 | -// Do not capture snapshotAfter, do not compute delta | ||
| 46 | -// Do not create full CcuTraceEntry | ||
| 47 | -return false; | ||
| 48 | -``` | ||
| 49 | - | ||
| 50 | -Only create a full entry after CKE passes (merging previous spin information). | ||
| 51 | - | ||
| 52 | ---- | ||
| 53 | - | ||
| 54 | -### P0-2: globalSeqId/execRound Maintenance Should Be in SequentialExecutor | ||
| 55 | - | ||
| 56 | -**Severity**: P0 (Approach feasibility error) | ||
| 57 | - | ||
| 58 | -**Problem Description**: | ||
| 59 | - | ||
| 60 | -The document assumes `CcuTraceCollector` maintains `globalSeqId/execRound/currentSqeTaskId` inside `CcuSimulator::ExecuteInstr()`. However, `CcuSimulator` can only see execution within its own CCU and cannot perceive global scheduling rounds or CCU switching. | ||
| 61 | - | ||
| 62 | -`CcuSimulator::ExecuteInstr()` executes within a single CCU and does not know: | ||
| 63 | -- Which round of the outer `while(HasTask())` it is (`execRound`) | ||
| 64 | -- The global execution sequence number (`globalSeqId`) | ||
| 65 | -- Which SQE task is currently being executed (`sqeTaskId`) | ||
| 66 | - | ||
| 67 | -This information is only available in the upper call chain of `SequentialExecutor::Execute()` and `TaskCcuGraph()`. | ||
| 68 | - | ||
| 69 | -**Code Evidence**: | ||
| 70 | - | ||
| 71 | -`hccl_task_sequential_execute.cc` lines 51-72 — Global scheduling loop: | ||
| 72 | -```cpp | ||
| 73 | -while (HasTask()) { | ||
| 74 | - uint32_t rankId = 0; | ||
| 75 | - for (auto& rankTasks : allRankTaskQueues_) { // Iterate all ranks | ||
| 76 | - for (auto& streamTasks : rankTasks) { // Iterate each stream | ||
| 77 | - while (!streamTasks.empty()) { | ||
| 78 | - auto task = streamTasks.front(); | ||
| 79 | - auto ret = ExecuteOneTask(task); // ← globalSeqId incremented here | ||
| 80 | - if (ret == HCCL_SIM_VRT_HOLD_CMD) break; | ||
| 81 | - streamTasks.pop(); | ||
| 82 | - } | ||
| 83 | - } | ||
| 84 | - } | ||
| 85 | -} | ||
| 86 | -``` | ||
| 87 | - | ||
| 88 | -`hccl_task_thread.cc` lines 135-148 — TaskCcuGraph: | ||
| 89 | -```cpp | ||
| 90 | -auto simulator = ccuResMgr.InitSimulator(rankId, dieId, instrStartId, endInstrId, instCnt); | ||
| 91 | -// sqeTaskId is known here (obtained from task parameters) | ||
| 92 | -if (simulator->Execute() == false) { | ||
| 93 | - return HCCL_SIM_VRT_HOLD_CMD; | ||
| 94 | -} | ||
| 95 | -``` | ||
| 96 | - | ||
| 97 | -**Fix Suggestion**: | ||
| 98 | - | ||
| 99 | -Global context is managed by `SequentialExecutor` and passed via parameters: | ||
| 100 | -```cpp | ||
| 101 | -// In SequentialExecutor::Execute() | ||
| 102 | -while (HasTask()) { | ||
| 103 | - uint32_t execRound = 0; | ||
| 104 | - for (rankTasks : allRankTaskQueues_) { | ||
| 105 | - for (streamTasks : rankTasks) { | ||
| 106 | - while (!streamTasks.empty()) { | ||
| 107 | - CcuTraceCollector::BeginGlobalStep(execRound); | ||
| 108 | - // globalSeqId incremented inside ExecuteOneTask | ||
| 109 | - auto ret = ExecuteOneTask(task); | ||
| 110 | - ... | ||
| 111 | - } | ||
| 112 | - } | ||
| 113 | - } | ||
| 114 | - execRound++; | ||
| 115 | -} | ||
| 116 | -``` | ||
| 117 | - | ||
| 118 | -Pass sqeTaskId to `CcuSimulator` in `TaskCcuGraph()`: | ||
| 119 | -```cpp | ||
| 120 | -uint32_t sqeTaskId = CcuTraceCollector::RegisterSqeTask(rankId, dieId, task); | ||
| 121 | -CcuSimulator::SetCurrentSqeTaskId(sqeTaskId); // Used internally by Simulator | ||
| 122 | -``` | ||
| 123 | - | ||
| 124 | ---- | ||
| 125 | - | ||
| 126 | -### P0-3: Full Snapshot Collection Has Excessive Performance Overhead | ||
| 127 | - | ||
| 128 | -**Severity**: P0 (Performance bottleneck) | ||
| 129 | - | ||
| 130 | -**Problem Description**: | ||
| 131 | - | ||
| 132 | -In Section 4.1, a `CaptureResourceSnapshot()` (full read of all resources) is performed before and after each instruction, with significant overhead: | ||
| 133 | - | ||
| 134 | -- Single snapshot: 4096×8(XN) + 4096×8(GSA) + 1024×2(CKE) ≈ 67KB | ||
| 135 | -- Before and after each instruction ≈ 134KB | ||
| 136 | -- 10000 instructions ≈ 1.34GB (snapshot data only) | ||
| 137 | - | ||
| 138 | -Section 4.5 mentions incremental collection optimization, but the pseudocode in 4.1 still follows the full snapshot + diff computation flow, which contradicts the optimization approach. | ||
| 139 | - | ||
| 140 | -**Industry Reference**: | ||
| 141 | - | ||
| 142 | -- **rr debugger**: Checkpoint + incremental recording model; full snapshots only at key nodes | ||
| 143 | -- **Chrome DevTools Timeline**: Event stream format; each event contains only changed args | ||
| 144 | -- **Perfetto (Android trace)**: Protobuf binary incremental format | ||
| 145 | - | ||
| 146 | -**Fix Suggestion**: | ||
| 147 | - | ||
| 148 | -Change to ResourceManager change interception + initial snapshot + periodic checkpoints: | ||
| 149 | - | ||
| 150 | -1. **Initial Snapshot**: Full snapshot at run start (stored in `CcuIdentity.initialSnapshot`) | ||
| 151 | -2. **Change Interception**: Intercept changes directly in `CcuResourceManager::UpdateXnValue/UpdateGsaValue/UpdateCkeValue` etc., recording delta: | ||
| 152 | -```cpp | ||
| 153 | -void CcuResourceManager::UpdateXnValue(int rankId, int dieId, uint16_t xnId, uint64_t value) { | ||
| 154 | - uint64_t oldValue = GetXnValue(rankId, dieId, xnId); | ||
| 155 | - if (oldValue != value) { | ||
| 156 | - CcuTraceCollector::RecordXnDelta(rankId, dieId, xnId, oldValue, value); | ||
| 157 | - } | ||
| 158 | - xnData_[rankId][dieId][xnId] = value; | ||
| 159 | -} | ||
| 160 | -``` | ||
| 161 | -3. **Periodic Checkpoint**: Full snapshot every N instructions (N configurable, default 1000) for quick intermediate state recovery | ||
| 162 | -4. **Restore Arbitrary Point State**: From nearest checkpoint + accumulate subsequent deltas | ||
| 163 | - | ||
| 164 | ---- | ||
| 165 | - | ||
| 166 | -## II. Design Optimization Points (Recommended Improvements) | ||
| 167 | - | ||
| 168 | -### P1-1: Loop Offset Formula Is Incomplete | ||
| 169 | - | ||
| 170 | -**Severity**: P1 (Information gap) | ||
| 171 | - | ||
| 172 | -**Problem Description**: | ||
| 173 | - | ||
| 174 | -The offset calculation in `UpdateAddress()` in the code is more complex than the `CcuExecutionContext.gsaOffset` in the document: | ||
| 175 | -```cpp | ||
| 176 | -uint64_t CcuExecutorBase::UpdateAddress(uint64_t addr, uint16_t addrExpandCoef) { | ||
| 177 | - return addr + ((ccuSimulator_->GetLoopExtendNum() * ccuSimulator_->GetGSAOffset()) << addrExpandCoef) | ||
| 178 | - + ((ccuSimulator_->GetCurLoopCnt() * ccuSimulator_->GetLoopIterStepGSA()) << addrExpandCoef); | ||
| 179 | -} | ||
| 180 | -``` | ||
| 181 | - | ||
| 182 | -This involves 5 parameters: `addr` (original address), `addrExpandCoef` (expansion coefficient), `loopExtendNum`, `gsaOffset`, `curLoopCnt`, `loopIterStepGSA`. | ||
| 183 | - | ||
| 184 | -The current `CcuExecutionContext` has only a simple `gsaOffset` field and cannot fully reproduce the Loop GSA address offset calculation process. | ||
| 185 | - | ||
| 186 | -**Fix Suggestion**: | ||
| 187 | - | ||
| 188 | -Add complete offset parameters to `CcuExecutionContext`: | ||
| 189 | -```cpp | ||
| 190 | -struct CcuExecutionContext { | ||
| 191 | - bool inLoop; | ||
| 192 | - uint16_t loopRound; // Current iteration round | ||
| 193 | - uint16_t loopExtendIndex; // Expand index | ||
| 194 | - | ||
| 195 | - // Loop offset parameters (valid only when inLoop=true) | ||
| 196 | - uint64_t gsaAddrOffset; // = extendIndex * gsaOffset + curLoopCnt * iterStepGSA (computed final offset) | ||
| 197 | - uint64_t gsaOffset; // GSA base offset coefficient (GetGSAOffset) | ||
| 198 | - uint64_t iterStepGSA; // GSA step per iteration round (GetLoopIterStepGSA) | ||
| 199 | - uint32_t curLoopCnt; // Current iteration count (GetCurLoopCnt) | ||
| 200 | - uint32_t loopExtendNum; // Expand count (GetLoopExtendNum) | ||
| 201 | - uint16_t addrExpandCoef; // Address expansion coefficient | ||
| 202 | - | ||
| 203 | - uint16_t msOffset; // MS ID offset (GetLoopMsOffset) | ||
| 204 | - uint16_t ckeOffset; // CKE ID offset (GetLoopCKEOffset) | ||
| 205 | - uint16_t xnIdOffset; // XN ID offset (GetLoopXnIdOffset) | ||
| 206 | -}; | ||
| 207 | -``` | ||
| 208 | - | ||
| 209 | ---- | ||
| 210 | - | ||
| 211 | -### P1-2: Cross-CCU Changes Should Be Intercepted in ResourceManager | ||
| 212 | - | ||
| 213 | -**Severity**: P1 (Collection accuracy) | ||
| 214 | - | ||
| 215 | -**Problem Description**: | ||
| 216 | - | ||
| 217 | -In Section 4.1, the cross-CCU change collection point is a post-hoc call to `CaptureCrossCcuChanges()` in `CcuSimulator::ExecuteInstr()`. However, cross-CCU operations actually occur in the Executor's `Process()` method (e.g., `SyncCkeExecutor::Process()` calls `SetRmtCKESignal()`). | ||
| 218 | - | ||
| 219 | -The post-hoc collection approach requires comparing the remote CCU's before/after state, meaning a remote CCU snapshot would be needed before and after instruction execution — high overhead and potentially missing changes (the remote CCU could be simultaneously modified by other code). | ||
| 220 | - | ||
| 221 | -**Fix Suggestion**: | ||
| 222 | - | ||
| 223 | -Intercept cross-CCU changes directly in `CcuResourceManager::UpdateCkeValue()`: | ||
| 224 | -```cpp | ||
| 225 | -void CcuResourceManager::UpdateCkeValue(int rankId, int dieId, uint16_t ckeId, uint16_t value) { | ||
| 226 | - uint16_t oldValue = GetCkeValue(rankId, dieId, ckeId); | ||
| 227 | - // Detect whether this is a cross-CCU operation | ||
| 228 | - auto [execRank, execDie] = CcuTraceCollector::GetCurrentExecutingCcu(); | ||
| 229 | - if (rankId != execRank || dieId != execDie) { | ||
| 230 | - CcuTraceCollector::RecordCrossCcuCkeChange( | ||
| 231 | - rankId, dieId, ckeId, oldValue, value, execRank, execDie); | ||
| 232 | - } | ||
| 233 | - ckeData_[rankId][dieId][ckeId] = value; | ||
| 234 | -} | ||
| 235 | -``` | ||
| 236 | - | ||
| 237 | -Similarly applicable to `UpdateXnValue()` (TransXnToRmt operations), `UpdateGsaValue()`, `TransMSToMS()`, etc. | ||
| 238 | - | ||
| 239 | ---- | ||
| 240 | - | ||
| 241 | -### P1-3: CcuInstrTraceDetail Polymorphism Is Over-engineered | ||
| 242 | - | ||
| 243 | -**Severity**: P1 (Architecture optimization) | ||
| 244 | - | ||
| 245 | -**Problem Description**: | ||
| 246 | - | ||
| 247 | -The current design has **13** `CcuInstrTraceDetail` subclasses (Load/Arith/Trans/Sync/Loop/LoopGroup/Cke/Jump/Wait/Fence/Reduce/...), but there are the following issues: | ||
| 248 | - | ||
| 249 | -1. **Duplication with common layer**: `CcuTransTraceDetail`'s `waitCKEId/setCKEId` duplicates `CcuTraceEntry.waitInfo`; `CcuCkeTraceDetail`'s `ckeId/ckeValueBefore/ckeValueAfter` duplicates `resourceDelta.ckeChanges` | ||
| 250 | -2. **Subclass proliferation**: The code has 30+ instruction types (~20 in V1 + ~10+ in V2); each requires a subclass | ||
| 251 | -3. **Complex frontend rendering**: Requires dispatching different rendering templates based on typeName | ||
| 252 | -4. **High cost of new instructions**: Each new instruction type requires a new subclass struct + CollectTraceDetail implementation | ||
| 253 | - | ||
| 254 | -**Industry Reference**: | ||
| 255 | - | ||
| 256 | -- **Chrome DevTools Trace Event Format**: Flat `args` field (key-value map), no polymorphic inheritance | ||
| 257 | -- **LLVM Execution Trace**: Flat "additional info" field | ||
| 258 | -- **GDB MI (Machine Interface)**: Key-value property list | ||
| 259 | - | ||
| 260 | -**Fix Suggestion**: | ||
| 261 | - | ||
| 262 | -Simplify `CcuInstrTraceDetail` to a flat structure: | ||
| 263 | -```cpp | ||
| 264 | -struct CcuInstrTraceDetail { | ||
| 265 | - std::string typeName; // e.g., "TransLocMemToLocMem" | ||
| 266 | - std::map<std::string, std::string> args; // Instruction-specific parameter key-value table | ||
| 267 | - // Examples: | ||
| 268 | - // Trans type: {"srcAddr": "0x7f0000", "dstAddr": "0x7f1000", "length": "4KB", "channelId": "0"} | ||
| 269 | - // Reduce type: {"op": "Add", "msList": "[0,1,2,3]", "dataType": "FP32", "castEn": "0"} | ||
| 270 | - // CKE type: {"ckeOp": "Set", "ckeId": "3", "ckeMask": "0x0001", "isRemote": "true"} | ||
| 271 | -}; | ||
| 272 | -``` | ||
| 273 | - | ||
| 274 | -Advantages: | ||
| 275 | -- No need to define a subclass for each instruction type | ||
| 276 | -- New instructions only need to populate args in `CollectTraceDetail()` | ||
| 277 | -- Unified frontend rendering logic (key-value table) | ||
| 278 | -- `Describe()` output can be used directly as args source | ||
| 279 | - | ||
| 280 | ---- | ||
| 281 | - | ||
| 282 | -### P1-4: JSON Serialization Format vs Large Data Volume | ||
| 283 | - | ||
| 284 | -**Severity**: P1 (Performance optimization) | ||
| 285 | - | ||
| 286 | -**Problem Description**: | ||
| 287 | - | ||
| 288 | -Section 3.4 adopts JSON as the serialization format, but JSON has weaknesses: | ||
| 289 | -- Each uint64_t XN/GSA value requires string representation (`"0x7f3a0000"`), 8 bytes becomes ~16 bytes | ||
| 290 | -- Large amounts of redundant key name repetition (`"xnChanges"` repeated in every entry) | ||
| 291 | -- 10000 instructions' JSON file can reach 50MB+ | ||
| 292 | -- Frontend loading and parsing of large JSON files is seriously slow | ||
| 293 | - | ||
| 294 | -**Industry Reference**: | ||
| 295 | - | ||
| 296 | -| Tool | Format | Characteristics | | ||
| 297 | -|------|------|------| | ||
| 298 | -| Chrome DevTools | JSON streaming (one event per line) | Supports line-by-line parsing | | ||
| 299 | -| Perfetto (Android) | Protobuf binary | Frontend WASM parsing, small size | | ||
| 300 | -| rr debugger | Custom binary | Efficient recording/playback | | ||
| 301 | -| Intel VTune | Custom binary + SQLite | On-demand querying | | ||
| 302 | - | ||
| 303 | -**Fix Suggestion**: | ||
| 304 | - | ||
| 305 | -Layered serialization strategy: | ||
| 306 | -- **Collection side**: msgpack/flatbuffers binary format, 5-10x smaller, faster writes | ||
| 307 | -- **Frontend loading**: Decode binary into frontend index structures via Worker | ||
| 308 | -- **Export/debug**: Optional export to JSON (for human readability and debugging) | ||
| 309 | -- JSON Schema `metadata.rankId/dieId` should be removed (changed to `rankSize/diePerRank`, consistent with global model) | ||
| 310 | - | ||
| 311 | ---- | ||
| 312 | - | ||
| 313 | -## III. Design Optimization Points (Recommended Improvements, Lower Priority) | ||
| 314 | - | ||
| 315 | -### P2-1: Describe() Can Serve as MVP Trace Information Source | ||
| 316 | - | ||
| 317 | -**Severity**: P2 (Implementation strategy) | ||
| 318 | - | ||
| 319 | -**Problem Description**: | ||
| 320 | - | ||
| 321 | -Every Executor in the code implements `Describe()`, returning formatted strings like: | ||
| 322 | -``` | ||
| 323 | -"[Simulation Execute] Wait CKE[3:0001], Sync LocCKE[5:00ff] To rmtCKE[8:00ff] | ||
| 324 | - Use Channel[0], Set CKE[10:0001], clearType[1]" | ||
| 325 | -``` | ||
| 326 | - | ||
| 327 | -These strings already contain key instruction parameter information. The current design requires each Executor to add a `CollectTraceDetail()` virtual method and implement it, which is a significant effort (30+ instruction types). | ||
| 328 | - | ||
| 329 | -**Fix Suggestion**: | ||
| 330 | - | ||
| 331 | -Phased implementation strategy: | ||
| 332 | - | ||
| 333 | -**Phase 1 (MVP)**: | ||
| 334 | -- Collect only `Describe()` output + resource delta | ||
| 335 | -- `instrDescribe` field directly uses `executor->Describe()` return value | ||
| 336 | -- Do not implement `CollectTraceDetail()`; detail field is empty or contains only typeName | ||
| 337 | - | ||
| 338 | -**Phase 2 (Enhancement)**: | ||
| 339 | -- Implement `CollectTraceDetail()` for high-frequency/critical instruction types (e.g., Trans, Reduce, SyncCke) | ||
| 340 | -- Detail uses flat key-value map (see P1-3) | ||
| 341 | -- Progressively cover all instruction types | ||
| 342 | - | ||
| 343 | -This enables rapid MVP delivery, reducing initial development cost. | ||
| 344 | - | ||
| 345 | ---- | ||
| 346 | - | ||
| 347 | -### P2-2: Notify and Other Non-CCU Tasks Not in Trace | ||
| 348 | - | ||
| 349 | -**Severity**: P2 (Information gap) | ||
| 350 | - | ||
| 351 | -**Problem Description**: | ||
| 352 | - | ||
| 353 | -`SequentialExecutor::Execute()` includes task types beyond `CCU_GRAPH`, such as `NOTIFY_RECORD/NOTIFY_WAIT/REDUCE/MEM_CPY/AIV_GRAPH`. `NotifyWait` can also return `HOLD_CMD`, with similar blocking behavior to CCU's waitCKE. | ||
| 354 | - | ||
| 355 | -The current trace only covers `CCU_GRAPH` type tasks. But Notify's Record/Wait affects execution flow: | ||
| 356 | -- `NotifyWait` blocking causes the outer loop to skip that stream | ||
| 357 | -- After `NotifyRecord` releases the block, the next round allows that stream's CCU task to continue | ||
| 358 | - | ||
| 359 | -If not reflected in trace, the frontend replay will show "CCU instructions suddenly jumping to the next round" with no explanation of what happened in between. | ||
| 360 | - | ||
| 361 | -**Fix Suggestion**: | ||
| 362 | - | ||
| 363 | -Add simplified records for non-CCU task types in `globalEntries[]`: | ||
| 364 | -```cpp | ||
| 365 | -struct CcuTraceNonCcuEntry { | ||
| 366 | - uint32_t globalSeqId; | ||
| 367 | - uint32_t execRound; | ||
| 368 | - int32_t rankId; | ||
| 369 | - HccLTaskMetaType taskType; // NOTIFY_RECORD, NOTIFY_WAIT, REDUCE, MEM_CPY... | ||
| 370 | - HcclVmResult execResult; // SUCCESS or HOLD_CMD | ||
| 371 | - std::string description; // Task description (for frontend display) | ||
| 372 | -}; | ||
| 373 | -``` | ||
| 374 | - | ||
| 375 | -During CCU switch notifications, the frontend can display: "Round 1: Rank1 NotifyWait blocked, skipped". | ||
| 376 | - | ||
| 377 | ---- | ||
| 378 | - | ||
| 379 | -### P2-3: JSON Schema Metadata Model Inconsistency | ||
| 380 | - | ||
| 381 | -**Severity**: P2 (Model consistency) | ||
| 382 | - | ||
| 383 | -**Problem Description**: | ||
| 384 | - | ||
| 385 | -The JSON Schema example in Section 3.4 still includes `rankId`/`dieId` fields in `metadata` (per-CCU model), but Section 3.3.1's `CcuRunMetadata` has already been changed to `rankSize`/`diePerRank` (global model). The two are inconsistent. | ||
| 386 | - | ||
| 387 | -Additionally, the JSON Schema example uses `"seqId"` instead of the new design's `"globalSeqId"`, and is missing `"execRound"`/`"sqeTaskId"`/`"ccuRegistry"`/`"sqeTaskRegistry"` and other new fields. | ||
| 388 | - | ||
| 389 | -**Fix Suggestion**: | ||
| 390 | - | ||
| 391 | -Update the JSON Schema example to be consistent with the data structure definitions in 3.3.1-3.3.2: | ||
| 392 | -- Remove `metadata.rankId`/`metadata.dieId` | ||
| 393 | -- Add `metadata.rankSize`/`metadata.diePerRank`/`metadata.totalExecRounds` | ||
| 394 | -- Add `ccuRegistry[]` and `sqeTaskRegistry[]` | ||
| 395 | -- Change `seqId` to `globalSeqId` in entries | ||
| 396 | -- Add `execRound`/`sqeTaskId`/`rankId`/`dieId` fields | ||
| 397 | - | ||
| 398 | ---- | ||
| 399 | - | ||
| 400 | -## IV. Summary Table | ||
| 401 | - | ||
| 402 | -| Priority | ID | Issue | Type | Fix Summary | | ||
| 403 | -|--------|------|------|------|---------| | ||
| 404 | -| P0 | P0-1 | Delta should not be computed during CKE Wait | Feasibility error | Record only key fields during waitCKE; create full entry only after CKE passes | | ||
| 405 | -| P0 | P0-2 | globalSeqId/execRound maintenance location is wrong | Feasibility error | Global context managed by SequentialExecutor, passed to Simulator via parameters | | ||
| 406 | -| P0 | P0-3 | Full snapshot performance bottleneck | Performance bottleneck | ResourceManager change interception + initial snapshot + periodic checkpoints | | ||
| 407 | -| P1 | P1-1 | Loop offset formula incomplete | Information gap | Add iterStepGSA/curLoopCnt/extendNum/addrExpandCoef | | ||
| 408 | -| P1 | P1-2 | Cross-CCU change collection timing | Collection accuracy | Intercept cross-CCU changes inside ResourceManager | | ||
| 409 | -| P1 | P1-3 | Detail polymorphism over-engineered | Architecture optimization | Simplify to flat key-value map | | ||
| 410 | -| P1 | P1-4 | JSON format unsuitable for large data | Performance optimization | Collection-side msgpack/flatbuffers, frontend WASM parsing | | ||
| 411 | -| P2 | P2-1 | Describe() can serve as MVP source | Implementation strategy | Phase 1: only Describe() + delta | | ||
| 412 | -| P2 | P2-2 | Notify and other non-CCU tasks missing | Information gap | Add simplified records | | ||
| 413 | -| P2 | P2-3 | JSON Schema model inconsistency | Model consistency | Align with 3.3.1-3.3.2 | | ||
| 414 | - | ||
| 415 | ---- | ||
| 416 | - | ||
| 417 | -## V. Fix Priority Recommendations | ||
| 418 | - | ||
| 419 | -**Step 1 (Required)**: Fix P0-1, P0-2, P0-3; otherwise the approach cannot be implemented | ||
| 420 | - | ||
| 421 | -**Step 2 (Recommended)**: Fix P1-1, P1-2, P1-3; improve approach quality and practicality | ||
| 422 | - | ||
| 423 | -**Step 3 (Optional)**: Fix P1-4, P2-1, P2-2, P2-3; refine details and user experience | ||
| @@ -1,11 +1,18 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * the terms and conditions of CANN Open Software License Agreement Version 2.0 |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * (the "License"). Please refer to the License for details. You may not use |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * this file except in compliance with the License. THIS SOFTWARE IS PROVIDED ON |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS |
| 9 | + * FOR A PARTICULAR PURPOSE. See LICENSE in the root of the software repository | ||
| 10 | + * for the full text of the License. | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 15 | + * for the full text of the License. | ||
| 9 | */ | 16 | */ |
| 10 | 17 | ||
| 11 | #ifndef DB_SIM_COMMUNICATOR_H | 18 | #ifndef DB_SIM_COMMUNICATOR_H |
| @@ -22,10 +29,12 @@ struct CommunicatorMemberInfo { | |||
| 22 | uint32_t rankId; | 29 | uint32_t rankId; |
| 23 | }; | 30 | }; |
| 24 | 31 | ||
| 25 | -bool GetCommunicatorMembers(uint64_t commId, std::vector<CommunicatorMemberInfo>& members); | 32 | +bool GetCommunicatorMembers(uint64_t commId, |
| 33 | + std::vector<CommunicatorMemberInfo> &members); | ||
| 26 | // 根据通信域成员 ID 查询其所属通信域名称。 | 34 | // 根据通信域成员 ID 查询其所属通信域名称。 |
| 27 | -bool GetCommunicatorName(uint64_t commId, std::string& commName); | 35 | +bool GetCommunicatorName(uint64_t commId, std::string &commName); |
| 28 | -bool GetCommunicatorIdentity(uint64_t commId, std::string& commName, uint64_t& commHash); | 36 | +bool GetCommunicatorIdentity(uint64_t commId, std::string &commName, |
| 37 | + uint64_t &commHash); | ||
| 29 | } // namespace sim | 38 | } // namespace sim |
| 30 | 39 | ||
| 31 | #endif // DB_SIM_COMMUNICATOR_H | 40 | #endif // DB_SIM_COMMUNICATOR_H |
| @@ -1,11 +1,18 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * the terms and conditions of CANN Open Software License Agreement Version 2.0 |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * (the "License"). Please refer to the License for details. You may not use |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * this file except in compliance with the License. THIS SOFTWARE IS PROVIDED ON |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS |
| 9 | + * FOR A PARTICULAR PURPOSE. See LICENSE in the root of the software repository | ||
| 10 | + * for the full text of the License. | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 15 | + * for the full text of the License. | ||
| 9 | */ | 16 | */ |
| 10 | 17 | ||
| 11 | #ifndef SIM_OP_DB_OPS_H | 18 | #ifndef SIM_OP_DB_OPS_H |
| @@ -20,52 +27,76 @@ | |||
| 20 | 27 | ||
| 21 | namespace sim { | 28 | namespace sim { |
| 22 | extern uint32_t g_currOpDetailId; | 29 | extern uint32_t g_currOpDetailId; |
| 30 | +extern uint32_t g_currOpMemId; | ||
| 31 | + | ||
| 32 | +/** | ||
| 33 | + * @brief 当前进程正在处理的算子迭代(= 最近一次 InsertOpDetail 分配的 | ||
| 34 | + * opIter)。 | ||
| 35 | + * | ||
| 36 | + * 用途:CCU 交换表(CcuSyncResTab)需要跨 rank 一致的 op | ||
| 37 | + * 身份来隔离不同算子的交换值。 opIter 由 InsertOpDetail 按 (commName, commHash) | ||
| 38 | + * 自增,两侧进程按同一算子序列 推进时天然对齐,可直接当 op 身份使用。 | ||
| 39 | + * | ||
| 40 | + * @return 最新分配的 opIter;尚无算子插入时为 0。 | ||
| 41 | + */ | ||
| 42 | +uint32_t GetCurOpIter(); | ||
| 23 | 43 | ||
| 24 | int InitOpDataDb(); | 44 | int InitOpDataDb(); |
| 25 | -int SetDbConfig(DBConfig& config); | 45 | +int SetDbConfig(DBConfig &config); |
| 26 | 46 | ||
| 27 | void AddSyncStreamIter(uint64_t streamId); | 47 | void AddSyncStreamIter(uint64_t streamId); |
| 28 | void RemoveSyncStreamIter(uint64_t streamId); | 48 | void RemoveSyncStreamIter(uint64_t streamId); |
| 29 | -bool NextStreamSyncIdx(uint64_t streamId, uint64_t& syncIdx); | 49 | +bool NextStreamSyncIdx(uint64_t streamId, uint64_t &syncIdx); |
| 30 | 50 | ||
| 31 | -int InsertOpDetail(OpDetailTab& rec); | 51 | +int InsertOpDetail(OpDetailTab &rec); |
| 32 | -int InsertOpMem(OpMemInfoTab& rec); | 52 | +int InsertOpMem(OpMemInfoTab &rec); |
| 33 | -int InsertOpDetailAndMem(OpDetailTab& detail, OpMemInfoTab& mem); | 53 | +int InsertOpDetailAndMem(OpDetailTab &detail, OpMemInfoTab &mem); |
| 34 | -int InsertCcuChannel(CcuChannelTab& rec); | 54 | +int InsertCcuChannel(CcuChannelTab &rec); |
| 35 | -int InsertJettyMap(JettyMapTab& rec); | 55 | +int InsertJettyMap(JettyMapTab &rec); |
| 36 | -int InsertOpTask(OpTaskTab& rec, bool isDevice = false); | 56 | +int InsertOpTask(OpTaskTab &rec, bool isDevice = false); |
| 37 | -int InsertSyncRecord(SyncRecordTab& rec); | 57 | +int InsertSyncRecord(SyncRecordTab &rec); |
| 38 | -int InsertCcuInstrRes(CcuInstrResTab& rec); | 58 | +int InsertCcuInstrRes(CcuInstrResTab &rec); |
| 39 | -int InsertCcuInstr(CcuInstrTab& rec); | 59 | +int InsertCcuInstr(CcuInstrTab &rec); |
| 40 | -int InsertHalfRTT(HalfRTTTab& rec); | 60 | +int InsertHalfRTT(HalfRTTTab &rec); |
| 41 | 61 | ||
| 42 | -int UpdateAndInsertByCcuId( | 62 | +int UpdateAndInsertByCcuId(uint64_t &ccuId, uint32_t deviceId, uint32_t dieId, |
| 43 | - uint64_t& ccuId, uint32_t deviceId, uint32_t dieId, uint32_t startId, uint32_t instrCount, uint32_t instrOffset, | 63 | + uint32_t startId, uint32_t instrCount, |
| 44 | - uint32_t instrInfoSize, const void* instrInfo, std::vector<uint8_t>* mergedInstrSpace = nullptr, | 64 | + uint32_t instrOffset, uint32_t instrInfoSize, |
| 45 | - uint32_t* totalInstrCount = nullptr); | 65 | + const void *instrInfo, |
| 46 | -int UpdateSyncRecordStatus(std::vector<SyncRecordTab>& syncRecord); | 66 | + std::vector<uint8_t> *mergedInstrSpace = nullptr, |
| 67 | + uint32_t *totalInstrCount = nullptr); | ||
| 68 | +int UpdateSyncRecordStatus(std::vector<SyncRecordTab> &syncRecord); | ||
| 47 | int UpdateOpMemCclBuffer(uint64_t cclAddr, uint64_t cclSize); | 69 | int UpdateOpMemCclBuffer(uint64_t cclAddr, uint64_t cclSize); |
| 48 | int UpdateOpExpansionMode(uint8_t mode); | 70 | int UpdateOpExpansionMode(uint8_t mode); |
| 71 | +int UpdateOpDetailMainStream(uint32_t opDetailId, uint64_t streamId); | ||
| 49 | 72 | ||
| 50 | int QueryLatestOpExpansionMode(); | 73 | int QueryLatestOpExpansionMode(); |
| 51 | -int QueryCcuChannelAll(std::vector<CcuChannelTab>& out); | 74 | +int QueryCcuChannelAll(std::vector<CcuChannelTab> &out); |
| 52 | -int QueryJettyMapAll(std::vector<JettyMapTab>& out); | 75 | +int QueryJettyMapAll(std::vector<JettyMapTab> &out); |
| 53 | -int QuerySyncRecordAll(std::vector<SyncRecordTab>& out); | 76 | +int QuerySyncRecordAll(std::vector<SyncRecordTab> &out); |
| 54 | -int QueryCcuInstrResAll(std::vector<CcuInstrResTab>& out); | 77 | +int QueryCcuInstrResAll(std::vector<CcuInstrResTab> &out); |
| 55 | -int QueryCcuResourceMetaCount(uint32_t& instrLoadCnt, uint32_t& channelCnt); | 78 | +int QueryCcuResourceMetaCount(uint32_t &instrLoadCnt, uint32_t &channelCnt); |
| 56 | -int QueryOpDetailIdentity(uint32_t opDetailId, uint64_t& commId, uint32_t& rankId, uint32_t& deviceId); | 79 | +int QueryOpDetailIdentity(uint32_t opDetailId, uint64_t &commId, |
| 57 | -int QueryCurrentOpMemInfo(uint64_t commId, uint32_t deviceId, OpMemInfoTab& out); | 80 | + uint32_t &rankId, uint32_t &deviceId); |
| 58 | -int QuerySyncRecordByStatus(uint8_t status, std::vector<SyncRecordTab>& out); | 81 | +int QueryOpDetailById(uint32_t opDetailId, OpDetailTab &out); |
| 59 | -int QueryOpExecutionIndexEntries(std::vector<OpExecutionIndexEntry>& out); | 82 | +int QueryLatestOpDetailByDeviceId(uint32_t deviceId, OpDetailTab &out); |
| 60 | -int QueryCompositeOpDetailBySyncIter(uint32_t syncIter, std::map<uint32_t, std::vector<CompositeOpDetail>>& detail); | 83 | +int QueryCurrentOpMemInfo(uint64_t commId, uint32_t deviceId, |
| 61 | -int QueryHalfRTTAll(std::vector<HalfRTTTab>& out); | 84 | + OpMemInfoTab &out); |
| 62 | -int QueryOpTaskTabNames(std::vector<std::string>& names); | 85 | +int QueryOpMemInfoByOpDetailId(uint32_t opDetailId, OpMemInfoTab &out); |
| 63 | -int QueryCompositeOpDetailByOpIter( | 86 | +int QuerySyncRecordByStatus(uint8_t status, std::vector<SyncRecordTab> &out); |
| 64 | - const std::string& commName, uint64_t commHash, uint32_t opIter, std::vector<CompositeOpDetail>& details); | 87 | +int QueryOpExecutionIndexEntries(std::vector<OpExecutionIndexEntry> &out); |
| 65 | -int QueryAllOpTasks(std::vector<OpTaskTab>& tasks, bool filterDone = false); | 88 | +int QueryCompositeOpDetailBySyncIter( |
| 66 | -int QueryOpTasksByStreamId(uint64_t streamId, std::vector<OpTaskTab>& tasks); | 89 | + uint32_t syncIter, |
| 67 | -int FinishOpTask(const OpTaskTab& task); | 90 | + std::map<uint32_t, std::vector<CompositeOpDetail>> &detail); |
| 68 | -int QueryHalfRTTAll(std::vector<HalfRTTTab>& out); | 91 | +int QueryHalfRTTAll(std::vector<HalfRTTTab> &out); |
| 92 | +int QueryOpTaskTabNames(std::vector<std::string> &names); | ||
| 93 | +int QueryCompositeOpDetailByOpIter(const std::string &commName, | ||
| 94 | + uint64_t commHash, uint32_t opIter, | ||
| 95 | + std::vector<CompositeOpDetail> &details); | ||
| 96 | +int QueryAllOpTasks(std::vector<OpTaskTab> &tasks, bool filterDone = false); | ||
| 97 | +int QueryOpTasksByStreamId(uint64_t streamId, std::vector<OpTaskTab> &tasks); | ||
| 98 | +int FinishOpTask(const OpTaskTab &task); | ||
| 99 | +int QueryHalfRTTAll(std::vector<HalfRTTTab> &out); | ||
| 69 | } // namespace sim | 100 | } // namespace sim |
| 70 | 101 | ||
| 71 | #endif | 102 | #endif |
| @@ -1,11 +1,18 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * the terms and conditions of CANN Open Software License Agreement Version 2.0 |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * (the "License"). Please refer to the License for details. You may not use |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * this file except in compliance with the License. THIS SOFTWARE IS PROVIDED ON |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS |
| 9 | + * FOR A PARTICULAR PURPOSE. See LICENSE in the root of the software repository | ||
| 10 | + * for the full text of the License. | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 15 | + * for the full text of the License. | ||
| 9 | */ | 16 | */ |
| 10 | 17 | ||
| 11 | #ifndef _SIM_RUNNER_COMMOM_H_ | 18 | #ifndef _SIM_RUNNER_COMMOM_H_ |
| @@ -30,18 +37,20 @@ namespace sim { | |||
| 30 | // 通信域server信息: 由TopoMetaConfig表项指向的topo_meta配置解析生成, | 37 | // 通信域server信息: 由TopoMetaConfig表项指向的topo_meta配置解析生成, |
| 31 | // 按rankId分配顺序排列 | 38 | // 按rankId分配顺序排列 |
| 32 | struct CommConfigServer { | 39 | struct CommConfigServer { |
| 33 | - uint64_t serverKey{0}; // Server表主键 | 40 | + uint64_t serverKey{0}; // Server表主键 |
| 34 | - uint32_t podId{0}; // 超级节点id | 41 | + uint32_t podId{0}; // 超级节点id |
| 35 | - uint32_t serverId{0}; // server id | 42 | + uint32_t serverId{0}; // server id |
| 36 | - uint32_t devNum{0}; // 通信域内该server的device数 | 43 | + uint32_t devNum{0}; // 通信域内该server的device数 |
| 37 | - uint32_t rankOffset{0}; // 该server首个rankId(前面server的device累计数) | 44 | + uint32_t rankOffset{0}; // 该server首个rankId(前面server的device累计数) |
| 38 | std::vector<PhyDeviceId> phyIds; // server内按rank顺序的物理device id | 45 | std::vector<PhyDeviceId> phyIds; // server内按rank顺序的物理device id |
| 39 | }; | 46 | }; |
| 40 | 47 | ||
| 41 | // 进程级通信域配置缓存(TopoMetaConfig指向的配置解析结果) | 48 | // 进程级通信域配置缓存(TopoMetaConfig指向的配置解析结果) |
| 42 | struct CommConfigData { | 49 | struct CommConfigData { |
| 43 | - std::string fileName; // topo_meta yaml文件名; "ranktable"表示ranktable.json模式 | 50 | + std::string |
| 44 | - std::vector<CommConfigServer> servers; // 按(podId, serverId)升序, 与rankId分配顺序一致 | 51 | + fileName; // topo_meta yaml文件名; "ranktable"表示ranktable.json模式 |
| 52 | + std::vector<CommConfigServer> | ||
| 53 | + servers; // 按(podId, serverId)升序, 与rankId分配顺序一致 | ||
| 45 | }; | 54 | }; |
| 46 | } // namespace sim | 55 | } // namespace sim |
| 47 | 56 | ||
| @@ -52,48 +61,57 @@ extern sim::CommConfigData g_comm_config_data; | |||
| 52 | namespace sim { | 61 | namespace sim { |
| 53 | // 仅供仍需"查找或复用"通信域成员的旧调用方使用; 主/子通信域创建路径均直接插入本 | 62 | // 仅供仍需"查找或复用"通信域成员的旧调用方使用; 主/子通信域创建路径均直接插入本 |
| 54 | // rank 的表行. | 63 | // rank 的表行. |
| 55 | -bool GetOrInsertCommunicator( | 64 | +bool GetOrInsertCommunicator(const char *commName, uint32_t rankSize, |
| 56 | - const char* commName, uint32_t rankSize, uint32_t rankId, uint64_t deviceId, uint64_t commHash, uint64_t& commId); | 65 | + uint32_t rankId, uint64_t deviceId, |
| 57 | -bool WaitCommunicatorReady(const char* commName, uint64_t commHash, uint32_t rankSize); | 66 | + uint64_t commHash, uint64_t &commId); |
| 67 | +bool WaitCommunicatorReady(const char *commName, uint64_t commHash, | ||
| 68 | + uint32_t rankSize); | ||
| 58 | // level 1 专用 | 69 | // level 1 专用 |
| 59 | bool WaitCommunicatorDestroyReady(uint64_t commId); | 70 | bool WaitCommunicatorDestroyReady(uint64_t commId); |
| 60 | // level 0 专用: 避免快卡提前销毁, 标记本 rank | 71 | // level 0 专用: 避免快卡提前销毁, 标记本 rank |
| 61 | // 已调用销毁接口并等待同通信域全部成员到达后再返回 | 72 | // 已调用销毁接口并等待同通信域全部成员到达后再返回 |
| 62 | bool MarkAndSyncCommunicatorDestroy(uint64_t commId); | 73 | bool MarkAndSyncCommunicatorDestroy(uint64_t commId); |
| 63 | 74 | ||
| 64 | -aclError GetDeviceByLogicId(uint32_t deviceId, sim::Device& device); | 75 | +aclError GetDeviceByLogicId(uint32_t deviceId, sim::Device &device); |
| 65 | -aclError GetDeviceByCommRank(uint64_t commId, uint32_t rankId, sim::Device& device); | 76 | +aclError GetDeviceByCommRank(uint64_t commId, uint32_t rankId, |
| 66 | -aclError GetDeviceByPhysicalId(uint32_t deviceId, sim::Device& device); | 77 | + sim::Device &device); |
| 67 | -aclError UpdateDeviceLogicId(uint64_t serverKey, uint32_t phyDevId, uint32_t logicDevId, uint32_t userId); | 78 | +aclError GetDeviceByPhysicalId(uint32_t deviceId, sim::Device &device); |
| 79 | +aclError UpdateDeviceLogicId(uint64_t serverKey, uint32_t phyDevId, | ||
| 80 | + uint32_t logicDevId, uint32_t userId); | ||
| 68 | aclError UpdateSuperDeviceId(uint32_t logicDevId, uint32_t superDeviceId); | 81 | aclError UpdateSuperDeviceId(uint32_t logicDevId, uint32_t superDeviceId); |
| 69 | -aclError GetCcuFromDeviceByDieId(uint64_t deviceKey, uint8_t dieId, sim::Ccu& ccu); | 82 | +aclError GetCcuFromDeviceByDieId(uint64_t deviceKey, uint8_t dieId, |
| 70 | -aclError GetCcuResourceByCcu(uint64_t ccuKey, sim::CcuResource& ccuRes); | 83 | + sim::Ccu &ccu); |
| 71 | -aclError GetContextByDevId(uint32_t deviceId, sim::Context& context); | 84 | +aclError GetContextByDevId(uint32_t deviceId, sim::Context &context); |
| 72 | -aclError GetPortByName(uint64_t serverKey, uint32_t phyDevId, const std::string& name, sim::Port& port); | 85 | +aclError GetPortByName(uint64_t serverKey, uint32_t phyDevId, |
| 73 | -aclError GetEndPointByIpAddr(const std::string& ip, sim::EndPoint& endPoint); | 86 | + const std::string &name, sim::Port &port); |
| 74 | -aclError GetEndPointByEid(const IpAddress& addr, sim::EndPoint& endPoint); | 87 | +aclError GetEndPointByIpAddr(const std::string &ip, sim::EndPoint &endPoint); |
| 75 | -aclError GetPortById(uint64_t portId, sim::Port& port); | 88 | +aclError GetEndPointByEid(const IpAddress &addr, sim::EndPoint &endPoint); |
| 89 | +aclError GetPortById(uint64_t portId, sim::Port &port); | ||
| 76 | 90 | ||
| 77 | uint32_t GetAICpuCount(uint64_t deviceId); | 91 | uint32_t GetAICpuCount(uint64_t deviceId); |
| 78 | uint32_t GetAICoreCount(uint64_t deviceId); | 92 | uint32_t GetAICoreCount(uint64_t deviceId); |
| 79 | uint32_t GetVectorCoreCount(uint64_t deviceId); | 93 | uint32_t GetVectorCoreCount(uint64_t deviceId); |
| 80 | std::string GetHardwareTypeByDevice(uint64_t deviceId); | 94 | std::string GetHardwareTypeByDevice(uint64_t deviceId); |
| 81 | -bool GetCommRankByDeviceId(uint64_t commId, uint32_t deviceId, uint32_t& rankId); | 95 | +bool GetCommRankByDeviceId(uint64_t commId, uint32_t deviceId, |
| 96 | + uint32_t &rankId); | ||
| 82 | bool ResetAllDeviceLogicId(); | 97 | bool ResetAllDeviceLogicId(); |
| 83 | -bool GetRankIdByMPI(uint32_t& rankId, uint64_t& serverId); | 98 | +bool GetRankIdByMPI(uint32_t &rankId, uint64_t &serverId); |
| 84 | uint64_t GetCurServerId(); | 99 | uint64_t GetCurServerId(); |
| 85 | 100 | ||
| 86 | // 公共解析函数: 解析topo_meta | 101 | // 公共解析函数: 解析topo_meta |
| 87 | // yaml(或ranktable模式下的data/ranktable.json)生成通信域server有序表. | 102 | // yaml(或ranktable模式下的data/ranktable.json)生成通信域server有序表. |
| 88 | // topoMeta非空时直接使用调用方已解析的结果, 避免重复读文件 | 103 | // topoMeta非空时直接使用调用方已解析的结果, 避免重复读文件 |
| 89 | -bool ParseCommConfigData(const std::string& fileName, const TopoMeta* topoMeta, CommConfigData& data); | 104 | +bool ParseCommConfigData(const std::string &fileName, const TopoMeta *topoMeta, |
| 105 | + CommConfigData &data); | ||
| 90 | // mock-comm每次执行时调用: 覆盖TopoMetaConfig表项并刷新本进程g_comm_config_data | 106 | // mock-comm每次执行时调用: 覆盖TopoMetaConfig表项并刷新本进程g_comm_config_data |
| 91 | -bool RefreshTopoMetaConfig(const std::string& fileName, const TopoMeta* topoMeta = nullptr); | 107 | +bool RefreshTopoMetaConfig(const std::string &fileName, |
| 108 | + const TopoMeta *topoMeta = nullptr); | ||
| 92 | // 通信域重置时清空进程缓存, 下次使用时按TopoMetaConfig表项重新加载 | 109 | // 通信域重置时清空进程缓存, 下次使用时按TopoMetaConfig表项重新加载 |
| 93 | void ResetCommConfigData(); | 110 | void ResetCommConfigData(); |
| 94 | // rankId → 所属server的serverKey | 111 | // rankId → 所属server的serverKey |
| 95 | -bool GetServerKeyByRankId(uint32_t rankId, uint64_t& serverKey); | 112 | +bool GetServerKeyByRankId(uint32_t rankId, uint64_t &serverKey); |
| 96 | // serverKey + 物理device id → 通信域内device序号(与Device.logic_id一致) | 113 | // serverKey + 物理device id → 通信域内device序号(与Device.logic_id一致) |
| 97 | -aclError GetDevIndexByPhyId(uint64_t serverKey, uint32_t phyId, uint32_t& devIndex); | 114 | +aclError GetDevIndexByPhyId(uint64_t serverKey, uint32_t phyId, |
| 115 | + uint32_t &devIndex); | ||
| 98 | } // namespace sim | 116 | } // namespace sim |
| 99 | #endif // _SIM_RUNNER_COMMOM_H_ | 117 | #endif // _SIM_RUNNER_COMMOM_H_ |
| @@ -1,11 +1,18 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * the terms and conditions of CANN Open Software License Agreement Version 2.0 |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * (the "License"). Please refer to the License for details. You may not use |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * this file except in compliance with the License. THIS SOFTWARE IS PROVIDED ON |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS |
| 9 | + * FOR A PARTICULAR PURPOSE. See LICENSE in the root of the software repository | ||
| 10 | + * for the full text of the License. | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 15 | + * for the full text of the License. | ||
| 9 | */ | 16 | */ |
| 10 | 17 | ||
| 11 | #ifndef SIM_RUNNER_DB_H | 18 | #ifndef SIM_RUNNER_DB_H |
| @@ -18,26 +25,24 @@ | |||
| 18 | #include "sim_models.h" | 25 | #include "sim_models.h" |
| 19 | #include "sim_runner_impl.inl" | 26 | #include "sim_runner_impl.inl" |
| 20 | namespace RunnerDB { | 27 | namespace RunnerDB { |
| 21 | -template <typename T> | 28 | +template <typename T> uint64_t Add(T &rec); |
| 22 | -uint64_t Add(T& rec); | 29 | + |
| 30 | +template <typename T> std::vector<uint64_t> AddBatch(std::vector<T> &recs); | ||
| 31 | + | ||
| 32 | +template <typename T> std::optional<T> GetById(uint64_t id); | ||
| 23 | 33 | ||
| 24 | template <typename T> | 34 | template <typename T> |
| 25 | -std::optional<T> GetById(uint64_t id); | 35 | +std::vector<T> GetByPred(std::function<bool(const T &)> pred); |
| 26 | 36 | ||
| 27 | template <typename T> | 37 | template <typename T> |
| 28 | -std::vector<T> GetByPred(std::function<bool(const T&)> pred); | 38 | +std::pair<T, bool> GetOneByPred(std::function<bool(const T &)> pred); |
| 29 | 39 | ||
| 30 | template <typename T> | 40 | template <typename T> |
| 31 | -std::pair<T, bool> GetOneByPred(std::function<bool(const T&)> pred); | 41 | +bool Update(uint64_t id, std::function<void(T &)> updater); |
| 32 | 42 | ||
| 33 | -template <typename T> | 43 | +template <typename T> bool Delete(uint64_t id); |
| 34 | -bool Update(uint64_t id, std::function<void(T&)> updater); | ||
| 35 | 44 | ||
| 36 | -template <typename T> | 45 | +template <typename T> bool DeleteAll(); |
| 37 | -bool Delete(uint64_t id); | ||
| 38 | - | ||
| 39 | -template <typename T> | ||
| 40 | -bool DeleteAll(); | ||
| 41 | 46 | ||
| 42 | std::vector<std::string> GetAllTableName(); | 47 | std::vector<std::string> GetAllTableName(); |
| 43 | } // namespace RunnerDB | 48 | } // namespace RunnerDB |
| @@ -1,11 +1,18 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * the terms and conditions of CANN Open Software License Agreement Version 2.0 |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * (the "License"). Please refer to the License for details. You may not use |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * this file except in compliance with the License. THIS SOFTWARE IS PROVIDED ON |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS |
| 9 | + * FOR A PARTICULAR PURPOSE. See LICENSE in the root of the software repository | ||
| 10 | + * for the full text of the License. | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 15 | + * for the full text of the License. | ||
| 9 | */ | 16 | */ |
| 10 | 17 | ||
| 11 | #ifndef _SIM_RUNNER_OPS_H_ | 18 | #ifndef _SIM_RUNNER_OPS_H_ |
| @@ -17,7 +24,7 @@ | |||
| 17 | #include "sim_models.h" | 24 | #include "sim_models.h" |
| 18 | 25 | ||
| 19 | namespace sim { | 26 | namespace sim { |
| 20 | -bool GetCurrRunnerTls(uint64_t serverKey, Runner& runner); | 27 | +bool GetCurrRunnerTls(uint64_t serverKey, Runner &runner); |
| 21 | bool SetCurrCtxTls(uint64_t ctx); | 28 | bool SetCurrCtxTls(uint64_t ctx); |
| 22 | uint64_t GetCurrDeviceId(); | 29 | uint64_t GetCurrDeviceId(); |
| 23 | uint64_t GetCurrDeviceKey(); | 30 | uint64_t GetCurrDeviceKey(); |
| @@ -1,11 +1,18 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * the terms and conditions of CANN Open Software License Agreement Version 2.0 |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * (the "License"). Please refer to the License for details. You may not use |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * this file except in compliance with the License. THIS SOFTWARE IS PROVIDED ON |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS |
| 9 | + * FOR A PARTICULAR PURPOSE. See LICENSE in the root of the software repository | ||
| 10 | + * for the full text of the License. | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 15 | + * for the full text of the License. | ||
| 9 | */ | 16 | */ |
| 10 | 17 | ||
| 11 | #ifndef SIM_SQLITE_DB_H | 18 | #ifndef SIM_SQLITE_DB_H |
| @@ -35,7 +42,7 @@ template <typename T> | |||
| 35 | using TableValue = typename sim::SqliteTable<T>::ValueType; | 42 | using TableValue = typename sim::SqliteTable<T>::ValueType; |
| 36 | 43 | ||
| 37 | struct SimRunnerSqliteDB { | 44 | struct SimRunnerSqliteDB { |
| 38 | -private: | 45 | + private: |
| 39 | sim::SqliteDatabase m_db; | 46 | sim::SqliteDatabase m_db; |
| 40 | 47 | ||
| 41 | sim::SqliteTable<sim::Server> m_serverTbl; | 48 | sim::SqliteTable<sim::Server> m_serverTbl; |
| @@ -59,7 +66,6 @@ private: | |||
| 59 | sim::SqliteTable<sim::EventSyncTask> m_eventSyncTaskTbl; | 66 | sim::SqliteTable<sim::EventSyncTask> m_eventSyncTaskTbl; |
| 60 | sim::SqliteTable<sim::Port> m_portTbl; | 67 | sim::SqliteTable<sim::Port> m_portTbl; |
| 61 | sim::SqliteTable<sim::Ccu> m_ccuTbl; | 68 | sim::SqliteTable<sim::Ccu> m_ccuTbl; |
| 62 | - sim::SqliteTable<sim::CcuResource> m_ccuResTbl; | ||
| 63 | sim::SqliteTable<sim::DeviceConnection> m_deviceConnTbl; | 69 | sim::SqliteTable<sim::DeviceConnection> m_deviceConnTbl; |
| 64 | sim::SqliteTable<sim::EndPointPair> m_endPointPairTbl; | 70 | sim::SqliteTable<sim::EndPointPair> m_endPointPairTbl; |
| 65 | sim::SqliteTable<sim::EndPointPortMapping> m_endPointPortMappingTbl; | 71 | sim::SqliteTable<sim::EndPointPortMapping> m_endPointPortMappingTbl; |
| @@ -103,23 +109,22 @@ private: | |||
| 103 | sim::SqliteTable<sim::Plugin> m_pluginTbl; | 109 | sim::SqliteTable<sim::Plugin> m_pluginTbl; |
| 104 | sim::SqliteTable<sim::DpuPendingNotify> m_dpuPendingNotifyTbl; | 110 | sim::SqliteTable<sim::DpuPendingNotify> m_dpuPendingNotifyTbl; |
| 105 | sim::SqliteTable<sim::DpuDeviceInfo> m_dpuDeviceInfoTbl; | 111 | sim::SqliteTable<sim::DpuDeviceInfo> m_dpuDeviceInfoTbl; |
| 112 | + sim::SqliteTable<sim::CcuSyncResTab> m_ccuSyncResTbl; | ||
| 106 | 113 | ||
| 107 | std::mutex m_lazyMutex; | 114 | std::mutex m_lazyMutex; |
| 108 | - std::unordered_map<std::type_index, sim::TableBase*> m_tableMap; | 115 | + std::unordered_map<std::type_index, sim::TableBase *> m_tableMap; |
| 109 | std::vector<std::string> m_tableNames; | 116 | std::vector<std::string> m_tableNames; |
| 110 | std::vector<std::unique_ptr<sim::TableBase>> m_lazyTables; | 117 | std::vector<std::unique_ptr<sim::TableBase>> m_lazyTables; |
| 111 | 118 | ||
| 112 | template <typename T> | 119 | template <typename T> |
| 113 | - void RegisterTable(sim::SqliteTable<T>& table, const std::string& name) | 120 | + void RegisterTable(sim::SqliteTable<T> &table, const std::string &name) { |
| 114 | - { | ||
| 115 | m_tableMap[std::type_index(typeid(T))] = &table; | 121 | m_tableMap[std::type_index(typeid(T))] = &table; |
| 116 | m_tableNames.push_back(name); | 122 | m_tableNames.push_back(name); |
| 117 | } | 123 | } |
| 118 | 124 | ||
| 119 | -public: | 125 | + public: |
| 120 | SimRunnerSqliteDB() | 126 | SimRunnerSqliteDB() |
| 121 | - : m_serverTbl(m_db.GetDb(), "Server"), | 127 | + : m_serverTbl(m_db.GetDb(), "Server"), m_hostTbl(m_db.GetDb(), "Host"), |
| 122 | - m_hostTbl(m_db.GetDb(), "Host"), | ||
| 123 | m_runnerTbl(m_db.GetDb(), "Runner"), | 128 | m_runnerTbl(m_db.GetDb(), "Runner"), |
| 124 | m_communicatorTbl(m_db.GetDb(), "Communicator"), | 129 | m_communicatorTbl(m_db.GetDb(), "Communicator"), |
| 125 | m_communicatorDestroySyncTbl(m_db.GetDb(), "CommunicatorDestroySync"), | 130 | m_communicatorDestroySyncTbl(m_db.GetDb(), "CommunicatorDestroySync"), |
| @@ -137,9 +142,7 @@ public: | |||
| 137 | m_fdMemWhiteListTbl(m_db.GetDb(), "FdMemWhiteList"), | 142 | m_fdMemWhiteListTbl(m_db.GetDb(), "FdMemWhiteList"), |
| 138 | m_taskTbl(m_db.GetDb(), "Task"), | 143 | m_taskTbl(m_db.GetDb(), "Task"), |
| 139 | m_eventSyncTaskTbl(m_db.GetDb(), "EventSyncTask"), | 144 | m_eventSyncTaskTbl(m_db.GetDb(), "EventSyncTask"), |
| 140 | - m_portTbl(m_db.GetDb(), "Port"), | 145 | + m_portTbl(m_db.GetDb(), "Port"), m_ccuTbl(m_db.GetDb(), "Ccu"), |
| 141 | - m_ccuTbl(m_db.GetDb(), "Ccu"), | ||
| 142 | - m_ccuResTbl(m_db.GetDb(), "CcuResource"), | ||
| 143 | m_deviceConnTbl(m_db.GetDb(), "DeviceConnection"), | 146 | m_deviceConnTbl(m_db.GetDb(), "DeviceConnection"), |
| 144 | m_endPointTbl(m_db.GetDb(), "EndPoint"), | 147 | m_endPointTbl(m_db.GetDb(), "EndPoint"), |
| 145 | m_endPointPairTbl(m_db.GetDb(), "EndPointPair"), | 148 | m_endPointPairTbl(m_db.GetDb(), "EndPointPair"), |
| @@ -151,10 +154,8 @@ public: | |||
| 151 | m_raSocketTbl(m_db.GetDb(), "RaSocket"), | 154 | m_raSocketTbl(m_db.GetDb(), "RaSocket"), |
| 152 | m_raSocketPairTbl(m_db.GetDb(), "RaSocketPair"), | 155 | m_raSocketPairTbl(m_db.GetDb(), "RaSocketPair"), |
| 153 | m_raDeviceTbl(m_db.GetDb(), "RaDevice"), | 156 | m_raDeviceTbl(m_db.GetDb(), "RaDevice"), |
| 154 | - m_raQPTbl(m_db.GetDb(), "RaQP"), | 157 | + m_raQPTbl(m_db.GetDb(), "RaQP"), m_raCQTbl(m_db.GetDb(), "RaCQ"), |
| 155 | - m_raCQTbl(m_db.GetDb(), "RaCQ"), | 158 | + m_raCQETbl(m_db.GetDb(), "RaCQE"), m_raMRTbl(m_db.GetDb(), "RaMR"), |
| 156 | - m_raCQETbl(m_db.GetDb(), "RaCQE"), | ||
| 157 | - m_raMRTbl(m_db.GetDb(), "RaMR"), | ||
| 158 | m_memoryLayoutTbl(m_db.GetDb(), "MemoryLayout"), | 159 | m_memoryLayoutTbl(m_db.GetDb(), "MemoryLayout"), |
| 159 | m_simModelDataTbl(m_db.GetDb(), "SimModelData"), | 160 | m_simModelDataTbl(m_db.GetDb(), "SimModelData"), |
| 160 | m_ipcNotifyTbl(m_db.GetDb(), "IpcNotify"), | 161 | m_ipcNotifyTbl(m_db.GetDb(), "IpcNotify"), |
| @@ -164,12 +165,10 @@ public: | |||
| 164 | m_raContextTbl(m_db.GetDb(), "RaContext"), | 165 | m_raContextTbl(m_db.GetDb(), "RaContext"), |
| 165 | m_raChanTbl(m_db.GetDb(), "RaChan"), | 166 | m_raChanTbl(m_db.GetDb(), "RaChan"), |
| 166 | m_raTokenIdTbl(m_db.GetDb(), "RaTokenId"), | 167 | m_raTokenIdTbl(m_db.GetDb(), "RaTokenId"), |
| 167 | - m_raTpTbl(m_db.GetDb(), "RaTp"), | 168 | + m_raTpTbl(m_db.GetDb(), "RaTp"), m_raRmemTbl(m_db.GetDb(), "RaRmem"), |
| 168 | - m_raRmemTbl(m_db.GetDb(), "RaRmem"), | ||
| 169 | m_raLmemTbl(m_db.GetDb(), "RaLmem"), | 169 | m_raLmemTbl(m_db.GetDb(), "RaLmem"), |
| 170 | m_raJettyTbl(m_db.GetDb(), "RaJetty"), | 170 | m_raJettyTbl(m_db.GetDb(), "RaJetty"), |
| 171 | - m_raJfcTbl(m_db.GetDb(), "RaJfc"), | 171 | + m_raJfcTbl(m_db.GetDb(), "RaJfc"), m_raCrTbl(m_db.GetDb(), "RaCr"), |
| 172 | - m_raCrTbl(m_db.GetDb(), "RaCr"), | ||
| 173 | m_raTlvTbl(m_db.GetDb(), "RaTlv"), | 172 | m_raTlvTbl(m_db.GetDb(), "RaTlv"), |
| 174 | m_runModeConfigTbl(m_db.GetDb(), "RunModeConfig"), | 173 | m_runModeConfigTbl(m_db.GetDb(), "RunModeConfig"), |
| 175 | m_hcclBufferTbl(m_db.GetDb(), "HcclBuffer"), | 174 | m_hcclBufferTbl(m_db.GetDb(), "HcclBuffer"), |
| @@ -182,8 +181,8 @@ public: | |||
| 182 | m_topoMetaConfigTbl(m_db.GetDb(), "TopoMetaConfig"), | 181 | m_topoMetaConfigTbl(m_db.GetDb(), "TopoMetaConfig"), |
| 183 | m_pluginTbl(m_db.GetDb(), "Plugin"), | 182 | m_pluginTbl(m_db.GetDb(), "Plugin"), |
| 184 | m_dpuPendingNotifyTbl(m_db.GetDb(), "DpuPendingNotify"), | 183 | m_dpuPendingNotifyTbl(m_db.GetDb(), "DpuPendingNotify"), |
| 185 | - m_dpuDeviceInfoTbl(m_db.GetDb(), "DpuDeviceInfo") | 184 | + m_dpuDeviceInfoTbl(m_db.GetDb(), "DpuDeviceInfo"), |
| 186 | - { | 185 | + m_ccuSyncResTbl(m_db.GetDb(), "CcuSyncRes") { |
| 187 | RegisterTable(m_serverTbl, "Server"); | 186 | RegisterTable(m_serverTbl, "Server"); |
| 188 | RegisterTable(m_hostTbl, "Host"); | 187 | RegisterTable(m_hostTbl, "Host"); |
| 189 | RegisterTable(m_runnerTbl, "Runner"); | 188 | RegisterTable(m_runnerTbl, "Runner"); |
| @@ -205,7 +204,6 @@ public: | |||
| 205 | RegisterTable(m_eventSyncTaskTbl, "EventSyncTask"); | 204 | RegisterTable(m_eventSyncTaskTbl, "EventSyncTask"); |
| 206 | RegisterTable(m_portTbl, "Port"); | 205 | RegisterTable(m_portTbl, "Port"); |
| 207 | RegisterTable(m_ccuTbl, "Ccu"); | 206 | RegisterTable(m_ccuTbl, "Ccu"); |
| 208 | - RegisterTable(m_ccuResTbl, "CcuResource"); | ||
| 209 | RegisterTable(m_deviceConnTbl, "DeviceConnection"); | 207 | RegisterTable(m_deviceConnTbl, "DeviceConnection"); |
| 210 | RegisterTable(m_endPointPairTbl, "EndPointPair"); | 208 | RegisterTable(m_endPointPairTbl, "EndPointPair"); |
| 211 | RegisterTable(m_endPointPortMappingTbl, "EndPointPortMapping"); | 209 | RegisterTable(m_endPointPortMappingTbl, "EndPointPortMapping"); |
| @@ -249,17 +247,17 @@ public: | |||
| 249 | RegisterTable(m_pluginTbl, "Plugin"); | 247 | RegisterTable(m_pluginTbl, "Plugin"); |
| 250 | RegisterTable(m_dpuPendingNotifyTbl, "DpuPendingNotify"); | 248 | RegisterTable(m_dpuPendingNotifyTbl, "DpuPendingNotify"); |
| 251 | RegisterTable(m_dpuDeviceInfoTbl, "DpuDeviceInfo"); | 249 | RegisterTable(m_dpuDeviceInfoTbl, "DpuDeviceInfo"); |
| 250 | + RegisterTable(m_ccuSyncResTbl, "CcuSyncRes"); | ||
| 252 | } | 251 | } |
| 253 | 252 | ||
| 254 | - SimRunnerSqliteDB(const SimRunnerSqliteDB&) = delete; | 253 | + SimRunnerSqliteDB(const SimRunnerSqliteDB &) = delete; |
| 255 | - SimRunnerSqliteDB& operator=(const SimRunnerSqliteDB&) = delete; | 254 | + SimRunnerSqliteDB &operator=(const SimRunnerSqliteDB &) = delete; |
| 256 | - SimRunnerSqliteDB(SimRunnerSqliteDB&&) = delete; | 255 | + SimRunnerSqliteDB(SimRunnerSqliteDB &&) = delete; |
| 257 | - SimRunnerSqliteDB& operator=(SimRunnerSqliteDB&&) = delete; | 256 | + SimRunnerSqliteDB &operator=(SimRunnerSqliteDB &&) = delete; |
| 258 | 257 | ||
| 259 | - static SimRunnerSqliteDB& Instance() | 258 | + static SimRunnerSqliteDB &Instance() { |
| 260 | - { | ||
| 261 | static std::mutex s_mtx; | 259 | static std::mutex s_mtx; |
| 262 | - static SimRunnerSqliteDB* s_instance = nullptr; | 260 | + static SimRunnerSqliteDB *s_instance = nullptr; |
| 263 | 261 | ||
| 264 | std::lock_guard<std::mutex> lock(s_mtx); | 262 | std::lock_guard<std::mutex> lock(s_mtx); |
| 265 | if (s_instance == nullptr) { | 263 | if (s_instance == nullptr) { |
| @@ -268,73 +266,62 @@ public: | |||
| 268 | return *s_instance; | 266 | return *s_instance; |
| 269 | } | 267 | } |
| 270 | 268 | ||
| 271 | - template <typename T> | 269 | + template <typename T> sim::SqliteTable<T> &GetTable() { |
| 272 | - sim::SqliteTable<T>& GetTable() | ||
| 273 | - { | ||
| 274 | std::lock_guard<std::mutex> lock(m_lazyMutex); | 270 | std::lock_guard<std::mutex> lock(m_lazyMutex); |
| 275 | auto it = m_tableMap.find(std::type_index(typeid(T))); | 271 | auto it = m_tableMap.find(std::type_index(typeid(T))); |
| 276 | if (it != m_tableMap.end()) { | 272 | if (it != m_tableMap.end()) { |
| 277 | - return *static_cast<sim::SqliteTable<T>*>(it->second); | 273 | + return *static_cast<sim::SqliteTable<T> *>(it->second); |
| 278 | } | 274 | } |
| 279 | std::string name = std::string("Unregistered_") + typeid(T).name(); | 275 | std::string name = std::string("Unregistered_") + typeid(T).name(); |
| 280 | - HCCL_VM_WARN( | 276 | + HCCL_VM_WARN("[SimRunnerSqliteDB::GetTable] Lazily registering " |
| 281 | - "[SimRunnerSqliteDB::GetTable] Lazily registering " | 277 | + "unregistered type: {}", |
| 282 | - "unregistered type: {}", | 278 | + name.c_str()); |
| 283 | - name.c_str()); | ||
| 284 | auto table = std::make_unique<sim::SqliteTable<T>>(m_db.GetDb(), name); | 279 | auto table = std::make_unique<sim::SqliteTable<T>>(m_db.GetDb(), name); |
| 285 | - auto* rawPtr = table.get(); | 280 | + auto *rawPtr = table.get(); |
| 286 | m_lazyTables.push_back(std::move(table)); | 281 | m_lazyTables.push_back(std::move(table)); |
| 287 | m_tableMap[std::type_index(typeid(T))] = rawPtr; | 282 | m_tableMap[std::type_index(typeid(T))] = rawPtr; |
| 288 | m_tableNames.push_back(name); | 283 | m_tableNames.push_back(name); |
| 289 | return *rawPtr; | 284 | return *rawPtr; |
| 290 | } | 285 | } |
| 291 | 286 | ||
| 292 | - template <typename T> | 287 | + template <typename T> std::optional<T> Find(TableKeyType<T> id) { |
| 293 | - std::optional<T> Find(TableKeyType<T> id) | ||
| 294 | - { | ||
| 295 | return GetTable<T>().Find(id); | 288 | return GetTable<T>().Find(id); |
| 296 | } | 289 | } |
| 297 | 290 | ||
| 298 | template <typename T> | 291 | template <typename T> |
| 299 | - std::pair<TableValue<T>, bool> Query(std::function<bool(const T&)> pred) | 292 | + std::pair<TableValue<T>, bool> Query(std::function<bool(const T &)> pred) { |
| 300 | - { | ||
| 301 | return GetTable<T>().Query(pred); | 293 | return GetTable<T>().Query(pred); |
| 302 | } | 294 | } |
| 303 | 295 | ||
| 304 | template <typename T> | 296 | template <typename T> |
| 305 | - std::vector<TableValue<T>> QueryList(std::function<bool(const T&)> pred) | 297 | + std::vector<TableValue<T>> QueryList(std::function<bool(const T &)> pred) { |
| 306 | - { | ||
| 307 | return GetTable<T>().QueryList(pred); | 298 | return GetTable<T>().QueryList(pred); |
| 308 | } | 299 | } |
| 309 | 300 | ||
| 310 | - template <typename T> | 301 | + template <typename T> TableKeyType<T> Add(T rec) { |
| 311 | - TableKeyType<T> Add(T rec) | ||
| 312 | - { | ||
| 313 | return GetTable<T>().Add(rec); | 302 | return GetTable<T>().Add(rec); |
| 314 | } | 303 | } |
| 315 | 304 | ||
| 316 | template <typename T> | 305 | template <typename T> |
| 317 | - bool Update(TableKeyType<T> id, std::function<void(T&)> updater) | 306 | + std::vector<TableKeyType<T>> AddBatch(std::vector<T> &recs) { |
| 318 | - { | 307 | + return GetTable<T>().AddBatch(recs); |
| 308 | + } | ||
| 309 | + | ||
| 310 | + template <typename T> | ||
| 311 | + bool Update(TableKeyType<T> id, std::function<void(T &)> updater) { | ||
| 319 | return GetTable<T>().Update(id, updater); | 312 | return GetTable<T>().Update(id, updater); |
| 320 | } | 313 | } |
| 321 | 314 | ||
| 322 | - template <typename T> | 315 | + template <typename T> bool Delete(TableKeyType<T> id) { |
| 323 | - bool Delete(TableKeyType<T> id) | ||
| 324 | - { | ||
| 325 | return GetTable<T>().Delete(id); | 316 | return GetTable<T>().Delete(id); |
| 326 | } | 317 | } |
| 327 | 318 | ||
| 328 | - template <typename T> | 319 | + template <typename T> bool DeleteAll() { return GetTable<T>().DeleteAll(); } |
| 329 | - bool DeleteAll() | ||
| 330 | - { | ||
| 331 | - return GetTable<T>().DeleteAll(); | ||
| 332 | - } | ||
| 333 | 320 | ||
| 334 | std::vector<std::string> GetAllTableName() const { return m_tableNames; } | 321 | std::vector<std::string> GetAllTableName() const { return m_tableNames; } |
| 335 | 322 | ||
| 336 | // 获取底层数据库连接对象(供批量写事务SqliteWriteTransaction使用) | 323 | // 获取底层数据库连接对象(供批量写事务SqliteWriteTransaction使用) |
| 337 | - sim::SqliteDatabase& GetDatabase() { return m_db; } | 324 | + sim::SqliteDatabase &GetDatabase() { return m_db; } |
| 338 | 325 | ||
| 339 | void ClearAll() { m_db.ClearAllTables(); } | 326 | void ClearAll() { m_db.ClearAllTables(); } |
| 340 | }; | 327 | }; |
| @@ -345,26 +332,25 @@ namespace sim { | |||
| 345 | // 显式调用Commit()提交; 未提交即离开作用域(异常/提前返回)时自动回滚。 | 332 | // 显式调用Commit()提交; 未提交即离开作用域(异常/提前返回)时自动回滚。 |
| 346 | // 注意: 事务期间应保证无其他线程并发写库。 | 333 | // 注意: 事务期间应保证无其他线程并发写库。 |
| 347 | class SqliteWriteTransaction { | 334 | class SqliteWriteTransaction { |
| 348 | -public: | 335 | + public: |
| 349 | - SqliteWriteTransaction() : db_(SimRunnerSqliteDB::Instance().GetDatabase()), began_(false), committed_(false) | 336 | + SqliteWriteTransaction() |
| 350 | - { | 337 | + : db_(SimRunnerSqliteDB::Instance().GetDatabase()), began_(false), |
| 338 | + committed_(false) { | ||
| 351 | began_ = db_.BeginTransaction(); | 339 | began_ = db_.BeginTransaction(); |
| 352 | } | 340 | } |
| 353 | 341 | ||
| 354 | - ~SqliteWriteTransaction() | 342 | + ~SqliteWriteTransaction() { |
| 355 | - { | ||
| 356 | if (began_ && !committed_) { | 343 | if (began_ && !committed_) { |
| 357 | db_.RollbackTransaction(); | 344 | db_.RollbackTransaction(); |
| 358 | } | 345 | } |
| 359 | } | 346 | } |
| 360 | 347 | ||
| 361 | - SqliteWriteTransaction(const SqliteWriteTransaction&) = delete; | 348 | + SqliteWriteTransaction(const SqliteWriteTransaction &) = delete; |
| 362 | - SqliteWriteTransaction& operator=(const SqliteWriteTransaction&) = delete; | 349 | + SqliteWriteTransaction &operator=(const SqliteWriteTransaction &) = delete; |
| 363 | - SqliteWriteTransaction(SqliteWriteTransaction&&) = delete; | 350 | + SqliteWriteTransaction(SqliteWriteTransaction &&) = delete; |
| 364 | - SqliteWriteTransaction& operator=(SqliteWriteTransaction&&) = delete; | 351 | + SqliteWriteTransaction &operator=(SqliteWriteTransaction &&) = delete; |
| 365 | 352 | ||
| 366 | - bool Commit() | 353 | + bool Commit() { |
| 367 | - { | ||
| 368 | if (!began_ || committed_) { | 354 | if (!began_ || committed_) { |
| 369 | return began_ && committed_; | 355 | return began_ && committed_; |
| 370 | } | 356 | } |
| @@ -372,8 +358,8 @@ public: | |||
| 372 | return committed_; | 358 | return committed_; |
| 373 | } | 359 | } |
| 374 | 360 | ||
| 375 | -private: | 361 | + private: |
| 376 | - SqliteDatabase& db_; | 362 | + SqliteDatabase &db_; |
| 377 | bool began_; | 363 | bool began_; |
| 378 | bool committed_; | 364 | bool committed_; |
| 379 | }; | 365 | }; |
| @@ -1,11 +1,18 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * the terms and conditions of CANN Open Software License Agreement Version 2.0 |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * (the "License"). Please refer to the License for details. You may not use |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * this file except in compliance with the License. THIS SOFTWARE IS PROVIDED ON |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS |
| 9 | + * FOR A PARTICULAR PURPOSE. See LICENSE in the root of the software repository | ||
| 10 | + * for the full text of the License. | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 15 | + * for the full text of the License. | ||
| 9 | */ | 16 | */ |
| 10 | 17 | ||
| 11 | #ifndef SIM_MODEL_DEFS_H | 18 | #ifndef SIM_MODEL_DEFS_H |
| @@ -68,9 +75,9 @@ enum CommStatus : uint8_t { | |||
| 68 | }; | 75 | }; |
| 69 | 76 | ||
| 70 | typedef struct { | 77 | typedef struct { |
| 71 | - uint64_t id; // PK(通信域锚点成员:同一 (comm_id, comm_hash) 下 id | 78 | + uint64_t id; // PK(通信域锚点成员:同一 (comm_id, comm_hash) 下 id |
| 72 | - // 最小者作为通信域标识) | 79 | + // 最小者作为通信域标识) |
| 73 | - char comm_id[128]; // 通信域名称,与 comm_hash 共同唯一标识通信域 | 80 | + char comm_id[128]; // 通信域名称,与 comm_hash 共同唯一标识通信域 |
| 74 | uint32_t rank_size; // 通信域总 Rank 数 | 81 | uint32_t rank_size; // 通信域总 Rank 数 |
| 75 | uint32_t rank_id; // 当前线程在通信域中的 Rank | 82 | uint32_t rank_id; // 当前线程在通信域中的 Rank |
| 76 | uint64_t device_id; // FK -> Device.id | 83 | uint64_t device_id; // FK -> Device.id |
| @@ -103,11 +110,16 @@ typedef struct { | |||
| 103 | uint32_t physical_id; | 110 | uint32_t physical_id; |
| 104 | uint32_t super_device_id; | 111 | uint32_t super_device_id; |
| 105 | uint32_t overflow_mode; | 112 | uint32_t overflow_mode; |
| 106 | - char soc_version[16]; | 113 | + // 完整SoC型号名(如"Ascend950DT_95A1",16字符)需16+1字节,32对齐hal侧MAX_CHIP_NAME |
| 114 | + char soc_version[32]; | ||
| 107 | uint32_t status; // 0 可用, 1不可用 | 115 | uint32_t status; // 0 可用, 1不可用 |
| 108 | } Device; | 116 | } Device; |
| 109 | 117 | ||
| 110 | -enum TsDevType { TS_DEV_TYPE_SCALAR = 0, TS_DEV_TYPE_CPU = 1, TS_DEV_TYPE_CCU = 2 }; | 118 | +enum TsDevType { |
| 119 | + TS_DEV_TYPE_SCALAR = 0, | ||
| 120 | + TS_DEV_TYPE_CPU = 1, | ||
| 121 | + TS_DEV_TYPE_CCU = 2 | ||
| 122 | +}; | ||
| 111 | 123 | ||
| 112 | typedef struct { | 124 | typedef struct { |
| 113 | uint64_t id; // PK | 125 | uint64_t id; // PK |
| @@ -115,7 +127,11 @@ typedef struct { | |||
| 115 | uint8_t type; // 0:Scalar, 1:CCU, 2:CPU | 127 | uint8_t type; // 0:Scalar, 1:CCU, 2:CPU |
| 116 | } TaskSchedulerDevice; | 128 | } TaskSchedulerDevice; |
| 117 | 129 | ||
| 118 | -enum ComputeDieType { COMPUTE_TYPE_CUBE = 0, COMPUTE_TYPE_VECTOR = 1, COMPUTE_TYPE_HYBRID = 2 }; | 130 | +enum ComputeDieType { |
| 131 | + COMPUTE_TYPE_CUBE = 0, | ||
| 132 | + COMPUTE_TYPE_VECTOR = 1, | ||
| 133 | + COMPUTE_TYPE_HYBRID = 2 | ||
| 134 | +}; | ||
| 119 | 135 | ||
| 120 | typedef struct { | 136 | typedef struct { |
| 121 | uint64_t id; // PK | 137 | uint64_t id; // PK |
| @@ -152,18 +168,6 @@ typedef struct { | |||
| 152 | uint8_t status; | 168 | uint8_t status; |
| 153 | } Ccu; | 169 | } Ccu; |
| 154 | 170 | ||
| 155 | -typedef struct { | ||
| 156 | - uint64_t id; // PK | ||
| 157 | - uint64_t ccu_id; // FK | ||
| 158 | - uint8_t instr_space[CCU_INSTRUCTION_NUM][CCU_INSTRUCTION_SIZE]; // 指令空间1M: 32K个指令 | ||
| 159 | - uint16_t instr_cnt{0}; | ||
| 160 | - uint16_t state{0}; | ||
| 161 | - // uint64_t xn[CCU_RESOURCE_XN_MAX]; // xn寄存器 | ||
| 162 | - // uint64_t gsa[CCU_RESOURCE_GSA_MAX]; // gsa寄存器 | ||
| 163 | - // uint16_t cke[CCU_RESOURCE_CKE_MAX]; // cke寄存器 | ||
| 164 | - // char ms[CCU_RESOURCE_MS_SIZE]; // ms寄存器 | ||
| 165 | -} CcuResource; // todo: 后续可能改为关系表,数据保存在共享内存 | ||
| 166 | - | ||
| 167 | typedef struct { | 171 | typedef struct { |
| 168 | uint64_t id; // PK | 172 | uint64_t id; // PK |
| 169 | uint64_t src_dev_id; // FK | 173 | uint64_t src_dev_id; // FK |
| @@ -181,6 +185,7 @@ typedef struct { | |||
| 181 | uint8_t eid[16]; | 185 | uint8_t eid[16]; |
| 182 | char ip_addr[64]; | 186 | char ip_addr[64]; |
| 183 | uint8_t status{0}; | 187 | uint8_t status{0}; |
| 188 | + bool is_uboe{false}; | ||
| 184 | } EndPoint; | 189 | } EndPoint; |
| 185 | 190 | ||
| 186 | typedef struct { | 191 | typedef struct { |
| @@ -312,8 +317,8 @@ typedef struct { | |||
| 312 | uint64_t id; | 317 | uint64_t id; |
| 313 | uint64_t start_ptr; // 按照卡分配的虚拟编址的地址 | 318 | uint64_t start_ptr; // 按照卡分配的虚拟编址的地址 |
| 314 | uint64_t dev_mapped_ptr; // device进程打开共享内存后的地址 | 319 | uint64_t dev_mapped_ptr; // device进程打开共享内存后的地址 |
| 315 | - uint8_t is_dev_access; // 0: dev不可直接访问, 1: dev可以直接访问 | 320 | + uint8_t is_dev_access; // 0: dev不可直接访问, 1: dev可以直接访问 |
| 316 | - uint64_t host_ptr{0}; // host进程打开共享内存后的地址 | 321 | + uint64_t host_ptr{0}; // host进程打开共享内存后的地址 |
| 317 | uint64_t size; | 322 | uint64_t size; |
| 318 | uint64_t ctx_id; | 323 | uint64_t ctx_id; |
| 319 | uint64_t device_id; // Device表主键 | 324 | uint64_t device_id; // Device表主键 |
| @@ -385,10 +390,12 @@ typedef struct { | |||
| 385 | 390 | ||
| 386 | // ReduceScatterV AllGatherV使用 | 391 | // ReduceScatterV AllGatherV使用 |
| 387 | struct VDataDesTagInner { | 392 | struct VDataDesTagInner { |
| 388 | - uint16_t dataType; // 数据类型 | 393 | + uint16_t dataType; // 数据类型 |
| 389 | - uint32_t count{0}; // rank size | 394 | + uint32_t count{0}; // rank size |
| 390 | uint64_t displs[64]; // 每个rank的数据在sendBuf中的偏移量(单位为dataType) | 395 | uint64_t displs[64]; // 每个rank的数据在sendBuf中的偏移量(单位为dataType) |
| 391 | - uint64_t counts[64]; | 396 | + uint64_t |
| 397 | + counts[64]; // 每个rank在sendBuf中的数据size,第i个元素表示需要向rank | ||
| 398 | + // i发送/接受的数据量 | ||
| 392 | }; | 399 | }; |
| 393 | 400 | ||
| 394 | struct All2AllDataDesTagInner { | 401 | struct All2AllDataDesTagInner { |
| @@ -539,6 +546,8 @@ typedef struct { | |||
| 539 | uint8_t state; // 0: RESET, 1: INIT, 2: RTR, 3:RTS | 546 | uint8_t state; // 0: RESET, 1: INIT, 2: RTR, 3:RTS |
| 540 | uint32_t mode; // jetty mode 0: URMA, 2: CCU, 3: Normal | 547 | uint32_t mode; // jetty mode 0: URMA, 2: CCU, 3: Normal |
| 541 | uint64_t peer_jetty_handle; | 548 | uint64_t peer_jetty_handle; |
| 549 | + uint64_t | ||
| 550 | + peer_endpoint_id; // 本jetty所在channel的对端EndPoint id(FK EndPoint.id) | ||
| 542 | uint64_t pid; | 551 | uint64_t pid; |
| 543 | } RaJetty; | 552 | } RaJetty; |
| 544 | 553 | ||
| @@ -585,9 +594,9 @@ typedef struct { | |||
| 585 | 594 | ||
| 586 | // 北向打桩接口——HCCL_Channel表 | 595 | // 北向打桩接口——HCCL_Channel表 |
| 587 | typedef struct { | 596 | typedef struct { |
| 588 | - uint64_t id; // channel的ID,PK | 597 | + uint64_t id; // channel的ID,PK |
| 589 | - uint64_t commId; // 所属的通信域FK | 598 | + uint64_t commId; // 所属的通信域FK |
| 590 | - uint64_t endpoint_id; // 所属的北向 HcommEndpoint 逻辑外键,0 表示未绑定 | 599 | + uint64_t endpoint_id; // 所属的北向 HcommEndpoint 逻辑外键,0 表示未绑定 |
| 591 | uint8_t engine; // 通信引起engine | 600 | uint8_t engine; // 通信引起engine |
| 592 | uint64_t remoteRankId; // 对端rankId | 601 | uint64_t remoteRankId; // 对端rankId |
| 593 | uint16_t notifyNum; // Notify的数量 | 602 | uint16_t notifyNum; // Notify的数量 |
| @@ -597,44 +606,46 @@ typedef struct { | |||
| 597 | 606 | ||
| 598 | // 北向打桩接口——HComm Endpoint 与南向拓扑 Endpoint 的绑定状态 | 607 | // 北向打桩接口——HComm Endpoint 与南向拓扑 Endpoint 的绑定状态 |
| 599 | enum HcommEndpointBindState : uint8_t { | 608 | enum HcommEndpointBindState : uint8_t { |
| 600 | - HCOMM_ENDPOINT_UNRESOLVED = 0, // 尚未找到唯一的南向 Endpoint | 609 | + HCOMM_ENDPOINT_UNRESOLVED = 0, // 尚未找到唯一的南向 Endpoint |
| 601 | - HCOMM_ENDPOINT_BOUND = 1, // 已绑定唯一的南向 Endpoint | 610 | + HCOMM_ENDPOINT_BOUND = 1, // 已绑定唯一的南向 Endpoint |
| 602 | HCOMM_ENDPOINT_NOT_APPLICABLE = 2, // 当前位置或协议不需要南向 Endpoint | 611 | HCOMM_ENDPOINT_NOT_APPLICABLE = 2, // 当前位置或协议不需要南向 Endpoint |
| 603 | }; | 612 | }; |
| 604 | 613 | ||
| 605 | // 北向打桩接口——HComm Endpoint 表 | 614 | // 北向打桩接口——HComm Endpoint 表 |
| 606 | typedef struct { | 615 | typedef struct { |
| 607 | - uint64_t id; // EndpointHandle 对应的主键 | 616 | + uint64_t id; // EndpointHandle 对应的主键 |
| 608 | - uint64_t runner_id; // 创建该 Endpoint 的 Runner 逻辑外键 | 617 | + uint64_t runner_id; // 创建该 Endpoint 的 Runner 逻辑外键 |
| 609 | - uint64_t south_endpoint_id; // 南向 sim::EndPoint 逻辑外键,0 表示未绑定或不适用 | 618 | + uint64_t |
| 610 | - int32_t protocol; // CommProtocol | 619 | + south_endpoint_id; // 南向 sim::EndPoint 逻辑外键,0 表示未绑定或不适用 |
| 611 | - int32_t addr_type; // CommAddrType | 620 | + int32_t protocol; // CommProtocol |
| 612 | - uint8_t addr[36]; // CommAddr 中的原始地址内容 | 621 | + int32_t addr_type; // CommAddrType |
| 613 | - int32_t loc_type; // EndpointLocType | 622 | + uint8_t addr[36]; // CommAddr 中的原始地址内容 |
| 614 | - uint8_t loc[60]; // EndpointLoc 中的原始位置内容 | 623 | + int32_t loc_type; // EndpointLocType |
| 615 | - uint8_t extension[52]; // EndpointDesc 预留扩展内容 | 624 | + uint8_t loc[60]; // EndpointLoc 中的原始位置内容 |
| 616 | - uint8_t bind_state; // HcommEndpointBindState | 625 | + uint8_t extension[52]; // EndpointDesc 预留扩展内容 |
| 626 | + uint8_t bind_state; // HcommEndpointBindState | ||
| 617 | } HcommEndpoint; | 627 | } HcommEndpoint; |
| 618 | 628 | ||
| 619 | // 北向打桩接口——HComm 内存记录类型 | 629 | // 北向打桩接口——HComm 内存记录类型 |
| 620 | enum HcommMemRecordKind : uint8_t { | 630 | enum HcommMemRecordKind : uint8_t { |
| 621 | HCOMM_MEM_LOCAL_REGISTERED = 0, // HcommMemReg 创建的本地注册内存 | 631 | HCOMM_MEM_LOCAL_REGISTERED = 0, // HcommMemReg 创建的本地注册内存 |
| 622 | - HCOMM_MEM_REMOTE_IMPORTED = 1, // HcommMemImport 创建的远端导入内存 | 632 | + HCOMM_MEM_REMOTE_IMPORTED = 1, // HcommMemImport 创建的远端导入内存 |
| 623 | }; | 633 | }; |
| 624 | 634 | ||
| 625 | // 北向打桩接口——HComm 内存资源表 | 635 | // 北向打桩接口——HComm 内存资源表 |
| 626 | typedef struct { | 636 | typedef struct { |
| 627 | - uint64_t id; // HcommMemHandle 对应的主键 | 637 | + uint64_t id; // HcommMemHandle 对应的主键 |
| 628 | - uint64_t endpoint_id; // 所属的北向 HcommEndpoint 逻辑外键 | 638 | + uint64_t endpoint_id; // 所属的北向 HcommEndpoint 逻辑外键 |
| 629 | - uint64_t runner_id; // 创建该记录的 Runner 逻辑外键 | 639 | + uint64_t runner_id; // 创建该记录的 Runner 逻辑外键 |
| 630 | - uint64_t source_endpoint_id; // 导入记录的源端 HcommEndpoint 主键,本地记录为 0 | 640 | + uint64_t |
| 631 | - uint64_t source_mem_id; // 导入记录的源端本地内存主键,本地记录为 0 | 641 | + source_endpoint_id; // 导入记录的源端 HcommEndpoint 主键,本地记录为 0 |
| 632 | - uint64_t descriptor_key; // 导出描述符的稳定校验键 | 642 | + uint64_t source_mem_id; // 导入记录的源端本地内存主键,本地记录为 0 |
| 633 | - uint64_t addr; // CommMem.addr 的整数形式 | 643 | + uint64_t descriptor_key; // 导出描述符的稳定校验键 |
| 634 | - uint64_t size; // CommMem.size | 644 | + uint64_t addr; // CommMem.addr 的整数形式 |
| 635 | - int32_t mem_type; // CommMemType | 645 | + uint64_t size; // CommMem.size |
| 636 | - uint8_t record_kind; // HcommMemRecordKind | 646 | + int32_t mem_type; // CommMemType |
| 637 | - char mem_tag[255]; // 本地注册内存标签,导入记录为空 | 647 | + uint8_t record_kind; // HcommMemRecordKind |
| 648 | + char mem_tag[255]; // 本地注册内存标签,导入记录为空 | ||
| 638 | } HcommMemReg; | 649 | } HcommMemReg; |
| 639 | 650 | ||
| 640 | // 北向打桩接口——HCCL_EngineCtx表 | 651 | // 北向打桩接口——HCCL_EngineCtx表 |
| @@ -673,5 +684,35 @@ typedef struct { | |||
| 673 | uint8_t consumed{0}; // 0: 未被消费, 1: 已被消费 | 684 | uint8_t consumed{0}; // 0: 未被消费, 1: 已被消费 |
| 674 | } DpuPendingNotify; | 685 | } DpuPendingNotify; |
| 675 | 686 | ||
| 687 | +// 北向打桩接口——CCU Level1 交换资源表(跨 rank 同步值,per-channel 交换区,**按 | ||
| 688 | +// op+轮次隔离**) 语义:hcomm CcuTransport::INIT_XN_NUM/INIT_CKE_NUM(4) —— 每 | ||
| 689 | +// channel 固定预留 | ||
| 690 | +// XN/CKE 0..3;PreSync 时写方把值写到对端坐标,读方(NotifyWait / | ||
| 691 | +// 首次使用处)查询。 | ||
| 692 | +// 逻辑键:(opIter, round, srcRank, targetRank, connOrdinal, dieId, resType, | ||
| 693 | +// resId); | ||
| 694 | +// opIter = 算子迭代(OpDetailTab.opIter,两侧进程按同一序列自增,天然跨 | ||
| 695 | +// rank 对齐), round = 写方 CCU launch 序号。**一轮一行、不覆盖** —— | ||
| 696 | +// 读方按自己所在 op+轮次精确取, | ||
| 697 | +// 可免疫两进程异步漂移(写方领先时不会被"未来轮次/未来 op 的值"污染)。 | ||
| 698 | +// op 维度不可省:round 是进程内全局 launch 计数,表跨 op 累积,若不带 op | ||
| 699 | +// 则后一 op 的 行会覆盖/裁掉前一 op 尚未被读走的行,落后 rank | ||
| 700 | +// 只能取到别的 op 的地址(现象: checker 报 MEM_CPY 目标地址落不到本 op | ||
| 701 | +// 内存布局)。 | ||
| 702 | +typedef struct { | ||
| 703 | + uint64_t id{0}; // PK | ||
| 704 | + uint32_t opIter{0}; // 算子迭代(跨 rank 一致的 op 身份) | ||
| 705 | + uint32_t round{0}; // 轮次(= 写方 CCU launch 序号) | ||
| 706 | + uint32_t targetRank{0}; // 被写入方 rank(= 读方 rank) | ||
| 707 | + uint32_t connOrdinal{ | ||
| 708 | + 0}; // 同 peer 多 channel 连接序号(multi-jetty;单连接=0) | ||
| 709 | + uint32_t dieId{0}; // 资源所在 die | ||
| 710 | + uint32_t resType{0}; // 0=XN(Var), 1=CKE | ||
| 711 | + uint32_t resId{0}; // 0..3(交换区槽位) | ||
| 712 | + uint64_t value{0}; // 交换值(地址/token/CKE 位置位) | ||
| 713 | + uint32_t srcRank{0}; // 写方 rank(排障) | ||
| 714 | + uint64_t ownerPid{0}; // 写方进程(排障) | ||
| 715 | +} CcuSyncResTab; | ||
| 716 | + | ||
| 676 | } // namespace sim | 717 | } // namespace sim |
| 677 | #endif | 718 | #endif |
| @@ -1,11 +1,18 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * the terms and conditions of CANN Open Software License Agreement Version 2.0 |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * (the "License"). Please refer to the License for details. You may not use |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * this file except in compliance with the License. THIS SOFTWARE IS PROVIDED ON |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS |
| 9 | + * FOR A PARTICULAR PURPOSE. See LICENSE in the root of the software repository | ||
| 10 | + * for the full text of the License. | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 15 | + * for the full text of the License. | ||
| 9 | */ | 16 | */ |
| 10 | 17 | ||
| 11 | #ifndef SIM_OP_DB_TYPES_H | 18 | #ifndef SIM_OP_DB_TYPES_H |
| @@ -29,21 +36,21 @@ struct DBConfig { | |||
| 29 | }; | 36 | }; |
| 30 | 37 | ||
| 31 | struct OpDetailTab { | 38 | struct OpDetailTab { |
| 32 | - uint32_t id; // PK (自增) | 39 | + uint32_t id; // PK (自增) |
| 33 | - uint32_t pid; // proxy 进程 ID | 40 | + uint32_t pid; // proxy 进程 ID |
| 34 | uint32_t deviceId; // 物理设备 ID(全局唯一,内部逻辑统一使用) | 41 | uint32_t deviceId; // 物理设备 ID(全局唯一,内部逻辑统一使用) |
| 35 | uint32_t rankId; // 通信域内 rank ID | 42 | uint32_t rankId; // 通信域内 rank ID |
| 36 | uint64_t commId; // 通信域成员 ID,FK -> Communicator.id | 43 | uint64_t commId; // 通信域成员 ID,FK -> Communicator.id |
| 37 | uint32_t opIter; // 算子迭代次数 (从 0 开始) | 44 | uint32_t opIter; // 算子迭代次数 (从 0 开始) |
| 38 | uint32_t syncIter; // 所属 sync 周期 (从 0 开始) // todo 可删 | 45 | uint32_t syncIter; // 所属 sync 周期 (从 0 开始) // todo 可删 |
| 39 | 46 | ||
| 40 | - uint64_t streamId; // streamId | 47 | + uint64_t streamId; // streamId |
| 41 | - uint32_t root; // root | 48 | + uint32_t root; // root |
| 42 | - uint32_t opExpansionMode; // 算子执行模式 0: ccu, 1: aicpu, 2: aiv | 49 | + uint32_t opExpansionMode; // 算子执行模式 0: ccu, 1: aicpu, 2: aiv |
| 43 | - uint32_t devType; // 设备类型 | 50 | + uint32_t devType; // 设备类型 |
| 44 | - uint32_t rankSize; // ransize | 51 | + uint32_t rankSize; // ransize |
| 45 | - uint32_t srcRank; // srcRank | 52 | + uint32_t srcRank; // srcRank |
| 46 | - uint32_t dstRank; // dstRank | 53 | + uint32_t dstRank; // dstRank |
| 47 | std::vector<uint8_t> opDetail; // BLOB | 54 | std::vector<uint8_t> opDetail; // BLOB |
| 48 | std::vector<uint8_t> opExtInfo; // BLOB | 55 | std::vector<uint8_t> opExtInfo; // BLOB |
| 49 | }; | 56 | }; |
| @@ -138,8 +145,7 @@ struct OpExecutionKey { | |||
| 138 | uint64_t commHash{0}; | 145 | uint64_t commHash{0}; |
| 139 | uint32_t opIter{0}; | 146 | uint32_t opIter{0}; |
| 140 | 147 | ||
| 141 | - bool operator<(const OpExecutionKey& other) const | 148 | + bool operator<(const OpExecutionKey &other) const { |
| 142 | - { | ||
| 143 | if (commName != other.commName) { | 149 | if (commName != other.commName) { |
| 144 | return commName < other.commName; | 150 | return commName < other.commName; |
| 145 | } | 151 | } |
| @@ -1,11 +1,13 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * the terms and conditions of CANN Open Software License Agreement Version 2.0 |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * (the "License"). Please refer to the License for details. You may not use |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * this file except in compliance with the License. THIS SOFTWARE IS PROVIDED ON |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS |
| 9 | + * FOR A PARTICULAR PURPOSE. See LICENSE in the root of the software repository | ||
| 10 | + * for the full text of the License. | ||
| 9 | */ | 11 | */ |
| 10 | 12 | ||
| 11 | #ifndef SIM_RUNNER_IMPL_INL | 13 | #ifndef SIM_RUNNER_IMPL_INL |
| @@ -17,47 +19,40 @@ | |||
| 17 | 19 | ||
| 18 | namespace RunnerDB { | 20 | namespace RunnerDB { |
| 19 | 21 | ||
| 20 | -template <typename T> | 22 | +template <typename T> uint64_t Add(T &rec) { |
| 21 | -uint64_t Add(T& rec) | ||
| 22 | -{ | ||
| 23 | return SimRunnerSqliteDB::Instance().Add<T>(rec); | 23 | return SimRunnerSqliteDB::Instance().Add<T>(rec); |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | -template <typename T> | 26 | +template <typename T> std::vector<uint64_t> AddBatch(std::vector<T> &recs) { |
| 27 | -std::optional<T> GetById(uint64_t id) | 27 | + return SimRunnerSqliteDB::Instance().AddBatch<T>(recs); |
| 28 | -{ | 28 | +} |
| 29 | + | ||
| 30 | +template <typename T> std::optional<T> GetById(uint64_t id) { | ||
| 29 | return SimRunnerSqliteDB::Instance().Find<T>(id); | 31 | return SimRunnerSqliteDB::Instance().Find<T>(id); |
| 30 | } | 32 | } |
| 31 | 33 | ||
| 32 | template <typename T> | 34 | template <typename T> |
| 33 | -std::vector<T> GetByPred(std::function<bool(const T&)> pred) | 35 | +std::vector<T> GetByPred(std::function<bool(const T &)> pred) { |
| 34 | -{ | ||
| 35 | return SimRunnerSqliteDB::Instance().QueryList<T>(pred); | 36 | return SimRunnerSqliteDB::Instance().QueryList<T>(pred); |
| 36 | } | 37 | } |
| 37 | 38 | ||
| 38 | template <typename T> | 39 | template <typename T> |
| 39 | -std::pair<T, bool> GetOneByPred(std::function<bool(const T&)> pred) | 40 | +std::pair<T, bool> GetOneByPred(std::function<bool(const T &)> pred) { |
| 40 | -{ | ||
| 41 | return SimRunnerSqliteDB::Instance().Query<T>(pred); | 41 | return SimRunnerSqliteDB::Instance().Query<T>(pred); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | template <typename T> | 44 | template <typename T> |
| 45 | -bool Update(uint64_t id, std::function<void(T&)> updater) | 45 | +bool Update(uint64_t id, std::function<void(T &)> updater) { |
| 46 | -{ | ||
| 47 | return SimRunnerSqliteDB::Instance().Update<T>(id, updater); | 46 | return SimRunnerSqliteDB::Instance().Update<T>(id, updater); |
| 48 | } | 47 | } |
| 49 | 48 | ||
| 50 | -template <typename T> | 49 | +template <typename T> bool Delete(uint64_t id) { |
| 51 | -bool Delete(uint64_t id) | ||
| 52 | -{ | ||
| 53 | return SimRunnerSqliteDB::Instance().Delete<T>(id); | 50 | return SimRunnerSqliteDB::Instance().Delete<T>(id); |
| 54 | } | 51 | } |
| 55 | 52 | ||
| 56 | -template <typename T> | 53 | +template <typename T> bool DeleteAll() { |
| 57 | -bool DeleteAll() | ||
| 58 | -{ | ||
| 59 | return SimRunnerSqliteDB::Instance().DeleteAll<T>(); | 54 | return SimRunnerSqliteDB::Instance().DeleteAll<T>(); |
| 60 | } | 55 | } |
| 61 | } // namespace RunnerDB | 56 | } // namespace RunnerDB |
| 62 | 57 | ||
| 63 | -#endif | 58 | +#endif |
| @@ -1,11 +1,18 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * the terms and conditions of CANN Open Software License Agreement Version 2.0 |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * (the "License"). Please refer to the License for details. You may not use |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * this file except in compliance with the License. THIS SOFTWARE IS PROVIDED ON |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS |
| 9 | + * FOR A PARTICULAR PURPOSE. See LICENSE in the root of the software repository | ||
| 10 | + * for the full text of the License. | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 15 | + * for the full text of the License. | ||
| 9 | */ | 16 | */ |
| 10 | 17 | ||
| 11 | #ifndef SIM_AICPU_PIPE_MSG_H | 18 | #ifndef SIM_AICPU_PIPE_MSG_H |
| @@ -38,7 +45,8 @@ constexpr uint8_t PIPE_RSP_FREE_WQE_PTR = 0x86; | |||
| 38 | constexpr uint8_t PIPE_RSP_READY = 0xA5; | 45 | constexpr uint8_t PIPE_RSP_READY = 0xA5; |
| 39 | 46 | ||
| 40 | constexpr uint8_t PIPE_RSP_ERROR = 0xFF; | 47 | constexpr uint8_t PIPE_RSP_ERROR = 0xFF; |
| 41 | -constexpr uint32_t IPC_MSG_LEN_MAX = 128 * 1024; // 变长消息 payload 上限(容纳 64KB args) | 48 | +constexpr uint32_t IPC_MSG_LEN_MAX = |
| 49 | + 128 * 1024; // 变长消息 payload 上限(容纳 64KB args) | ||
| 42 | 50 | ||
| 43 | #pragma pack(push, 1) | 51 | #pragma pack(push, 1) |
| 44 | 52 | ||
| @@ -1,11 +1,18 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * the terms and conditions of CANN Open Software License Agreement Version 2.0 |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * (the "License"). Please refer to the License for details. You may not use |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * this file except in compliance with the License. THIS SOFTWARE IS PROVIDED ON |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS |
| 9 | + * FOR A PARTICULAR PURPOSE. See LICENSE in the root of the software repository | ||
| 10 | + * for the full text of the License. | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | +AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, * | ||
| 15 | +the full text of the License. | ||
| 9 | */ | 16 | */ |
| 10 | 17 | ||
| 11 | #ifndef BINRAY_DATA_TYPE_PUB_H | 18 | #ifndef BINRAY_DATA_TYPE_PUB_H |
| @@ -16,7 +23,6 @@ | |||
| 16 | 23 | ||
| 17 | #include "ccu_microcode_v1.h" | 24 | #include "ccu_microcode_v1.h" |
| 18 | #include "hccl_types.h" | 25 | #include "hccl_types.h" |
| 19 | -#include "sim_capacity_limits.h" | ||
| 20 | #include "sim_common_defs.h" | 26 | #include "sim_common_defs.h" |
| 21 | 27 | ||
| 22 | namespace HcclSim { | 28 | namespace HcclSim { |
| @@ -41,9 +47,9 @@ struct FileHeader { | |||
| 41 | struct VDataDesTag { | 47 | struct VDataDesTag { |
| 42 | uint16_t dataType; // 数据类型 | 48 | uint16_t dataType; // 数据类型 |
| 43 | uint32_t count; // rank size | 49 | uint32_t count; // rank size |
| 44 | - uint64_t* displs; // 每个rank的数据在sendBuf中的偏移量(单位为dataType) | 50 | + uint64_t *displs; // 每个rank的数据在sendBuf中的偏移量(单位为dataType) |
| 45 | - uint64_t* counts; // 每个rank在sendBuf中的数据size,第i个元素表示需要向rank | 51 | + uint64_t *counts; // 每个rank在sendBuf中的数据size,第i个元素表示需要向rank |
| 46 | - // i发送/接受的数据量 | 52 | + // i发送/接受的数据量 |
| 47 | }; | 53 | }; |
| 48 | 54 | ||
| 49 | struct All2AllDataDesTag { | 55 | struct All2AllDataDesTag { |
| @@ -52,7 +58,7 @@ struct All2AllDataDesTag { | |||
| 52 | uint64_t sendCount; // 发送数据量 (All2All) | 58 | uint64_t sendCount; // 发送数据量 (All2All) |
| 53 | uint64_t recvCount; // 接收数据量 (All2All) | 59 | uint64_t recvCount; // 接收数据量 (All2All) |
| 54 | uint32_t count; // count = rankSize * rankSize | 60 | uint32_t count; // count = rankSize * rankSize |
| 55 | - uint64_t* sendCountMatrix; // (All2AllVC) sendCountMatrix[i * ranksize + j] | 61 | + uint64_t *sendCountMatrix; // (All2AllVC) sendCountMatrix[i * ranksize + j] |
| 56 | // 代表rank i发送到rank j的count参数 | 62 | // 代表rank i发送到rank j的count参数 |
| 57 | }; | 63 | }; |
| 58 | 64 | ||
| @@ -92,12 +98,12 @@ struct ChannelData { | |||
| 92 | uint8_t reid[16]; | 98 | uint8_t reid[16]; |
| 93 | uint16_t protocol; | 99 | uint16_t protocol; |
| 94 | uint16_t jettyNum; | 100 | uint16_t jettyNum; |
| 95 | - uint32_t jettyId[HCCL_VM_MAX_CHANNEL_JETTIES]; | 101 | + uint32_t jettyId[32]; |
| 96 | }; | 102 | }; |
| 97 | 103 | ||
| 98 | struct ChannelInfo { | 104 | struct ChannelInfo { |
| 99 | uint32_t count; | 105 | uint32_t count; |
| 100 | - ChannelData* data; | 106 | + ChannelData *data; |
| 101 | }; | 107 | }; |
| 102 | 108 | ||
| 103 | struct MemLayoutData { | 109 | struct MemLayoutData { |
| @@ -111,7 +117,7 @@ struct MemLayoutData { | |||
| 111 | 117 | ||
| 112 | struct MemLayoutInfo { | 118 | struct MemLayoutInfo { |
| 113 | uint32_t count; | 119 | uint32_t count; |
| 114 | - MemLayoutData* data; | 120 | + MemLayoutData *data; |
| 115 | }; | 121 | }; |
| 116 | 122 | ||
| 117 | struct MicrocodeInstrDesc { | 123 | struct MicrocodeInstrDesc { |
| @@ -123,7 +129,7 @@ struct MicrocodeInstrDesc { | |||
| 123 | 129 | ||
| 124 | struct MicrocodeInstr { | 130 | struct MicrocodeInstr { |
| 125 | MicrocodeInstrDesc desc; | 131 | MicrocodeInstrDesc desc; |
| 126 | - hcomm::CcuRep::CcuInstr* data; | 132 | + hcomm::CcuRep::CcuInstr *data; |
| 127 | }; | 133 | }; |
| 128 | 134 | ||
| 129 | struct ModelInfoCommInner { | 135 | struct ModelInfoCommInner { |
| @@ -160,20 +166,24 @@ struct MemLayoutInfoInner { | |||
| 160 | 166 | ||
| 161 | // ReduceScatterV AllGatherV使用 | 167 | // ReduceScatterV AllGatherV使用 |
| 162 | struct VDataDesTagInner { | 168 | struct VDataDesTagInner { |
| 163 | - uint16_t dataType; // 数据类型 | 169 | + uint16_t dataType; // 数据类型 |
| 164 | - uint32_t count{0}; // rank size | 170 | + uint32_t count{0}; // rank size |
| 165 | - std::vector<uint64_t> displs; // 每个rank的数据在sendBuf中的偏移量(单位为dataType) | 171 | + std::vector<uint64_t> |
| 166 | - std::vector<uint64_t> counts; | 172 | + displs; // 每个rank的数据在sendBuf中的偏移量(单位为dataType) |
| 173 | + std::vector<uint64_t> | ||
| 174 | + counts; // 每个rank在sendBuf中的数据size,第i个元素表示需要向rank | ||
| 175 | + // i发送/接受的数据量 | ||
| 167 | }; | 176 | }; |
| 168 | 177 | ||
| 169 | struct All2AllDataDesTagInner { | 178 | struct All2AllDataDesTagInner { |
| 170 | - uint16_t sendType; // 发送数据的数据类型 | 179 | + uint16_t sendType; // 发送数据的数据类型 |
| 171 | - uint16_t recvType; // 接收数据的数据类型 | 180 | + uint16_t recvType; // 接收数据的数据类型 |
| 172 | - uint64_t sendCount; // 发送数据量 (All2All) | 181 | + uint64_t sendCount; // 发送数据量 (All2All) |
| 173 | - uint64_t recvCount; // 接收数据量 (All2All) | 182 | + uint64_t recvCount; // 接收数据量 (All2All) |
| 174 | - uint32_t count{0}; // count = rankSize * rankSize | 183 | + uint32_t count{0}; // count = rankSize * rankSize |
| 175 | - std::vector<uint64_t> sendCountMatrix; // (All2AllVC) sendCountMatrix[i * ranksize + j] | 184 | + std::vector<uint64_t> |
| 176 | - // 代表rank i发送到rank j的count参数 | 185 | + sendCountMatrix; // (All2AllVC) sendCountMatrix[i * ranksize + j] |
| 186 | + // 代表rank i发送到rank j的count参数 | ||
| 177 | }; | 187 | }; |
| 178 | 188 | ||
| 179 | struct ModelInfoInner { | 189 | struct ModelInfoInner { |
| @@ -1,11 +1,18 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * the terms and conditions of CANN Open Software License Agreement Version 2.0 |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * (the "License"). Please refer to the License for details. You may not use |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * this file except in compliance with the License. THIS SOFTWARE IS PROVIDED ON |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS |
| 9 | + * FOR A PARTICULAR PURPOSE. See LICENSE in the root of the software repository | ||
| 10 | + * for the full text of the License. | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | +AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, * | ||
| 15 | +the full text of the License. | ||
| 9 | */ | 16 | */ |
| 10 | 17 | ||
| 11 | #ifndef SIM_CCU_CHANNEL_CTX_H | 18 | #ifndef SIM_CCU_CHANNEL_CTX_H |
| @@ -94,22 +101,10 @@ struct ChannelCtxDataV1 { | |||
| 94 | /********64 Bytes**********/ | 101 | /********64 Bytes**********/ |
| 95 | 102 | ||
| 96 | ChannelCtxDataV1() | 103 | ChannelCtxDataV1() |
| 97 | - : vtpHigh(0), | 104 | + : vtpHigh(0), srcPfeId{0}, startJettyIdLow{0}, startJettyIdHigh{0}, |
| 98 | - srcPfeId{0}, | 105 | + jettyNumLow{0}, jettyNumHigh{0}, ioDieId{0}, dstTokenIdLow(0), |
| 99 | - startJettyIdLow{0}, | 106 | + dstTokenIdHigh{0}, dstTokenValueLow{0}, dstTokenValueHigh{0}, |
| 100 | - startJettyIdHigh{0}, | 107 | + dstVaLow{0}, dstVaHigher{0}, dstTokenValueValid{0}, rsv14Bits{0} {} |
| 101 | - jettyNumLow{0}, | ||
| 102 | - jettyNumHigh{0}, | ||
| 103 | - ioDieId{0}, | ||
| 104 | - dstTokenIdLow(0), | ||
| 105 | - dstTokenIdHigh{0}, | ||
| 106 | - dstTokenValueLow{0}, | ||
| 107 | - dstTokenValueHigh{0}, | ||
| 108 | - dstVaLow{0}, | ||
| 109 | - dstVaHigher{0}, | ||
| 110 | - dstTokenValueValid{0}, | ||
| 111 | - rsv14Bits{0} | ||
| 112 | - {} | ||
| 113 | }; | 108 | }; |
| 114 | 109 | ||
| 115 | struct ChannelDataV2 { | 110 | struct ChannelDataV2 { |
| @@ -1,11 +1,18 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * the terms and conditions of CANN Open Software License Agreement Version 2.0 |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * (the "License"). Please refer to the License for details. You may not use |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * this file except in compliance with the License. THIS SOFTWARE IS PROVIDED ON |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS |
| 9 | + * FOR A PARTICULAR PURPOSE. See LICENSE in the root of the software repository | ||
| 10 | + * for the full text of the License. | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | +AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, * | ||
| 15 | +the full text of the License. | ||
| 9 | */ | 16 | */ |
| 10 | 17 | ||
| 11 | #ifndef SIM_CCU_JETTY_CTX_H | 18 | #ifndef SIM_CCU_JETTY_CTX_H |
| @@ -36,8 +43,9 @@ struct LocalJettyCtxData { | |||
| 36 | uint16_t doorbellAddr[4] = {0}; // jetty doorbell addr | 43 | uint16_t doorbellAddr[4] = {0}; // jetty doorbell addr |
| 37 | /********8 Bytes**********/ | 44 | /********8 Bytes**********/ |
| 38 | 45 | ||
| 39 | - uint16_t pfeIdx : 4; // jetty relegation use PFE num. | 46 | + uint16_t pfeIdx : 4; // jetty relegation use PFE num. |
| 40 | - uint16_t ioDieId : 1; // 0: locall jetty use IODIE0, 1: locall jetty use IODIE1. | 47 | + uint16_t |
| 48 | + ioDieId : 1; // 0: locall jetty use IODIE0, 1: locall jetty use IODIE1. | ||
| 41 | uint16_t doorbellAddrType : 1; // doorbell addr type: 0:PA, 1:VA. | 49 | uint16_t doorbellAddrType : 1; // doorbell addr type: 0:PA, 1:VA. |
| 42 | uint16_t tokenValueIsValid : 1; // doorbell addr releate token value valid | 50 | uint16_t tokenValueIsValid : 1; // doorbell addr releate token value valid |
| 43 | // type: invalid(0), vailid(1). | 51 | // type: invalid(0), vailid(1). |
| @@ -76,22 +84,11 @@ struct LocalJettyCtxData { | |||
| 76 | /********32 Bytes**********/ | 84 | /********32 Bytes**********/ |
| 77 | 85 | ||
| 78 | LocalJettyCtxData() | 86 | LocalJettyCtxData() |
| 79 | - : pfeIdx(0), | 87 | + : pfeIdx(0), ioDieId{0}, doorbellAddrType{0}, tokenValueIsValid{0}, |
| 80 | - ioDieId{0}, | 88 | + cqeErrValue{0}, tokenIdLow{0}, tokenIdHigh{0}, tokenValueLow(0), |
| 81 | - doorbellAddrType{0}, | 89 | + tokenValueHigh{0}, sqeBasicBlockLeftShifts{0}, oooCqeCnt{0}, |
| 82 | - tokenValueIsValid{0}, | 90 | + startWqeBasicBlockIdxLow{0}, startWqeBasicBlockIdxHigh{0}, |
| 83 | - cqeErrValue{0}, | 91 | + doorbellSendState{0}, rsvSixBits{0} {} |
| 84 | - tokenIdLow{0}, | ||
| 85 | - tokenIdHigh{0}, | ||
| 86 | - tokenValueLow(0), | ||
| 87 | - tokenValueHigh{0}, | ||
| 88 | - sqeBasicBlockLeftShifts{0}, | ||
| 89 | - oooCqeCnt{0}, | ||
| 90 | - startWqeBasicBlockIdxLow{0}, | ||
| 91 | - startWqeBasicBlockIdxHigh{0}, | ||
| 92 | - doorbellSendState{0}, | ||
| 93 | - rsvSixBits{0} | ||
| 94 | - {} | ||
| 95 | }; | 92 | }; |
| 96 | #pragma pack(pop) | 93 | #pragma pack(pop) |
| 97 | } // namespace HcclSim | 94 | } // namespace HcclSim |
| @@ -1,11 +1,18 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * the terms and conditions of CANN Open Software License Agreement Version 2.0 |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * (the "License"). Please refer to the License for details. You may not use |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * this file except in compliance with the License. THIS SOFTWARE IS PROVIDED ON |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS |
| 9 | + * FOR A PARTICULAR PURPOSE. See LICENSE in the root of the software repository | ||
| 10 | + * for the full text of the License. | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 15 | + * for the full text of the License. | ||
| 9 | */ | 16 | */ |
| 10 | 17 | ||
| 11 | #ifndef SIM_COMMON_API_H | 18 | #ifndef SIM_COMMON_API_H |
| @@ -19,16 +26,16 @@ | |||
| 19 | #include "sim_common_defs.h" | 26 | #include "sim_common_defs.h" |
| 20 | 27 | ||
| 21 | class InstallPath { | 28 | class InstallPath { |
| 22 | -public: | 29 | + public: |
| 23 | // 获取 hccl-vm-install 根目录的绝对路径 | 30 | // 获取 hccl-vm-install 根目录的绝对路径 |
| 24 | - static const std::string& GetHcclVmInstallAbsPath(); | 31 | + static const std::string &GetHcclVmInstallAbsPath(); |
| 25 | 32 | ||
| 26 | // 把相对路径解析为基于 install root 的绝对路径 | 33 | // 把相对路径解析为基于 install root 的绝对路径 |
| 27 | // @param relPath 相对路径(如 "data/hccl_vm_data.db") | 34 | // @param relPath 相对路径(如 "data/hccl_vm_data.db") |
| 28 | // @note - 已是绝对路径(以 '/' 开头)则原样返回 | 35 | // @note - 已是绝对路径(以 '/' 开头)则原样返回 |
| 29 | // - 以 "./" 开头也原样返回 | 36 | // - 以 "./" 开头也原样返回 |
| 30 | // - 空字符串原样返回 | 37 | // - 空字符串原样返回 |
| 31 | - static std::string ResolveToInstallRoot(const std::string& relPath); | 38 | + static std::string ResolveToInstallRoot(const std::string &relPath); |
| 32 | }; | 39 | }; |
| 33 | 40 | ||
| 34 | std::string GetDataTypeStr(HcclDataType type); | 41 | std::string GetDataTypeStr(HcclDataType type); |
| @@ -36,7 +43,7 @@ std::string GetDataTypeStr(HcclDataType type); | |||
| 36 | std::string GetReduceOpStr(HcclReduceOp op); | 43 | std::string GetReduceOpStr(HcclReduceOp op); |
| 37 | 44 | ||
| 38 | #if !defined(NO_YAML_CONFIG) && defined(HAVE_YAML_CPP) | 45 | #if !defined(NO_YAML_CONFIG) && defined(HAVE_YAML_CPP) |
| 39 | -bool ParseTopoMetaYaml(const std::string& fileName, TopoMeta& topo); | 46 | +bool ParseTopoMetaYaml(const std::string &fileName, TopoMeta &topo); |
| 40 | #endif | 47 | #endif |
| 41 | 48 | ||
| 42 | #endif // SIM_COMMON_API_H | 49 | #endif // SIM_COMMON_API_H |
| @@ -1,15 +1,22 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * the terms and conditions of CANN Open Software License Agreement Version 2.0 |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * (the "License"). Please refer to the License for details. You may not use |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * this file except in compliance with the License. THIS SOFTWARE IS PROVIDED ON |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS |
| 9 | + * FOR A PARTICULAR PURPOSE. See LICENSE in the root of the software repository | ||
| 10 | + * for the full text of the License. | ||
| 9 | */ | 11 | */ |
| 10 | 12 | ||
| 11 | -#ifndef HCOMM_HCCL_VM_SIM_COMMON_DEFS_H | 13 | +/** |
| 12 | -#define HCOMM_HCCL_VM_SIM_COMMON_DEFS_H | 14 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 15 | + * for the full text of the License. | ||
| 16 | + */ | ||
| 17 | + | ||
| 18 | +#ifndef HCCL_COMMON_DEFS_H | ||
| 19 | +#define HCCL_COMMON_DEFS_H | ||
| 13 | 20 | ||
| 14 | #include <array> | 21 | #include <array> |
| 15 | #include <cstdint> | 22 | #include <cstdint> |
| @@ -50,6 +57,8 @@ using SimEid = std::array<uint8_t, URMA_EID_LEN>; | |||
| 50 | constexpr uint8_t DEVICE_WAIT = 0; | 57 | constexpr uint8_t DEVICE_WAIT = 0; |
| 51 | constexpr uint8_t DEVICE_RUN = 1; | 58 | constexpr uint8_t DEVICE_RUN = 1; |
| 52 | 59 | ||
| 60 | +constexpr uint32_t AICPU_JETTY_NUM_MAX = 40960; // 暂定扩大至40960个 | ||
| 61 | + | ||
| 53 | typedef struct { | 62 | typedef struct { |
| 54 | uint8_t dieId; | 63 | uint8_t dieId; |
| 55 | uint8_t missionId; | 64 | uint8_t missionId; |
| @@ -98,9 +107,9 @@ enum HcclVmResult { | |||
| 98 | HCCL_SIM_E_REMOTE = 21, /**< error cqe */ | 107 | HCCL_SIM_E_REMOTE = 21, /**< error cqe */ |
| 99 | HCCL_SIM_E_SUSPENDING = 22, /**< error communicator suspending */ | 108 | HCCL_SIM_E_SUSPENDING = 22, /**< error communicator suspending */ |
| 100 | HCCL_SIM_E_OPRETRY_FAIL = 23, /**< retry constraint */ | 109 | HCCL_SIM_E_OPRETRY_FAIL = 23, /**< retry constraint */ |
| 101 | - HCCL_SIM_E_IN_STATUS = 1041, /**< The error information is in the status. */ | 110 | + HCCL_SIM_E_IN_STATUS = 1041, /**< The error information is in the status. */ |
| 102 | - HCCL_SIM_E_RESERVED, /**< reserved */ | 111 | + HCCL_SIM_E_RESERVED, /**< reserved */ |
| 103 | - HCCL_SIM_E_SKIP, /**< skip */ | 112 | + HCCL_SIM_E_SKIP, /**< skip */ |
| 104 | 113 | ||
| 105 | // 4096 ~ 8191: HCCL_SIM错误码 | 114 | // 4096 ~ 8191: HCCL_SIM错误码 |
| 106 | // 4096 ~ 5119: HCCL_SIM Host错误码 | 115 | // 4096 ~ 5119: HCCL_SIM Host错误码 |
| @@ -160,14 +169,13 @@ using ServerMeta = std::vector<PhyDeviceId>; | |||
| 160 | using SuperPodMeta = std::map<uint32_t, ServerMeta>; | 169 | using SuperPodMeta = std::map<uint32_t, ServerMeta>; |
| 161 | using TopoMeta = std::map<uint32_t, SuperPodMeta>; | 170 | using TopoMeta = std::map<uint32_t, SuperPodMeta>; |
| 162 | 171 | ||
| 163 | -static inline uint32_t ShmGetPhyDeviceTotalCount(const TopoMeta& topo_meta) | 172 | +static inline uint32_t ShmGetPhyDeviceTotalCount(const TopoMeta &topo_meta) { |
| 164 | -{ | ||
| 165 | uint32_t total_count = 0; | 173 | uint32_t total_count = 0; |
| 166 | 174 | ||
| 167 | // 第一层:遍历所有 SuperPod(超级节点) | 175 | // 第一层:遍历所有 SuperPod(超级节点) |
| 168 | - for (const auto& [pod_id, super_pod] : topo_meta) { | 176 | + for (const auto &[pod_id, super_pod] : topo_meta) { |
| 169 | // 第二层:遍历每个 SuperPod 中的所有 Server(服务器) | 177 | // 第二层:遍历每个 SuperPod 中的所有 Server(服务器) |
| 170 | - for (const auto& [server_id, server] : super_pod) { | 178 | + for (const auto &[server_id, server] : super_pod) { |
| 171 | // 第三层:累加每个 Server 中的 PhyDeviceId 数量 | 179 | // 第三层:累加每个 Server 中的 PhyDeviceId 数量 |
| 172 | total_count += static_cast<uint32_t>(server.size()); | 180 | total_count += static_cast<uint32_t>(server.size()); |
| 173 | } | 181 | } |
| @@ -183,6 +191,7 @@ enum class HccLTaskMetaType : char { | |||
| 183 | CCU_GRAPH, | 191 | CCU_GRAPH, |
| 184 | AIV_GRAPH, | 192 | AIV_GRAPH, |
| 185 | SYNC_STREAM, | 193 | SYNC_STREAM, |
| 194 | + MODEL_EXEC, | ||
| 186 | INVALID | 195 | INVALID |
| 187 | }; | 196 | }; |
| 188 | 197 | ||
| @@ -235,11 +244,11 @@ typedef struct { | |||
| 235 | uint64_t len; | 244 | uint64_t len; |
| 236 | uint8_t protocol; | 245 | uint8_t protocol; |
| 237 | 246 | ||
| 238 | - std::string Describe() const | 247 | + std::string Describe() const { |
| 239 | - { | ||
| 240 | std::ostringstream oss; | 248 | std::ostringstream oss; |
| 241 | - oss << "srcDeviceId=" << srcDeviceId << " srcOffset=" << srcOffset << " dstDeviceId=" << dstDeviceId | 249 | + oss << "srcDeviceId=" << srcDeviceId << " srcOffset=" << srcOffset |
| 242 | - << " dstOffset=" << dstOffset << " len=" << len; | 250 | + << " dstDeviceId=" << dstDeviceId << " dstOffset=" << dstOffset |
| 251 | + << " len=" << len; | ||
| 243 | return oss.str(); | 252 | return oss.str(); |
| 244 | } | 253 | } |
| 245 | } TransMemTask; | 254 | } TransMemTask; |
| @@ -247,14 +256,32 @@ typedef struct { | |||
| 247 | typedef struct { | 256 | typedef struct { |
| 248 | uint64_t syncIdx; | 257 | uint64_t syncIdx; |
| 249 | 258 | ||
| 250 | - std::string Describe() const | 259 | + std::string Describe() const { |
| 251 | - { | ||
| 252 | std::ostringstream oss; | 260 | std::ostringstream oss; |
| 253 | oss << "syncIdx=" << syncIdx; | 261 | oss << "syncIdx=" << syncIdx; |
| 254 | return oss.str(); | 262 | return oss.str(); |
| 255 | } | 263 | } |
| 256 | } SyncStreamTask; | 264 | } SyncStreamTask; |
| 257 | 265 | ||
| 266 | +// 模型重放触发任务角色:同一次 rtModelExecute 的 4 个任务共享同一个 | ||
| 267 | +// execSeq,checker 据此配对建边 | ||
| 268 | +typedef struct { | ||
| 269 | + uint32_t | ||
| 270 | + execSeq; // 同一次 rtModelExecute 的 4 个任务共享,用于 checker 配对 | ||
| 271 | + uint8_t role; // 0=MODEL_EXEC_START, 1=MODEL_EXEC_START_SUB, | ||
| 272 | + // 2=MODEL_EXEC_END_SUB, 3=MODEL_EXEC_END | ||
| 273 | + uint64_t modelId; // 所属 model 句柄(观察用) | ||
| 274 | + uint64_t | ||
| 275 | + peerStreamId; // 对端流:START 填 sub 流,START_SUB 填 main 流,反向同理 | ||
| 276 | + | ||
| 277 | + std::string Describe() const { | ||
| 278 | + std::ostringstream oss; | ||
| 279 | + oss << "execSeq=" << execSeq << " role=" << static_cast<uint32_t>(role) | ||
| 280 | + << " modelId=" << modelId << " peerStreamId=" << peerStreamId; | ||
| 281 | + return oss.str(); | ||
| 282 | + } | ||
| 283 | +} ModelExecTask; | ||
| 284 | + | ||
| 258 | typedef struct { | 285 | typedef struct { |
| 259 | uint32_t srcDeviceId; | 286 | uint32_t srcDeviceId; |
| 260 | uint64_t srcOffset; | 287 | uint64_t srcOffset; |
| @@ -266,12 +293,13 @@ typedef struct { | |||
| 266 | uint8_t protocol; | 293 | uint8_t protocol; |
| 267 | uint8_t resv; | 294 | uint8_t resv; |
| 268 | 295 | ||
| 269 | - std::string Describe() const | 296 | + std::string Describe() const { |
| 270 | - { | ||
| 271 | std::ostringstream oss; | 297 | std::ostringstream oss; |
| 272 | - oss << "srcDeviceId=" << srcDeviceId << " srcOffset=" << srcOffset << " dstDeviceId=" << dstDeviceId | 298 | + oss << "srcDeviceId=" << srcDeviceId << " srcOffset=" << srcOffset |
| 273 | - << " dstOffset=" << dstOffset << " dataCount=" << dataCount | 299 | + << " dstDeviceId=" << dstDeviceId << " dstOffset=" << dstOffset |
| 274 | - << " dataType=" << static_cast<uint32_t>(dataType) << " reduceOp=" << static_cast<uint32_t>(reduceOp); | 300 | + << " dataCount=" << dataCount |
| 301 | + << " dataType=" << static_cast<uint32_t>(dataType) | ||
| 302 | + << " reduceOp=" << static_cast<uint32_t>(reduceOp); | ||
| 275 | return oss.str(); | 303 | return oss.str(); |
| 276 | } | 304 | } |
| 277 | } ReduceTask; | 305 | } ReduceTask; |
| @@ -283,10 +311,10 @@ typedef struct { | |||
| 283 | uint8_t notifyCount; | 311 | uint8_t notifyCount; |
| 284 | uint8_t protocol; | 312 | uint8_t protocol; |
| 285 | 313 | ||
| 286 | - std::string Describe() const | 314 | + std::string Describe() const { |
| 287 | - { | ||
| 288 | std::ostringstream oss; | 315 | std::ostringstream oss; |
| 289 | - oss << "srcDeviceId=" << srcDeviceId << " dstDeviceId=" << dstDeviceId << " notifyId=" << notifyId; | 316 | + oss << "srcDeviceId=" << srcDeviceId << " dstDeviceId=" << dstDeviceId |
| 317 | + << " notifyId=" << notifyId; | ||
| 290 | return oss.str(); | 318 | return oss.str(); |
| 291 | } | 319 | } |
| 292 | } NotifyTask; | 320 | } NotifyTask; |
| @@ -301,11 +329,12 @@ typedef struct { | |||
| 301 | uint32_t argSize; | 329 | uint32_t argSize; |
| 302 | uint64_t args[RT_CCU_SQE_ARGS_LEN]; | 330 | uint64_t args[RT_CCU_SQE_ARGS_LEN]; |
| 303 | 331 | ||
| 304 | - std::string Describe() const | 332 | + std::string Describe() const { |
| 305 | - { | ||
| 306 | std::ostringstream oss; | 333 | std::ostringstream oss; |
| 307 | - oss << "dieId=" << static_cast<uint32_t>(dieId) << " missionId=" << static_cast<uint32_t>(missionId) | 334 | + oss << "dieId=" << static_cast<uint32_t>(dieId) |
| 308 | - << " timeout=" << timeout << " instStart=" << instStartId << " instCnt=" << instCnt << " key=" << key | 335 | + << " missionId=" << static_cast<uint32_t>(missionId) |
| 336 | + << " timeout=" << timeout << " instStart=" << instStartId | ||
| 337 | + << " instCnt=" << instCnt << " key=" << key | ||
| 309 | << " argSize=" << argSize; | 338 | << " argSize=" << argSize; |
| 310 | return oss.str(); | 339 | return oss.str(); |
| 311 | } | 340 | } |
| @@ -314,8 +343,7 @@ typedef struct { | |||
| 314 | typedef struct { | 343 | typedef struct { |
| 315 | uint64_t launchIdx; | 344 | uint64_t launchIdx; |
| 316 | 345 | ||
| 317 | - std::string Describe() const | 346 | + std::string Describe() const { |
| 318 | - { | ||
| 319 | std::ostringstream oss; | 347 | std::ostringstream oss; |
| 320 | oss << "launchIdx=" << launchIdx; | 348 | oss << "launchIdx=" << launchIdx; |
| 321 | return oss.str(); | 349 | return oss.str(); |
| @@ -337,10 +365,10 @@ typedef struct HcclTaskMetaData { | |||
| 337 | CcuTask ccu; | 365 | CcuTask ccu; |
| 338 | AivTask aiv; | 366 | AivTask aiv; |
| 339 | SyncStreamTask syncStreamTask; | 367 | SyncStreamTask syncStreamTask; |
| 368 | + ModelExecTask modelExec; | ||
| 340 | } taskData; | 369 | } taskData; |
| 341 | 370 | ||
| 342 | - HcclTaskMetaData() | 371 | + HcclTaskMetaData() { |
| 343 | - { | ||
| 344 | taskType = HccLTaskMetaType::INVALID; | 372 | taskType = HccLTaskMetaType::INVALID; |
| 345 | commId = 0; | 373 | commId = 0; |
| 346 | rankId = UINT32_MAX; | 374 | rankId = UINT32_MAX; |
| @@ -351,45 +379,51 @@ typedef struct HcclTaskMetaData { | |||
| 351 | memset(&taskData, 0, sizeof(taskData)); | 379 | memset(&taskData, 0, sizeof(taskData)); |
| 352 | } | 380 | } |
| 353 | 381 | ||
| 354 | - std::string TaskTypeName() const | 382 | + std::string TaskTypeName() const { |
| 355 | - { | ||
| 356 | static const std::map<HccLTaskMetaType, std::string> TASK_NAMES{ | 383 | static const std::map<HccLTaskMetaType, std::string> TASK_NAMES{ |
| 357 | - {HccLTaskMetaType::NOTIFY_WAIT, "NOTIFY_WAIT"}, {HccLTaskMetaType::NOTIFY_RECORD, "NOTIFY_RECORD"}, | 384 | + {HccLTaskMetaType::NOTIFY_WAIT, "NOTIFY_WAIT"}, |
| 358 | - {HccLTaskMetaType::REDUCE, "REDUCE"}, {HccLTaskMetaType::MEM_CPY, "MEM_CPY"}, | 385 | + {HccLTaskMetaType::NOTIFY_RECORD, "NOTIFY_RECORD"}, |
| 359 | - {HccLTaskMetaType::CCU_GRAPH, "CCU_GRAPH"}, {HccLTaskMetaType::AIV_GRAPH, "AIV_GRAPH"}, | 386 | + {HccLTaskMetaType::REDUCE, "REDUCE"}, |
| 387 | + {HccLTaskMetaType::MEM_CPY, "MEM_CPY"}, | ||
| 388 | + {HccLTaskMetaType::CCU_GRAPH, "CCU_GRAPH"}, | ||
| 389 | + {HccLTaskMetaType::AIV_GRAPH, "AIV_GRAPH"}, | ||
| 360 | {HccLTaskMetaType::SYNC_STREAM, "SYNC_STREAM"}, | 390 | {HccLTaskMetaType::SYNC_STREAM, "SYNC_STREAM"}, |
| 391 | + {HccLTaskMetaType::MODEL_EXEC, "MODEL_EXEC"}, | ||
| 361 | }; | 392 | }; |
| 362 | auto it = TASK_NAMES.find(taskType); | 393 | auto it = TASK_NAMES.find(taskType); |
| 363 | return it != TASK_NAMES.end() ? it->second : "INVALID"; | 394 | return it != TASK_NAMES.end() ? it->second : "INVALID"; |
| 364 | } | 395 | } |
| 365 | 396 | ||
| 366 | - std::string Describe() const | 397 | + std::string Describe() const { |
| 367 | - { | ||
| 368 | std::ostringstream oss; | 398 | std::ostringstream oss; |
| 369 | - oss << "taskType=" << TaskTypeName() << " commId=" << commId << " rankId=" << rankId << " deviceId=" << deviceId | 399 | + oss << "taskType=" << TaskTypeName() << " commId=" << commId |
| 400 | + << " rankId=" << rankId << " deviceId=" << deviceId | ||
| 370 | << " streamId=" << streamId << " jettyId=" << jettyId; | 401 | << " streamId=" << streamId << " jettyId=" << jettyId; |
| 371 | switch (taskType) { | 402 | switch (taskType) { |
| 372 | - case HccLTaskMetaType::NOTIFY_WAIT: | 403 | + case HccLTaskMetaType::NOTIFY_WAIT: |
| 373 | - case HccLTaskMetaType::NOTIFY_RECORD: | 404 | + case HccLTaskMetaType::NOTIFY_RECORD: |
| 374 | - oss << " taskData={" << taskData.notify.Describe() << "}"; | 405 | + oss << " taskData={" << taskData.notify.Describe() << "}"; |
| 375 | - break; | 406 | + break; |
| 376 | - case HccLTaskMetaType::REDUCE: | 407 | + case HccLTaskMetaType::REDUCE: |
| 377 | - oss << " taskData={" << taskData.reduce.Describe() << "}"; | 408 | + oss << " taskData={" << taskData.reduce.Describe() << "}"; |
| 378 | - break; | 409 | + break; |
| 379 | - case HccLTaskMetaType::MEM_CPY: | 410 | + case HccLTaskMetaType::MEM_CPY: |
| 380 | - oss << " taskData={" << taskData.transMem.Describe() << "}"; | 411 | + oss << " taskData={" << taskData.transMem.Describe() << "}"; |
| 381 | - break; | 412 | + break; |
| 382 | - case HccLTaskMetaType::CCU_GRAPH: | 413 | + case HccLTaskMetaType::CCU_GRAPH: |
| 383 | - oss << " taskData={" << taskData.ccu.Describe() << "}"; | 414 | + oss << " taskData={" << taskData.ccu.Describe() << "}"; |
| 384 | - break; | 415 | + break; |
| 385 | - case HccLTaskMetaType::AIV_GRAPH: | 416 | + case HccLTaskMetaType::AIV_GRAPH: |
| 386 | - oss << " taskData={" << taskData.aiv.Describe() << "}"; | 417 | + oss << " taskData={" << taskData.aiv.Describe() << "}"; |
| 387 | - break; | 418 | + break; |
| 388 | - case HccLTaskMetaType::SYNC_STREAM: | 419 | + case HccLTaskMetaType::SYNC_STREAM: |
| 389 | - oss << " taskData={" << taskData.syncStreamTask.Describe() << "}"; | 420 | + oss << " taskData={" << taskData.syncStreamTask.Describe() << "}"; |
| 390 | - break; | 421 | + break; |
| 391 | - default: | 422 | + case HccLTaskMetaType::MODEL_EXEC: |
| 392 | - break; | 423 | + oss << " taskData={" << taskData.modelExec.Describe() << "}"; |
| 424 | + break; | ||
| 425 | + default: | ||
| 426 | + break; | ||
| 393 | } | 427 | } |
| 394 | return oss.str(); | 428 | return oss.str(); |
| 395 | } | 429 | } |
| @@ -410,13 +444,14 @@ typedef struct { | |||
| 410 | enum BufferType { INPUT = 0, OUTPUT, CCL, RESERVED }; | 444 | enum BufferType { INPUT = 0, OUTPUT, CCL, RESERVED }; |
| 411 | 445 | ||
| 412 | class DataSlice { | 446 | class DataSlice { |
| 413 | -public: | 447 | + public: |
| 414 | DataSlice() : type_(BufferType::INPUT), offset_(0), size_(0) {} | 448 | DataSlice() : type_(BufferType::INPUT), offset_(0), size_(0) {} |
| 415 | - DataSlice(BufferType type, uint64_t offset, uint64_t size) : type_(type), offset_(offset), size_(size) {} | 449 | + DataSlice(BufferType type, uint64_t offset, uint64_t size) |
| 416 | - std::string Describe() const | 450 | + : type_(type), offset_(offset), size_(size) {} |
| 417 | - { | 451 | + std::string Describe() const { |
| 418 | - return "BufferType: " + std::to_string(static_cast<int>(type_)) + ", Offset: " + std::to_string(offset_) | 452 | + return "BufferType: " + std::to_string(static_cast<int>(type_)) + |
| 419 | - + ", Size: " + std::to_string(size_); | 453 | + ", Offset: " + std::to_string(offset_) + |
| 454 | + ", Size: " + std::to_string(size_); | ||
| 420 | } | 455 | } |
| 421 | inline BufferType GetType() const { return type_; } | 456 | inline BufferType GetType() const { return type_; } |
| 422 | inline uint64_t GetOffset() const { return offset_; } | 457 | inline uint64_t GetOffset() const { return offset_; } |
| @@ -425,7 +460,7 @@ public: | |||
| 425 | void SetOffset(uint64_t offset) { offset_ = offset; } | 460 | void SetOffset(uint64_t offset) { offset_ = offset; } |
| 426 | void SetSize(uint64_t size) { size_ = size; } | 461 | void SetSize(uint64_t size) { size_ = size; } |
| 427 | 462 | ||
| 428 | -private: | 463 | + private: |
| 429 | BufferType type_; | 464 | BufferType type_; |
| 430 | uint64_t offset_; | 465 | uint64_t offset_; |
| 431 | uint64_t size_; | 466 | uint64_t size_; |
| @@ -441,8 +476,7 @@ private: | |||
| 441 | * | 476 | * |
| 442 | * @return "x86_64" 或 "aarch64" | 477 | * @return "x86_64" 或 "aarch64" |
| 443 | */ | 478 | */ |
| 444 | -inline std::string GetArchStr() | 479 | +inline std::string GetArchStr() { |
| 445 | -{ | ||
| 446 | #if defined(__aarch64__) | 480 | #if defined(__aarch64__) |
| 447 | return "aarch64"; | 481 | return "aarch64"; |
| 448 | #else | 482 | #else |
| @@ -450,4 +484,14 @@ inline std::string GetArchStr() | |||
| 450 | #endif | 484 | #endif |
| 451 | } | 485 | } |
| 452 | 486 | ||
| 453 | -#endif // HCOMM_HCCL_VM_SIM_COMMON_DEFS_H | 487 | +struct ErrorInfo { |
| 488 | + unsigned int errIndex; | ||
| 489 | + int errCode; | ||
| 490 | +}; | ||
| 491 | + | ||
| 492 | +struct RmaConnErrorInfo { | ||
| 493 | + struct ErrorInfo errInfo; | ||
| 494 | + int resType; | ||
| 495 | +}; | ||
| 496 | + | ||
| 497 | +#endif | ||
| @@ -1,11 +1,18 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * the terms and conditions of CANN Open Software License Agreement Version 2.0 |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * (the "License"). Please refer to the License for details. You may not use |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * this file except in compliance with the License. THIS SOFTWARE IS PROVIDED ON |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS |
| 9 | + * FOR A PARTICULAR PURPOSE. See LICENSE in the root of the software repository | ||
| 10 | + * for the full text of the License. | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 15 | + * for the full text of the License. | ||
| 9 | */ | 16 | */ |
| 10 | 17 | ||
| 11 | #ifndef SIM_COMMON_MACRO_H | 18 | #ifndef SIM_COMMON_MACRO_H |
| @@ -17,24 +24,25 @@ | |||
| 17 | #define UNLIKELY(x) __builtin_expect(!!(x), 0) | 24 | #define UNLIKELY(x) __builtin_expect(!!(x), 0) |
| 18 | 25 | ||
| 19 | /* 检查函数返回值, 并返回指定错误码 */ | 26 | /* 检查函数返回值, 并返回指定错误码 */ |
| 20 | -#define HCCLVM_CHK_RET(call) \ | 27 | +#define HCCLVM_CHK_RET(call) \ |
| 21 | - do { \ | 28 | + do { \ |
| 22 | - auto hcclRet = call; \ | 29 | + auto hcclRet = call; \ |
| 23 | - if (UNLIKELY(hcclRet != 0)) { \ | 30 | + if (UNLIKELY(hcclRet != 0)) { \ |
| 24 | - HCCL_VM_INFO("call trace: hcclRet -> {}", static_cast<int>(hcclRet)); \ | 31 | + HCCL_VM_INFO("call trace: hcclRet -> {}", \ |
| 25 | - return hcclRet; \ | 32 | + static_cast<int>(hcclRet)); \ |
| 26 | - } \ | 33 | + return hcclRet; \ |
| 34 | + } \ | ||
| 27 | } while (0) | 35 | } while (0) |
| 28 | 36 | ||
| 29 | /* 检查指针, 若指针为NULL, 则记录日志, 并返回错误 */ | 37 | /* 检查指针, 若指针为NULL, 则记录日志, 并返回错误 */ |
| 30 | -#define HCCLVM_CHK_PTR(ptr) \ | 38 | +#define HCCLVM_CHK_PTR(ptr) \ |
| 31 | - do { \ | 39 | + do { \ |
| 32 | - if (UNLIKELY((ptr) == nullptr)) { \ | 40 | + if (UNLIKELY((ptr) == nullptr)) { \ |
| 33 | - HCCL_VM_INFO( \ | 41 | + HCCL_VM_INFO( \ |
| 34 | - "errNo[0x{:x}], ptr [{}] is nullptr, return HCCL_E_PTR", static_cast<unsigned int>(HCCL_SIM_E_PTR), \ | 42 | + "errNo[0x{:x}], ptr [{}] is nullptr, return HCCL_E_PTR", \ |
| 35 | - #ptr); \ | 43 | + static_cast<unsigned int>(HCCL_SIM_E_PTR), #ptr); \ |
| 36 | - return HCCL_SIM_E_PTR; \ | 44 | + return HCCL_SIM_E_PTR; \ |
| 37 | - } \ | 45 | + } \ |
| 38 | } while (0) | 46 | } while (0) |
| 39 | 47 | ||
| 40 | #endif // SIM_COMMON_MACRO_H | 48 | #endif // SIM_COMMON_MACRO_H |
| @@ -1,11 +1,18 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * the terms and conditions of CANN Open Software License Agreement Version 2.0 |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * (the "License"). Please refer to the License for details. You may not use |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * this file except in compliance with the License. THIS SOFTWARE IS PROVIDED ON |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS |
| 9 | + * FOR A PARTICULAR PURPOSE. See LICENSE in the root of the software repository | ||
| 10 | + * for the full text of the License. | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 15 | + * for the full text of the License. | ||
| 9 | */ | 16 | */ |
| 10 | 17 | ||
| 11 | #ifndef SIM_IP_ADDRESS_H | 18 | #ifndef SIM_IP_ADDRESS_H |
| @@ -51,27 +58,26 @@ union BinaryAddr { | |||
| 51 | }; | 58 | }; |
| 52 | 59 | ||
| 53 | class IpAddress { | 60 | class IpAddress { |
| 54 | -public: | 61 | + public: |
| 55 | - IpAddress() | 62 | + IpAddress() { |
| 56 | - { | ||
| 57 | scopeID_ = 0; | 63 | scopeID_ = 0; |
| 58 | family_ = AF_INET; | 64 | family_ = AF_INET; |
| 59 | binaryAddr_.addr.s_addr = 0; | 65 | binaryAddr_.addr.s_addr = 0; |
| 60 | } | 66 | } |
| 61 | 67 | ||
| 62 | - explicit IpAddress(const union BinaryAddr& ip, s32 family, s32 scopeID = 0) : family_(family), scopeID_(scopeID) | 68 | + explicit IpAddress(const union BinaryAddr &ip, s32 family, s32 scopeID = 0) |
| 63 | - { | 69 | + : family_(family), scopeID_(scopeID) { |
| 64 | binaryAddr_ = ip; | 70 | binaryAddr_ = ip; |
| 65 | // 区分ipv4和ipv6转eid | 71 | // 区分ipv4和ipv6转eid |
| 66 | if (family_ == AF_INET6) { | 72 | if (family_ == AF_INET6) { |
| 67 | - (void)memcpy(eid_.raw, binaryAddr_.addr6.s6_addr, sizeof(binaryAddr_.addr6.s6_addr)); | 73 | + (void)memcpy(eid_.raw, binaryAddr_.addr6.s6_addr, |
| 74 | + sizeof(binaryAddr_.addr6.s6_addr)); | ||
| 68 | } else { | 75 | } else { |
| 69 | ipv4AddrToEid(binaryAddr_.addr.s_addr); | 76 | ipv4AddrToEid(binaryAddr_.addr.s_addr); |
| 70 | } | 77 | } |
| 71 | } | 78 | } |
| 72 | 79 | ||
| 73 | - explicit IpAddress(u32 ipAddr) | 80 | + explicit IpAddress(u32 ipAddr) { |
| 74 | - { | ||
| 75 | struct in_addr addr { | 81 | struct in_addr addr { |
| 76 | ipAddr | 82 | ipAddr |
| 77 | }; | 83 | }; |
| @@ -80,8 +86,7 @@ public: | |||
| 80 | ipv4AddrToEid(ipAddr); | 86 | ipv4AddrToEid(ipAddr); |
| 81 | } | 87 | } |
| 82 | 88 | ||
| 83 | - explicit IpAddress(const Eid& eidInput) | 89 | + explicit IpAddress(const Eid &eidInput) { |
| 84 | - { | ||
| 85 | for (uint32_t i = 0; i < URMA_EID_LEN; i++) { | 90 | for (uint32_t i = 0; i < URMA_EID_LEN; i++) { |
| 86 | eid_.raw[i] = eidInput.raw[i]; | 91 | eid_.raw[i] = eidInput.raw[i]; |
| 87 | } | 92 | } |
| @@ -90,11 +95,12 @@ public: | |||
| 90 | (void)memcpy(binaryAddr_.addr6.s6_addr, eid_.raw, sizeof(eid_.raw)); | 95 | (void)memcpy(binaryAddr_.addr6.s6_addr, eid_.raw, sizeof(eid_.raw)); |
| 91 | } | 96 | } |
| 92 | 97 | ||
| 93 | - explicit IpAddress(const std::string& ip, s32 family = AF_INET) : family_(family) | 98 | + explicit IpAddress(const std::string &ip, s32 family = AF_INET) |
| 94 | - { | 99 | + : family_(family) { |
| 95 | - void* dst; | 100 | + void *dst; |
| 96 | if (family != AF_INET && family != AF_INET6) { | 101 | if (family != AF_INET && family != AF_INET6) { |
| 97 | - throw std::invalid_argument("[IpAddress] Unsupported Address Family"); | 102 | + throw std::invalid_argument( |
| 103 | + "[IpAddress] Unsupported Address Family"); | ||
| 98 | } | 104 | } |
| 99 | if (family == AF_INET6) { | 105 | if (family == AF_INET6) { |
| 100 | dst = &binaryAddr_.addr6; | 106 | dst = &binaryAddr_.addr6; |
| @@ -103,12 +109,14 @@ public: | |||
| 103 | } | 109 | } |
| 104 | int res = inet_pton(family, ip.c_str(), dst); | 110 | int res = inet_pton(family, ip.c_str(), dst); |
| 105 | if (res == -1) { | 111 | if (res == -1) { |
| 106 | - throw std::invalid_argument("[IpAddress] Unsupported Address Family"); | 112 | + throw std::invalid_argument( |
| 113 | + "[IpAddress] Unsupported Address Family"); | ||
| 107 | } else if (res == 0) { | 114 | } else if (res == 0) { |
| 108 | throw std::invalid_argument("[IpAddress] Invalid Network Address"); | 115 | throw std::invalid_argument("[IpAddress] Invalid Network Address"); |
| 109 | } | 116 | } |
| 110 | if (family_ == AF_INET6) { | 117 | if (family_ == AF_INET6) { |
| 111 | - (void)memcpy(eid_.raw, binaryAddr_.addr6.s6_addr, sizeof(binaryAddr_.addr6.s6_addr)); | 118 | + (void)memcpy(eid_.raw, binaryAddr_.addr6.s6_addr, |
| 119 | + sizeof(binaryAddr_.addr6.s6_addr)); | ||
| 112 | } else { | 120 | } else { |
| 113 | ipv4AddrToEid(binaryAddr_.addr.s_addr); | 121 | ipv4AddrToEid(binaryAddr_.addr.s_addr); |
| 114 | } | 122 | } |
| @@ -118,8 +126,7 @@ public: | |||
| 118 | 126 | ||
| 119 | Eid GetEid() const { return eid_; } | 127 | Eid GetEid() const { return eid_; } |
| 120 | 128 | ||
| 121 | - std::string EidToHexString() const | 129 | + std::string EidToHexString() const { |
| 122 | - { | ||
| 123 | std::ostringstream oss; | 130 | std::ostringstream oss; |
| 124 | oss << std::hex << std::setfill('0'); | 131 | oss << std::hex << std::setfill('0'); |
| 125 | for (uint32_t i = 0; i < URMA_EID_LEN; i++) { | 132 | for (uint32_t i = 0; i < URMA_EID_LEN; i++) { |
| @@ -128,34 +135,34 @@ public: | |||
| 128 | return oss.str(); | 135 | return oss.str(); |
| 129 | } | 136 | } |
| 130 | 137 | ||
| 131 | - std::string GetIpStr() const | 138 | + std::string GetIpStr() const { |
| 132 | - { | 139 | + const void *src = nullptr; |
| 133 | - const void* src = nullptr; | ||
| 134 | if (family_ == AF_INET) { | 140 | if (family_ == AF_INET) { |
| 135 | src = &binaryAddr_.addr; | 141 | src = &binaryAddr_.addr; |
| 136 | } else if (family_ == AF_INET6) { | 142 | } else if (family_ == AF_INET6) { |
| 137 | src = &binaryAddr_.addr6; | 143 | src = &binaryAddr_.addr6; |
| 138 | } else { | 144 | } else { |
| 139 | - throw std::invalid_argument("[IpAddress] Unsupported Address Family"); | 145 | + throw std::invalid_argument( |
| 146 | + "[IpAddress] Unsupported Address Family"); | ||
| 140 | } | 147 | } |
| 141 | char dst[INET6_ADDRSTRLEN]; | 148 | char dst[INET6_ADDRSTRLEN]; |
| 142 | - const char* res = inet_ntop(family_, src, dst, INET6_ADDRSTRLEN); | 149 | + const char *res = inet_ntop(family_, src, dst, INET6_ADDRSTRLEN); |
| 143 | if (res == nullptr) { | 150 | if (res == nullptr) { |
| 144 | - throw std::invalid_argument("[IpAddress] Invalid Binary Network Address"); | 151 | + throw std::invalid_argument( |
| 152 | + "[IpAddress] Invalid Binary Network Address"); | ||
| 145 | } | 153 | } |
| 146 | return dst; | 154 | return dst; |
| 147 | } | 155 | } |
| 148 | 156 | ||
| 149 | auto GetFamily() const { return family_; } | 157 | auto GetFamily() const { return family_; } |
| 150 | 158 | ||
| 151 | -private: | 159 | + private: |
| 152 | union BinaryAddr binaryAddr_ {}; // 二进制IP地址 | 160 | union BinaryAddr binaryAddr_ {}; // 二进制IP地址 |
| 153 | s32 family_{AF_INET}; | 161 | s32 family_{AF_INET}; |
| 154 | s32 scopeID_{0}; | 162 | s32 scopeID_{0}; |
| 155 | Eid eid_{}; | 163 | Eid eid_{}; |
| 156 | 164 | ||
| 157 | - void ipv4AddrToEid(const uint32_t& inAddr) | 165 | + void ipv4AddrToEid(const uint32_t &inAddr) { |
| 158 | - { | ||
| 159 | eid_.in4.reserved = 0; | 166 | eid_.in4.reserved = 0; |
| 160 | eid_.in4.prefix = URMA_EID_IPV4_PREFIX; | 167 | eid_.in4.prefix = URMA_EID_IPV4_PREFIX; |
| 161 | eid_.in4.addr = inAddr; | 168 | eid_.in4.addr = inAddr; |
| @@ -1,11 +1,18 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * the terms and conditions of CANN Open Software License Agreement Version 2.0 |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * (the "License"). Please refer to the License for details. You may not use |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * this file except in compliance with the License. THIS SOFTWARE IS PROVIDED ON |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS |
| 9 | + * FOR A PARTICULAR PURPOSE. See LICENSE in the root of the software repository | ||
| 10 | + * for the full text of the License. | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 15 | + * for the full text of the License. | ||
| 9 | */ | 16 | */ |
| 10 | 17 | ||
| 11 | #ifndef SIM_LOADER_H | 18 | #ifndef SIM_LOADER_H |
| @@ -18,59 +25,67 @@ | |||
| 18 | #include <tuple> | 25 | #include <tuple> |
| 19 | #include <vector> | 26 | #include <vector> |
| 20 | 27 | ||
| 21 | -#include "operation_data/operation_data_types.h" | 28 | +#include "sim_op_db_types.h" |
| 22 | 29 | ||
| 23 | namespace loader { | 30 | namespace loader { |
| 24 | using ProxyId = uint32_t; | 31 | using ProxyId = uint32_t; |
| 25 | 32 | ||
| 26 | -using OpStage = std::vector<sim::operation::CompositeOpDetail>; // 某一次算子任务 | 33 | +using OpStage = std::vector<sim::CompositeOpDetail>; // 某一次算子任务 |
| 27 | -using OpPipeline = std::map<uint32_t, OpStage>; // 所有算子任务 | 34 | +using OpPipeline = std::map<uint32_t, OpStage>; // 所有算子任务 |
| 28 | 35 | ||
| 29 | class Loader { | 36 | class Loader { |
| 30 | -public: | 37 | + public: |
| 31 | Loader(); | 38 | Loader(); |
| 32 | ~Loader(); | 39 | ~Loader(); |
| 33 | 40 | ||
| 34 | // dbPath: 数据库路径 | 41 | // dbPath: 数据库路径 |
| 35 | HcclResult LoadOpTaskFile(const std::string dbPath = ""); | 42 | HcclResult LoadOpTaskFile(const std::string dbPath = ""); |
| 36 | 43 | ||
| 37 | - HcclResult GetSyncInfo(std::vector<sim::operation::SyncRecordTab>& syncRecords); | 44 | + HcclResult GetSyncInfo(std::vector<sim::SyncRecordTab> &syncRecords); |
| 38 | 45 | ||
| 39 | - HcclResult GetSyncRecordsByStatus(uint8_t status, std::vector<sim::operation::SyncRecordTab>& syncRecords); | ||
| 40 | - | ||
| 41 | - HcclResult LoadOpExecutionKeys(std::vector<sim::operation::OpExecutionKey>& keys); | ||
| 42 | HcclResult | 46 | HcclResult |
| 43 | - LoadOpExecutionByKey(const sim::operation::OpExecutionKey& key, sim::operation::OpExecution& opExecution); | 47 | + GetSyncRecordsByStatus(uint8_t status, |
| 44 | - HcclResult LoadAllOpExecutions(std::vector<sim::operation::OpExecution>& opExecutions); | 48 | + std::vector<sim::SyncRecordTab> &syncRecords); |
| 49 | + | ||
| 50 | + HcclResult LoadOpExecutionKeys(std::vector<sim::OpExecutionKey> &keys); | ||
| 51 | + HcclResult LoadOpExecutionByKey(const sim::OpExecutionKey &key, | ||
| 52 | + sim::OpExecution &opExecution); | ||
| 53 | + HcclResult LoadAllOpExecutions(std::vector<sim::OpExecution> &opExecutions); | ||
| 45 | 54 | ||
| 46 | // Runner: 每 sync 一次调用一次,outSyncIter: 输出本次加载的 syncIter | 55 | // Runner: 每 sync 一次调用一次,outSyncIter: 输出本次加载的 syncIter |
| 47 | - HcclResult LoadRunnerSingleSync( | 56 | + HcclResult |
| 48 | - const uint32_t& outSyncIter, | 57 | + LoadRunnerSingleSync(const uint32_t &outSyncIter, |
| 49 | - std::map<uint32_t, std::vector<sim::operation::CompositeOpDetail>>& compositeDataMap); | 58 | + std::map<uint32_t, std::vector<sim::CompositeOpDetail>> |
| 59 | + &compositeDataMap); | ||
| 50 | 60 | ||
| 51 | // 根据 syncIter 查询复合算子详情 | 61 | // 根据 syncIter 查询复合算子详情 |
| 52 | HcclResult LoadCompositeOpDetailBySyncIter( | 62 | HcclResult LoadCompositeOpDetailBySyncIter( |
| 53 | - uint32_t syncIter, std::map<uint32_t, std::vector<sim::operation::CompositeOpDetail>>& compositeDataMap); | 63 | + uint32_t syncIter, |
| 64 | + std::map<uint32_t, std::vector<sim::CompositeOpDetail>> | ||
| 65 | + &compositeDataMap); | ||
| 54 | 66 | ||
| 55 | - HcclResult GetCcuChannelInfo(std::vector<sim::operation::CcuChannelTab>& channels); | 67 | + HcclResult GetCcuChannelInfo(std::vector<sim::CcuChannelTab> &channels); |
| 56 | - HcclResult GetHalfRTTInfo(std::vector<sim::operation::HalfRTTTab>& halfRTT); | 68 | + HcclResult GetHalfRTTInfo(std::vector<sim::HalfRTTTab> &halfRTT); |
| 57 | - HcclResult GetJettyMapInfo(std::vector<sim::operation::JettyMapTab>& jettyMaps); | 69 | + HcclResult GetJettyMapInfo(std::vector<sim::JettyMapTab> &jettyMaps); |
| 58 | - HcclResult GetInstrResInfo(std::vector<sim::operation::CcuInstrResTab>& instrRes); | 70 | + HcclResult GetInstrResInfo(std::vector<sim::CcuInstrResTab> &instrRes); |
| 59 | 71 | ||
| 60 | // 返回内部已组装好的完整 Pipeline 缓存 | 72 | // 返回内部已组装好的完整 Pipeline 缓存 |
| 61 | - const OpPipeline& GetOpTasks() const; | 73 | + const OpPipeline &GetOpTasks() const; |
| 62 | 74 | ||
| 63 | - HcclResult LoadAllOpTasks(std::vector<sim::operation::OpTaskTab>& tasks, bool filterDone = false); | 75 | + HcclResult LoadAllOpTasks(std::vector<sim::OpTaskTab> &tasks, |
| 64 | - HcclResult LoadCompositeOpDetailByOpIter( | 76 | + bool filterDone = false); |
| 65 | - const std::string& commName, uint64_t commHash, uint32_t opIter, | 77 | + HcclResult |
| 66 | - std::vector<sim::operation::CompositeOpDetail>& details); | 78 | + LoadCompositeOpDetailByOpIter(const std::string &commName, |
| 67 | - HcclResult FinishOpTask(const sim::operation::OpTaskTab& task); | 79 | + uint64_t commHash, uint32_t opIter, |
| 80 | + std::vector<sim::CompositeOpDetail> &details); | ||
| 81 | + HcclResult FinishOpTask(const sim::OpTaskTab &task); | ||
| 68 | 82 | ||
| 69 | -private: | 83 | + private: |
| 70 | // 成员变量 | 84 | // 成员变量 |
| 71 | OpPipeline opTaskCache_; | 85 | OpPipeline opTaskCache_; |
| 72 | using OpExecutionIdentity = std::tuple<std::string, uint64_t, uint32_t>; | 86 | using OpExecutionIdentity = std::tuple<std::string, uint64_t, uint32_t>; |
| 73 | - std::map<OpExecutionIdentity, std::vector<sim::operation::OpExecutionIndexEntry>> opExecutionEntriesByKey_; | 87 | + std::map<OpExecutionIdentity, std::vector<sim::OpExecutionIndexEntry>> |
| 88 | + opExecutionEntriesByKey_; | ||
| 74 | }; | 89 | }; |
| 75 | } // namespace loader | 90 | } // namespace loader |
| 76 | 91 | ||
| @@ -1,17 +1,25 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * the terms and conditions of CANN Open Software License Agreement Version 2.0 |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * (the "License"). Please refer to the License for details. You may not use |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * this file except in compliance with the License. THIS SOFTWARE IS PROVIDED ON |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS |
| 9 | + * FOR A PARTICULAR PURPOSE. See LICENSE in the root of the software repository | ||
| 10 | + * for the full text of the License. | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 15 | + * for the full text of the License. | ||
| 9 | */ | 16 | */ |
| 10 | 17 | ||
| 11 | #ifndef SIM_LOG_H | 18 | #ifndef SIM_LOG_H |
| 12 | #define SIM_LOG_H | 19 | #define SIM_LOG_H |
| 13 | 20 | ||
| 14 | -#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_TRACE // global级别设置为最低, 只通过sink的级别控制日志输出 | 21 | +#define SPDLOG_ACTIVE_LEVEL \ |
| 22 | + SPDLOG_LEVEL_TRACE // global级别设置为最低, 只通过sink的级别控制日志输出 | ||
| 15 | 23 | ||
| 16 | #include <iostream> | 24 | #include <iostream> |
| 17 | #include <memory> | 25 | #include <memory> |
| @@ -20,7 +28,7 @@ | |||
| 20 | 28 | ||
| 21 | #include "spdlog/spdlog.h" | 29 | #include "spdlog/spdlog.h" |
| 22 | 30 | ||
| 23 | -extern spdlog::logger* g_logger; | 31 | +extern spdlog::logger *g_logger; |
| 24 | 32 | ||
| 25 | #ifdef HCCL_VM_MODULE | 33 | #ifdef HCCL_VM_MODULE |
| 26 | #define HCCL_VM_TAG "[HCCL-VM-" HCCL_VM_MODULE "]" | 34 | #define HCCL_VM_TAG "[HCCL-VM-" HCCL_VM_MODULE "]" |
| @@ -28,46 +36,46 @@ extern spdlog::logger* g_logger; | |||
| 28 | #define HCCL_VM_TAG "[HCCL-VM]" | 36 | #define HCCL_VM_TAG "[HCCL-VM]" |
| 29 | #endif | 37 | #endif |
| 30 | 38 | ||
| 31 | -#define HCCL_VM_TRACE(...) \ | 39 | +#define HCCL_VM_TRACE(...) \ |
| 32 | - do { \ | 40 | + do { \ |
| 33 | - if (g_logger != nullptr) { \ | 41 | + if (g_logger != nullptr) { \ |
| 34 | - SPDLOG_LOGGER_TRACE(g_logger, HCCL_VM_TAG __VA_ARGS__); \ | 42 | + SPDLOG_LOGGER_TRACE(g_logger, HCCL_VM_TAG __VA_ARGS__); \ |
| 35 | - } \ | 43 | + } \ |
| 36 | } while (0) | 44 | } while (0) |
| 37 | 45 | ||
| 38 | -#define HCCL_VM_DEBUG(...) \ | 46 | +#define HCCL_VM_DEBUG(...) \ |
| 39 | - do { \ | 47 | + do { \ |
| 40 | - if (g_logger != nullptr) { \ | 48 | + if (g_logger != nullptr) { \ |
| 41 | - SPDLOG_LOGGER_DEBUG(g_logger, HCCL_VM_TAG __VA_ARGS__); \ | 49 | + SPDLOG_LOGGER_DEBUG(g_logger, HCCL_VM_TAG __VA_ARGS__); \ |
| 42 | - } \ | 50 | + } \ |
| 43 | } while (0) | 51 | } while (0) |
| 44 | 52 | ||
| 45 | -#define HCCL_VM_INFO(...) \ | 53 | +#define HCCL_VM_INFO(...) \ |
| 46 | - do { \ | 54 | + do { \ |
| 47 | - if (g_logger != nullptr) { \ | 55 | + if (g_logger != nullptr) { \ |
| 48 | - SPDLOG_LOGGER_INFO(g_logger, HCCL_VM_TAG __VA_ARGS__); \ | 56 | + SPDLOG_LOGGER_INFO(g_logger, HCCL_VM_TAG __VA_ARGS__); \ |
| 49 | - } \ | 57 | + } \ |
| 50 | } while (0) | 58 | } while (0) |
| 51 | 59 | ||
| 52 | -#define HCCL_VM_WARN(...) \ | 60 | +#define HCCL_VM_WARN(...) \ |
| 53 | - do { \ | 61 | + do { \ |
| 54 | - if (g_logger != nullptr) { \ | 62 | + if (g_logger != nullptr) { \ |
| 55 | - SPDLOG_LOGGER_WARN(g_logger, HCCL_VM_TAG __VA_ARGS__); \ | 63 | + SPDLOG_LOGGER_WARN(g_logger, HCCL_VM_TAG __VA_ARGS__); \ |
| 56 | - } \ | 64 | + } \ |
| 57 | } while (0) | 65 | } while (0) |
| 58 | 66 | ||
| 59 | -#define HCCL_VM_ERROR(...) \ | 67 | +#define HCCL_VM_ERROR(...) \ |
| 60 | - do { \ | 68 | + do { \ |
| 61 | - if (g_logger != nullptr) { \ | 69 | + if (g_logger != nullptr) { \ |
| 62 | - SPDLOG_LOGGER_ERROR(g_logger, HCCL_VM_TAG __VA_ARGS__); \ | 70 | + SPDLOG_LOGGER_ERROR(g_logger, HCCL_VM_TAG __VA_ARGS__); \ |
| 63 | - } \ | 71 | + } \ |
| 64 | } while (0) | 72 | } while (0) |
| 65 | 73 | ||
| 66 | -#define HCCL_VM_CRITICAL(...) \ | 74 | +#define HCCL_VM_CRITICAL(...) \ |
| 67 | - do { \ | 75 | + do { \ |
| 68 | - if (g_logger != nullptr) { \ | 76 | + if (g_logger != nullptr) { \ |
| 69 | - SPDLOG_LOGGER_CRITICAL(g_logger, HCCL_VM_TAG __VA_ARGS__); \ | 77 | + SPDLOG_LOGGER_CRITICAL(g_logger, HCCL_VM_TAG __VA_ARGS__); \ |
| 70 | - } \ | 78 | + } \ |
| 71 | } while (0) | 79 | } while (0) |
| 72 | 80 | ||
| 73 | struct LogConfig { | 81 | struct LogConfig { |
| @@ -81,8 +89,8 @@ struct LogConfig { | |||
| 81 | bool enableCompress{false}; | 89 | bool enableCompress{false}; |
| 82 | }; | 90 | }; |
| 83 | 91 | ||
| 84 | -LogConfig LoadLogConfig(const std::string& process_name); | 92 | +LogConfig LoadLogConfig(const std::string &process_name); |
| 85 | -void InitLogger(const LogConfig& config); | 93 | +void InitLogger(const LogConfig &config); |
| 86 | void FlushLog(); | 94 | void FlushLog(); |
| 87 | void DeInitLogger(); | 95 | void DeInitLogger(); |
| 88 | 96 | ||
| @@ -1,11 +1,18 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * the terms and conditions of CANN Open Software License Agreement Version 2.0 |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * (the "License"). Please refer to the License for details. You may not use |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * this file except in compliance with the License. THIS SOFTWARE IS PROVIDED ON |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS |
| 9 | + * FOR A PARTICULAR PURPOSE. See LICENSE in the root of the software repository | ||
| 10 | + * for the full text of the License. | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 15 | + * for the full text of the License. | ||
| 9 | */ | 16 | */ |
| 10 | 17 | ||
| 11 | #ifndef SIM_THREAD_SAFE_MAP_H | 18 | #ifndef SIM_THREAD_SAFE_MAP_H |
| @@ -14,23 +21,19 @@ | |||
| 14 | #include <map> | 21 | #include <map> |
| 15 | #include <mutex> | 22 | #include <mutex> |
| 16 | 23 | ||
| 17 | -template <typename K, typename V> | 24 | +template <typename K, typename V> class ThreadSafeMap { |
| 18 | -class ThreadSafeMap { | 25 | + public: |
| 19 | -public: | 26 | + V &operator[](const K &key) { |
| 20 | - V& operator[](const K& key) | ||
| 21 | - { | ||
| 22 | std::lock_guard<std::mutex> lock(mutex_); | 27 | std::lock_guard<std::mutex> lock(mutex_); |
| 23 | return data_[key]; | 28 | return data_[key]; |
| 24 | } | 29 | } |
| 25 | 30 | ||
| 26 | - void insert(const K& key, const V& value) | 31 | + void insert(const K &key, const V &value) { |
| 27 | - { | ||
| 28 | std::lock_guard<std::mutex> lock(mutex_); | 32 | std::lock_guard<std::mutex> lock(mutex_); |
| 29 | data_[key] = value; | 33 | data_[key] = value; |
| 30 | } | 34 | } |
| 31 | 35 | ||
| 32 | - bool try_get(const K& key, V& output) const | 36 | + bool try_get(const K &key, V &output) const { |
| 33 | - { | ||
| 34 | std::lock_guard<std::mutex> lock(mutex_); | 37 | std::lock_guard<std::mutex> lock(mutex_); |
| 35 | auto it = data_.find(key); | 38 | auto it = data_.find(key); |
| 36 | if (it != data_.end()) { | 39 | if (it != data_.end()) { |
| @@ -40,44 +43,36 @@ public: | |||
| 40 | return false; | 43 | return false; |
| 41 | } | 44 | } |
| 42 | 45 | ||
| 43 | - bool erase(const K& key) | 46 | + bool erase(const K &key) { |
| 44 | - { | ||
| 45 | std::lock_guard<std::mutex> lock(mutex_); | 47 | std::lock_guard<std::mutex> lock(mutex_); |
| 46 | return data_.erase(key) > 0; | 48 | return data_.erase(key) > 0; |
| 47 | } | 49 | } |
| 48 | 50 | ||
| 49 | - bool contains(const K& key) const | 51 | + bool contains(const K &key) const { |
| 50 | - { | ||
| 51 | std::lock_guard<std::mutex> lock(mutex_); | 52 | std::lock_guard<std::mutex> lock(mutex_); |
| 52 | return data_.find(key) != data_.end(); | 53 | return data_.find(key) != data_.end(); |
| 53 | } | 54 | } |
| 54 | 55 | ||
| 55 | - size_t size() const | 56 | + size_t size() const { |
| 56 | - { | ||
| 57 | std::lock_guard<std::mutex> lock(mutex_); | 57 | std::lock_guard<std::mutex> lock(mutex_); |
| 58 | return data_.size(); | 58 | return data_.size(); |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | - void clear() | 61 | + void clear() { |
| 62 | - { | ||
| 63 | std::lock_guard<std::mutex> lock(mutex_); | 62 | std::lock_guard<std::mutex> lock(mutex_); |
| 64 | data_.clear(); | 63 | data_.clear(); |
| 65 | } | 64 | } |
| 66 | 65 | ||
| 67 | // 遍历操作 | 66 | // 遍历操作 |
| 68 | - template <typename F> | 67 | + template <typename F> void for_each(F func) { |
| 69 | - void for_each(F func) | ||
| 70 | - { | ||
| 71 | std::lock_guard<std::mutex> lock(mutex_); | 68 | std::lock_guard<std::mutex> lock(mutex_); |
| 72 | - for (auto& pair : data_) { | 69 | + for (auto &pair : data_) { |
| 73 | func(pair.first, pair.second); | 70 | func(pair.first, pair.second); |
| 74 | } | 71 | } |
| 75 | } | 72 | } |
| 76 | 73 | ||
| 77 | // 条件删除 | 74 | // 条件删除 |
| 78 | - template <typename Predicate> | 75 | + template <typename Predicate> size_t erase_if(Predicate pred) { |
| 79 | - size_t erase_if(Predicate pred) | ||
| 80 | - { | ||
| 81 | std::lock_guard<std::mutex> lock(mutex_); | 76 | std::lock_guard<std::mutex> lock(mutex_); |
| 82 | size_t count = 0; | 77 | size_t count = 0; |
| 83 | for (auto it = data_.begin(); it != data_.end();) { | 78 | for (auto it = data_.begin(); it != data_.end();) { |
| @@ -91,7 +86,7 @@ public: | |||
| 91 | return count; | 86 | return count; |
| 92 | } | 87 | } |
| 93 | 88 | ||
| 94 | -private: | 89 | + private: |
| 95 | std::map<K, V> data_; | 90 | std::map<K, V> data_; |
| 96 | mutable std::mutex mutex_; | 91 | mutable std::mutex mutex_; |
| 97 | }; | 92 | }; |
| @@ -1,11 +1,18 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * the terms and conditions of CANN Open Software License Agreement Version 2.0 |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * (the "License"). Please refer to the License for details. You may not use |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * this file except in compliance with the License. THIS SOFTWARE IS PROVIDED ON |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS |
| 9 | + * FOR A PARTICULAR PURPOSE. See LICENSE in the root of the software repository | ||
| 10 | + * for the full text of the License. | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 15 | + * for the full text of the License. | ||
| 9 | */ | 16 | */ |
| 10 | 17 | ||
| 11 | #ifndef SIM_YAML_CONFIG_H | 18 | #ifndef SIM_YAML_CONFIG_H |
| @@ -15,7 +22,7 @@ | |||
| 15 | #include <string> | 22 | #include <string> |
| 16 | 23 | ||
| 17 | // 解析yaml文件 | 24 | // 解析yaml文件 |
| 18 | -bool LoadYamlStringMap( | 25 | +bool LoadYamlStringMap(const std::string &yamlPath, const std::string &nodeName, |
| 19 | - const std::string& yamlPath, const std::string& nodeName, std::map<std::string, std::string>& out); | 26 | + std::map<std::string, std::string> &out); |
| 20 | 27 | ||
| 21 | #endif // SIM_YAML_CONFIG_H | 28 | #endif // SIM_YAML_CONFIG_H |
| @@ -1,11 +1,18 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * the terms and conditions of CANN Open Software License Agreement Version 2.0 |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * (the "License"). Please refer to the License for details. You may not use |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * this file except in compliance with the License. THIS SOFTWARE IS PROVIDED ON |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS |
| 9 | + * FOR A PARTICULAR PURPOSE. See LICENSE in the root of the software repository | ||
| 10 | + * for the full text of the License. | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 15 | + * for the full text of the License. | ||
| 9 | */ | 16 | */ |
| 10 | 17 | ||
| 11 | #ifndef STORE_SIM_COMM_MEMORY_MANAGER_H | 18 | #ifndef STORE_SIM_COMM_MEMORY_MANAGER_H |
| @@ -25,7 +32,7 @@ constexpr uint32_t kSlotsPerPage = 127099; | |||
| 25 | constexpr uint64_t kCommPageSize = 1ULL << 30; | 32 | constexpr uint64_t kCommPageSize = 1ULL << 30; |
| 26 | constexpr uint32_t kPageMagic = 0x5241504F; | 33 | constexpr uint32_t kPageMagic = 0x5241504F; |
| 27 | constexpr uint32_t kMaxPages = 4; | 34 | constexpr uint32_t kMaxPages = 4; |
| 28 | -constexpr uint32_t kAllocBatchSize = 4; | 35 | +constexpr uint32_t kAllocBatchSize = 1024; |
| 29 | constexpr uint32_t kSlotRefCountOff = 136; | 36 | constexpr uint32_t kSlotRefCountOff = 136; |
| 30 | constexpr uint32_t kSlotHeaderSize = 256; | 37 | constexpr uint32_t kSlotHeaderSize = 256; |
| 31 | constexpr uint32_t kC2sLockOff = 0; | 38 | constexpr uint32_t kC2sLockOff = 0; |
| @@ -36,7 +43,8 @@ constexpr int32_t kSpinCountLimit = 20; | |||
| 36 | 43 | ||
| 37 | constexpr uint32_t kRsFdClient = 0x01U; | 44 | constexpr uint32_t kRsFdClient = 0x01U; |
| 38 | constexpr uint32_t kRsFdServer = 0x00U; | 45 | constexpr uint32_t kRsFdServer = 0x00U; |
| 39 | -#define MAKE_FD(slot_idx, role) (((uint64_t)(role) << 63) | (uint64_t)(slot_idx)) | 46 | +#define MAKE_FD(slot_idx, role) \ |
| 47 | + (((uint64_t)(role) << 63) | (uint64_t)(slot_idx)) | ||
| 40 | #define FD_SLOT_IDX(fd) ((fd) & 0x7FFFFFFFFFFFFFFFULL) | 48 | #define FD_SLOT_IDX(fd) ((fd) & 0x7FFFFFFFFFFFFFFFULL) |
| 41 | #define FD_ROLE(fd) ((fd) >> 63) | 49 | #define FD_ROLE(fd) ((fd) >> 63) |
| 42 | 50 | ||
| @@ -58,21 +66,22 @@ struct PageHeader { | |||
| 58 | }; | 66 | }; |
| 59 | 67 | ||
| 60 | struct SlotHandle { | 68 | struct SlotHandle { |
| 61 | - char* base; | 69 | + char *base; |
| 62 | - char* sendBuf; | 70 | + char *sendBuf; |
| 63 | - volatile uint32_t* sendLock; | 71 | + volatile uint32_t *sendLock; |
| 64 | - volatile uint32_t* sendSize; | 72 | + volatile uint32_t *sendSize; |
| 65 | - char* recvBuf; | 73 | + char *recvBuf; |
| 66 | - volatile uint32_t* recvLock; | 74 | + volatile uint32_t *recvLock; |
| 67 | - volatile uint32_t* recvSize; | 75 | + volatile uint32_t *recvSize; |
| 68 | }; | 76 | }; |
| 69 | 77 | ||
| 70 | class CommunicationMemoryManager { | 78 | class CommunicationMemoryManager { |
| 71 | -public: | 79 | + public: |
| 72 | - static CommunicationMemoryManager& GetInstance(); | 80 | + static CommunicationMemoryManager &GetInstance(); |
| 73 | 81 | ||
| 74 | - CommunicationMemoryManager(const CommunicationMemoryManager&) = delete; | 82 | + CommunicationMemoryManager(const CommunicationMemoryManager &) = delete; |
| 75 | - CommunicationMemoryManager& operator=(const CommunicationMemoryManager&) = delete; | 83 | + CommunicationMemoryManager & |
| 84 | + operator=(const CommunicationMemoryManager &) = delete; | ||
| 76 | 85 | ||
| 77 | bool InitPool(); | 86 | bool InitPool(); |
| 78 | 87 | ||
| @@ -80,9 +89,9 @@ public: | |||
| 80 | 89 | ||
| 81 | SlotHandle GetSlotHandle(uint32_t slotIdx, uint32_t role); | 90 | SlotHandle GetSlotHandle(uint32_t slotIdx, uint32_t role); |
| 82 | 91 | ||
| 83 | - int64_t Send(const SlotHandle& handle, const void* data, size_t size); | 92 | + int64_t Send(const SlotHandle &handle, const void *data, size_t size); |
| 84 | 93 | ||
| 85 | - int64_t Recv(const SlotHandle& handle, void* data, size_t size); | 94 | + int64_t Recv(const SlotHandle &handle, void *data, size_t size); |
| 86 | 95 | ||
| 87 | void AddRef(uint32_t slotIdx); | 96 | void AddRef(uint32_t slotIdx); |
| 88 | 97 | ||
| @@ -90,7 +99,7 @@ public: | |||
| 90 | 99 | ||
| 91 | void Shutdown(); | 100 | void Shutdown(); |
| 92 | 101 | ||
| 93 | -private: | 102 | + private: |
| 94 | struct BatchCache { | 103 | struct BatchCache { |
| 95 | uint32_t start = 0; | 104 | uint32_t start = 0; |
| 96 | uint32_t current = 0; | 105 | uint32_t current = 0; |
| @@ -100,13 +109,13 @@ private: | |||
| 100 | CommunicationMemoryManager(); | 109 | CommunicationMemoryManager(); |
| 101 | ~CommunicationMemoryManager(); | 110 | ~CommunicationMemoryManager(); |
| 102 | 111 | ||
| 103 | - void* GetOrCreatePage(uint32_t pageId); | 112 | + void *GetOrCreatePage(uint32_t pageId); |
| 104 | 113 | ||
| 105 | std::mutex m_mutex; | 114 | std::mutex m_mutex; |
| 106 | - std::vector<void*> m_pages; | 115 | + std::vector<void *> m_pages; |
| 107 | BatchCache m_batchCache; | 116 | BatchCache m_batchCache; |
| 108 | }; | 117 | }; |
| 109 | 118 | ||
| 110 | } // namespace sim | 119 | } // namespace sim |
| 111 | 120 | ||
| 112 | -#endif // STORE_SIM_COMM_MEMORY_MANAGER_H | 121 | +#endif // STORE_SIM_COMM_MEMORY_MANAGER_H |
| @@ -1,11 +1,18 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | * Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * the terms and conditions of CANN Open Software License Agreement Version 2.0 |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * (the "License"). Please refer to the License for details. You may not use |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * this file except in compliance with the License. THIS SOFTWARE IS PROVIDED ON |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS |
| 9 | + * FOR A PARTICULAR PURPOSE. See LICENSE in the root of the software repository | ||
| 10 | + * for the full text of the License. | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 15 | + * for the full text of the License. | ||
| 9 | */ | 16 | */ |
| 10 | 17 | ||
| 11 | #ifndef SIM_COMM_POOL_POLICY_H | 18 | #ifndef SIM_COMM_POOL_POLICY_H |
| @@ -17,25 +24,26 @@ namespace sim { | |||
| 17 | // HcclCommPool | 24 | // HcclCommPool |
| 18 | // 复用区的准入策略,主机侧与设备侧共用的纯判定。阈值与上界集中在此定义。 | 25 | // 复用区的准入策略,主机侧与设备侧共用的纯判定。阈值与上界集中在此定义。 |
| 19 | struct CommPoolPolicy { | 26 | struct CommPoolPolicy { |
| 20 | - static constexpr size_t kBigBlockThreshold = 200ULL * 1024 * 1024; // 200MB,对齐 CCL buffer 默认 | 27 | + static constexpr size_t kBigBlockThreshold = |
| 28 | + 200ULL * 1024 * 1024; // 200MB,对齐 CCL buffer 默认 | ||
| 21 | // 复用区规格 4GB,大块可申请和可寻址的上界(含等于)。超过 4GB 由 | 29 | // 复用区规格 4GB,大块可申请和可寻址的上界(含等于)。超过 4GB 由 |
| 22 | // ExceedsCeiling 报错。 | 30 | // ExceedsCeiling 报错。 |
| 23 | static constexpr size_t kPoolSize = 4ULL * 1024 * 1024 * 1024; // 4GB | 31 | static constexpr size_t kPoolSize = 4ULL * 1024 * 1024 * 1024; // 4GB |
| 24 | 32 | ||
| 25 | // 复用区共享内存名。 | 33 | // 复用区共享内存名。 |
| 26 | - static constexpr const char* kPoolName = "HcclCommPool"; | 34 | + static constexpr const char *kPoolName = "HcclCommPool"; |
| 27 | 35 | ||
| 28 | // 本次申请是否应引流到复用区:仅校验模式开且 threshold <= size <= | 36 | // 本次申请是否应引流到复用区:仅校验模式开且 threshold <= size <= |
| 29 | // poolSize。 | 37 | // poolSize。 |
| 30 | - static bool | 38 | + static bool ShouldRedirect(size_t size, bool checkOnlyMode, |
| 31 | - ShouldRedirect(size_t size, bool checkOnlyMode, size_t threshold = kBigBlockThreshold, size_t poolSize = kPoolSize) | 39 | + size_t threshold = kBigBlockThreshold, |
| 32 | - { | 40 | + size_t poolSize = kPoolSize) { |
| 33 | return checkOnlyMode && size >= threshold && size <= poolSize; | 41 | return checkOnlyMode && size >= threshold && size <= poolSize; |
| 34 | } | 42 | } |
| 35 | 43 | ||
| 36 | // 本次申请是否超出复用区上界、应报错:仅仅校验模式下拦 size > poolSize。 | 44 | // 本次申请是否超出复用区上界、应报错:仅仅校验模式下拦 size > poolSize。 |
| 37 | - static bool ExceedsCeiling(size_t size, bool checkOnlyMode, size_t poolSize = kPoolSize) | 45 | + static bool ExceedsCeiling(size_t size, bool checkOnlyMode, |
| 38 | - { | 46 | + size_t poolSize = kPoolSize) { |
| 39 | return checkOnlyMode && size > poolSize; | 47 | return checkOnlyMode && size > poolSize; |
| 40 | } | 48 | } |
| 41 | }; | 49 | }; |