已关闭
[Bug-Report|缺陷反馈]: Ascend 950PR(arch35)下 build.sh --soc=ascend950 构建失败:test/spmm 源文件路径错误、spgemm_common.h 头文件无法找到、spgemm_kernel 缺少 kernel 类型属性 #169
moonlife创建于  8月24日关闭于  8月26日
moonlife
8月24日 创建

Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.

Describe the current behavior / 问题描述 (Mandatory / 必填)

在 Ascend 950PR(arch35 / DAV-3510)上执行 bash build.sh --soc=ascend950 --ops=spmm,构建在配置/编译阶段连续报三类错误,无法产出 libops_sparse.so 与测试二进制(按出现顺序):

① test/spmm 测试源文件路径错误(CMake Configure 阶段)

CMake Error at test/spmm/CMakeLists.txt:15 (add_executable):
  Cannot find source file:

    spmm_test.cpp

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h
  .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc

② spgemm_common.h 头文件找不到(编译阶段)

/workspace/ops-sparse/sparse/spgemm/arch35/spgemm.h:21:10: fatal error: 'spgemm_common.h' file not found
#include "spgemm_common.h"
         ^~~~~~~~~~~~~~~~~

③ spgemm_kernel 缺少 kernel 类型属性(链接/编译阶段)

ld.lld: error: Error: the type of kernel function spgemm_kernel auto derivate failed, please manually add the function type attribute
ld.lld: error: Error: the type of kernel function spgemm_kernel auto derivate failed, please manually add the function type attribute
bisheng: error: ld.lld command failed with exit code 1

Environment / 环境信息 (Mandatory / 必填)

  • 昇腾硬件型号:Ascend 950PR(arch35 / DAV-3510)
  • 主机架构:x86_64(Linux 容器)
  • CANN 版本:CANN 9.1.0(/usr/local/Ascend/cann-9.1.0;编译器 bisheng,基于 clang 15.0.5;链接器 ld.lld)
  • Python:3.12.13
  • 构建方式:bash build.sh --soc=ascend950 --ops=spmm
  • 代码基线:上游 master(commit ae60d05)基础上 fork 的开发分支 moonlife/spgemm

Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)

  1. 克隆仓库并检出基线(上游 master 或 ae60d05);
  2. 加载 CANN 环境变量(source <CANN>/set_env.sh 等);
  3. 在仓库根目录执行:
    bash build.sh --soc=ascend950 --ops=spmm
    
  4. 观察错误按如下顺序依次出现:
    • 先:CMake Configure 阶段报 错误 ①(test/spmm 找不到 spmm_test.cpp);
    • 修复 ① 后:编译阶段报 错误 ②(spgemm_common.h not found);
    • 修复 ② 后:链接阶段报 错误 ③(spgemm_kernel 类型推导失败)。

Describe the expected behavior / 预期结果 (Mandatory / 必填)

  • bash build.sh --soc=ascend950 --ops=spmm 应无错误完成配置与构建,正常产出 libops_sparse.so、libops_sparseLt.so 以及 spmm_test 测试二进制;
  • 各 test/<op>/CMakeLists.txt 应按 SOC 分支正确引用对应 archXX/ 子目录下的测试源文件(与 arch22 分支写法一致);
  • 各算子 archXX/ 头文件引用的公共头(如 spgemm_common.h)应能正常解析,无需逐个算子向根 CMakeLists.txt 追加 include 目录;
  • 每个 __global__ kernel 入口应携带与 sparse/spmm/arch35 一致的 kernel 任务类型属性(KERNEL_TASK_TYPE_DEFAULT(...)),使工具链能正确推导 kernel 类型。

构建日志关键片段(SOC_VERSION=ascend950, NPU_ARCH=dav-3510, SOC_ARCH_DIRS=arch35):

错误 ①(test/spmm)

-- SOC_VERSION=ascend950, NPU_ARCH=dav-3510
--   -> SOC [ascend950] matched arch35 (DAV-3510)
-- SOC_ARCH_DIRS=arch35
...
CMake Error at test/spmm/CMakeLists.txt:15 (add_executable):
  Cannot find source file:

    spmm_test.cpp

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h
  .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc
CMake Error at test/spmm/CMakeLists.txt:15 (add_executable):
  No SOURCES given to target: spmm_test
CMake Generate step failed.  Build files cannot be regenerated correctly.

错误 ②(spgemm_common.h)

