ralna / spral

Sparse Parallel Robust Algorithms Library
https://ralna.github.io/spral/
Other
104 stars 27 forks source link

[macOS] Build with Clang fails: `ldlt_app.cxx:2385:37: error: no matching constructor for initialization of 'std::vector<int, IntAlloc>'` #166

Closed barracuda156 closed 10 months ago

barracuda156 commented 10 months ago

This was on Sonoma aarch64:

:info:build src/ssids/cpu/kernels/ldlt_app.cxx:2385:37: error: no matching constructor for initialization of 'std::vector<int, IntAlloc>' (aka 'vector<int, BuddyAllocator<int, std::allocator<double>>>')
:info:build          std::vector<int, IntAlloc> failed_perm(n-num_elim, alloc);
:info:build                                     ^           ~~~~~~~~~~~~~~~~~
:info:build src/ssids/cpu/kernels/ldlt_app.cxx:2530:9: note: in instantiation of member function 'spral::ssids::cpu::ldlt_app_internal::LDLT<double, 32, spral::ssids::cpu::ldlt_app_internal::CopyBackup<double, spral::ssids::cpu::BuddyAllocator<double, std::allocator<double>>>, true, false, spral::ssids::cpu::BuddyAllocator<double, std::allocator<double>>>::factor' requested here
:info:build       ::factor(
:info:build         ^
. . .
:info:build src/ssids/cpu/kernels/ldlt_app.cxx:2400:33: error: no matching constructor for initialization of 'std::vector<double, TAlloc>' (aka 'vector<double, BuddyAllocator<double, std::allocator<double>>>')
:info:build          std::vector<T, TAlloc> failed_rect(nfail*(m-n), alloc);
:info:build                                 ^           ~~~~~~~~~~~~~~~~~~

Etc.

barracuda156 commented 10 months ago

Also confirmed on macOS 13 x86_64:

    /opt/local/bin/clang++-mp-16 -DHAVE_CONFIG_H -I.   -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I./include -I./src -std=c++11 -fopenmp  -I/opt/local/include/libxml2 -pipe -Os -stdlib=libc++ -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -arch x86_64 -MT src/ssids/cpu/kernels/ldlt_app.o -MD -MP -MF $depbase.Tpo -c -o src/ssids/cpu/kernels/ldlt_app.o src/ssids/cpu/kernels/ldlt_app.cxx &&\
    mv -f $depbase.Tpo $depbase.Po
  src/ssids/cpu/kernels/ldlt_app.cxx:2385:37: error: no matching constructor for initialization of 'std::vector<int, IntAlloc>' (aka 'vector<int, BuddyAllocator<int, std::allocator<double>>>')
           std::vector<int, IntAlloc> failed_perm(n-num_elim, alloc);
                                      ^           ~~~~~~~~~~~~~~~~~
  src/ssids/cpu/kernels/ldlt_app.cxx:2530:9: note: in instantiation of member function 'spral::ssids::cpu::ldlt_app_internal::LDLT<double, 32, spral::ssids::cpu::ldlt_app_internal::CopyBackup<double, spral::ssids::cpu::BuddyAllocator<double, std::allocator<double>>>, true, false, spral::ssids::cpu::BuddyAllocator<double, std::allocator<double>>>::factor' requested here
        ::factor(
          ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:395:57: note: candidate constructor not viable: no known conversion from 'const spral::ssids::cpu::BuddyAllocator<double, std::allocator<double>>' to 'const value_type' (aka 'const int') for 2nd argument
      _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(size_type __n, const value_type& __x);
                                                          ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:459:57: note: candidate constructor not viable: no known conversion from 'int' to 'const vector<int, BuddyAllocator<int, allocator<double>>>' for 1st argument
      _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(const vector& __x, const __type_identity_t<allocator_type>& __a);
                                                          ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:468:5: note: candidate constructor not viable: no known conversion from 'int' to 'initializer_list<value_type>' (aka 'initializer_list<int>') for 1st argument
      vector(initializer_list<value_type> __il, const allocator_type& __a);
      ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:484:5: note: candidate constructor not viable: no known conversion from 'int' to 'vector<int, BuddyAllocator<int, allocator<double>>>' for 1st argument
      vector(vector&& __x, const __type_identity_t<allocator_type>& __a);
      ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:414:55: note: candidate template ignored: deduced conflicting types for parameter '_InputIterator' ('int' vs. 'spral::ssids::cpu::BuddyAllocator<double, std::allocator<double>>')
    _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_InputIterator __first, _InputIterator __last);
                                                        ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:427:55: note: candidate template ignored: deduced conflicting types for parameter '_ForwardIterator' ('int' vs. 'spral::ssids::cpu::BuddyAllocator<double, std::allocator<double>>')
    _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_ForwardIterator __first, _ForwardIterator __last);
                                                        ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:381:66: note: candidate constructor not viable: requires single argument '__a', but 2 arguments were provided
      _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(const allocator_type& __a)
                                                                   ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:391:66: note: candidate constructor not viable: requires single argument '__n', but 2 arguments were provided
      _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n);
                                                                   ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:458:57: note: candidate constructor not viable: requires single argument '__x', but 2 arguments were provided
      _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(const vector& __x);
                                                          ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:465:5: note: candidate constructor not viable: requires single argument '__il', but 2 arguments were provided
      vector(initializer_list<value_type> __il);
      ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:476:5: note: candidate constructor not viable: requires single argument '__x', but 2 arguments were provided
      vector(vector&& __x)
      ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:399:5: note: candidate constructor template not viable: requires 3 arguments, but 2 were provided
      vector(size_type __n, const value_type& __x, const allocator_type& __a)
      ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:420:3: note: candidate constructor template not viable: requires 3 arguments, but 2 were provided
    vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a);
    ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:434:3: note: candidate constructor template not viable: requires 3 arguments, but 2 were provided
    vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a);
    ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:377:5: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
      vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
      ^
  src/ssids/cpu/kernels/ldlt_app.cxx:2399:33: error: no matching constructor for initialization of 'std::vector<double, TAlloc>' (aka 'vector<double, BuddyAllocator<double, std::allocator<double>>>')
           std::vector<T, TAlloc> failed_diag(nfail*n, alloc);
                                  ^           ~~~~~~~~~~~~~~
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:395:57: note: candidate constructor not viable: no known conversion from 'const spral::ssids::cpu::BuddyAllocator<double, std::allocator<double>>' to 'const value_type' (aka 'const double') for 2nd argument
      _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(size_type __n, const value_type& __x);
                                                          ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:459:57: note: candidate constructor not viable: no known conversion from 'int' to 'const vector<double, BuddyAllocator<double, allocator<double>>>' for 1st argument
      _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(const vector& __x, const __type_identity_t<allocator_type>& __a);
                                                          ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:468:5: note: candidate constructor not viable: no known conversion from 'int' to 'initializer_list<value_type>' (aka 'initializer_list<double>') for 1st argument
      vector(initializer_list<value_type> __il, const allocator_type& __a);
      ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:484:5: note: candidate constructor not viable: no known conversion from 'int' to 'vector<double, BuddyAllocator<double, allocator<double>>>' for 1st argument
      vector(vector&& __x, const __type_identity_t<allocator_type>& __a);
      ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:414:55: note: candidate template ignored: deduced conflicting types for parameter '_InputIterator' ('int' vs. 'spral::ssids::cpu::BuddyAllocator<double, std::allocator<double>>')
    _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_InputIterator __first, _InputIterator __last);
                                                        ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:427:55: note: candidate template ignored: deduced conflicting types for parameter '_ForwardIterator' ('int' vs. 'spral::ssids::cpu::BuddyAllocator<double, std::allocator<double>>')
    _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_ForwardIterator __first, _ForwardIterator __last);
                                                        ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:381:66: note: candidate constructor not viable: requires single argument '__a', but 2 arguments were provided
      _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(const allocator_type& __a)
                                                                   ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:391:66: note: candidate constructor not viable: requires single argument '__n', but 2 arguments were provided
      _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n);
                                                                   ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:458:57: note: candidate constructor not viable: requires single argument '__x', but 2 arguments were provided
      _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(const vector& __x);
                                                          ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:465:5: note: candidate constructor not viable: requires single argument '__il', but 2 arguments were provided
      vector(initializer_list<value_type> __il);
      ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:476:5: note: candidate constructor not viable: requires single argument '__x', but 2 arguments were provided
      vector(vector&& __x)
      ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:399:5: note: candidate constructor template not viable: requires 3 arguments, but 2 were provided
      vector(size_type __n, const value_type& __x, const allocator_type& __a)
      ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:420:3: note: candidate constructor template not viable: requires 3 arguments, but 2 were provided
    vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a);
    ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:434:3: note: candidate constructor template not viable: requires 3 arguments, but 2 were provided
    vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a);
    ^
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:377:5: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
      vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
      ^
  src/ssids/cpu/kernels/ldlt_app.cxx:2400:33: error: no matching constructor for initialization of 'std::vector<double, TAlloc>' (aka 'vector<double, BuddyAllocator<double, std::allocator<double>>>')
           std::vector<T, TAlloc> failed_rect(nfail*(m-n), alloc);
                                  ^           ~~~~~~~~~~~~~~~~~~
  /opt/local/libexec/llvm-16/bin/../include/c++/v1/vector:395:57: note: candidate constructor not viable: no known conversion from 'const spral::ssids::cpu::BuddyAllocator<double, std::allocator<double>>' to 'const value_type' (aka 'const double') for 2nd argument
