| Files | Last commit | Last update |
|---|---|---|
【PR】: 新增 Context 作用域确定性配置样例 Co-authored-by: 2403_89963296<2540257541@qq.com> # message auto-generated for no-merge-commit merge: !5024 merge example/1_basic_features/context/1_context_scoped_determinism into master 【PR】: 新增 Context 作用域确定性配置样例 Created-by: 2403_89963296 Commit-by: 2403_89963296 Merged-by: cann-robot Description: # Pull Request ## 描述 新增 example/1_basic_features/context/1_context_scoped_determinism 单 Device 样例。 样例观察 aclrtSetDevice 前后默认 Context 的激活状态,保存并恢复进程级确定性配置,并为两个显式 Context 分别设置不同的确定性计算模式。通过切换 Context 后重新读取配置,验证 Context 级参数相互隔离。 同时新增中英文使用文档、CMake 构建配置和运行脚本,并更新 Context 样例导航。 ## 变更类型 - [ ] 🐛 Bug 修复 - [x] ✨ 新功能 - [ ] 💄 代码风格更新(格式化,局部变量) - [ ] ♻️ 重构(既不修复错误也不增加功能的代码变动) - [ ] 📦 构建过程或辅助工具的变动 - [x] 📝 文档内容更新 ## 如何测试 1. 加载 CANN 环境并进入样例目录。 2. 执行 bash run.sh。 3. 确认默认 Context 状态按预期变化。 4. 确认 Context A、Context B 的配置分别保持为 1 和 0。 5. 确认进程级配置已恢复,并输出样例执行成功标记。 测试结果: - CMake 配置及编译通过。 - Ascend 环境实机运行通过。 - clang-format 和 OAT pre-commit 检查通过。 - git diff --check 与 bash -n 检查通过。 ## 核对清单 - [x] 我的代码遵循了项目的代码风格 - [x] 我已对代码进行了自测 - [x] 我已更新了相关的文档 - [x] 我在标题中使用了合适的类型标签 - [x] 我已经详细阅读了贡献指南,并遵守其中的规定 ## 其他信息 配置读回用于验证 Context 作用域隔离和配置生效,不表示任意算子在对应配置下都具备确定性。 See merge request: cann/runtime!5024 | 2 months ago | |
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: 迁移 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: Synchronize memory example handoffs Co-authored-by: aodebiao<18003961989@163.com> # message auto-generated for no-merge-commit merge: !5987 merge fix/synchronize-memory-example-reads-20261030 into master fix: Synchronize memory example handoffs Created-by: gxhgxh2475698 Commit-by: aodebiao Merged-by: cann-robot Description: # Pull Request ## Description Synchronize asynchronous device reads and writes before handing off or releasing memory in five examples. ## Motivation The memory-copy examples enqueue a read and immediately force-destroy the stream, which does not wait for pending tasks. In the IPC examples, the producer publishes the memory identifier before its write completes and the consumer sends the completion flag before its read completes. File handoffs do not synchronize device streams. The consumer also signals before closing its import, although the API requires importers to close before the exporter. ## Changes - Check aclrtSynchronizeStream after the read in three memory-copy examples. - Wait for the producer write before publishing the identifier, and for the consumer read before closing its import and sending the completion flag in both IPC examples. ## Change Type - [x] Bug Fix - [ ] New Feature - [ ] Code Style Update - [ ] Refactoring - [ ] Build Process or Auxiliary Tool Changes - [ ] Documentation Content Update ## Associated Issues Fixes #1290 ## How to Test - Checked source order before and after in all seven files against the kernel helpers and documented force-destroy and IPC close ordering. - git diff --check passed. CANN/NPU execution and compilation were not available. ## Checklist - [x] My code follows the project's code style - [x] I have self-tested the code - [ ] I have updated related documentation - [x] I used appropriate type labels in the title - [x] I have read the Contributing Guide and followed its regulations ## Additional Information The change is limited to examples; no Runtime implementation is changed. See merge request: cann/runtime!5987 | 22 days ago | |
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 | |
优化example示例中 产品支持情况 描述 Co-authored-by: qiang_zq<qiang.zhangqiang@huawei.com> # message auto-generated for no-merge-commit merge: !1276 merge sample into master 优化example示例中 产品支持情况 描述 Created-by: qiang_zq Commit-by: qiang_zq Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> 1、补充部分新增example示例 readme 缺少的“产品支持情况”描述 2、历史example示例 readme 中“产品支持情况”与docs中API描述不一致 3、优化example样例执行步骤,run.sh中编译完成后自动执行,将原来编译+运行 2步操作 合为一步 4、目录 README 补全: 为 device、stream、event、memory、kernel、callback、model_ri、notify、tdt_buffer、tdt_channel、tdt_queue、built_in_task 等目录新增了 README.md,改善了导航体验 5、链接路径修正: 修正了嵌套目录的相对路径(从 ../../README.md 改为 ../../../README.md) 代码审查报告 https://gitcode.com/cann/runtime/pull/1276?ref=&did=65e24693459e9d96f1d4ad02bef022d0968fba55#tid-166839878 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #000--> https://gitcode.com/cann/runtime/issues/299 ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> /example/0_quickstart/0_hello_cann$ 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/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 = 0x12c0c0016000 Get workspace size successfully, workspace size = 0 [Warning]: tiling struct [ReduceOpTilingDataV2] is conflict with one in file kl_div_v2.cc, line 41 [Warning]: tiling struct [RepeatInterleaveGradTilingData] is conflict with one in file repeat_interleave_grad_tiling.h, line 21 [Warning]: tiling struct [IndexFillTilingData] is conflict with one in file index_fill_tiling.h, line 21 [Warning]: tiling struct [MapIndexTilingData] is conflict with one in file map_index_tiling_arch35.h, line 23 [Warning]: tiling struct [MaskedSelectV3TilingData] is conflict with one in file masked_select_v3_tiling.h, line 27 [Warning]: tiling struct [MaskedSelectV3TilingData] is conflict with one in file masked_select_v3_tiling.h, line 27 [Warning]: tiling struct [ScatterPaKvCacheTilingData] is conflict with one in file scatter_pa_kv_cache_tiling.h, line 35 [Warning]: tiling struct [ScatterPaKvCacheTilingData] is conflict with one in file scatter_pa_kv_cache_tiling.h, line 35 [Warning]: tiling struct [TopKTopPSampleTilingData] is conflict with one in file top_k_top_p_sample_tiling.h, line 26 [Warning]: tiling struct [AvgPool3dGradTilingBlockParam] is conflict with one in file avg_pool_3d_grad_tiling.h, line 99 [Warning]: tiling struct [AvgPool3dGradTilingParam] is conflict with one in file avg_pool_3d_grad_tiling.h, line 125 [Warning]: tiling struct [FusedCrossEntropyLossWithMaxSumTilingData] is conflict with one in file fused_cross_entropy_loss_with_max_sum_tiling.h, line 27 [Warning]: tiling struct [TilingDataBackgroundReplace] is conflict with one in file background_replace_tiling.h, line 22 [Warning]: tiling struct [TilingDataBlendImages] is conflict with one in file blend_images_custom_tiling.h, line 24 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! /example/0_quickstart/1_error_handling$ 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/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: 2238268] 2026-03-30-14:54:54.405.703 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 ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> example/0_quickstart/1_error_handling/README.md example/1_basic_features/device/0_device_normal/README.md .... example/*/README.md ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: See merge request: cann/runtime!1276 | 7 months ago | |
【PR】: Add English md files Co-authored-by: ycm0028<yechengmei@huawei.com> Co-authored-by: gitcode-bot<noreply@gitcode.com> # message auto-generated for no-merge-commit merge: !2990 merge master into master 【PR】: Add English md files Created-by: ycm0028 Commit-by: ycm0028;gitcode-bot Merged-by: cann-robot Description: # Pull Request ## 描述 Add English md files ## 变更类型 请选择本次引入的变更类型: <!-- [x] 表示选中 --> - [ ] 🐛 Bug 修复 - [ ] ✨ 新功能 - [ ] 💄 代码风格更新(格式化,局部变量) - [ ] ♻️ 重构(既不修复错误也不增加功能的代码变动) - [ ] 📦 构建过程或辅助工具的变动 - [.x] 📝 文档内容更新 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在当前页面的右侧'关联Issue'部分添加相应Issue链接,并勾选'合并后关闭已关联的 Issue'选项。 --> ## 如何测试 The English md files have been checked. ## 核对清单 <!-- [x] 表示选中 --> - [ ] 我的代码遵循了项目的代码风格 - [ ] 我已对代码进行了自测 - [ x] 我已更新了相关的文档 - [ ] 我在标题中使用了合适的类型标签(如: feat:, fix:) - [ ] 我已经详细阅读了贡献指南(CONTRIBUTING.md),并遵守了其中的所有规定,包括但不限于commit message的格式、无效commit的合并等 ## 其他信息 在此添加任何其他关于本次 PR 的说明。 See merge request: cann/runtime!2990 | 5 months ago |
1_basic_features
This chapter focuses on Runtime basic programming capabilities, suitable for continuing to learn core usage of Device, Context, Stream, Event, and Memory after completing quick start.
Sample List
- device: Device initialization, switching, multi-thread, and multi-Device data interaction.
- stream: Default stream, normal stream, multi-stream synchronization, failure mode control.
- event: Event status, timestamp, and synchronization behavior.
- memory: Host/Device data copy, shared memory, IPC, and multi-stream memory synchronization.
Related Topics
- context: Context lifecycle, switching, and reuse.