| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
【PR】: fix: sample 易用性规范性优化 Co-authored-by: qiang_zq<qiang.zhangqiang@huawei.com> # message auto-generated for no-merge-commit merge: !2067 merge master into master 【PR】: fix: sample 易用性规范性优化 Created-by: qiang_zq Commit-by: qiang_zq Merged-by: cann-robot Description: # Pull Request ## 描述 1、sample样例 readme规范化 整改 2、sample样例 补充优化注释 3、sample样例 cmakelist 连接包优化,libascendcl.so -> libacl_rt.so 4、新增一键导入 SOC_VERSION和ASCENDC_CMAKE_DIR变量的工具 ## 变更类型 请选择本次引入的变更类型: <!-- [x] 表示选中 --> - [ ] 🐛 Bug 修复 - [ ] ✨ 新功能 - [x] 💄 代码风格更新(格式化,局部变量) - [ ] ♻️ 重构(既不修复错误也不增加功能的代码变动) - [ ] 📦 构建过程或辅助工具的变动 - [x] 📝 文档内容更新 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在当前页面的右侧'关联Issue'部分添加相应Issue链接,并勾选'合并后关闭已关联的 Issue'选项。 --> ## 如何测试 描述测试此变更的步骤和前提条件: 1. example/0_quickstart/4_custom_kernel_launch Vector addition result: result[0] = 1.5 (expected: 1.5) result[1] = 3.0 (expected: 3.0) result[2] = 4.5 (expected: 4.5) result[3] = 6.0 (expected: 6.0) result[4] = 7.5 (expected: 7.5) result[5] = 9.0 (expected: 9.0) result[6] = 10.5 (expected: 10.5) result[7] = 12.0 (expected: 12.0) Free device memory successfully Destroy stream successfully Reset device successfully ACL finalize successfully Sample run successfully with <<<>>> kernel call! 2. 样例执行验证 ===== START 0_quickstart/0_hello_cann ===== RESULT 0_quickstart/0_hello_cann rc=0 -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /mnt/workspace/gitCode/qiang_zq/runtime/example/0_quickstart/0_hello_cann/build Building... [ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o [100%] Linking CXX executable main [100%] Built target main Build completed successfully! Executable location: /mnt/workspace/gitCode/qiang_zq/runtime/example/0_quickstart/0_hello_cann/build/main Run the sample: ./build/main ACL init successfully Set device 0 successfully Create stream successfully Input vectors: self: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0] other: [0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0] alpha: 1.0 Create output aclDataBuffer successfully, buffer addr = 0x12e0c0016000 Get workspace size successfully, workspace size = 0 Launch aclnnAdd successfully Synchronize stream successfully Vector addition result: result[0] = 1.5 (expected: 1.5) result[1] = 3.0 (expected: 3.0) result[2] = 4.5 (expected: 4.5) result[3] = 6.0 (expected: 6.0) result[4] = 7.5 (expected: 7.5) result[5] = 9.0 (expected: 9.0) result[6] = 10.5 (expected: 10.5) result[7] = 12.0 (expected: 12.0) Free device memory successfully Destroy stream successfully Reset device successfully ACL finalize successfully Sample run successfully! ===== END 0_quickstart/0_hello_cann ===== ===== START 0_quickstart/1_error_handling ===== RESULT 0_quickstart/1_error_handling rc=0 Configuring CMake... -- The C compiler identification is GNU 13.3.0 -- The CXX compiler identification is GNU 13.3.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /mnt/workspace/gitCode/qiang_zq/runtime/example/0_quickstart/1_error_handling/build Building... [ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o [100%] Linking CXX executable main [100%] Built target main Build completed successfully! Executable location: /mnt/workspace/gitCode/qiang_zq/runtime/example/0_quickstart/1_error_handling/build/main Run the sample: ./build/main [INFO] ACL init and set device successfully [INFO] Current run mode: ACL_HOST [INFO] Triggering an expected invalid-parameter error with aclrtGetRunMode(nullptr) [ERROR] Diagnostics: ret=100000, peekErr=0, lastErr=0, recentErrMsg=[PID: 334883] 2026-05-12-16:34:08.984.159 Invalid_Argument_Null_Pointer(EH0002): Argument [runMode] must not be null. Solution: Try again with a correct pointer argument. [WARN] aclrtGetErrorVerbose(0) returned error code 207000 [INFO] After diagnostics are consumed once: peekErr=207000, lastErr=207000, recentErrMsg=<null> [INFO] ACL finalize successfully ===== END 0_quickstart/1_error_handling ===== ===== START 0_quickstart/2_system_info ===== RESULT 0_quickstart/2_system_info rc=0 Configuring CMake... -- The C compiler identification is GNU 13.3.0 -- The CXX compiler identification is GNU 13.3.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /mnt/workspace/gitCode/qiang_zq/runtime/example/0_quickstart/2_system_info/build Building... [ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o [100%] Linking CXX executable main [100%] Built target main Build completed successfully! Executable location: /mnt/workspace/gitCode/qiang_zq/runtime/example/0_quickstart/2_system_info/build/main Run the sample: ./build/main [INFO] ACL init successfully [INFO] ACL Runtime API version: 1.16.0 [INFO] CANN package [runtime] version string: 9.0.0 [INFO] CANN package [runtime] version number: 90000000 [INFO] Current run mode: ACL_HOST [INFO] Float conversion: 1.625000 -> 0x3e80 -> 1.625000 [INFO] Data type size: ACL_FLOAT=4, ACL_FLOAT16=2, ACL_INT64=8 [INFO] ACL finalize successfully ===== END 0_quickstart/2_system_info ===== ===== START 1_basic_features/device/0_device_normal ===== RESULT 1_basic_features/device/0_device_normal rc=0 [INFO]: Current compile soc version is ascend910_9362 -- The C compiler identification is GNU 13.3.0 -- The CXX compiler identification is GNU 13.3.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /mnt/workspace/gitCode/qiang_zq/runtime/example/1_basic_features/device/0_device_normal/build [ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o [100%] Linking CXX executable main [100%] Built target main -- Install configuration: \"Debug\" [INFO] Start to run device_normal sample. [INFO] result[0] is: 1.200000 [INFO] result[1] is: 2.200000 [INFO] result[2] is: 3.200000 [INFO] result[3] is: 5.400000 [INFO] result[4] is: 6.400000 [INFO] result[5] is: 7.400000 [INFO] result[6] is: 9.600000 [INFO] result[7] is: 10.600000 [INFO] Run the device_normal sample successfully. ===== END 1_basic_features/device/0_device_normal ===== ## 核对清单 <!-- [x] 表示选中 --> - [x] 我的代码遵循了项目的代码风格 - [x] 我已对代码进行了自测 - [x] 我已更新了相关的文档 - [x] 我在标题中使用了合适的类型标签(如:feat:, fix:) - [x] 我已经详细阅读了贡献指南(CONTRIBUTING.md),并遵守了其中的所有规定,包括但不限于commit message的格式、无效commit的合并等 ## 其他信息 在此添加任何其他关于本次 PR 的说明。 See merge request: cann/runtime!2067 | 2 个月前 | |
【PR】: simplify runtime sample run steps Co-authored-by: shi-qiong<shiqiong3@huawei.com> # message auto-generated for no-merge-commit merge: !3087 merge feature/example-fix into master 【PR】: simplify runtime sample run steps Created-by: shi-qiong Commit-by: shi-qiong Merged-by: cann-robot Description: # Pull Request ## 描述 本次 PR 优化部分 Runtime 样例的运行步骤和 run.sh 健壮性,降低样例执行复杂度。 主要变更: - 移除样例 README 中额外的 ASCEND_INSTALL_PATH 配置步骤 - 统一通过 source ${install_root}/cann/set_env.sh 提供 CANN 环境 - run.sh 改为使用 ASCEND_HOME_PATH - 补充 set -euo pipefail、变量引用引号和失败返回 - 多进程/IPC 样例补充 proc_a / proc_b 退出码检查,避免误判成功 ## 变更类型 - [ ] 🐛 Bug 修复 - [ ] ✨ 新功能 - [x] 💄 代码风格更新(格式化,局部变量) - [ ] ♻️ 重构(既不修复错误也不增加功能的代码变动) - [ ] 📦 构建过程或辅助工具的变动 - [x] 📝 文档内容更新 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在当前页面的右侧'关联Issue'部分添加相应Issue链接,并勾选'合并后关闭已关联的 Issue'选项。 --> ## 如何测试 描述测试此变更的步骤和前提条件: 验证已整改样例: source ${install_root}/cann/set_env.sh source ${git_clone_path}/example/set_sample_env.sh bash run.sh ## 核对清单 <!-- [x] 表示选中 --> - [x] 我的代码遵循了项目的代码风格 - [x] 我已对代码进行了自测 - [x] 我已更新了相关的文档 - [x] 我在标题中使用了合适的类型标签(如:feat:, fix:) - [x] 我已经详细阅读了贡献指南(CONTRIBUTING.md),并遵守了其中的所有规定,包括但不限于commit message的格式、无效commit的合并等 ## 其他信息 在此添加任何其他关于本次 PR 的说明。 See merge request: cann/runtime!3087 | 23 天前 | |
【PR】: fix issue Co-authored-by: shi-qiong<shiqiong3@huawei.com> # message auto-generated for no-merge-commit merge: !3309 merge feature/issue-fix into master 【PR】: fix issue Created-by: shi-qiong Commit-by: shi-qiong Merged-by: cann-robot Description: # Pull Request ## 描述 请清晰准确地描述本次 Pull Request 的意图和变更内容。 ## 变更类型 请选择本次引入的变更类型: <!-- [x] 表示选中 --> - [ ] 🐛 Bug 修复 - [ ] ✨ 新功能 - [ ] 💄 代码风格更新(格式化,局部变量) - [ ] ♻️ 重构(既不修复错误也不增加功能的代码变动) - [ ] 📦 构建过程或辅助工具的变动 - [x] 📝 文档内容更新 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在当前页面的右侧'关联Issue'部分添加相应Issue链接,并勾选'合并后关闭已关联的 Issue'选项。 --> 621 ## 如何测试 描述测试此变更的步骤和前提条件: 1. 2. ## 核对清单 <!-- [x] 表示选中 --> - [x] 我的代码遵循了项目的代码风格 - [x] 我已对代码进行了自测 - [x] 我已更新了相关的文档 - [x] 我在标题中使用了合适的类型标签(如: feat:, fix:) - [x] 我已经详细阅读了贡献指南(CONTRIBUTING.md),并遵守了其中的所有规定,包括但不限于commit message的格式、无效commit的合并等 ## 其他信息 在此添加任何其他关于本次 PR 的说明。 See merge request: cann/runtime!3309 | 17 天前 | |
【PR】: fix: sample 易用性规范性优化 Co-authored-by: qiang_zq<qiang.zhangqiang@huawei.com> # message auto-generated for no-merge-commit merge: !2067 merge master into master 【PR】: fix: sample 易用性规范性优化 Created-by: qiang_zq Commit-by: qiang_zq Merged-by: cann-robot Description: # Pull Request ## 描述 1、sample样例 readme规范化 整改 2、sample样例 补充优化注释 3、sample样例 cmakelist 连接包优化,libascendcl.so -> libacl_rt.so 4、新增一键导入 SOC_VERSION和ASCENDC_CMAKE_DIR变量的工具 ## 变更类型 请选择本次引入的变更类型: <!-- [x] 表示选中 --> - [ ] 🐛 Bug 修复 - [ ] ✨ 新功能 - [x] 💄 代码风格更新(格式化,局部变量) - [ ] ♻️ 重构(既不修复错误也不增加功能的代码变动) - [ ] 📦 构建过程或辅助工具的变动 - [x] 📝 文档内容更新 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在当前页面的右侧'关联Issue'部分添加相应Issue链接,并勾选'合并后关闭已关联的 Issue'选项。 --> ## 如何测试 描述测试此变更的步骤和前提条件: 1. example/0_quickstart/4_custom_kernel_launch Vector addition result: result[0] = 1.5 (expected: 1.5) result[1] = 3.0 (expected: 3.0) result[2] = 4.5 (expected: 4.5) result[3] = 6.0 (expected: 6.0) result[4] = 7.5 (expected: 7.5) result[5] = 9.0 (expected: 9.0) result[6] = 10.5 (expected: 10.5) result[7] = 12.0 (expected: 12.0) Free device memory successfully Destroy stream successfully Reset device successfully ACL finalize successfully Sample run successfully with <<<>>> kernel call! 2. 样例执行验证 ===== START 0_quickstart/0_hello_cann ===== RESULT 0_quickstart/0_hello_cann rc=0 -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /mnt/workspace/gitCode/qiang_zq/runtime/example/0_quickstart/0_hello_cann/build Building... [ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o [100%] Linking CXX executable main [100%] Built target main Build completed successfully! Executable location: /mnt/workspace/gitCode/qiang_zq/runtime/example/0_quickstart/0_hello_cann/build/main Run the sample: ./build/main ACL init successfully Set device 0 successfully Create stream successfully Input vectors: self: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0] other: [0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0] alpha: 1.0 Create output aclDataBuffer successfully, buffer addr = 0x12e0c0016000 Get workspace size successfully, workspace size = 0 Launch aclnnAdd successfully Synchronize stream successfully Vector addition result: result[0] = 1.5 (expected: 1.5) result[1] = 3.0 (expected: 3.0) result[2] = 4.5 (expected: 4.5) result[3] = 6.0 (expected: 6.0) result[4] = 7.5 (expected: 7.5) result[5] = 9.0 (expected: 9.0) result[6] = 10.5 (expected: 10.5) result[7] = 12.0 (expected: 12.0) Free device memory successfully Destroy stream successfully Reset device successfully ACL finalize successfully Sample run successfully! ===== END 0_quickstart/0_hello_cann ===== ===== START 0_quickstart/1_error_handling ===== RESULT 0_quickstart/1_error_handling rc=0 Configuring CMake... -- The C compiler identification is GNU 13.3.0 -- The CXX compiler identification is GNU 13.3.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /mnt/workspace/gitCode/qiang_zq/runtime/example/0_quickstart/1_error_handling/build Building... [ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o [100%] Linking CXX executable main [100%] Built target main Build completed successfully! Executable location: /mnt/workspace/gitCode/qiang_zq/runtime/example/0_quickstart/1_error_handling/build/main Run the sample: ./build/main [INFO] ACL init and set device successfully [INFO] Current run mode: ACL_HOST [INFO] Triggering an expected invalid-parameter error with aclrtGetRunMode(nullptr) [ERROR] Diagnostics: ret=100000, peekErr=0, lastErr=0, recentErrMsg=[PID: 334883] 2026-05-12-16:34:08.984.159 Invalid_Argument_Null_Pointer(EH0002): Argument [runMode] must not be null. Solution: Try again with a correct pointer argument. [WARN] aclrtGetErrorVerbose(0) returned error code 207000 [INFO] After diagnostics are consumed once: peekErr=207000, lastErr=207000, recentErrMsg=<null> [INFO] ACL finalize successfully ===== END 0_quickstart/1_error_handling ===== ===== START 0_quickstart/2_system_info ===== RESULT 0_quickstart/2_system_info rc=0 Configuring CMake... -- The C compiler identification is GNU 13.3.0 -- The CXX compiler identification is GNU 13.3.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /mnt/workspace/gitCode/qiang_zq/runtime/example/0_quickstart/2_system_info/build Building... [ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o [100%] Linking CXX executable main [100%] Built target main Build completed successfully! Executable location: /mnt/workspace/gitCode/qiang_zq/runtime/example/0_quickstart/2_system_info/build/main Run the sample: ./build/main [INFO] ACL init successfully [INFO] ACL Runtime API version: 1.16.0 [INFO] CANN package [runtime] version string: 9.0.0 [INFO] CANN package [runtime] version number: 90000000 [INFO] Current run mode: ACL_HOST [INFO] Float conversion: 1.625000 -> 0x3e80 -> 1.625000 [INFO] Data type size: ACL_FLOAT=4, ACL_FLOAT16=2, ACL_INT64=8 [INFO] ACL finalize successfully ===== END 0_quickstart/2_system_info ===== ===== START 1_basic_features/device/0_device_normal ===== RESULT 1_basic_features/device/0_device_normal rc=0 [INFO]: Current compile soc version is ascend910_9362 -- The C compiler identification is GNU 13.3.0 -- The CXX compiler identification is GNU 13.3.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /mnt/workspace/gitCode/qiang_zq/runtime/example/1_basic_features/device/0_device_normal/build [ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o [100%] Linking CXX executable main [100%] Built target main -- Install configuration: \"Debug\" [INFO] Start to run device_normal sample. [INFO] result[0] is: 1.200000 [INFO] result[1] is: 2.200000 [INFO] result[2] is: 3.200000 [INFO] result[3] is: 5.400000 [INFO] result[4] is: 6.400000 [INFO] result[5] is: 7.400000 [INFO] result[6] is: 9.600000 [INFO] result[7] is: 10.600000 [INFO] Run the device_normal sample successfully. ===== END 1_basic_features/device/0_device_normal ===== ## 核对清单 <!-- [x] 表示选中 --> - [x] 我的代码遵循了项目的代码风格 - [x] 我已对代码进行了自测 - [x] 我已更新了相关的文档 - [x] 我在标题中使用了合适的类型标签(如:feat:, fix:) - [x] 我已经详细阅读了贡献指南(CONTRIBUTING.md),并遵守了其中的所有规定,包括但不限于commit message的格式、无效commit的合并等 ## 其他信息 在此添加任何其他关于本次 PR 的说明。 See merge request: cann/runtime!2067 | 2 个月前 | |
【PR】: simplify runtime sample run steps Co-authored-by: shi-qiong<shiqiong3@huawei.com> # message auto-generated for no-merge-commit merge: !3087 merge feature/example-fix into master 【PR】: simplify runtime sample run steps Created-by: shi-qiong Commit-by: shi-qiong Merged-by: cann-robot Description: # Pull Request ## 描述 本次 PR 优化部分 Runtime 样例的运行步骤和 run.sh 健壮性,降低样例执行复杂度。 主要变更: - 移除样例 README 中额外的 ASCEND_INSTALL_PATH 配置步骤 - 统一通过 source ${install_root}/cann/set_env.sh 提供 CANN 环境 - run.sh 改为使用 ASCEND_HOME_PATH - 补充 set -euo pipefail、变量引用引号和失败返回 - 多进程/IPC 样例补充 proc_a / proc_b 退出码检查,避免误判成功 ## 变更类型 - [ ] 🐛 Bug 修复 - [ ] ✨ 新功能 - [x] 💄 代码风格更新(格式化,局部变量) - [ ] ♻️ 重构(既不修复错误也不增加功能的代码变动) - [ ] 📦 构建过程或辅助工具的变动 - [x] 📝 文档内容更新 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在当前页面的右侧'关联Issue'部分添加相应Issue链接,并勾选'合并后关闭已关联的 Issue'选项。 --> ## 如何测试 描述测试此变更的步骤和前提条件: 验证已整改样例: source ${install_root}/cann/set_env.sh source ${git_clone_path}/example/set_sample_env.sh bash run.sh ## 核对清单 <!-- [x] 表示选中 --> - [x] 我的代码遵循了项目的代码风格 - [x] 我已对代码进行了自测 - [x] 我已更新了相关的文档 - [x] 我在标题中使用了合适的类型标签(如:feat:, fix:) - [x] 我已经详细阅读了贡献指南(CONTRIBUTING.md),并遵守了其中的所有规定,包括但不限于commit message的格式、无效commit的合并等 ## 其他信息 在此添加任何其他关于本次 PR 的说明。 See merge request: cann/runtime!3087 | 23 天前 | |
【PR】: fix: sample 易用性规范性优化 Co-authored-by: qiang_zq<qiang.zhangqiang@huawei.com> # message auto-generated for no-merge-commit merge: !2067 merge master into master 【PR】: fix: sample 易用性规范性优化 Created-by: qiang_zq Commit-by: qiang_zq Merged-by: cann-robot Description: # Pull Request ## 描述 1、sample样例 readme规范化 整改 2、sample样例 补充优化注释 3、sample样例 cmakelist 连接包优化,libascendcl.so -> libacl_rt.so 4、新增一键导入 SOC_VERSION和ASCENDC_CMAKE_DIR变量的工具 ## 变更类型 请选择本次引入的变更类型: <!-- [x] 表示选中 --> - [ ] 🐛 Bug 修复 - [ ] ✨ 新功能 - [x] 💄 代码风格更新(格式化,局部变量) - [ ] ♻️ 重构(既不修复错误也不增加功能的代码变动) - [ ] 📦 构建过程或辅助工具的变动 - [x] 📝 文档内容更新 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在当前页面的右侧'关联Issue'部分添加相应Issue链接,并勾选'合并后关闭已关联的 Issue'选项。 --> ## 如何测试 描述测试此变更的步骤和前提条件: 1. example/0_quickstart/4_custom_kernel_launch Vector addition result: result[0] = 1.5 (expected: 1.5) result[1] = 3.0 (expected: 3.0) result[2] = 4.5 (expected: 4.5) result[3] = 6.0 (expected: 6.0) result[4] = 7.5 (expected: 7.5) result[5] = 9.0 (expected: 9.0) result[6] = 10.5 (expected: 10.5) result[7] = 12.0 (expected: 12.0) Free device memory successfully Destroy stream successfully Reset device successfully ACL finalize successfully Sample run successfully with <<<>>> kernel call! 2. 样例执行验证 ===== START 0_quickstart/0_hello_cann ===== RESULT 0_quickstart/0_hello_cann rc=0 -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /mnt/workspace/gitCode/qiang_zq/runtime/example/0_quickstart/0_hello_cann/build Building... [ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o [100%] Linking CXX executable main [100%] Built target main Build completed successfully! Executable location: /mnt/workspace/gitCode/qiang_zq/runtime/example/0_quickstart/0_hello_cann/build/main Run the sample: ./build/main ACL init successfully Set device 0 successfully Create stream successfully Input vectors: self: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0] other: [0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0] alpha: 1.0 Create output aclDataBuffer successfully, buffer addr = 0x12e0c0016000 Get workspace size successfully, workspace size = 0 Launch aclnnAdd successfully Synchronize stream successfully Vector addition result: result[0] = 1.5 (expected: 1.5) result[1] = 3.0 (expected: 3.0) result[2] = 4.5 (expected: 4.5) result[3] = 6.0 (expected: 6.0) result[4] = 7.5 (expected: 7.5) result[5] = 9.0 (expected: 9.0) result[6] = 10.5 (expected: 10.5) result[7] = 12.0 (expected: 12.0) Free device memory successfully Destroy stream successfully Reset device successfully ACL finalize successfully Sample run successfully! ===== END 0_quickstart/0_hello_cann ===== ===== START 0_quickstart/1_error_handling ===== RESULT 0_quickstart/1_error_handling rc=0 Configuring CMake... -- The C compiler identification is GNU 13.3.0 -- The CXX compiler identification is GNU 13.3.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /mnt/workspace/gitCode/qiang_zq/runtime/example/0_quickstart/1_error_handling/build Building... [ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o [100%] Linking CXX executable main [100%] Built target main Build completed successfully! Executable location: /mnt/workspace/gitCode/qiang_zq/runtime/example/0_quickstart/1_error_handling/build/main Run the sample: ./build/main [INFO] ACL init and set device successfully [INFO] Current run mode: ACL_HOST [INFO] Triggering an expected invalid-parameter error with aclrtGetRunMode(nullptr) [ERROR] Diagnostics: ret=100000, peekErr=0, lastErr=0, recentErrMsg=[PID: 334883] 2026-05-12-16:34:08.984.159 Invalid_Argument_Null_Pointer(EH0002): Argument [runMode] must not be null. Solution: Try again with a correct pointer argument. [WARN] aclrtGetErrorVerbose(0) returned error code 207000 [INFO] After diagnostics are consumed once: peekErr=207000, lastErr=207000, recentErrMsg=<null> [INFO] ACL finalize successfully ===== END 0_quickstart/1_error_handling ===== ===== START 0_quickstart/2_system_info ===== RESULT 0_quickstart/2_system_info rc=0 Configuring CMake... -- The C compiler identification is GNU 13.3.0 -- The CXX compiler identification is GNU 13.3.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /mnt/workspace/gitCode/qiang_zq/runtime/example/0_quickstart/2_system_info/build Building... [ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o [100%] Linking CXX executable main [100%] Built target main Build completed successfully! Executable location: /mnt/workspace/gitCode/qiang_zq/runtime/example/0_quickstart/2_system_info/build/main Run the sample: ./build/main [INFO] ACL init successfully [INFO] ACL Runtime API version: 1.16.0 [INFO] CANN package [runtime] version string: 9.0.0 [INFO] CANN package [runtime] version number: 90000000 [INFO] Current run mode: ACL_HOST [INFO] Float conversion: 1.625000 -> 0x3e80 -> 1.625000 [INFO] Data type size: ACL_FLOAT=4, ACL_FLOAT16=2, ACL_INT64=8 [INFO] ACL finalize successfully ===== END 0_quickstart/2_system_info ===== ===== START 1_basic_features/device/0_device_normal ===== RESULT 1_basic_features/device/0_device_normal rc=0 [INFO]: Current compile soc version is ascend910_9362 -- The C compiler identification is GNU 13.3.0 -- The CXX compiler identification is GNU 13.3.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /mnt/workspace/gitCode/qiang_zq/runtime/example/1_basic_features/device/0_device_normal/build [ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o [100%] Linking CXX executable main [100%] Built target main -- Install configuration: \"Debug\" [INFO] Start to run device_normal sample. [INFO] result[0] is: 1.200000 [INFO] result[1] is: 2.200000 [INFO] result[2] is: 3.200000 [INFO] result[3] is: 5.400000 [INFO] result[4] is: 6.400000 [INFO] result[5] is: 7.400000 [INFO] result[6] is: 9.600000 [INFO] result[7] is: 10.600000 [INFO] Run the device_normal sample successfully. ===== END 1_basic_features/device/0_device_normal ===== ## 核对清单 <!-- [x] 表示选中 --> - [x] 我的代码遵循了项目的代码风格 - [x] 我已对代码进行了自测 - [x] 我已更新了相关的文档 - [x] 我在标题中使用了合适的类型标签(如:feat:, fix:) - [x] 我已经详细阅读了贡献指南(CONTRIBUTING.md),并遵守了其中的所有规定,包括但不限于commit message的格式、无效commit的合并等 ## 其他信息 在此添加任何其他关于本次 PR 的说明。 See merge request: cann/runtime!2067 | 2 个月前 | |
【PR】: fix: sample 易用性规范性优化 Co-authored-by: qiang_zq<qiang.zhangqiang@huawei.com> # message auto-generated for no-merge-commit merge: !2067 merge master into master 【PR】: fix: sample 易用性规范性优化 Created-by: qiang_zq Commit-by: qiang_zq Merged-by: cann-robot Description: # Pull Request ## 描述 1、sample样例 readme规范化 整改 2、sample样例 补充优化注释 3、sample样例 cmakelist 连接包优化,libascendcl.so -> libacl_rt.so 4、新增一键导入 SOC_VERSION和ASCENDC_CMAKE_DIR变量的工具 ## 变更类型 请选择本次引入的变更类型: <!-- [x] 表示选中 --> - [ ] 🐛 Bug 修复 - [ ] ✨ 新功能 - [x] 💄 代码风格更新(格式化,局部变量) - [ ] ♻️ 重构(既不修复错误也不增加功能的代码变动) - [ ] 📦 构建过程或辅助工具的变动 - [x] 📝 文档内容更新 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在当前页面的右侧'关联Issue'部分添加相应Issue链接,并勾选'合并后关闭已关联的 Issue'选项。 --> ## 如何测试 描述测试此变更的步骤和前提条件: 1. example/0_quickstart/4_custom_kernel_launch Vector addition result: result[0] = 1.5 (expected: 1.5) result[1] = 3.0 (expected: 3.0) result[2] = 4.5 (expected: 4.5) result[3] = 6.0 (expected: 6.0) result[4] = 7.5 (expected: 7.5) result[5] = 9.0 (expected: 9.0) result[6] = 10.5 (expected: 10.5) result[7] = 12.0 (expected: 12.0) Free device memory successfully Destroy stream successfully Reset device successfully ACL finalize successfully Sample run successfully with <<<>>> kernel call! 2. 样例执行验证 ===== START 0_quickstart/0_hello_cann ===== RESULT 0_quickstart/0_hello_cann rc=0 -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /mnt/workspace/gitCode/qiang_zq/runtime/example/0_quickstart/0_hello_cann/build Building... [ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o [100%] Linking CXX executable main [100%] Built target main Build completed successfully! Executable location: /mnt/workspace/gitCode/qiang_zq/runtime/example/0_quickstart/0_hello_cann/build/main Run the sample: ./build/main ACL init successfully Set device 0 successfully Create stream successfully Input vectors: self: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0] other: [0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0] alpha: 1.0 Create output aclDataBuffer successfully, buffer addr = 0x12e0c0016000 Get workspace size successfully, workspace size = 0 Launch aclnnAdd successfully Synchronize stream successfully Vector addition result: result[0] = 1.5 (expected: 1.5) result[1] = 3.0 (expected: 3.0) result[2] = 4.5 (expected: 4.5) result[3] = 6.0 (expected: 6.0) result[4] = 7.5 (expected: 7.5) result[5] = 9.0 (expected: 9.0) result[6] = 10.5 (expected: 10.5) result[7] = 12.0 (expected: 12.0) Free device memory successfully Destroy stream successfully Reset device successfully ACL finalize successfully Sample run successfully! ===== END 0_quickstart/0_hello_cann ===== ===== START 0_quickstart/1_error_handling ===== RESULT 0_quickstart/1_error_handling rc=0 Configuring CMake... -- The C compiler identification is GNU 13.3.0 -- The CXX compiler identification is GNU 13.3.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /mnt/workspace/gitCode/qiang_zq/runtime/example/0_quickstart/1_error_handling/build Building... [ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o [100%] Linking CXX executable main [100%] Built target main Build completed successfully! Executable location: /mnt/workspace/gitCode/qiang_zq/runtime/example/0_quickstart/1_error_handling/build/main Run the sample: ./build/main [INFO] ACL init and set device successfully [INFO] Current run mode: ACL_HOST [INFO] Triggering an expected invalid-parameter error with aclrtGetRunMode(nullptr) [ERROR] Diagnostics: ret=100000, peekErr=0, lastErr=0, recentErrMsg=[PID: 334883] 2026-05-12-16:34:08.984.159 Invalid_Argument_Null_Pointer(EH0002): Argument [runMode] must not be null. Solution: Try again with a correct pointer argument. [WARN] aclrtGetErrorVerbose(0) returned error code 207000 [INFO] After diagnostics are consumed once: peekErr=207000, lastErr=207000, recentErrMsg=<null> [INFO] ACL finalize successfully ===== END 0_quickstart/1_error_handling ===== ===== START 0_quickstart/2_system_info ===== RESULT 0_quickstart/2_system_info rc=0 Configuring CMake... -- The C compiler identification is GNU 13.3.0 -- The CXX compiler identification is GNU 13.3.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /mnt/workspace/gitCode/qiang_zq/runtime/example/0_quickstart/2_system_info/build Building... [ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o [100%] Linking CXX executable main [100%] Built target main Build completed successfully! Executable location: /mnt/workspace/gitCode/qiang_zq/runtime/example/0_quickstart/2_system_info/build/main Run the sample: ./build/main [INFO] ACL init successfully [INFO] ACL Runtime API version: 1.16.0 [INFO] CANN package [runtime] version string: 9.0.0 [INFO] CANN package [runtime] version number: 90000000 [INFO] Current run mode: ACL_HOST [INFO] Float conversion: 1.625000 -> 0x3e80 -> 1.625000 [INFO] Data type size: ACL_FLOAT=4, ACL_FLOAT16=2, ACL_INT64=8 [INFO] ACL finalize successfully ===== END 0_quickstart/2_system_info ===== ===== START 1_basic_features/device/0_device_normal ===== RESULT 1_basic_features/device/0_device_normal rc=0 [INFO]: Current compile soc version is ascend910_9362 -- The C compiler identification is GNU 13.3.0 -- The CXX compiler identification is GNU 13.3.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /mnt/workspace/gitCode/qiang_zq/runtime/example/1_basic_features/device/0_device_normal/build [ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o [100%] Linking CXX executable main [100%] Built target main -- Install configuration: \"Debug\" [INFO] Start to run device_normal sample. [INFO] result[0] is: 1.200000 [INFO] result[1] is: 2.200000 [INFO] result[2] is: 3.200000 [INFO] result[3] is: 5.400000 [INFO] result[4] is: 6.400000 [INFO] result[5] is: 7.400000 [INFO] result[6] is: 9.600000 [INFO] result[7] is: 10.600000 [INFO] Run the device_normal sample successfully. ===== END 1_basic_features/device/0_device_normal ===== ## 核对清单 <!-- [x] 表示选中 --> - [x] 我的代码遵循了项目的代码风格 - [x] 我已对代码进行了自测 - [x] 我已更新了相关的文档 - [x] 我在标题中使用了合适的类型标签(如:feat:, fix:) - [x] 我已经详细阅读了贡献指南(CONTRIBUTING.md),并遵守了其中的所有规定,包括但不限于commit message的格式、无效commit的合并等 ## 其他信息 在此添加任何其他关于本次 PR 的说明。 See merge request: cann/runtime!2067 | 2 个月前 |
4_custom_kernel_launch
描述
本样例提供一个最小可运行示例,演示如何使用 <<<>>> 内核调用符下发自定义 AscendC Kernel,完成 8 元素向量加法。运行成功后,结果应与 0_hello_cann 中的向量加法结果一致。
产品支持情况
本样例支持以下产品:
| 产品 | 是否支持 |
|---|---|
| Ascend 950PR/Ascend 950DT | √ |
| Atlas A3 训练系列产品/Atlas A3 推理系列产品 | √ |
| Atlas A2 训练系列产品/Atlas A2 推理系列产品 | √ |
编译运行
1.下载样例代码至安装CANN软件的环境,切换到样例目录。
cd ${git_clone_path}/example/0_quickstart/4_custom_kernel_launch
2.设置环境变量。
# ${install_root} 替换为 CANN 安装根目录,默认安装在`/usr/local/Ascend`目录
source ${install_root}/cann/set_env.sh
# 自动识别 SOC_VERSION 和 ASCENDC_CMAKE_DIR
source ${git_clone_path}/example/set_sample_env.sh
3.执行以下命令运行样例。
bash run.sh
CANN RUNTIME API
在该Sample中,涉及的关键功能点及其关键接口,如下所示:
- 初始化
- 调用
aclInit接口进行初始化配置。 - 调用
aclFinalize接口实现去初始化。
- 调用
- Device 与 Stream 管理
- 调用
aclrtSetDevice接口指定用于运算的 Device。 - 调用
aclrtCreateStream接口创建 Stream。 - 调用
aclrtSynchronizeStream接口阻塞等待 Stream 上任务完成。 - 调用
aclrtDestroyStream接口销毁 Stream。 - 调用
aclrtResetDeviceForce接口强制复位当前运算的 Device,回收 Device 上的资源。
- 调用
- 内存管理与数据传输
- 调用
aclrtMalloc接口申请 Device 上的内存。 - 调用
aclrtMemcpy接口完成 Host/Device 数据传输。 - 调用
aclrtFree接口释放 Device 上的内存。
- 调用
- Kernel 调用
- 使用
<<<>>>内核调用符下发自定义 AscendC Kernel。
- 使用
示例输出
样例会打印输入向量、<<<>>> 调用成功信息以及最终结果。典型输出如下:
ACL init successfully
Set device 0 successfully
Create stream successfully
Allocate device buffers successfully
Copy input vectors to device successfully
Input vectors:
self: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]
other: [0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0]
alpha: 1.0
Custom AscendC kernel <<<>>> call successfully
Synchronize stream successfully
Vector addition result:
result[0] = 1.5 (expected: 1.5)
result[1] = 3.0 (expected: 3.0)
result[2] = 4.5 (expected: 4.5)
result[3] = 6.0 (expected: 6.0)
result[4] = 7.5 (expected: 7.5)
result[5] = 9.0 (expected: 9.0)
result[6] = 10.5 (expected: 10.5)
result[7] = 12.0 (expected: 12.0)
Sample run successfully with <<<>>> kernel call!
如果输出结果与预期一致,说明 CANN 自定义 Kernel 的 <<<>>> 调用路径工作正常。
相关样例
- 0_hello_cann:使用
aclnnAdd完成相同的向量加法。