In file included from /workspace/ops-sparse/sparse/spgemm/arch35/spgemm_host.cpp:31:
/workspace/ops-sparse/sparse/spgemm/arch35/spgemm.h:21:10: fatal error: 'spgemm_common.h' file not found
#include "spgemm_common.h"
         ^~~~~~~~~~~~~~~~~
1 error generated.

错误 ③(spgemm_kernel 类型)

ld.lld: error: Error: the type of kernel function spgemm_kernel auto derivate failed, please manually add the function type attribute
ld.lld: error: Error: the type of kernel function spgemm_kernel auto derivate failed, please manually add the function type attribute
bisheng: error: ld.lld command failed with exit code 1
gmake[2]: *** [CMakeFiles/ops_sparse.dir/build.make:352: CMakeFiles/ops_sparse.dir/sparse/spgemm/arch35/spgemm_kernel.cpp.o] Error 1
gmake: *** [Makefile:136: all] Error 2

Special notes for this issue/备注 (Optional / 选填)

  1. 根因小结:

    • ① test/spmm/CMakeLists.txt 的 ascend950 分支漏写 arch35/ 前缀(spmm_test.cpp → 应为 arch35/spmm_test.cpp);arch22 分支写的是 arch22/spmm_test.cpp,正确。
    • ② sparse/spgemm/arch35/spgemm.h 以裸名 #include "spgemm_common.h",而该头位于 sparse/spgemm/;ops_sparse 库的 include 路径仅含 ./include、./sparse/common,不含 ./sparse/spgemm。
    • ③ sparse/spgemm/arch35/spgemm_kernel.cpp 的 __global__ 入口 spgemm_kernel 是 M1 骨架,缺少 Ascend C kernel 任务类型属性,bisheng/ld.lld 无法自动推导。
  2. 建议(已在本 fork 分支验证通过):

    • test/spmm/CMakeLists.txt:ascend950 分支源文件改为 arch35/spmm_test.cpp;
    • sparse/spgemm/arch35/spgemm.h:改用相对路径 #include "../spgemm_common.h"(按头文件自身目录解析,无需修改根 CMakeLists.txt,保持新增算子可扩展性);
    • sparse/spgemm/arch35/spgemm_kernel.cpp:入口体内补充 KERNEL_TASK_TYPE_DEFAULT(KERNEL_TYPE_AIV_ONLY);,与 sparse/spmm/arch35 既有 kernel 写法保持一致。
  3. 参考提交(fork 分支 moonlife/spgemm):

    • 91ce6e7 fix(test/spmm): ascend950 分支源文件改为 arch35/spmm_test.cpp
    • ca11768 fix(spgemm): 修复 arch35 编译(公共头相对 include + kernel 类型属性)
  4. 建议上游统一约定:各 test/<op>/CMakeLists.txt 的 arch 源文件引用方式、以及 archXX/ 引用公共头的方式建议统一,避免后续新增算子/芯片架构时重复出现同类问题。

likedislike
Mmoonlife
8月24日 issue类型由 任务 改变为 缺陷
HKFLYE
HKFLYE成员
8月25日 评论:

您好,感谢反馈,问题确认中。

likedislike
HKFLYE
HKFLYE成员
8月25日 评论:

@gcw_gYpnrvNC
问题①,当前master分支主线已修复,请在开发分支同步后再次尝试编译。
问题②和③,当前master分支不存在sparse/spGEMM目录,请确认是否为本地开发分支引入的问题。
若有开发分支上的咨询问题,请提交咨询pr并提供对应的个人分支链接或者源码。
本issue仅跟踪当前master分支上已有代码的工程问题。

likedislike
HKFLYEHKFLYE成员
8月25日 添加了label:wait-feedback
HKFLYEHKFLYE成员
8月25日 将 HuangKun8682 设为负责人
moonlife
8月25日 评论:

@HuangKun8682

抱歉,问题②和③是误反馈了。问题①我稍后验证。

likedislike
CANN-robotCANN-robot成员
8月25日 删除了label:wait-feedback
moonlife
8月25日 评论:

取最新代码后编译正常,问题①已经解决。

likedislike
HKFLYE
HKFLYE成员
8月26日 评论:

@gcw_gYpnrvNC
感谢反馈,当前issue问题已解决,此issue关闭。若后续还有相关的问题,可以重新开启issue,提供相关的环境和报错信息来提问。

likedislike
HKFLYEHKFLYE成员
8月26日 issue状态由 待办的 改变为 已解决
HKFLYEHKFLYE成员
8月26日 关闭了 issue