合并受阻
变更摘要
本 PR 为「代码侦探 Challenge05」的提交,目标是补全 MulCustom 逐元素乘法算子(z[i] = x[i] * y[i])。改动新增了 Kernel 侧的初始化、分块(Tiling)与双缓冲(Double Buffer)队列管理,按 CopyIn → Compute → CopyOut 流程完成 float32 逐元素乘法,并在 Host 侧补全了内存申请、数据搬运、Kernel 启动、流同步及精度校验逻辑,另附带一键构建脚本 run.sh;整个实现被严格限定在题目要求的 3 个文件内。
主要改动
- 算子核心流程实现:新增
KernelMul算子类,实现Init(按GetBlockNum()分块并初始化三个GlobalTensor与队列缓冲)、Process(循环驱动CopyIn→Compute→CopyOut),其中Compute通过AscendC::Mul完成z = x * y,数据流为 GM → UB → GM;__global__入口mul_custom接收MulCustomTilingData(totalLength、tileNum)并调度算子执行。 - 双缓冲与队列管理:通过
BUFFER_NUM = 2定义TPipe及输入队列inQueueX/inQueueY、输出队列outQueueZ,在CopyIn/CopyOut中使用AllocTensor、EnQue、DeQue、FreeTensor维护数据搬运与计算的重叠,提升流水效率。 - Host 侧驱动逻辑:在
kernel_mul中补全 Host 端流程——aclInit/aclrtSetDevice初始化、aclrtMalloc申请显存与aclrtMallocHost申请主机内存、aclrtMemcpy完成 H2D/D2H 搬运、以<<<blockDim, nullptr, stream>>>启动 Kernel、aclrtSynchronizeStream同步后统一释放资源并aclFinalize。 - 精度校验与测试入口:新增
VerifyResult,打印 Output/Golden 前若干元素并通过std::equal逐元素比对,输出[Success]/[Failed]判定结果;main以固定长度(8 * 2048)与常量1.2f、2.3f构造输入并生成期望的乘法 golden 值,返回校验结果作为进程退出码。 - 一键构建脚本:新增
run.sh,激活 CANN 环境(sourceset_env.sh),在build目录执行cmake、make构建出mul_test并运行可执行文件完成验证。


Hi @gang1022, welcome to submitting your first PR to cann-outreach!
PR Merge Steps
1. CLA Signing
If the current PR label includes cann-cla/yes, it means you have signed the CLA and can proceed to the next step. If the label includes cann-cla/no, please sign the CLA first. If you have any questions, please refer to the FAQ.
2. CI Check
Please comment /compile to trigger the CI pipeline check. If the CI run is successful, the PR will be tagged with ci-pipeline-passed and you can proceed to the next step. If the CI run fails, the PR will be tagged with ci-pipeline-failed, please check the CI logs to fix the issues in the PR. If you have any questions, please refer to the FAQ.
3. Code Review
After CI passes, please refer to the PR Approval Progress and proactively @ the committers in the table to review the code. After approval, committers will comment /lgtm and /approve. Once the lgtm and approved labels are successfully added, the PR will be merged automatically.


Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
⚠️ This PR does not yet meet the following requirements:lgtm (requires ≥ 2 person(s) per module)、approve (requires ≥ 1 person(s) per module)
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/cann-outreach | ❌ (0/2)(You can also ask: 田晓亮, li-shengxian3, yanhf, shaoyf, yanyawen) | ❌ (0/1)(You can also ask: shaoyf, 田晓亮, 傅涛, Carolina_yuan, jxlang) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
gang1022, thanks for your pull request. All authors of the commits have signed the CLA. 👍


CLA检查已通过,详情可参考这里


AI Declaration Check Failed
@gang1022, AI declaration is not compliant. AI tool: Codex
Please check:
- The AI tool and model declared in the PR description must be real.
- Commit messages must include the AI model, and it must be consistent with the PR description. ⚠️


当前PR是否有AI参与:
[ ] 否
[x] 是
实现概述
自验证