hcc icon indicating copy to clipboard operation
hcc copied to clipboard

It is not possible to copy struct containing array member into kernel lambda [crash]

Open misos1 opened this issue 7 years ago • 5 comments

#include <hc.hpp>

int main()
{
	struct Test
	{
		int arr[10];
	};
	Test test;
	hc::array_view<int> result(1);
	parallel_for_each(hc::extent<1>(1), [=](hc::index<1> i) [[hc]]
	{
		result[0] = test.arr[0];
	});
	return 0;
}

This prints compile errors and causes compiler to crash:

miso@miso:~/test$ hcc main.cpp `hcc-config --cxxflags` -std=c++17 -Ofast
main.cpp:11:38: error: no matching constructor for initialization of 'Test'
        parallel_for_each(hc::extent<1>(1), [=](hc::index<1> i) [[hc]]
                                            ^
/opt/rocm/bin/../hcc/include/hc.hpp:7634:36: note: in instantiation of function template specialization 'Kalmar::mcw_cxxamp_launch_kernel_async<(lambda at main.cpp:11:38), 1>' requested
      here
  return completion_future(Kalmar::mcw_cxxamp_launch_kernel_async<Kernel, 1>(av.pQueue, &ext, NULL, f));
                                   ^
/opt/rocm/bin/../hcc/include/hc.hpp:7511:12: note: in instantiation of function template specialization 'hc::parallel_for_each<(lambda at main.cpp:11:38)>' requested here
    return parallel_for_each(accelerator::get_auto_selection_view(), compute_domain, f);
           ^
main.cpp:11:2: note: in instantiation of function template specialization 'hc::parallel_for_each<1, (lambda at main.cpp:11:38)>' requested here
        parallel_for_each(hc::extent<1>(1), [=](hc::index<1> i) [[hc]]
        ^
main.cpp:5:9: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int [10]' to 'const Test' for 1st argument
        struct Test
               ^
main.cpp:5:9: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'int [10]' to 'Test' for 1st argument
        struct Test
               ^
main.cpp:5:9: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int [10]' to 'int [10]' for 1st argument
        struct Test
               ^
main.cpp:5:9: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided
#0 0x00000000016ea95a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/opt/rocm/hcc/bin/clang-7.0+0x16ea95a)
#1 0x00000000016e8a3e llvm::sys::RunSignalHandlers() (/opt/rocm/hcc/bin/clang-7.0+0x16e8a3e)
#2 0x00000000016e8b8c SignalHandler(int) (/opt/rocm/hcc/bin/clang-7.0+0x16e8b8c)
#3 0x00007faac7c54150 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x13150)
#4 0x0000000002fe0ee2 clang::Expr::HasSideEffects(clang::ASTContext const&, bool) const (/opt/rocm/hcc/bin/clang-7.0+0x2fe0ee2)
#5 0x0000000002ad5064 CollectFieldInitializer(clang::Sema&, (anonymous namespace)::BaseAndFieldInfo&, clang::FieldDecl*, clang::IndirectFieldDecl*) [clone .constprop.4055] (/opt/rocm/hcc/bin/clang-7.0+0x2ad5064)
#6 0x0000000002ad765a clang::Sema::SetCtorInitializers(clang::CXXConstructorDecl*, bool, llvm::ArrayRef<clang::CXXCtorInitializer*>) (/opt/rocm/hcc/bin/clang-7.0+0x2ad765a)
#7 0x0000000002ad86d8 clang::Sema::DefineAmpGpuDeSerializeFunction(clang::SourceLocation, clang::CXXMethodDecl*) (/opt/rocm/hcc/bin/clang-7.0+0x2ad86d8)
#8 0x0000000002b55a60 clang::Sema::MarkFunctionReferenced(clang::SourceLocation, clang::FunctionDecl*, bool) (/opt/rocm/hcc/bin/clang-7.0+0x2b55a60)
#9 0x0000000002acd6da clang::Sema::DeclareAMPTrampoline(clang::CXXRecordDecl*, clang::DeclarationName) (/opt/rocm/hcc/bin/clang-7.0+0x2acd6da)
#10 0x0000000002c2271f DeclareImplicitMemberFunctionsWithName(clang::Sema&, clang::DeclarationName, clang::SourceLocation, clang::DeclContext const*) (/opt/rocm/hcc/bin/clang-7.0+0x2c2271f)
#11 0x0000000002c28f2d LookupDirect(clang::Sema&, clang::LookupResult&, clang::DeclContext const*) (/opt/rocm/hcc/bin/clang-7.0+0x2c28f2d)
#12 0x0000000002c30abc clang::Sema::LookupQualifiedName(clang::LookupResult&, clang::DeclContext*, bool) [clone .part.1023] [clone .constprop.1105] (/opt/rocm/hcc/bin/clang-7.0+0x2c30abc)
#13 0x0000000002b5d096 clang::Sema::BuildQualifiedDeclarationNameExpr(clang::CXXScopeSpec&, clang::DeclarationNameInfo const&, bool, clang::Scope const*, clang::TypeSourceInfo**) (/opt/rocm/hcc/bin/clang-7.0+0x2b5d096)
#14 0x0000000002dbf3c1 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformDependentScopeDeclRefExpr(clang::DependentScopeDeclRefExpr*, bool, clang::TypeSourceInfo**) (/opt/rocm/hcc/bin/clang-7.0+0x2dbf3c1)
#15 0x0000000002dc1729 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformUnaryOperator(clang::UnaryOperator*) (/opt/rocm/hcc/bin/clang-7.0+0x2dc1729)
#16 0x0000000002da4278 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) (/opt/rocm/hcc/bin/clang-7.0+0x2da4278)
#17 0x0000000002db1d02 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCXXStaticCastExpr(clang::CXXStaticCastExpr*) (/opt/rocm/hcc/bin/clang-7.0+0x2db1d02)
#18 0x0000000002da4129 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) (/opt/rocm/hcc/bin/clang-7.0+0x2da4129)
#19 0x0000000002da53e8 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformInitializer(clang::Expr*, bool) (/opt/rocm/hcc/bin/clang-7.0+0x2da53e8)
#20 0x0000000002da561b clang::Sema::SubstInitializer(clang::Expr*, clang::MultiLevelTemplateArgumentList const&, bool) (/opt/rocm/hcc/bin/clang-7.0+0x2da561b)
#21 0x0000000002dcb4a9 clang::Sema::InstantiateVariableInitializer(clang::VarDecl*, clang::VarDecl*, clang::MultiLevelTemplateArgumentList const&) (/opt/rocm/hcc/bin/clang-7.0+0x2dcb4a9)
#22 0x0000000002dd5416 clang::Sema::BuildVariableInstantiation(clang::VarDecl*, clang::VarDecl*, clang::MultiLevelTemplateArgumentList const&, llvm::SmallVector<clang::Sema::LateInstantiatedAttribute, 16u>*, clang::DeclContext*, clang::LocalInstantiationScope*, bool) (/opt/rocm/hcc/bin/clang-7.0+0x2dd5416)
#23 0x0000000002dd5a01 clang::TemplateDeclInstantiator::VisitVarDecl(clang::VarDecl*, bool, llvm::ArrayRef<clang::BindingDecl*>*) (/opt/rocm/hcc/bin/clang-7.0+0x2dd5a01)
#24 0x0000000002dd8105 clang::Sema::SubstDecl(clang::Decl*, clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&) (/opt/rocm/hcc/bin/clang-7.0+0x2dd8105)
#25 0x0000000002d9ddac clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformDeclStmt(clang::DeclStmt*) (/opt/rocm/hcc/bin/clang-7.0+0x2d9ddac)
#26 0x0000000002dc1de5 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformStmt(clang::Stmt*) (/opt/rocm/hcc/bin/clang-7.0+0x2dc1de5)
#27 0x0000000002dc33b3 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*, bool) (/opt/rocm/hcc/bin/clang-7.0+0x2dc33b3)
#28 0x0000000002dc34db clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*) (/opt/rocm/hcc/bin/clang-7.0+0x2dc34db)
#29 0x0000000002dc1e25 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformStmt(clang::Stmt*) (/opt/rocm/hcc/bin/clang-7.0+0x2dc1e25)
#30 0x0000000002dc6f5f clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&) (/opt/rocm/hcc/bin/clang-7.0+0x2dc6f5f)
#31 0x0000000002ddb8c7 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/opt/rocm/hcc/bin/clang-7.0+0x2ddb8c7)
#32 0x0000000002dd9f73 clang::Sema::PerformPendingInstantiations(bool) (/opt/rocm/hcc/bin/clang-7.0+0x2dd9f73)
#33 0x0000000002ddb1ff clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/opt/rocm/hcc/bin/clang-7.0+0x2ddb1ff)
#34 0x0000000002dd9f73 clang::Sema::PerformPendingInstantiations(bool) (/opt/rocm/hcc/bin/clang-7.0+0x2dd9f73)
#35 0x0000000002ddb1ff clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/opt/rocm/hcc/bin/clang-7.0+0x2ddb1ff)
#36 0x0000000002dd9f73 clang::Sema::PerformPendingInstantiations(bool) (/opt/rocm/hcc/bin/clang-7.0+0x2dd9f73)
#37 0x0000000002977754 clang::Sema::ActOnEndOfTranslationUnit() (/opt/rocm/hcc/bin/clang-7.0+0x2977754)
#38 0x00000000027635a4 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) (/opt/rocm/hcc/bin/clang-7.0+0x27635a4)
#39 0x0000000002756f23 clang::ParseAST(clang::Sema&, bool, bool) (/opt/rocm/hcc/bin/clang-7.0+0x2756f23)
#40 0x0000000001fe4367 clang::CodeGenAction::ExecuteAction() (/opt/rocm/hcc/bin/clang-7.0+0x1fe4367)
#41 0x0000000001c9e89e clang::FrontendAction::Execute() (/opt/rocm/hcc/bin/clang-7.0+0x1c9e89e)
#42 0x0000000001c69b16 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/rocm/hcc/bin/clang-7.0+0x1c69b16)
#43 0x0000000001d323ac clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/rocm/hcc/bin/clang-7.0+0x1d323ac)
#44 0x00000000008df7a8 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/rocm/hcc/bin/clang-7.0+0x8df7a8)
#45 0x0000000000881871 main (/opt/rocm/hcc/bin/clang-7.0+0x881871)
#46 0x00007faac69451c1 __libc_start_main /build/glibc-itYbWN/glibc-2.26/csu/../csu/libc-start.c:342:0
#47 0x00000000008dceb9 _start (/opt/rocm/hcc/bin/clang-7.0+0x8dceb9)
Stack dump:
0.	Program arguments: /opt/rocm/hcc/bin/clang-7.0 -cc1 -D__KALMAR_HC__=1 -D__HCC_HC__=1 -D__KALMAR_CPU__=1 -D__HCC_CPU__=1 -triple x86_64-unknown-linux-gnu -S -disable-free -disable-llvm-verifier -main-file-name main.cpp -mrelocation-model static -mthread-model posix -menable-no-infs -menable-no-nans -menable-unsafe-fp-math -fno-signed-zeros -mreassociate -freciprocal-math -fno-trapping-math -ffp-contract=fast -ffast-math -ffinite-math-only -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -resource-dir /opt/rocm/hcc/lib/clang/7.0.0 -I/opt/rocm/bin/../include -I/opt/rocm/bin/../hcc/include -I /opt/rocm/hcc/include -I /opt/rocm/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/x86_64-linux-gnu/c++/7.2.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/x86_64-linux-gnu/c++/7.2.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/backward -internal-isystem /usr/local/include -internal-isystem /opt/rocm/hcc/lib/clang/7.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Ofast -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/miso/test -ferror-limit 19 -fmessage-length 185 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -famp -fhsa-ext -o /tmp/main-cf00b7.s -x hc-host main.cpp -emit-llvm-bc 
1.	<eof> parser at end of file
2.	/opt/rocm/bin/../hcc/include/hc.hpp:7510:19: instantiating function definition 'hc::parallel_for_each<1, (lambda at main.cpp:11:38)>'
3.	/opt/rocm/bin/../hcc/include/hc.hpp:7614:50: instantiating function definition 'hc::parallel_for_each<(lambda at main.cpp:11:38)>'
4.	/opt/rocm/bin/../hcc/include/hc.hpp:643:56: instantiating function definition 'Kalmar::mcw_cxxamp_launch_kernel_async<(lambda at main.cpp:11:38), 1>'
clang-7.0: error: unable to execute command: Segmentation fault (core dumped)
main.cpp:11:38: error: no matching constructor for initialization of 'Test'
        parallel_for_each(hc::extent<1>(1), [=](hc::index<1> i) [[hc]]
                                            ^
/opt/rocm/bin/../hcc/include/hc.hpp:7511:12: note: in instantiation of function template specialization 'hc::parallel_for_each<(lambda at main.cpp:11:38)>' requested here
    return parallel_for_each(accelerator::get_auto_selection_view(), compute_domain, f);
           ^
main.cpp:11:2: note: in instantiation of function template specialization 'hc::parallel_for_each<1, (lambda at main.cpp:11:38)>' requested here
        parallel_for_each(hc::extent<1>(1), [=](hc::index<1> i) [[hc]]
        ^
main.cpp:5:9: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int [10]' to 'const Test' for 1st argument
        struct Test
               ^
main.cpp:5:9: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'int [10]' to 'Test' for 1st argument
        struct Test
               ^
main.cpp:5:9: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int [10]' to 'int [10]' for 1st argument
        struct Test
               ^
main.cpp:5:9: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided
#0 0x00000000016ea95a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/opt/rocm/hcc/bin/clang-7.0+0x16ea95a)
#1 0x00000000016e8a3e llvm::sys::RunSignalHandlers() (/opt/rocm/hcc/bin/clang-7.0+0x16e8a3e)
#2 0x00000000016e8b8c SignalHandler(int) (/opt/rocm/hcc/bin/clang-7.0+0x16e8b8c)
#3 0x00007fbd8765e150 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x13150)
#4 0x0000000002fe0ee2 clang::Expr::HasSideEffects(clang::ASTContext const&, bool) const (/opt/rocm/hcc/bin/clang-7.0+0x2fe0ee2)
#5 0x0000000002ad5064 CollectFieldInitializer(clang::Sema&, (anonymous namespace)::BaseAndFieldInfo&, clang::FieldDecl*, clang::IndirectFieldDecl*) [clone .constprop.4055] (/opt/rocm/hcc/bin/clang-7.0+0x2ad5064)
#6 0x0000000002ad765a clang::Sema::SetCtorInitializers(clang::CXXConstructorDecl*, bool, llvm::ArrayRef<clang::CXXCtorInitializer*>) (/opt/rocm/hcc/bin/clang-7.0+0x2ad765a)
#7 0x0000000002ad86d8 clang::Sema::DefineAmpGpuDeSerializeFunction(clang::SourceLocation, clang::CXXMethodDecl*) (/opt/rocm/hcc/bin/clang-7.0+0x2ad86d8)
#8 0x0000000002b55a60 clang::Sema::MarkFunctionReferenced(clang::SourceLocation, clang::FunctionDecl*, bool) (/opt/rocm/hcc/bin/clang-7.0+0x2b55a60)
#9 0x0000000002acd6da clang::Sema::DeclareAMPTrampoline(clang::CXXRecordDecl*, clang::DeclarationName) (/opt/rocm/hcc/bin/clang-7.0+0x2acd6da)
#10 0x0000000002c2271f DeclareImplicitMemberFunctionsWithName(clang::Sema&, clang::DeclarationName, clang::SourceLocation, clang::DeclContext const*) (/opt/rocm/hcc/bin/clang-7.0+0x2c2271f)
#11 0x0000000002c28f2d LookupDirect(clang::Sema&, clang::LookupResult&, clang::DeclContext const*) (/opt/rocm/hcc/bin/clang-7.0+0x2c28f2d)
#12 0x0000000002c30abc clang::Sema::LookupQualifiedName(clang::LookupResult&, clang::DeclContext*, bool) [clone .part.1023] [clone .constprop.1105] (/opt/rocm/hcc/bin/clang-7.0+0x2c30abc)
#13 0x0000000002b5d096 clang::Sema::BuildQualifiedDeclarationNameExpr(clang::CXXScopeSpec&, clang::DeclarationNameInfo const&, bool, clang::Scope const*, clang::TypeSourceInfo**) (/opt/rocm/hcc/bin/clang-7.0+0x2b5d096)
#14 0x0000000002dbf3c1 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformDependentScopeDeclRefExpr(clang::DependentScopeDeclRefExpr*, bool, clang::TypeSourceInfo**) (/opt/rocm/hcc/bin/clang-7.0+0x2dbf3c1)
#15 0x0000000002dc1729 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformUnaryOperator(clang::UnaryOperator*) (/opt/rocm/hcc/bin/clang-7.0+0x2dc1729)
#16 0x0000000002da4278 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) (/opt/rocm/hcc/bin/clang-7.0+0x2da4278)
#17 0x0000000002da53e8 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformInitializer(clang::Expr*, bool) (/opt/rocm/hcc/bin/clang-7.0+0x2da53e8)
#18 0x0000000002da561b clang::Sema::SubstInitializer(clang::Expr*, clang::MultiLevelTemplateArgumentList const&, bool) (/opt/rocm/hcc/bin/clang-7.0+0x2da561b)
#19 0x0000000002dcb4a9 clang::Sema::InstantiateVariableInitializer(clang::VarDecl*, clang::VarDecl*, clang::MultiLevelTemplateArgumentList const&) (/opt/rocm/hcc/bin/clang-7.0+0x2dcb4a9)
#20 0x0000000002dd5416 clang::Sema::BuildVariableInstantiation(clang::VarDecl*, clang::VarDecl*, clang::MultiLevelTemplateArgumentList const&, llvm::SmallVector<clang::Sema::LateInstantiatedAttribute, 16u>*, clang::DeclContext*, clang::LocalInstantiationScope*, bool) (/opt/rocm/hcc/bin/clang-7.0+0x2dd5416)
#21 0x0000000002dd5a01 clang::TemplateDeclInstantiator::VisitVarDecl(clang::VarDecl*, bool, llvm::ArrayRef<clang::BindingDecl*>*) (/opt/rocm/hcc/bin/clang-7.0+0x2dd5a01)
#22 0x0000000002dd8105 clang::Sema::SubstDecl(clang::Decl*, clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&) (/opt/rocm/hcc/bin/clang-7.0+0x2dd8105)
#23 0x0000000002d9ddac clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformDeclStmt(clang::DeclStmt*) (/opt/rocm/hcc/bin/clang-7.0+0x2d9ddac)
#24 0x0000000002dc1de5 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformStmt(clang::Stmt*) (/opt/rocm/hcc/bin/clang-7.0+0x2dc1de5)
#25 0x0000000002dc33b3 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*, bool) (/opt/rocm/hcc/bin/clang-7.0+0x2dc33b3)
#26 0x0000000002dc34db clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*) (/opt/rocm/hcc/bin/clang-7.0+0x2dc34db)
#27 0x0000000002dc1e25 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformStmt(clang::Stmt*) (/opt/rocm/hcc/bin/clang-7.0+0x2dc1e25)
#28 0x0000000002dc6f5f clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&) (/opt/rocm/hcc/bin/clang-7.0+0x2dc6f5f)
#29 0x0000000002ddb8c7 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/opt/rocm/hcc/bin/clang-7.0+0x2ddb8c7)
#30 0x0000000002dd9f73 clang::Sema::PerformPendingInstantiations(bool) (/opt/rocm/hcc/bin/clang-7.0+0x2dd9f73)
#31 0x0000000002ddb1ff clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/opt/rocm/hcc/bin/clang-7.0+0x2ddb1ff)
#32 0x0000000002dd9f73 clang::Sema::PerformPendingInstantiations(bool) (/opt/rocm/hcc/bin/clang-7.0+0x2dd9f73)
#33 0x0000000002977754 clang::Sema::ActOnEndOfTranslationUnit() (/opt/rocm/hcc/bin/clang-7.0+0x2977754)
#34 0x00000000027635a4 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) (/opt/rocm/hcc/bin/clang-7.0+0x27635a4)
#35 0x0000000002756f23 clang::ParseAST(clang::Sema&, bool, bool) (/opt/rocm/hcc/bin/clang-7.0+0x2756f23)
#36 0x0000000001fe4367 clang::CodeGenAction::ExecuteAction() (/opt/rocm/hcc/bin/clang-7.0+0x1fe4367)
#37 0x0000000001c9e89e clang::FrontendAction::Execute() (/opt/rocm/hcc/bin/clang-7.0+0x1c9e89e)
#38 0x0000000001c69b16 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/rocm/hcc/bin/clang-7.0+0x1c69b16)
#39 0x0000000001d323ac clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/rocm/hcc/bin/clang-7.0+0x1d323ac)
#40 0x00000000008df7a8 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/rocm/hcc/bin/clang-7.0+0x8df7a8)
#41 0x0000000000881871 main (/opt/rocm/hcc/bin/clang-7.0+0x881871)
#42 0x00007fbd8634f1c1 __libc_start_main /build/glibc-itYbWN/glibc-2.26/csu/../csu/libc-start.c:342:0
#43 0x00000000008dceb9 _start (/opt/rocm/hcc/bin/clang-7.0+0x8dceb9)
Stack dump:
0.	Program arguments: /opt/rocm/hcc/bin/clang-7.0 -cc1 -D__KALMAR_HC__=1 -D__HCC_HC__=1 -D__GPU__=1 -D__KALMAR_ACCELERATOR__=1 -D__HCC_ACCELERATOR__=1 -famp-is-device -fno-builtin -fno-common -O2 -triple amdgcn--amdhsa-hcc -aux-triple x86_64-unknown-linux-gnu -S -disable-free -disable-llvm-verifier -main-file-name main.cpp -mrelocation-model pic -pic-level 1 -mthread-model posix -mdisable-fp-elim -menable-no-infs -menable-no-nans -menable-unsafe-fp-math -fno-signed-zeros -mreassociate -freciprocal-math -fno-trapping-math -ffp-contract=fast -ffast-math -ffinite-math-only -no-integrated-as -mconstructor-aliases -fuse-init-array -resource-dir /opt/rocm/hcc/lib/clang/7.0.0 -I/opt/rocm/bin/../include -I/opt/rocm/bin/../hcc/include -I /opt/rocm/hcc/include -I /opt/rocm/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/x86_64-linux-gnu/c++/7.2.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/x86_64-linux-gnu/c++/7.2.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/backward -internal-isystem /usr/local/include -internal-isystem /opt/rocm/hcc/lib/clang/7.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Ofast -std=c++17 -fdeprecated-macro -fno-dwarf-directory-asm -fdebug-compilation-dir /home/miso/test -ferror-limit 19 -fmessage-length 185 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -famp -fhsa-ext -o /tmp/main-abc744.s -x hc-kernel main.cpp -emit-llvm-bc 
1.	<eof> parser at end of file
2.	/opt/rocm/bin/../hcc/include/hc.hpp:7510:19: instantiating function definition 'hc::parallel_for_each<1, (lambda at main.cpp:11:38)>'
3.	/opt/rocm/bin/../hcc/include/hc.hpp:7614:50: instantiating function definition 'hc::parallel_for_each<(lambda at main.cpp:11:38)>'
clang-7.0: error: unable to execute command: Segmentation fault (core dumped)
clang-7.0: error: clang frontend command failed due to signal (use -v to see invocation)
clang-7.0: error: clang frontend command failed due to signal (use -v to see invocation)
HCC clang version 7.0.0 (ssh://gerritgit/compute/ec/hcc-tot/clang 86791fc4961dc8ffde77bde20d7dfa5e5cbeff5e) (ssh://gerritgit/compute/ec/hcc-tot/llvm c1f9263485c0192d7af512ac2c7dd15d5082538e) (based on HCC 1.2.18272-47899bc-86791fc-c1f9263 )
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/rocm/bin
clang-7.0: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
clang-7.0: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-7.0: note: diagnostic msg: /tmp/main-f76319.cpp
clang-7.0: note: diagnostic msg: /tmp/main-1e81e3.cpp
clang-7.0: note: diagnostic msg: /tmp/main-f76319.sh
clang-7.0: note: diagnostic msg: 

********************

misos1 avatar Sep 09 '18 19:09 misos1

I can reproduce this crash on 1.9.0. The error is printed but then it crashes. Not much of a surprise that struct is not working. Best to stick to array views or maybe basic types I think.

JMadgwick avatar Sep 18 '18 11:09 JMadgwick

Structs are working normally and must work in other case hc::array_view and hc::index would not work as they are structs. Struct containing simple C++ array with few elements is not working. Same crash happens when using C++ array directly or fixed size std::array.

So this struct is not working:

struct S
{
	int s[5];
};

But this yes:

struct S
{
	int s0;
	int s1;
	int s2;
	int s3;
	int s4;
};

misos1 avatar Sep 18 '18 12:09 misos1

If I remember correctly HCC doesn't support passing structs with array fields as kernel args. And this behavior was mentioned somewhere in docs but I can't find it anymore.

Workaround are very similar to what you do (pass individual fields and rebuild the array if you need it) or use custom serializer and deserializer.

ex-rzr avatar Oct 03 '18 05:10 ex-rzr

Oh, I've found the doc. It's actually from HIP, but this chapter was removed from there because HIP has different kernel launching implementation now.

Here the old version: https://github.com/ROCm-Developer-Tools/HIP/blob/91f82ce541b51ad1106a28e951b410a256e61f62/docs/markdown/hip_bugs.md#errors-related-to-no-matching-constructor

And an example from tests:

https://github.com/RadeonOpenCompute/hcc/blob/clang_tot_upgrade/tests/Unit/HC/capture_struct_with_carray_by_copy4.cpp

I think this should be mentioned somewhere in HCC docs.

ex-rzr avatar Oct 03 '18 05:10 ex-rzr

There is bug in compiler. It should not crash. I do not see any reason why they should not be supported. Imagine array with 20 elements instead of 5. Then individual fields or custom serializer/deserializer are impractical.

misos1 avatar Oct 07 '18 19:10 misos1