Code Monkey home page Code Monkey logo

hipcc's Introduction

HIPCC has moved!

This project is now located in the AMD Fork of the LLVM Project, under the "amd/hipcc" directory. This repository is now read-only.

All issues and pull requests related to the ROCm device libraries should be filed at https://github.com/ROCm/llvm-project with the hipcc tag.

Users wishing to include hipcc with upstream LLVM without needing to clone the entire ROCm llvm-project fork can still do so as follows:

cd <upstream-llvm-project>
git remote add rocm-llvm https://github.com/ROCm/llvm-project.git
git fetch rocm-llvm <branch> (default branch is amd-staging)
git checkout rocm-llvm/<branch> -- amd (default branch is amd-staging)

The amd-specific projects, including comgr, hipcc, and device-libs, will now be present in the <upstream llvm-project>/amd directory.

hipcc's People

Contributors

lamb-j avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hipcc's Issues

Duplicate symbols issue

I have a cmake project that looks like: main depends on two static libraries lib1 and lib2, lib2 depends also on lib1 .

When compiled with CMAKE_CXX_COMPILER=hipcc and CMAKE_CXX_FLAGS=-fgpu-rdc, I end up with an error at link stage about duplicate symbols from lib1. Am I doing something wrong ?

I noticed that if relocatable device code is disabled, the executable links fine. If main does not depend on lib1, it links fine. If I use the HIP language support of cmake without hipcc, it links fine.

You can find attached a minimal reproducer.zip to be compiled with cmake -DCMAKE_CXX_COMPILER=hipcc ...

On my system hipcc --version gives:

HIP version: 5.4.22804-
AMD clang version 15.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: ...

HIPCC error: implicit instantiation of undefined template

When I using hipcc to compile libfmt, I got the following errors:

fmt-src/include/fmt/format.h:3122:38: error: implicit instantiation of undefined template 'fmt::detail::dragonbox::float_info<long double>'
    const auto f = basic_fp<typename info::carrier_uint>(converted_value);
                                     ^
fmt-src/include/fmt/format.h:3230:13: note: in instantiation of function template specialization 'fmt::detail::format_float<long double>' requested here
  int exp = format_float(convert_float(value), precision, fspecs, buffer);
            ^
fmt-src/include/fmt/format.h:3394:20: note: in instantiation of function template specialization 'fmt::detail::write<char, fmt::appender, long double, 0>' requested here
    return detail::write(out, value, specs, locale);
                   ^
fmt-src/include/fmt/core.h:1649:12: note: in instantiation of function template specialization 'fmt::detail::arg_formatter<char>::operator()<long double>' requested here
    return vis(arg.value_.long_double_value);
           ^
fmt-src/include/fmt/format.h:4132:26: note: in instantiation of function template specialization 'fmt::visit_format_arg<fmt::detail::arg_formatter<char> &, fmt::basic_format_context<fmt::appender, char>>' requested here
      context.advance_to(visit_format_arg(f, arg));
                         ^
