Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[simd][error] construct simd:scalar from minmax fail #51

Closed
fepicture opened this issue Aug 25, 2022 · 3 comments
Closed

[simd][error] construct simd:scalar from minmax fail #51

fepicture opened this issue Aug 25, 2022 · 3 comments
Assignees

Comments

@fepicture
Copy link

What happens

call the ex::minmax function from simd_abi::scalar will fail. the issue seems due to the std::pair
While other simd_abi work well.

code snippet

namespace ex = std::experimental::parallelism_v2;
void test_minmax() {
  int n = (int)ex::simd<int, ex::simd_abi::scalar>::size();

  ex::minmax(ex::simd<int, ex::simd_abi::scalar>([](int i) { return i; }),
         ex::simd<int, ex::simd_abi::scalar>([n](int i) { return n - 1 - i; }));
}

environment:

clang14 -std=c++17

error log

error log
In file included from /root/llvm-project/libcxx/test/std/experimental/simd/simd.alg/minmax.pass.cpp:18:
In file included from /root/llvm-project/build/include/c++/v1/experimental/simd:694:
/root/llvm-project/build/include/c++/v1/__simd/abi/scalar.h:82:12: error: no matching constructor for initialization of 'std::pair<_Simd, _Simd>' (aka 'pair<__simd_storage<int, simd_abi::__scalar>, __simd_storage<int, simd_abi::__scalar>>')
    return {__min, __max};
           ^~~~~~~~~~~~~~
/root/llvm-project/build/include/c++/v1/experimental/simd:1522:51: note: in instantiation of member function 'std::experimental::__simd_traits<int, std::experimental::simd_abi::__scalar>::__minmax' requested here
  auto [__min, __max] = __simd_traits<_Tp, _Abi>::__minmax(__a.__s_, __b.__s_);
                                                  ^