mjacobse commented 10 months ago

Can confirm this on Linux with CXX=clang++ and CXXFLAGS=-stdlib=libc++. libc++ reveals that this code relies on a constructor that was only introduced in C++14, but stdlibc++ silently (and wrongfully) provided for us even in C++11. Will create a pull request.

amontoison commented 10 months ago

Do you compile with the old build system or with Meson? We request C++17 wih Meson: https://github.com/ralna/spral/blob/master/meson.build#L13

If you fix the issue for the Autotools build system, should we change it for C++11 or C++14 now in Meson?

mjacobse commented 10 months ago

Oh I was not aware of Meson setting a different C++ standard, I was using the old build system still.

I think this is a decision on what C++ standard (and consequently what compiler versions) SPRAL should require/support. If this is meant to be C++11, then I think we should merge #168 and set the standard in Meson to C++11 to be clear about what is supported. If the decision is made to move to a newer standard, then we can disregard #168. But I think then the C++ standard in the autotools files should be updated accordingly, at least as long as those files still remain in the repository, otherwise this may continue to cause confusion.

amontoison commented 10 months ago

We set a different C++ standard because we were unable to compile without this flag... The goal was not to move to a newer standard.

Can you modify the C++ standard here in your PR #168? If the tests pass with Meson, I will merge the PR.

mjacobse commented 10 months ago

Oh I understand now, thanks. I added that change to the PR.

amontoison commented 10 months ago

Thanks @mjacobse!

barracuda156 commented 10 months ago

Do you compile with the old build system or with Meson?

I think released version did not yet have meson support. As long as autotools work fine, I will perhaps keep it at that. Personally I do not find meson system either user-friendly or convenient for development.

amontoison commented 10 months ago

I asked this question because we fix a few issues with it and we run more tests with meson test -C .... We plan to drop the autotools build system in the future.