fmt-src/include/fmt/format.h:4082:10: note: in instantiation of member function 'fmt::detail::vformat_to(buffer<char> &, basic_string_view<char>, basic_format_args<basic_format_context<detail::buffer_appender<type_identity_t<char>>, type_identity_t<char>>>, fmt::detail::locale_ref)::format_handler::on_format_specs' requested here
  struct format_handler : error_handler {
         ^
fmt-src/src/format.cc:34:23: note: in instantiation of function template specialization 'fmt::detail::vformat_to<char>' requested here
template FMT_API void vformat_to(buffer<char>&, string_view,
                      ^
fmt-src/include/fmt/format.h:1289:54: note: template is declared here
template <typename T, typename Enable = void> struct float_info;

But, if I using the g++ compiler, libfmt can be successful compiled. The total compile options and link options are same. The only different is the compiler(hipcc VS. g++). If you have any suggestions, thanks for your help!

rocm 5.7: hipcc crashes if `ranges` is included, whatever `gcc` installed

Describe the bug

Trying to compile a c++20 code with hipcc provided by the Docker image rocm/dev-ubuntu-22.04:5.7 crashes if g++12 is installed whatever gcc version is installed (as of today 28th Sep. 2023).

I was able to reproduce the bug, see below bash script and dockerfile.

Details

We start from rocm/dev-ubuntu-22.04:5.7 and we (possibly) add g++-12 (note that g++-11 is the default in Ubuntu 22.04).

Then, compiling a simple C++ code that includes <ranges> crashes.

Note that it works with ROCm 5.6. This might indicate that the culprit is clang 17.0.0 that ships with ROCm 5.7...

Here is a simple reproducer code:

    #include <ranges>

    int main()
    {
        return 0;
    }

Summary

Summary of when it works (:heavy_check_mark:), and when it does not (:red_circle:).

gcc compiler installed ROCm 5.6 ROCm 5.7
gcc-11 โœ”๏ธ ๐Ÿ”ด
gcc-12 โœ”๏ธ ๐Ÿ”ด

Reproducer

Launch this bash script:

set -ex

# We start from 'rocm/dev-ubuntu-22.04', either with tag '5.6' or '5.7'.
# For each, we build:
#   - 'gcc-de' : an image with the sample C++ code embedded, nothing else added [note that 'de' stands for 'default']
#   - 'gcc-12' : an image with the sample C++ code embedded, and we add gcc-12 g++-12

# The name of the image we'll build, on top of 'rocm/dev-ubuntu-22.04:5.6'
BASE_IMAGE_56=rocm/dev-ubuntu-22.04-gcc-de:5.6
TEST_IMAGE_56_GCC_DE=rocm/dev-ubuntu-22.04-gcc-de:5.6
TEST_IMAGE_56_GCC_12=rocm/dev-ubuntu-22.04-gcc-12:5.6

# The name of the image we'll build, on top of 'rocm/dev-ubuntu-22.04:5.7'
BASE_IMAGE_57=rocm/dev-ubuntu-22.04:5.7
TEST_IMAGE_57_GCC_DE=rocm/dev-ubuntu-22.04-gcc-de:5.7
TEST_IMAGE_57_GCC_12=rocm/dev-ubuntu-22.04-gcc-12:5.7

# Build image with and without GCC 12 and ROCm 5.6 (default for Ubuntu 22.04 is GCC 11)
docker build -f reproducer.dockerfile -t ${TEST_IMAGE_56_GCC_DE} --build-arg BASE_IMAGE=${BASE_IMAGE_56} --build-arg ADD_GCC_12=0 $PWD
docker build -f reproducer.dockerfile -t ${TEST_IMAGE_56_GCC_12} --build-arg BASE_IMAGE=${BASE_IMAGE_56} --build-arg ADD_GCC_12=1 $PWD

# Build image with and without GCC 12 and ROCm 5.7 (default for Ubuntu 22.04 is GCC 11)
docker build -f reproducer.dockerfile -t ${TEST_IMAGE_57_GCC_DE} --build-arg BASE_IMAGE=${BASE_IMAGE_57} --build-arg ADD_GCC_12=0 $PWD
docker build -f reproducer.dockerfile -t ${TEST_IMAGE_57_GCC_12} --build-arg BASE_IMAGE=${BASE_IMAGE_57} --build-arg ADD_GCC_12=1 $PWD

# Ask the new image to compile the code. Without the 'ranges' include, it goes well for both ROCm 5.6 and 5.7 (whatever 'gcc' version).
docker run --rm -it --device=/dev/kfd --device=/dev/dri $TEST_IMAGE_56_GCC_DE bash -c "cd /testing && hipcc --version && hipcc -std=c++20 test.cpp"
docker run --rm -it --device=/dev/kfd --device=/dev/dri $TEST_IMAGE_56_GCC_12 bash -c "cd /testing && hipcc --version && hipcc -std=c++20 test.cpp"
docker run --rm -it --device=/dev/kfd --device=/dev/dri $TEST_IMAGE_57_GCC_DE bash -c "cd /testing && hipcc --version && hipcc -std=c++20 test.cpp"
docker run --rm -it --device=/dev/kfd --device=/dev/dri $TEST_IMAGE_57_GCC_12 bash -c "cd /testing && hipcc --version && hipcc -std=c++20 test.cpp"

# Ask the new image to compile the code. With the 'ranges' include, it crashes with ROCm 5.7 but is fine with ROCm 5.6 (whatever 'gcc' version)
docker run --rm -it --device=/dev/kfd --device=/dev/dri $TEST_IMAGE_56_GCC_DE bash -c "cd /testing && hipcc --version && hipcc -DENABLE_BUG -std=c++20 test.cpp" 
docker run --rm -it --device=/dev/kfd --device=/dev/dri $TEST_IMAGE_56_GCC_12 bash -c "cd /testing && hipcc --version && hipcc -DENABLE_BUG -std=c++20 test.cpp"

docker run --rm -it --device=/dev/kfd --device=/dev/dri $TEST_IMAGE_57_GCC_DE bash -c "cd /testing && hipcc --version && hipcc -DENABLE_BUG -std=c++20 test.cpp" || echo "Failed as expected"
docker run --rm -it --device=/dev/kfd --device=/dev/dri $TEST_IMAGE_57_GCC_12 bash -c "cd /testing && hipcc --version && hipcc -DENABLE_BUG -std=c++20 test.cpp" || echo "Failed as expected"

with this dockerfile:

# The file is related to https://github.com/ROCm-Developer-Tools/HIPCC/issues/137.

ARG BASE_IMAGE
FROM ${BASE_IMAGE}

ARG ADD_GCC_12

RUN <<EOF

    set -ex

    if [ ${ADD_GCC_12} = 1 ];then

        echo "Installing 'gcc-12'."

        apt update

        apt --yes install gcc-12 g++-12

        update-alternatives --install /usr/bin/gcc  gcc  /usr/bin/gcc-12 10 
        update-alternatives --install /usr/bin/g++  g++  /usr/bin/g++-12 10 
        update-alternatives --display gcc
        update-alternatives --display g++
    else
        echo "Not installing 'gcc-12'."
    fi
EOF

# Embed the **very simple** example C++ code
COPY <<EOF /testing/test.cpp
    #ifdef ENABLE_BUG
    #include <ranges>
    #endif

    int main()
    {
        return 0;
    }

EOF

Here is the crash report:

+ docker run --rm -it --device=/dev/kfd --device=/dev/dri rocm/dev-ubuntu-22.04-gcc-12:5.7 bash -c 'cd /testing && hipcc --version && hipcc -DENABLE_BUG -std=c++20 test.cpp'
HIP version: 5.7.31921-d1770ee1b
AMD clang version 17.0.0 (https://github.com/RadeonOpenCompute/llvm-project roc-5.7.0 23352 d1e13c532a947d0cbfc94759c00dcf152294aa13)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/rocm-5.7.0/llvm/bin
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /opt/rocm-5.7.0/llvm/bin/clang-17 -cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-linux-gnu -emit-obj -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.cpp -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=none -fno-rounding-math -mconstructor-aliases -aux-target-cpu x86-64 -fcuda-is-device -mllvm -amdgpu-internalize-symbols -fcuda-allow-variadic-functions -fvisibility=hidden -fapply-global-visibility-to-externs -mlink-builtin-bitcode /opt/rocm-5.7.0/amdgcn/bitcode/hip.bc -mlink-builtin-bitcode /opt/rocm-5.7.0/amdgcn/bitcode/ocml.bc -mlink-builtin-bitcode /opt/rocm-5.7.0/amdgcn/bitcode/ockl.bc -mlink-builtin-bitcode /opt/rocm-5.7.0/amdgcn/bitcode/oclc_daz_opt_off.bc -mlink-builtin-bitcode /opt/rocm-5.7.0/amdgcn/bitcode/oclc_unsafe_math_off.bc -mlink-builtin-bitcode /opt/rocm-5.7.0/amdgcn/bitcode/oclc_finite_only_off.bc -mlink-builtin-bitcode /opt/rocm-5.7.0/amdgcn/bitcode/oclc_correctly_rounded_sqrt_on.bc -mlink-builtin-bitcode /opt/rocm-5.7.0/amdgcn/bitcode/oclc_wavefrontsize64_on.bc -mlink-builtin-bitcode /opt/rocm-5.7.0/amdgcn/bitcode/oclc_isa_version_906.bc -mlink-builtin-bitcode /opt/rocm-5.7.0/amdgcn/bitcode/oclc_abi_version_500.bc -target-cpu gfx906 -debugger-tuning=gdb -resource-dir /opt/rocm-5.7.0/llvm/lib/clang/17.0.0 -internal-isystem /opt/rocm-5.7.0/llvm/lib/clang/17.0.0/include/cuda_wrappers -idirafter /opt/rocm-5.7.0/include -include __clang_hip_runtime_wrapper.h -c-isystem /opt/rocm-5.7.0/llvm/include/gpu-none-llvm -isystem /opt/rocm-5.7.0/include -D ENABLE_BUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/x86_64-linux-gnu/c++/12 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/backward -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/x86_64-linux-gnu/c++/12 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/backward -internal-isystem /opt/rocm-5.7.0/llvm/lib/clang/17.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -internal-isystem /opt/rocm-5.7.0/llvm/lib/clang/17.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -std=c++20 -fdeprecated-macro -fno-autolink -fdebug-compilation-dir=/testing -ferror-limit 19 -fhip-new-launch-api -fgnuc-version=4.2.1 -fno-implicit-modules -fcxx-exceptions -fexceptions -fcolor-diagnostics -vectorize-loops -vectorize-slp -mllvm -amdgpu-early-inline-all=true -mllvm -amdgpu-function-calls=false -cuid=44554cf282633cd2 -fcuda-allow-variadic-functions -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/test-gfx906-84beef.o -x hip test.cpp
1.      /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:991:2: current parser token '{'
2.      /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:56:1: parsing namespace 'std'
3.      /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:59:1: parsing namespace 'std::ranges'
4.      /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:846:1: parsing namespace 'std::ranges::views'
5.      /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/ranges:972:5: parsing struct/union/class body 'std::ranges::views::__adaptor::_Partial<_Adaptor, _Arg>'
 #0 0x000056170b573576 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x254f576)
 #1 0x000056170b570e74 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007faec49bc520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x000056170e0a22e8 clang::ASTContext::getSubstTemplateTypeParmType(clang::QualType, clang::Decl*, unsigned int, std::optional<unsigned int>) const (/opt/rocm-5.7.0/llvm/bin/clang-17+0x507e2e8)
 #4 0x000056170de26cfb (anonymous namespace)::TemplateInstantiator::BuildSubstTemplateTypeParmType(clang::TypeLocBuilder&, bool, bool, clang::Decl*, unsigned int, std::optional<unsigned int>, clang::TemplateArgument, clang::SourceLocation) (.isra.0) SemaTemplateInstantiate.cpp:0:0
 #5 0x000056170de288d9 (anonymous namespace)::TemplateInstantiator::TransformTemplateTypeParmType(clang::TypeLocBuilder&, clang::TemplateTypeParmTypeLoc, bool) SemaTemplateInstantiate.cpp:0:0
 #6 0x000056170de493a0 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) SemaTemplateInstantiate.cpp:0:0
 #7 0x000056170de4d258 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformReferenceType(clang::TypeLocBuilder&, clang::ReferenceTypeLoc) SemaTemplateInstantiate.cpp:0:0
 #8 0x000056170de493b9 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) SemaTemplateInstantiate.cpp:0:0
 #9 0x000056170de4d589 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeSourceInfo*) SemaTemplateInstantiate.cpp:0:0
#10 0x000056170de50b56 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTemplateArgument(clang::TemplateArgumentLoc const&, clang::TemplateArgumentLoc&, bool) SemaTemplateInstantiate.cpp:0:0
#11 0x000056170de5459a bool clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTemplateArguments<clang::TemplateArgumentLoc const*>(clang::TemplateArgumentLoc const*, clang::TemplateArgumentLoc const*, clang::TemplateArgumentListInfo&, bool) (.constprop.0) SemaTemplateInstantiate.cpp:0:0
#12 0x000056170de55198 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformConceptSpecializationExpr(clang::ConceptSpecializationExpr*) SemaTemplateInstantiate.cpp:0:0
#13 0x000056170de6bc33 clang::Sema::SubstConstraintExpr(clang::Expr*, clang::MultiLevelTemplateArgumentList const&) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x4e47c33)
#14 0x000056170d6b6914 SubstituteConstraintExpression(clang::Sema&, clang::NamedDecl const*, clang::Expr const*) SemaConcept.cpp:0:0
#15 0x000056170d6b917a clang::Sema::AreConstraintExpressionsEqual(clang::NamedDecl const*, clang::Expr const*, clang::NamedDecl const*, clang::Expr const*) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x469517a)
#16 0x000056170dd1302a clang::Sema::TemplateParameterListsAreEqual(clang::NamedDecl const*, clang::TemplateParameterList*, clang::NamedDecl const*, clang::TemplateParameterList*, bool, clang::Sema::TemplateParameterListEqualKind, clang::SourceLocation) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x4cef02a)
#17 0x000056170dc42560 clang::Sema::IsOverload(clang::FunctionDecl*, clang::FunctionDecl*, bool, bool, bool) (.part.0) SemaOverload.cpp:0:0
#18 0x000056170dc42d7a clang::Sema::CheckOverload(clang::Scope*, clang::FunctionDecl*, clang::LookupResult const&, clang::NamedDecl*&, bool) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x4c1ed7a)
#19 0x000056170d77268d clang::Sema::CheckFunctionDeclaration(clang::Scope*, clang::FunctionDecl*, clang::LookupResult&, bool, bool) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x474e68d)
#20 0x000056170d787785 clang::Sema::ActOnFunctionDeclarator(clang::Scope*, clang::Declarator&, clang::DeclContext*, clang::TypeSourceInfo*, clang::LookupResult&, llvm::MutableArrayRef<clang::TemplateParameterList*>, bool&) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x4763785)
#21 0x000056170d78ad68 clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x4766d68)
#22 0x000056170d83f0cf clang::Sema::ActOnCXXMemberDeclarator(clang::Scope*, clang::AccessSpecifier, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>, clang::Expr*, clang::VirtSpecifiers const&, clang::InClassInitStyle) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x481b0cf)
#23 0x000056170d45a390 clang::Parser::ParseCXXInlineMethodDef(clang::AccessSpecifier, clang::ParsedAttributesView const&, clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::VirtSpecifiers const&, clang::SourceLocation) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x4436390)
#24 0x000056170d49afb6 clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject*) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x4476fb6)
#25 0x000056170d53d962 clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x4519962)
#26 0x000056170d5456ac clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x45216ac)
#27 0x000056170d49a664 clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject*) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x4476664)
#28 0x000056170d49c392 clang::Parser::ParseCXXClassMemberDeclarationWithPragmas(clang::AccessSpecifier&, clang::ParsedAttributes&, clang::TypeSpecifierType, clang::Decl*) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x4478392)
#29 0x000056170d49c9a3 clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributes&, unsigned int, clang::Decl*) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x44789a3)
#30 0x000056170d49ebbc clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x447abbc)
#31 0x000056170d46dd3a clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x4449d3a)
#32 0x000056170d53cdf7 clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x4518df7)
#33 0x000056170d5456ac clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x45216ac)
#34 0x000056170d54592a clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x452192a)
#35 0x000056170d47cd2d clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x4458d2d)
#36 0x000056170d44ee87 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x442ae87)
#37 0x000056170d4926dc clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x446e6dc)
#38 0x000056170d4925be clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x446e5be)
#39 0x000056170d498187 clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x4474187)
#40 0x000056170d47cdf5 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x4458df5)
#41 0x000056170d44ee87 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x442ae87)
#42 0x000056170d4926dc clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x446e6dc)
#43 0x000056170d498187 clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x4474187)
#44 0x000056170d47cdf5 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x4458df5)
#45 0x000056170d44ee87 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x442ae87)
#46 0x000056170d4926dc clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x446e6dc)
#47 0x000056170d498187 clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x4474187)
#48 0x000056170d47cdf5 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x4458df5)
#49 0x000056170d44ee87 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x442ae87)
#50 0x000056170d450756 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x442c756)
#51 0x000056170d4413da clang::ParseAST(clang::Sema&, bool, bool) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x441d3da)
#52 0x000056170bfb7e49 clang::FrontendAction::Execute() (/opt/rocm-5.7.0/llvm/bin/clang-17+0x2f93e49)
#53 0x000056170bf3e451 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x2f1a451)
#54 0x000056170c0798d8 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/rocm-5.7.0/llvm/bin/clang-17+0x30558d8)
#55 0x0000561709d8d095 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/rocm-5.7.0/llvm/bin/clang-17+0xd69095)
#56 0x0000561709d8850d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#57 0x0000561709d89bc4 clang_main(int, char**, llvm::ToolContext const&) (/opt/rocm-5.7.0/llvm/bin/clang-17+0xd65bc4)
#58 0x0000561709cca643 main (/opt/rocm-5.7.0/llvm/bin/clang-17+0xca6643)
#59 0x00007faec49a3d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#60 0x00007faec49a3e40 call_init ./csu/../csu/libc-start.c:128:20
#61 0x00007faec49a3e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#62 0x0000561709d84155 _start (/opt/rocm-5.7.0/llvm/bin/clang-17+0xd60155)
clang++: error: unable to execute command: Segmentation fault (core dumped)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
AMD clang version 17.0.0 (https://github.com/RadeonOpenCompute/llvm-project roc-5.7.0 23352 d1e13c532a947d0cbfc94759c00dcf152294aa13)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/rocm-5.7.0/llvm/bin
clang++: note: diagnostic msg: Error generating preprocessed source(s).

Edit 1

I just added the tests for ROCm 5.6 (no bug for that release apparently).

Edit 2

I forgot to update the dockerfile to allow for ARG BASE_IMAGE while doing Edit 1. Sorry!

Edit 3

In fact, with ROCm 5.7, it always fails, i.e. it does not depend on what gcc version is installed.

ld.lld: error: undefined symbol: main

At first, I installed rocm-5.4.2, and everything is OK.

Then I upgraded it to version 5.4.3. After that it returns errors when I use hipcc -v.

(PyTorch) loong@home:~$ hipcc -v
AMD clang version 15.0.0 (https://github.com/RadeonOpenCompute/llvm-project roc-5.4.3 23045 a29fe425c7b0e5aba97ed2f95f61fd5ecba68aed)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/rocm-5.4.3/llvm/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12
Candidate multilib: .;@m64
Selected multilib: .;@m64
Found HIP installation: /opt/rocm-5.4.3, version 5.4.22804
 "/opt/rocm-5.4.3/llvm/bin/ld.lld" -z relro --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out /lib/x86_64-linux-gnu/crt1.o /lib/x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/12/crtbegin.o -L/opt/rocm-5.4.3/lib -L/opt/rocm-5.4.3/llvm/bin/../lib/clang/15.0.0/lib/linux -L/usr/lib/gcc/x86_64-linux-gnu/12 -L/usr/lib/gcc/x86_64-linux-gnu/12/../../../../lib64 -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib64 -L/lib -L/usr/lib -L/usr/lib/llvm-14/lib -L. -lgcc_s -lgcc -lpthread -lm -lrt -rpath=/opt/rocm-5.4.3/lib:/opt/rocm-5.4.3/lib -lamdhip64 -lclang_rt.builtins-x86_64 -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/12/crtend.o /lib/x86_64-linux-gnu/crtn.o
ld.lld: error: undefined symbol: main
>>> referenced by /lib/x86_64-linux-gnu/crt1.o:(_start)
clang-15: error: linker command failed with exit code 1 (use -v to see invocation)

How to export a function defined with __device__?

I am trying to share utility functions defined with device

I have a "dark_functions.cpp" file, which contain hello() function, which I would like to make available to kernels.

--- dark_functions.cpp ---

#include <hip/hip_runtime.h>
#include <hip/hip_runtime_api.h>
#include <hip/amd_detail/amd_hip_runtime.h>

extern "C" {

device u_int64_t hello() {
u_int64_t ret = 10;
return ret;
}

}

Now, if I compile the file by using "/opt/rocm/hip/bin/hipcc -c dark_functions.cpp" command and try to see the symbols with "objdump -t dark_functions.o" I don't see hello symbol being exported.

Also if I try to call hello() from a kernel I get compile time error:
lld: error: undefined hidden symbol: hello

How do I use device functions from other object files?

Windows *.bat files installed on Linux

With the 5.6 release both the Linux and Windows wrappers for the perl scripts of hipcc and hipconfig are installed. This confuses the build system of ROCm math libraries like rocBLAS as they only expect either the Linux or the Windows script to be installed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.