/root/llvm-project/libcxx/test/std/experimental/simd/simd.alg/minmax.pass.cpp:60:7: note: in instantiation of function template specialization 'std::experimental::minmax<int, std::experimental::simd_abi::__scalar>' requested here
  ex::minmax(ex::simd<int, ex::simd_abi::scalar>([](int i) { return i; }),
      ^
/root/llvm-project/build/include/c++/v1/__utility/pair.h:166:5: note: candidate constructor template not viable: no known conversion from 'const int' to 'const std::experimental::__simd_storage<int, std::experimental::simd_abi::__scalar>' for 1st argument
    pair(_T1 const& __t1, _T2 const& __t2)
    ^
/root/llvm-project/build/include/c++/v1/__utility/pair.h:157:14: note: candidate template ignored: requirement '_CheckArgsDep<true>::__enable_explicit()' was not satisfied [with _Dummy = true]
    explicit pair(_T1 const& __t1, _T2 const& __t2)
             ^
/root/llvm-project/build/include/c++/v1/__utility/pair.h:180:14: note: candidate template ignored: requirement '_CheckArgs::__enable_explicit()' was not satisfied [with _U1 = const int &, _U2 = const int &]
    explicit pair(_U1&& __u1, _U2&& __u2)
             ^
/root/llvm-project/build/include/c++/v1/__utility/pair.h:194:5: note: candidate template ignored: requirement '_CheckArgs::__enable_implicit()' was not satisfied [with _U1 = const int &, _U2 = const int &]
    pair(_U1&& __u1, _U2&& __u2)
    ^
/root/llvm-project/build/include/c++/v1/__utility/pair.h:52:5: note: candidate constructor not viable: requires 1 argument, but 2 were provided
    pair(pair const&) = default;
    ^
/root/llvm-project/build/include/c++/v1/__utility/pair.h:53:5: note: candidate constructor not viable: requires 1 argument, but 2 were provided
    pair(pair&&) = default;
    ^
/root/llvm-project/build/include/c++/v1/__utility/pair.h:203:14: note: candidate constructor template not viable: requires single argument '__p', but 2 arguments were provided
    explicit pair(pair<_U1, _U2> const& __p)
             ^
/root/llvm-project/build/include/c++/v1/__utility/pair.h:212:5: note: candidate constructor template not viable: requires single argument '__p', but 2 arguments were provided
    pair(pair<_U1, _U2> const& __p)
    ^
/root/llvm-project/build/include/c++/v1/__utility/pair.h:221:14: note: candidate constructor template not viable: requires single argument '__p', but 2 arguments were provided
    explicit pair(pair<_U1, _U2>&&__p)
             ^
/root/llvm-project/build/include/c++/v1/__utility/pair.h:230:5: note: candidate constructor template not viable: requires single argument '__p', but 2 arguments were provided
    pair(pair<_U1, _U2>&& __p)
    ^
/root/llvm-project/build/include/c++/v1/__utility/pair.h:239:14: note: candidate constructor template not viable: requires single argument '__p', but 2 arguments were provided
    explicit pair(_Tuple&& __p)
             ^
/root/llvm-project/build/include/c++/v1/__utility/pair.h:247:5: note: candidate constructor template not viable: requires single argument '__p', but 2 arguments were provided
    pair(_Tuple&& __p)
    ^
/root/llvm-project/build/include/c++/v1/__utility/pair.h:253:5: note: candidate constructor template not viable: requires 3 arguments, but 2 were provided
    pair(piecewise_construct_t __pc,
    ^
/root/llvm-project/build/include/c++/v1/__utility/pair.h:141:5: note: candidate constructor template not viable: requires 0 arguments, but 2 were provided
    pair() _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value &&
    ^
/root/llvm-project/build/include/c++/v1/__utility/pair.h:149:5: note: candidate constructor template not viable: requires 0 arguments, but 2 were provided
    pair() _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value &&
    ^
/root/llvm-project/build/include/c++/v1/__utility/pair.h:312:5: note: candidate constructor template not viable: requires 5 arguments, but 2 were provided
    pair(piecewise_construct_t,
    ^
1 error generated.

error: command failed with exit status: 1

--
fepicture added a commit to fepicture/llvm-project that referenced this issue Aug 25, 2022
@joy2myself joy2myself self-assigned this Aug 29, 2022
@joy2myself
Copy link
Collaborator

joy2myself commented Aug 29, 2022

I've tried to give a fix for minmax and clamp in ABI scalar. See as following:

joy2myself@76e2d2c

But I tried it with your test cases, there are still failings in min/max/minmax/clamp. I'm not sure if there are issues in test cases.

@fepicture
Copy link
Author

fepicture commented Aug 30, 2022

But I tried it with your test cases, there are still failings in min/max/minmax/clamp. I'm not sure if there are issues in test cases.

it's interesting. Oh in my local, under the latest compile command (also called gitlab-ci.yml) will fail, but it works well on the old one. see the commit change 3839711

edit1: I will update some commits to fix later.

@fepicture
Copy link
Author

fepicture commented Aug 31, 2022

edit1:

sorry, the bug is due to long double and ex::simd_abi::native<long double>>, or shortly just avoid using native<long double> in the following 4 tests. See commit: fepicture@0425f8e

origin:

@joy2myself Hi, I push a new commit aab830f that will pass the 4 tests under simd/simd.alg directory.

Basically, I forbade the type"long double", and it works well.
and I have no clue why such weird things happen.(the error log output in below)

It's cost time to run all test, so I strongly recommend reduce the length in (std::make_integer_sequence<std::size_t, length>()); on file test_util.h . Also, comment/hide some vectorizable type to reduce time.

error log(with long double)

error log
clang-14: /root/llvm-project/clang/lib/Sema/SemaExpr.cpp:12287: clang::QualType clang::Sema::GetSignedVectorType(clang::QualType): 
Assertion `TypeSize == Context.getTypeSize(Context.CharTy) && "Unhandled vector element size in vector compare"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /root/llvm-project/latest_build/build/bin/clang-14 -cc1 -triple
 x86_64-unknown-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend
  -main-file-name min.pass.cpp -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -v -fcoverage-compilation-dir=/root/llvm-project/latest_build/build/runtimes/runtimes-x86_64-unknown-linux-gnu-bins/libcxx/test/std/experimental/simd/simd.alg -nostdinc++ -resource-dir /root/llvm-project/latest_build/build/lib/clang/14.0.0 -include /root/llvm-project/libcxx/test/support/nasty_macros.h -I /root/llvm-project/latest_build/build/include/x86_64-unknown-linux-gnu/c++/v1 -I /root/llvm-project/latest_build/build/include/c++/v1 -I /root/llvm-project/latest_build/build/runtimes/runtimes-x86_64-unknown-linux-gnu-bins/libcxx/include/c++build -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -D __STDC_CONSTANT_MACROS -I /root/llvm-project/libcxx/test/support -D _LIBCPP_DISABLE_AVAILABILITY -D _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D _LIBCPP_HAS_THREAD_API_PTHREAD -D _LIBCPP_ABI_VERSION=1 -internal-isystem /root/llvm-project/latest_build/build/lib/clang/14.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Werror -Wall -Wextra -Wshadow -Wundef -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-user-defined-literals -Wno-noexcept-type -Wno-atomic-alignment -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -Werror=thread-safety -Wuser-defined-warnings -Wno-macro-redefined -Wno-macro-redefined -std=c++2b -fdeprecated-macro -fdebug-compilation-dir=/root/llvm-project/latest_build/build/runtimes/runtimes-x86_64-unknown-linux-gnu-bins/libcxx/test/std/experimental/simd/simd.alg -ferror-limit 19 -fcoroutines-ts -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/min-b3efda.o -x c++ /root/llvm-project/libcxx/test/std/experimental/simd/simd.alg/min.pass.cpp
1.	<eof> parser at end of file
2.	/root/llvm-project/libcxx/test/std/experimental/simd/simd.alg/../test_util.h:29:6: instantiating function definition 'test_all_simd_abi<CheckMinTrue>'
3.	/root/llvm-project/libcxx/test/std/experimental/simd/simd.alg/../test_util.h:20:6: instantiating function definition 'test_all_simd_abi<CheckMinTrue, long double, 0UL, 1UL, 2UL, 3UL, 4UL, 5UL, 6UL, 7UL, 8UL, 9UL, 10UL, 11UL, 12UL, 13UL, 14UL, 15UL, 16UL, 17UL, 18UL, 19UL, 20UL, 21UL, 22UL, 23UL, 24UL, 25UL, 26UL, 27UL, 28UL, 29UL, 30UL, 31UL, 32UL, 33UL, 34UL, 35UL, 36UL, 37UL, 38UL, 39UL, 40UL, 41UL, 42UL, 43UL, 44UL, 45UL, 46UL, 47UL, 48UL, 49UL, 50UL, 51UL, 52UL, 53UL, 54UL, 55UL, 56UL, 57UL, 58UL, 59UL, 60UL, 61UL, 62UL, 63UL>'
4.	/root/llvm-project/libcxx/test/std/experimental/simd/simd.alg/../test_util.h:17:6: instantiating function definition 'test_simd_abi<CheckMinTrue, 64UL, long double, std::experimental::simd_abi::__vec_ext<1>, std::experimental::simd_abi::__vec_ext<64>, std::experimental::simd_abi::__scalar, std::experimental::simd_abi::__vec_ext<1>, std::experimental::simd_abi::__vec_ext<64>>'
5.	/root/llvm-project/libcxx/test/std/experimental/simd/simd.alg/min.pass.cpp:36:8: instantiating function definition 'CheckMinTrue::operator()<long double, std::experimental::simd_abi::__vec_ext<1>>'
6.	/root/llvm-project/latest_build/build/include/c++/v1/experimental/simd:1709:15: instantiating function definition 'std::experimental::min<long double, std::experimental::simd_abi::__vec_ext<1>>'
7.	/root/llvm-project/latest_build/build/include/c++/v1/__simd/abi/builtin.h:119:16: instantiating function definition 'std::experimental::__simd_traits<long double, std::experimental::simd_abi::__vec_ext<1>>::__min'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
/root/llvm-project/latest_build/build/bin/clang-14(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamEi+0x40)[0x5609f18fb818]
/root/llvm-project/latest_build/build/bin/clang-14(+0x4c148df)[0x5609f18fb8df]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN4llvm3sys17RunSignalHandlersEv+0x8c)[0x5609f18f9498]
/root/llvm-project/latest_build/build/bin/clang-14(+0x4c14149)[0x5609f18fb149]
/lib/x86_64-linux-gnu/libc.so.6(+0x42520)[0x7f0d7ef1a520]
/lib/x86_64-linux-gnu/libc.so.6(pthread_kill+0x12c)[0x7f0d7ef6ea7c]
/lib/x86_64-linux-gnu/libc.so.6(raise+0x16)[0x7f0d7ef1a476]
/lib/x86_64-linux-gnu/libc.so.6(abort+0xd3)[0x7f0d7ef007f3]
/lib/x86_64-linux-gnu/libc.so.6(+0x2871b)[0x7f0d7ef0071b]
/lib/x86_64-linux-gnu/libc.so.6(+0x39e96)[0x7f0d7ef11e96]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang4Sema19GetSignedVectorTypeENS_8QualTypeE+0x535)[0x5609f53dcd89]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang4Sema26CheckVectorCompareOperandsERNS_12ActionResultIPNS_4ExprELb1EEES5_NS_14SourceLocationENS_18BinaryOperatorKindE+0x349)[0x5609f53dd131]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang4Sema20CheckCompareOperandsERNS_12ActionResultIPNS_4ExprELb1EEES5_NS_14SourceLocationENS_18BinaryOperatorKindE+0x3c6)[0x5609f53d9fe6]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang4Sema18CreateBuiltinBinOpENS_14SourceLocationENS_18BinaryOperatorKindEPNS_4ExprES4_+0xb3b)[0x5609f53e5f6d]
/root/llvm-project/latest_build/build/bin/clang-14(+0x8f7e141)[0x5609f5c65141]
/root/llvm-project/latest_build/build/bin/clang-14(+0x8f60349)[0x5609f5c47349]
/root/llvm-project/latest_build/build/bin/clang-14(+0x8f506d4)[0x5609f5c376d4]
/root/llvm-project/latest_build/build/bin/clang-14(+0x8f59d8a)[0x5609f5c40d8a]
/root/llvm-project/latest_build/build/bin/clang-14(+0x8f500c8)[0x5609f5c370c8]
/root/llvm-project/latest_build/build/bin/clang-14(+0x8f57e88)[0x5609f5c3ee88]
/root/llvm-project/latest_build/build/bin/clang-14(+0x8f62737)[0x5609f5c49737]
/root/llvm-project/latest_build/build/bin/clang-14(+0x8f50cb5)[0x5609f5c37cb5]
/root/llvm-project/latest_build/build/bin/clang-14(+0x8f57313)[0x5609f5c3e313]
/root/llvm-project/latest_build/build/bin/clang-14(+0x8f7a5e9)[0x5609f5c615e9]
/root/llvm-project/latest_build/build/bin/clang-14(+0x8f5661c)[0x5609f5c3d61c]
/root/llvm-project/latest_build/build/bin/clang-14(+0x8f8175c)[0x5609f5c6875c]
/root/llvm-project/latest_build/build/bin/clang-14(+0x8f740fd)[0x5609f5c5b0fd]
/root/llvm-project/latest_build/build/bin/clang-14(+0x8f55881)[0x5609f5c3c881]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang4Sema9SubstStmtEPNS_4StmtERKNS_30MultiLevelTemplateArgumentListE+0xa8)[0x5609f5c33a62]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang4Sema29InstantiateFunctionDefinitionENS_14SourceLocationEPNS_12FunctionDeclEbbb+0xd56)[0x5609f5c9eb1e]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang4Sema28PerformPendingInstantiationsEb+0x202)[0x5609f5ca334e]
/root/llvm-project/latest_build/build/bin/clang-14(+0x90020e2)[0x5609f5ce90e2]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang4Sema29InstantiateFunctionDefinitionENS_14SourceLocationEPNS_12FunctionDeclEbbb+0xef3)[0x5609f5c9ecbb]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang4Sema28PerformPendingInstantiationsEb+0x202)[0x5609f5ca334e]
/root/llvm-project/latest_build/build/bin/clang-14(+0x90020e2)[0x5609f5ce90e2]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang4Sema29InstantiateFunctionDefinitionENS_14SourceLocationEPNS_12FunctionDeclEbbb+0xef3)[0x5609f5c9ecbb]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang4Sema28PerformPendingInstantiationsEb+0x202)[0x5609f5ca334e]
/root/llvm-project/latest_build/build/bin/clang-14(+0x90020e2)[0x5609f5ce90e2]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang4Sema29InstantiateFunctionDefinitionENS_14SourceLocationEPNS_12FunctionDeclEbbb+0xef3)[0x5609f5c9ecbb]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang4Sema28PerformPendingInstantiationsEb+0x202)[0x5609f5ca334e]
/root/llvm-project/latest_build/build/bin/clang-14(+0x90020e2)[0x5609f5ce90e2]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang4Sema29InstantiateFunctionDefinitionENS_14SourceLocationEPNS_12FunctionDeclEbbb+0xef3)[0x5609f5c9ecbb]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang4Sema28PerformPendingInstantiationsEb+0x202)[0x5609f5ca334e]
/root/llvm-project/latest_build/build/bin/clang-14(+0x90020e2)[0x5609f5ce90e2]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang4Sema29InstantiateFunctionDefinitionENS_14SourceLocationEPNS_12FunctionDeclEbbb+0xef3)[0x5609f5c9ecbb]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang4Sema28PerformPendingInstantiationsEb+0x202)[0x5609f5ca334e]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang4Sema33ActOnEndOfTranslationUnitFragmentENS0_14TUFragmentKindE+0x2c4)[0x5609f4f12a28]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang4Sema25ActOnEndOfTranslationUnitEv+0x10b)[0x5609f4f12cc3]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang6Parser17ParseTopLevelDeclERNS_9OpaquePtrINS_12DeclGroupRefEEEb+0x4ea)[0x5609f4d9a852]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang8ParseASTERNS_4SemaEbb+0x2b8)[0x5609f4d95f01]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang17ASTFrontendAction13ExecuteActionEv+0x147)[0x5609f27c1967]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang13CodeGenAction13ExecuteActionEv+0x6a)[0x5609f3247074]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang14FrontendAction7ExecuteEv+0x9e)[0x5609f27c1216]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang16CompilerInstance13ExecuteActionERNS_14FrontendActionE+0x3bf)[0x5609f26f9b6b]
/root/llvm-project/latest_build/build/bin/clang-14(_ZN5clang25ExecuteCompilerInvocationEPNS_16CompilerInstanceE+0x3b3)[0x5609f2968b09]
/root/llvm-project/latest_build/build/bin/clang-14(_Z8cc1_mainN4llvm8ArrayRefIPKcEES2_Pv+0x619)[0x5609ee28ff9f]
/root/llvm-project/latest_build/build/bin/clang-14(+0x159c873)[0x5609ee283873]
/root/llvm-project/latest_build/build/bin/clang-14(main+0x4f0)[0x5609ee283fad]
/lib/x86_64-linux-gnu/libc.so.6(+0x29d90)[0x7f0d7ef01d90]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80)[0x7f0d7ef01e40]
/root/llvm-project/latest_build/build/bin/clang-14(_start+0x25)[0x5609ee281f85]
clang-14: error: unable to execute command: Aborted (core dumped)
clang-14: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 14.0.0 (https://github.com/joy2myself/llvm-project 76e2d2c5d64aaaa993d459bb4518b1d693ad14ec)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /root/llvm-project/latest_build/build/./bin

fepicture added a commit to fepicture/llvm-project that referenced this issue Sep 8, 2022
fepicture added a commit to fepicture/llvm-project that referenced this issue Sep 8, 2022
fepicture added a commit to fepicture/llvm-project that referenced this issue Sep 8, 2022
fepicture added a commit to fepicture/llvm-project that referenced this issue Sep 12, 2022
fepicture added a commit to fepicture/llvm-project that referenced this issue Sep 23, 2022
fepicture added a commit to fepicture/llvm-project that referenced this issue Sep 26, 2022
melonedo added a commit to melonedo/llvm-project that referenced this issue Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants