【纯小白提问】【编译问题】照着文档做add_custom.cpp不会编译,编译出来报错。不会用cmake, 想直接用命令编译。示例里面好几个cmake文件搞得有点头晕。运行示例的run.sh没错,我想自己编译,出错。求助。
收藏回复举报
【纯小白提问】【编译问题】照着文档做add_custom.cpp不会编译,编译出来报错。不会用cmake, 想直接用命令编译。示例里面好几个cmake文件搞得有点头晕。运行示例的run.sh没错,我想自己编译,出错。求助。
t('forum.solved') 已解决
发表于2024-01-31 10:39:43
0 查看

代码地址

https://gitee.com/ascend/samples/blob/master/operator/AddCustomSample/KernelLaunch/AddKernelInvocation/add_custom.cpp

jupyter notebook中运行如下代码

import os
ascend_toolkit_path = "/usr/local/Ascend/ascend-toolkit/latest"
include_path = ""
library_path = ""
device_type = "Ascend910ProA"
include_path += "-I" + ascend_toolkit_path + "/include " 
include_path += "-I" + ascend_toolkit_path + "/acllib/include " 
include_path += "-I" + ascend_toolkit_path + "/compiler/tikcpp " 
include_path += "-I" + ascend_toolkit_path + "/compiler/tikcpp/tikcfw " 
include_path += "-I" + ascend_toolkit_path + "/compiler/tikcpp/tikcfw/impl " 
include_path += "-I" + ascend_toolkit_path + "/compiler/tikcpp/tikcfw/interface " 
include_path += "-I" + ascend_toolkit_path + "/tools/tikicpulib/lib/include " 
library_path += "-L" + ascend_toolkit_path + "/runtime/lib64 "
link_library = "-lruntime -lascendcl"
# ! echo {include_path}
! ccec -Wall -std=c++17 -fPIC --cce-fatobj-link --cce-aicore-arch=dav-c100 {include_path} {library_path} {link_library} add_custom.cpp

报错结果:

In file included from add_custom.cpp:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/kernel_operator.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tpipe.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tensor.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_utils.h:19:
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_event.h:86:1: error: a type specifier is required for all declarations
__aicore__ constexpr Hardware GetPhyType(TPosition pos)
^
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_macros.h:20:20: note: expanded from macro '__aicore__'
#define __aicore__ [aicore]
                   ^
In file included from add_custom.cpp:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/kernel_operator.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tpipe.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tensor.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_utils.h:19:
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_event.h:86:1: error: decomposition declaration cannot be declared with type 'int'; declared type must be 'auto' or reference to 'auto'
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_macros.h:20:20: note: expanded from macro '__aicore__'
#define __aicore__ [aicore]
                   ^
In file included from add_custom.cpp:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/kernel_operator.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tpipe.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tensor.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_utils.h:19:
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_event.h:86:1: error: decomposition declaration '[aicore]' requires an initializer
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_macros.h:20:20: note: expanded from macro '__aicore__'
#define __aicore__ [aicore]
                   ^
In file included from add_custom.cpp:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/kernel_operator.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tpipe.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tensor.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_utils.h:19:
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_event.h:86:11: error: expected ';' after top level declarator
__aicore__ constexpr Hardware GetPhyType(TPosition pos)
          ^
          ;
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_event.h:125:1: error: a type specifier is required for all declarations
__aicore__ constexpr TPosition GetPosition(TPosition srcPos, TPosition dstPos)
^
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_macros.h:20:20: note: expanded from macro '__aicore__'
#define __aicore__ [aicore]
                   ^
In file included from add_custom.cpp:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/kernel_operator.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tpipe.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tensor.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_utils.h:19:
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_event.h:125:1: error: decomposition declaration cannot be declared with type 'int'; declared type must be 'auto' or reference to 'auto'
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_macros.h:20:20: note: expanded from macro '__aicore__'
#define __aicore__ [aicore]
                   ^
In file included from add_custom.cpp:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/kernel_operator.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tpipe.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tensor.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_utils.h:19:
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_event.h:125:1: error: redefinition of 'aicore'
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_macros.h:20:21: note: expanded from macro '__aicore__'
#define __aicore__ [aicore]
                    ^
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_event.h:86:1: note: previous definition is here
__aicore__ constexpr Hardware GetPhyType(TPosition pos)
^
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_macros.h:20:21: note: expanded from macro '__aicore__'
#define __aicore__ [aicore]
                    ^
