| Files | Last commit | Last update |
|---|---|---|
fix: 迁移 Ascend C 样例至 ASC 前端 Co-authored-by: xiao_hhh<guohui37@huawei.com> # message auto-generated for no-merge-commit merge: !5323 merge fix_ascendc_cmake into master fix: 迁移 Ascend C 样例至 ASC 前端 Created-by: xiao_hhh Commit-by: xiao_hhh Merged-by: cann-robot Description: # Pull Request ## 描述 将 40 个实际编译 Ascend C Kernel 的 Runtime example 从 legacy --cce-aicore-lang 构建链迁移到 ASC CMake 前端,统一使用 find_package(ASC)、ASC language 和显式 NPU 架构映射。 同时保留样例原有执行行为,复用公共 Kernel 源文件,补齐 FatBin 安装规则,并保留 D2D 同步拷贝场景所需的显式流同步。 ## 变更类型 - [x] 🐛 Bug 修复 - [ ] ✨ 新功能 - [x] 💄 代码风格更新(格式化,局部变量) - [x] ♻️ 重构(既不修复错误也不增加功能的代码变动) - [x] 📦 构建过程或辅助工具的变动 - [ ] 📝 文档内容更新 ## 关联的Issue 无。 ## 如何测试 1. CANN 9.1.0、Ascend 910B3、Driver 25.5.0:40/40 Kernel target 编译通过,59/59 Device ELF 包含 ParamSummary,35/35 可执行单机样例通过。 2. CANN 9.2.0-beta.2、Ascend 910B3、Driver 25.5.0:40/40 Kernel target 编译通过,59/59 Device ELF 包含 ParamSummary;安装版可构建的 34 个单机样例全部通过,0_launch_kernel 的 simple/placeholder 模式均通过。 3. 使用当前源码 Runtime 补测 9.2-beta.2 安装包尚未提供的接口:binary_enumerate_functions、binary_get_function_count、launch_blocking 均编译并真机运行通过,ldd -r 无未定义符号。 4. pre-commit run --files <本次74个文件>、clang-format、OAT 和 git diff --check 均通过。 说明:跨服务器物理内存共享样例需要双机环境,未执行运行验证;9.2-beta.2 环境未安装匹配的 910B OPS 包,因此两个依赖 aclnnAdd 的 model 样例仅完成 ASC Kernel 与元数据验证,不将混用 9.1 OPS 的结果计为 9.2 通过。 ## 核对清单 - [x] 我的代码遵循了项目的代码风格 - [x] 我已对代码进行了自测 - [x] 我已确认本次变更无需更新接口文档 - [x] 我在标题中使用了合适的类型标签(如:feat:, fix:) - [x] 我已经详细阅读了贡献指南(CONTRIBUTING.md),并遵守了其中的所有规定,包括但不限于commit message的格式、无效commit的合并等 ## 其他信息 本 PR 仅包含 74 个本次 ASC 前端迁移及 pre-commit 修复涉及的 example/ 文件,不包含本地构建产物、验证日志或其他工作区文件。 See merge request: cann/runtime!5323 | 1 month ago | |
【fix】:统一使用 aclrtLaunchHostFunc,移除混用接口 Co-authored-by: qq_64748107<2592856994@qq.com> # message auto-generated for no-merge-commit merge: !4605 merge fix/callback-hostfunc-only-892 into master 【fix】:统一使用 aclrtLaunchHostFunc,移除混用接口 Created-by: qq_64748107 Commit-by: qq_64748107 Merged-by: cann-robot Description: # Pull Request ## 描述 ## 关联 Issue #892 ## 问题 example/2_advanced_features/callback/0_simple_callback/callback_sample.cpp 中 aclrtLaunchCallback 与 aclrtLaunchHostFunc 在同一个 Stream 上混用,违反文档约束: 「对于同一个 Stream,两套实现异步场景下的 callback 功能的接口不能混用,否则可能出现异常」 ## 修复方案 统一使用 aclrtLaunchHostFunc 接口,移除 aclrtLaunchCallback 系列接口 (SubscribeReport/ProcessReport/UnSubscribeReport)和自建后台线程。 aclrtLaunchHostFunc 内部自动创建并管理回调线程,代码大幅简化。 ## 改动文件 callback_sample.h:删除 ThreadFunc、HostFuncThreadFunc、HostFunc 声明,移除冗余的 #include <thread> 和 #include <string> callback_sample.cpp:删除自建线程和第一套接口,统一用 aclrtLaunchHostFunc;删除 GetThreadId 调用和线程 ID 日志;简化 Callback() 为 before→kernel→after 三个任务 CMakeLists.txt:移除未使用的 ../callback_utils.cpp 编译项 README.md / README_en.md:更新描述、API 列表、示例输出 ## 验证 - 编译运行通过,回调执行顺序正确 - 相关 UT(8个)全部通过 ## 变更类型 请选择本次引入的变更类型: <!-- [x] 表示选中 --> - [x] 🐛 Bug 修复 - [ ] ✨ 新功能 - [ ] 💄 代码风格更新(格式化,局部变量) - [ ] ♻️ 重构(既不修复错误也不增加功能的代码变动) - [ ] 📦 构建过程或辅助工具的变动 - [ ] 📝 文档内容更新 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在当前页面的右侧'关联Issue'部分添加相应Issue链接,并勾选'合并后关闭已关联的 Issue'选项。 --> ## 如何测试 描述测试此变更的步骤和前提条件: 1. 2. ## 核对清单 <!-- [x] 表示选中 --> - [x] 我的代码遵循了项目的代码风格 - [x] 我已对代码进行了自测 - [x] 我已更新了相关的文档 - [x] 我在标题中使用了合适的类型标签(如: feat:, fix:) - [x] 我已经详细阅读了贡献指南(CONTRIBUTING.md),并遵守了其中的所有规定,包括但不限于commit message的格式、无效commit的合并等 ## 其他信息 在此添加任何其他关于本次 PR 的说明。 See merge request: cann/runtime!4605 | 2 months ago | |
【fix】:统一使用 aclrtLaunchHostFunc,移除混用接口 Co-authored-by: qq_64748107<2592856994@qq.com> # message auto-generated for no-merge-commit merge: !4605 merge fix/callback-hostfunc-only-892 into master 【fix】:统一使用 aclrtLaunchHostFunc,移除混用接口 Created-by: qq_64748107 Commit-by: qq_64748107 Merged-by: cann-robot Description: # Pull Request ## 描述 ## 关联 Issue #892 ## 问题 example/2_advanced_features/callback/0_simple_callback/callback_sample.cpp 中 aclrtLaunchCallback 与 aclrtLaunchHostFunc 在同一个 Stream 上混用,违反文档约束: 「对于同一个 Stream,两套实现异步场景下的 callback 功能的接口不能混用,否则可能出现异常」 ## 修复方案 统一使用 aclrtLaunchHostFunc 接口,移除 aclrtLaunchCallback 系列接口 (SubscribeReport/ProcessReport/UnSubscribeReport)和自建后台线程。 aclrtLaunchHostFunc 内部自动创建并管理回调线程,代码大幅简化。 ## 改动文件 callback_sample.h:删除 ThreadFunc、HostFuncThreadFunc、HostFunc 声明,移除冗余的 #include <thread> 和 #include <string> callback_sample.cpp:删除自建线程和第一套接口,统一用 aclrtLaunchHostFunc;删除 GetThreadId 调用和线程 ID 日志;简化 Callback() 为 before→kernel→after 三个任务 CMakeLists.txt:移除未使用的 ../callback_utils.cpp 编译项 README.md / README_en.md:更新描述、API 列表、示例输出 ## 验证 - 编译运行通过,回调执行顺序正确 - 相关 UT(8个)全部通过 ## 变更类型 请选择本次引入的变更类型: <!-- [x] 表示选中 --> - [x] 🐛 Bug 修复 - [ ] ✨ 新功能 - [ ] 💄 代码风格更新(格式化,局部变量) - [ ] ♻️ 重构(既不修复错误也不增加功能的代码变动) - [ ] 📦 构建过程或辅助工具的变动 - [ ] 📝 文档内容更新 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在当前页面的右侧'关联Issue'部分添加相应Issue链接,并勾选'合并后关闭已关联的 Issue'选项。 --> ## 如何测试 描述测试此变更的步骤和前提条件: 1. 2. ## 核对清单 <!-- [x] 表示选中 --> - [x] 我的代码遵循了项目的代码风格 - [x] 我已对代码进行了自测 - [x] 我已更新了相关的文档 - [x] 我在标题中使用了合适的类型标签(如: feat:, fix:) - [x] 我已经详细阅读了贡献指南(CONTRIBUTING.md),并遵守了其中的所有规定,包括但不限于commit message的格式、无效commit的合并等 ## 其他信息 在此添加任何其他关于本次 PR 的说明。 See merge request: cann/runtime!4605 | 2 months ago | |
【fix】:统一使用 aclrtLaunchHostFunc,移除混用接口 Co-authored-by: qq_64748107<2592856994@qq.com> # message auto-generated for no-merge-commit merge: !4605 merge fix/callback-hostfunc-only-892 into master 【fix】:统一使用 aclrtLaunchHostFunc,移除混用接口 Created-by: qq_64748107 Commit-by: qq_64748107 Merged-by: cann-robot Description: # Pull Request ## 描述 ## 关联 Issue #892 ## 问题 example/2_advanced_features/callback/0_simple_callback/callback_sample.cpp 中 aclrtLaunchCallback 与 aclrtLaunchHostFunc 在同一个 Stream 上混用,违反文档约束: 「对于同一个 Stream,两套实现异步场景下的 callback 功能的接口不能混用,否则可能出现异常」 ## 修复方案 统一使用 aclrtLaunchHostFunc 接口,移除 aclrtLaunchCallback 系列接口 (SubscribeReport/ProcessReport/UnSubscribeReport)和自建后台线程。 aclrtLaunchHostFunc 内部自动创建并管理回调线程,代码大幅简化。 ## 改动文件 callback_sample.h:删除 ThreadFunc、HostFuncThreadFunc、HostFunc 声明,移除冗余的 #include <thread> 和 #include <string> callback_sample.cpp:删除自建线程和第一套接口,统一用 aclrtLaunchHostFunc;删除 GetThreadId 调用和线程 ID 日志;简化 Callback() 为 before→kernel→after 三个任务 CMakeLists.txt:移除未使用的 ../callback_utils.cpp 编译项 README.md / README_en.md:更新描述、API 列表、示例输出 ## 验证 - 编译运行通过,回调执行顺序正确 - 相关 UT(8个)全部通过 ## 变更类型 请选择本次引入的变更类型: <!-- [x] 表示选中 --> - [x] 🐛 Bug 修复 - [ ] ✨ 新功能 - [ ] 💄 代码风格更新(格式化,局部变量) - [ ] ♻️ 重构(既不修复错误也不增加功能的代码变动) - [ ] 📦 构建过程或辅助工具的变动 - [ ] 📝 文档内容更新 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在当前页面的右侧'关联Issue'部分添加相应Issue链接,并勾选'合并后关闭已关联的 Issue'选项。 --> ## 如何测试 描述测试此变更的步骤和前提条件: 1. 2. ## 核对清单 <!-- [x] 表示选中 --> - [x] 我的代码遵循了项目的代码风格 - [x] 我已对代码进行了自测 - [x] 我已更新了相关的文档 - [x] 我在标题中使用了合适的类型标签(如: feat:, fix:) - [x] 我已经详细阅读了贡献指南(CONTRIBUTING.md),并遵守了其中的所有规定,包括但不限于commit message的格式、无效commit的合并等 ## 其他信息 在此添加任何其他关于本次 PR 的说明。 See merge request: cann/runtime!4605 | 2 months ago | |
【fix】:统一使用 aclrtLaunchHostFunc,移除混用接口 Co-authored-by: qq_64748107<2592856994@qq.com> # message auto-generated for no-merge-commit merge: !4605 merge fix/callback-hostfunc-only-892 into master 【fix】:统一使用 aclrtLaunchHostFunc,移除混用接口 Created-by: qq_64748107 Commit-by: qq_64748107 Merged-by: cann-robot Description: # Pull Request ## 描述 ## 关联 Issue #892 ## 问题 example/2_advanced_features/callback/0_simple_callback/callback_sample.cpp 中 aclrtLaunchCallback 与 aclrtLaunchHostFunc 在同一个 Stream 上混用,违反文档约束: 「对于同一个 Stream,两套实现异步场景下的 callback 功能的接口不能混用,否则可能出现异常」 ## 修复方案 统一使用 aclrtLaunchHostFunc 接口,移除 aclrtLaunchCallback 系列接口 (SubscribeReport/ProcessReport/UnSubscribeReport)和自建后台线程。 aclrtLaunchHostFunc 内部自动创建并管理回调线程,代码大幅简化。 ## 改动文件 callback_sample.h:删除 ThreadFunc、HostFuncThreadFunc、HostFunc 声明,移除冗余的 #include <thread> 和 #include <string> callback_sample.cpp:删除自建线程和第一套接口,统一用 aclrtLaunchHostFunc;删除 GetThreadId 调用和线程 ID 日志;简化 Callback() 为 before→kernel→after 三个任务 CMakeLists.txt:移除未使用的 ../callback_utils.cpp 编译项 README.md / README_en.md:更新描述、API 列表、示例输出 ## 验证 - 编译运行通过,回调执行顺序正确 - 相关 UT(8个)全部通过 ## 变更类型 请选择本次引入的变更类型: <!-- [x] 表示选中 --> - [x] 🐛 Bug 修复 - [ ] ✨ 新功能 - [ ] 💄 代码风格更新(格式化,局部变量) - [ ] ♻️ 重构(既不修复错误也不增加功能的代码变动) - [ ] 📦 构建过程或辅助工具的变动 - [ ] 📝 文档内容更新 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在当前页面的右侧'关联Issue'部分添加相应Issue链接,并勾选'合并后关闭已关联的 Issue'选项。 --> ## 如何测试 描述测试此变更的步骤和前提条件: 1. 2. ## 核对清单 <!-- [x] 表示选中 --> - [x] 我的代码遵循了项目的代码风格 - [x] 我已对代码进行了自测 - [x] 我已更新了相关的文档 - [x] 我在标题中使用了合适的类型标签(如: feat:, fix:) - [x] 我已经详细阅读了贡献指南(CONTRIBUTING.md),并遵守了其中的所有规定,包括但不限于commit message的格式、无效commit的合并等 ## 其他信息 在此添加任何其他关于本次 PR 的说明。 See merge request: cann/runtime!4605 | 2 months ago | |
优化example目录结构易用性及补充用例 Co-authored-by: qiang_zq<qiang.zhangqiang@huawei.com> # message auto-generated for no-merge-commit merge: !1163 merge sample into master 优化example目录结构易用性及补充用例 Created-by: qiang_zq Commit-by: qiang_zq Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> 1、example 目录结构优化,按学习阶段重新组织目录结构(0_quickstart ~ 6_scenarios) 2、补充部分API的example用例 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #000--> https://gitcode.com/cann/runtime/issues/284 ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> 部分用例执行过程 source /home/developer/Ascend/cann/set_env.sh && export SOC_VERSION=ascend910b3 && export ASCENDC_CMAKE_DIR=/home/developer/Ascend/cann/aarch64-linux/tikcpp/ascendc_kernel_cmake && export ASCEND_INSTALL_PATH=/home/developer/Ascend/cann && cd /mnt/workspace/gitCode/qiang_zq/runtime/example/3_memory_advanced/allocator/0_custom_allocator && rm -rf build && dos2unix run.sh 2>/dev/null || sed -i 's/\\r$//' run.sh && bash run.sh 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/3_memory_advanced/allocator/0_custom_allocator/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/3_memory_advanced/allocator/0_custom_allocator/build/main Run the sample: ./build/main ./build/main [INFO] CustomAlloc size=256 [INFO] CustomAllocAdvise size=128 [INFO] CustomAlloc size=128 [INFO] CustomFree invoked [INFO] CustomFree invoked [INFO] Allocator desc queried: descOut=0xaaaabd6a3780 allocCount=2 freeCount=2 用例执行报告 0_quickstart (3/3) ✅ ✅ 0_hello_cann ✅ 1_error_handling ✅ 2_system_info 1_basic_features (23/23) ✅ ✅ device/0_device_normal ✅ device/1_device_multi_thread ✅ device/2_device_P2P ✅ event/0_event_status ✅ event/1_event_timestamp ✅ memory/0_h2h_memory_copy ✅ memory/10_ipc_memory_withpid ✅ memory/11_ipc_memory_withoutpid ✅ memory/1_h2d_sync_memory_copy ✅ memory/2_h2d_async_memory_copy ✅ memory/3_d2h_sync_memory_copy ✅ memory/4_d2h_async_memory_copy ✅ memory/5_d2d_sync_memory_copy ✅ memory/6_d2d_async_memory_copy ✅ memory/7_physical_memory_sharing_withpid ✅ memory/8_physical_memory_sharing_withoutpid ✅ memory/9_multistream_sync_memory ✅ stream/0_simple_stream ✅ stream/1_stream_with_failure_mode ✅ stream/2_multi_stream 2_advanced_features (17/17) ✅ ✅ built_in_task/0_reduce_task ✅ built_in_task/1_random_num_task ✅ callback/0_simple_callback ✅ callback/1_callback_hostfunc ✅ callback/2_callback_exception ✅ group/0_compute_group ✅ kernel/0_launch_kernel ✅ kernel/1_launch_kernel_with_reslimit ✅ label/0_simple_label ✅ model_ri/0_simple_model ✅ model_ri/1_model_update ✅ model_ri/2_model_switch ✅ notify/0_ipc_notify_withpid ✅ notify/1_ipc_notify_withoutpid ✅ notify/2_cntnotify ✅ tdt_buffer/0_shared_buffer ✅ tdt_channel/0_simple_channel ✅ tdt_channel/1_channel_capacity ✅ tdt_queue/0_simple_queue ✅ tdt_queue/1_queue_route ✅ tdt_queue/2_queue_grant_attach 3_memory_advanced (1/1) ✅ ✅ allocator/0_custom_allocator 4_reliability (2/2) ✅ ✅ overflow_detection/0_overflow_detection ✅ snapshot/0_snapshot_management 5_performance (6/6) ✅ ✅ adump/0_adump_args ✅ adump/1_adump_callback ✅ adump/2_model_dump_config ✅ profiling/0_create_config ✅ profiling/1_msproftx ✅ profiling/2_subscribe_model ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> docs/02_dev_guide/初始化.md example/*.md ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: See merge request: cann/runtime!1163 | 7 months ago | |
fix(example): 保留回调和模型样例的执行退出码 Co-authored-by: 梁晋轩<19303092837@163.com> # message auto-generated for no-merge-commit merge: !6389 merge fix-ci-nov18-sample-exit into master fix(example): 保留回调和模型样例的执行退出码 Created-by: liangjinxuan-2026 Commit-by: 梁晋轩 Merged-by: cann-robot Description: # Pull Request ## 描述 回调与模型执行样例通过 tee 写日志。启用 pipefail 后,样例程序返回非零时启动脚本也会失败。 - example/2_advanced_features/callback/0_simple_callback/run.sh - example/2_advanced_features/callback/1_callback_hostfunc/run.sh - example/2_advanced_features/callback/2_callback_exception/run.sh - example/2_advanced_features/model_ri/0_simple_model/run.sh - example/2_advanced_features/model_ri/1_model_update/run.sh - example/2_advanced_features/model_ri/2_model_switch/run.sh - example/2_advanced_features/model_ri/3_cond_model/run.sh ## 变更类型 - [x] 🐛 Bug 修复 - [x] 📦 构建过程或辅助工具的变动 ## 关联的Issue Fixes #1399 ## 如何测试 Git Bash 临时目录中运行七个样例的实际执行段。替身程序分别返回 0 和 23,核对脚本状态。未运行 CANN 构建或设备计算。 Baseline: 353ab6f4bea1b3e988aee37c6be7500cbd69d0c3. - sample failure (7 script(s)): exit 0 → 23. Output: sample. - sample success (7 script(s)): exit 0 → 0. Output: sample. bash -n and git diff --check passed. ## 核对清单 - [x] 已做隔离自测 ## 其他信息 AI 辅助定位、修改与隔离验证。 See merge request: cann/runtime!6389 | 9 days ago |
0_simple_callback
Description
This sample demonstrates how to launch Host callback tasks on a Stream using aclrtLaunchHostFunc, inserting CPU callback functions before and after NPU tasks. This interface internally creates and manages the callback thread, without requiring users to create threads or register manually.
Product Support
Key interfaces in this sample have the following support status on different products:
| Interface | Ascend 950PR/Ascend 950DT | Atlas A3 training series products/Atlas A3 inference series products | Atlas A2 training series products/Atlas A2 inference series products |
|---|---|---|---|
| aclrtLaunchHostFunc | Yes | Yes | Yes |
Build and Run
For environment installation details and running details, see README in the example directory.
Run steps:
# Replace ${install_root} with CANN installation root directory, default installation at /usr/local/Ascend
source ${install_root}/cann/set_env.sh
# Automatically identify SOC_VERSION and ASCENDC_CMAKE_DIR.
source ${git_clone_path}/example/set_sample_env.sh
# Build and run
bash run.sh
CANN RUNTIME API
Key features and interfaces in this sample:
- Initialization and Resource Management
aclInit/aclFinalizeaclrtSetDevice/aclrtResetDeviceForceaclrtCreateContext/aclrtDestroyContextaclrtCreateStream/aclrtDestroyStreamForceaclrtSetStreamFailureMode
- Host Callback
aclrtLaunchHostFunc
- Memory and Data Transfer
aclrtMalloc/aclrtFreeaclrtMemcpyaclrtSynchronizeStream
Sample Output
[INFO] This callback before task, result: user data is: 520.
[INFO] After begin a task, launch one hostfunc.
[INFO] This callback after task, result: user data is: 520.
[INFO] After assigning the task, the current int is: ...
Known Issues
None.