In file included from add_custom.cpp:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/kernel_operator.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tpipe.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tensor.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_utils.h:19:
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_event.h:125:1: error: decomposition declaration '[aicore]' requires an initializer
__aicore__ constexpr TPosition GetPosition(TPosition srcPos, TPosition dstPos)
^
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_macros.h:20:20: note: expanded from macro '__aicore__'
#define __aicore__ [aicore]
                   ^
In file included from add_custom.cpp:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/kernel_operator.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tpipe.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tensor.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_utils.h:19:
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_event.h:125:11: error: expected ';' after top level declarator
__aicore__ constexpr TPosition GetPosition(TPosition srcPos, TPosition dstPos)
          ^
          ;
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_event.h:142:1: error: a type specifier is required for all declarations
__aicore__ constexpr Hardware GetBufferPos(TPosition srcPos, TPosition dstPos)
^
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_macros.h:20:20: note: expanded from macro '__aicore__'
#define __aicore__ [aicore]
                   ^
In file included from add_custom.cpp:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/kernel_operator.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tpipe.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tensor.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_utils.h:19:
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_event.h:142:1: error: decomposition declaration cannot be declared with type 'int'; declared type must be 'auto' or reference to 'auto'
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_macros.h:20:20: note: expanded from macro '__aicore__'
#define __aicore__ [aicore]
                   ^
In file included from add_custom.cpp:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/kernel_operator.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tpipe.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tensor.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_utils.h:19:
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_event.h:142:1: error: redefinition of 'aicore'
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_macros.h:20:21: note: expanded from macro '__aicore__'
#define __aicore__ [aicore]
                    ^
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_event.h:86:1: note: previous definition is here
__aicore__ constexpr Hardware GetPhyType(TPosition pos)
^
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_macros.h:20:21: note: expanded from macro '__aicore__'
#define __aicore__ [aicore]
                    ^
In file included from add_custom.cpp:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/kernel_operator.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tpipe.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tensor.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_utils.h:19:
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_event.h:142:1: error: decomposition declaration '[aicore]' requires an initializer
__aicore__ constexpr Hardware GetBufferPos(TPosition srcPos, TPosition dstPos)
^
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_macros.h:20:20: note: expanded from macro '__aicore__'
#define __aicore__ [aicore]
                   ^
In file included from add_custom.cpp:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/kernel_operator.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tpipe.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tensor.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_utils.h:19:
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_event.h:142:11: error: expected ';' after top level declarator
__aicore__ constexpr Hardware GetBufferPos(TPosition srcPos, TPosition dstPos)
          ^
          ;
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_event.h:159:1: error: a type specifier is required for all declarations
__aicore__ constexpr TPosition GetBufferLogicPos(TPosition pos, bool isSrc)
^
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_macros.h:20:20: note: expanded from macro '__aicore__'
#define __aicore__ [aicore]
                   ^
In file included from add_custom.cpp:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/kernel_operator.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tpipe.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tensor.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_utils.h:19:
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_event.h:159:1: error: decomposition declaration cannot be declared with type 'int'; declared type must be 'auto' or reference to 'auto'
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_macros.h:20:20: note: expanded from macro '__aicore__'
#define __aicore__ [aicore]
                   ^
In file included from add_custom.cpp:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/kernel_operator.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tpipe.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tensor.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_utils.h:19:
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_event.h:159:1: error: redefinition of 'aicore'
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_macros.h:20:21: note: expanded from macro '__aicore__'
#define __aicore__ [aicore]
                    ^
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_event.h:125:1: note: previous definition is here
__aicore__ constexpr TPosition GetPosition(TPosition srcPos, TPosition dstPos)
^
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_macros.h:20:21: note: expanded from macro '__aicore__'
#define __aicore__ [aicore]
                    ^
In file included from add_custom.cpp:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/kernel_operator.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tpipe.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tensor.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_utils.h:19:
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_event.h:159:1: error: decomposition declaration '[aicore]' requires an initializer
__aicore__ constexpr TPosition GetBufferLogicPos(TPosition pos, bool isSrc)
^
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_macros.h:20:20: note: expanded from macro '__aicore__'
#define __aicore__ [aicore]
                   ^
In file included from add_custom.cpp:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/kernel_operator.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tpipe.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/interface/kernel_tensor.h:7:
In file included from /usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_utils.h:19:
/usr/local/Ascend/ascend-toolkit/latest/compiler/tikcpp/tikcfw/impl/kernel_event.h:159:11: error: expected ';' after top level declarator
__aicore__ constexpr TPosition GetBufferLogicPos(TPosition pos, bool isSrc)
          ^
          ;
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

我要发帖子