xsimd icon indicating copy to clipboard operation
xsimd copied to clipboard

Compile error with xsimd on on ARM64/Apple Silicon

Open hameer-spire opened this issue 2 years ago • 10 comments

Here is the traceback, unfortunately I cannot share a bigger reproducible due to proprietary code, but feel free to ask for more information.

The xtensor-dependent program compiles fine with xsimd off.

error: no viable conversion from returned value of type 'xsimd::batch_bool<float, xsimd::neon64>' to function return type 'simd_return_type<float>' (aka 'xsimd::batch<float>')

hameer-spire avatar May 12 '22 19:05 hameer-spire

MCVE:

#include <xtensor/xtensor.hpp>

int main() {
    xt::xtensor<double, 2> a = {{1}};
    xt::xtensor<double, 2> b = {{1}};
    auto out = xt::eval(!(xt::isnan(a) | xt::isnan(b)));
}
Complete log with xsimd
Consolidate compiler generated dependencies of target xtensor_test
[ 50%] Building CXX object CMakeFiles/xtensor_test.dir/main.cpp.o
In file included from /Users/habbasi/Code/xtensor-test/main.cpp:1:
In file included from /Users/habbasi/mambaforge/envs/cpp/include/xtensor/xtensor.hpp:20:
In file included from /Users/habbasi/mambaforge/envs/cpp/include/xtensor/xcontainer.hpp:25:
In file included from /Users/habbasi/mambaforge/envs/cpp/include/xtensor/xmath.hpp:28:
In file included from /Users/habbasi/mambaforge/envs/cpp/include/xtensor/xmanipulation.hpp:13:
In file included from /Users/habbasi/mambaforge/envs/cpp/include/xtensor/xbuilder.hpp:30:
/Users/habbasi/mambaforge/envs/cpp/include/xtensor/xfunction.hpp:772:16: error: no viable conversion from returned value of type 'xsimd::batch_bool<double, xsimd::neon64>' to function return type 'simd_return_type<double>' (aka 'xsimd::batch<double>')
        return load_simd_impl<align, requested_type, N>(std::make_index_sequence<sizeof...(CT)>(), i);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/habbasi/mambaforge/envs/cpp/include/xtensor/xfunction.hpp:830:23: note: in instantiation of function template specialization 'xt::xfunction<xt::detail::bitwise_or, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>>::load_simd<xt::inner_aligned_mode, double, 2UL>' requested here
            .template load_simd<align, requested_type>(i))...);
                      ^
/Users/habbasi/mambaforge/envs/cpp/include/xtensor/xassign.hpp:686:67: note: in instantiation of function template specialization 'xt::xfunction<xt::detail::logical_not, xt::xfunction<xt::detail::bitwise_or, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>>>::load_simd<xt::inner_aligned_mode, double, 2UL>' requested here
            e1.template store_simd<lhs_align_mode>(i, e2.template load_simd<rhs_align_mode, value_type>(i));
                                                                  ^
/Users/habbasi/mambaforge/envs/cpp/include/xtensor/xassign.hpp:391:47: note: in instantiation of function template specialization 'xt::linear_assigner<true>::run<xt::xtensor_container<xt::uvector<bool, xsimd::aligned_allocator<bool, 16>>, 2, xt::layout_type::row_major>, xt::xfunction<xt::detail::logical_not, xt::xfunction<xt::detail::bitwise_or, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>>>>' requested here
                linear_assigner<simd_assign>::run(de1, de2);
                                              ^
/Users/habbasi/mambaforge/envs/cpp/include/xtensor/xassign.hpp:414:20: note: in instantiation of function template specialization 'xt::xexpression_assigner_base<xt::xtensor_expression_tag>::assign_data<xt::xtensor_container<xt::uvector<bool, xsimd::aligned_allocator<bool, 16>>, 2, xt::layout_type::row_major>, xt::xfunction<xt::detail::logical_not, xt::xfunction<xt::detail::bitwise_or, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>>>>' requested here
        base_type::assign_data(e1, e2, trivial_broadcast);
                   ^
/Users/habbasi/mambaforge/envs/cpp/include/xtensor/xassign.hpp:205:40: note: in instantiation of function template specialization 'xt::xexpression_assigner<xt::xtensor_expression_tag>::assign_xexpression<xt::xexpression<xt::xtensor_container<xt::uvector<bool, xsimd::aligned_allocator<bool, 16>>, 2, xt::layout_type::row_major>>, xt::xexpression<xt::xfunction<xt::detail::logical_not, xt::xfunction<xt::detail::bitwise_or, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>>>>>' requested here
            xexpression_assigner<tag>::assign_xexpression(e1, e2);
                                       ^
/Users/habbasi/mambaforge/envs/cpp/include/xtensor/xsemantic.hpp:623:13: note: in instantiation of function template specialization 'xt::assign_xexpression<xt::xtensor_container<xt::uvector<bool, xsimd::aligned_allocator<bool, 16>>, 2, xt::layout_type::row_major>, xt::xfunction<xt::detail::logical_not, xt::xfunction<xt::detail::bitwise_or, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>>>>' requested here
        xt::assign_xexpression(*this, e);
            ^
/Users/habbasi/mambaforge/envs/cpp/include/xtensor/xsemantic.hpp:489:37: note: in instantiation of function template specialization 'xt::xcontainer_semantic<xt::xtensor_container<xt::uvector<bool, xsimd::aligned_allocator<bool, 16>>, 2, xt::layout_type::row_major>>::assign_xexpression<xt::xfunction<xt::detail::logical_not, xt::xfunction<xt::detail::bitwise_or, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>>>>' requested here
        return this->derived_cast().assign_xexpression(e);
                                    ^
/Users/habbasi/mambaforge/envs/cpp/include/xtensor/xtensor.hpp:555:24: note: in instantiation of function template specialization 'xt::xsemantic_base<xt::xtensor_container<xt::uvector<bool, xsimd::aligned_allocator<bool, 16>>, 2, xt::layout_type::row_major>>::assign<xt::xfunction<xt::detail::logical_not, xt::xfunction<xt::detail::bitwise_or, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>>>>' requested here
        semantic_base::assign(e);
                       ^
/Users/habbasi/mambaforge/envs/cpp/include/xtensor/xeval.hpp:48:16: note: in instantiation of function template specialization 'xt::xtensor_container<xt::uvector<bool, xsimd::aligned_allocator<bool, 16>>, 2, xt::layout_type::row_major>::xtensor_container<xt::xfunction<xt::detail::logical_not, xt::xfunction<xt::detail::bitwise_or, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>>>>' requested here
        return std::forward<T>(t);
               ^
/Users/habbasi/Code/xtensor-test/main.cpp:6:20: note: in instantiation of function template specialization 'xt::eval<xt::xfunction<xt::detail::logical_not, xt::xfunction<xt::detail::bitwise_or, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>>>>' requested here
    auto out = xt::eval(!(xt::isnan(a) | xt::isnan(b)));
                   ^
/Users/habbasi/mambaforge/envs/cpp/include/xsimd/config/../types/../types/xsimd_batch.hpp:46:11: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'xsimd::batch_bool<double, xsimd::neon64>' to 'const xsimd::batch<double> &' for 1st argument
    class batch : public types::simd_register<T, A>
          ^
/Users/habbasi/mambaforge/envs/cpp/include/xsimd/config/../types/../types/xsimd_batch.hpp:46:11: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'xsimd::batch_bool<double, xsimd::neon64>' to 'xsimd::batch<double> &&' for 1st argument
/Users/habbasi/mambaforge/envs/cpp/include/xsimd/config/../types/../types/xsimd_batch.hpp:58:9: note: candidate constructor not viable: no known conversion from 'xsimd::batch_bool<double, xsimd::neon64>' to 'double' for 1st argument
        batch(T val) noexcept;
        ^
/Users/habbasi/mambaforge/envs/cpp/include/xsimd/config/../types/../types/xsimd_batch.hpp:59:9: note: candidate constructor not viable: no known conversion from 'xsimd::batch_bool<double, xsimd::neon64>' to 'std::initializer_list<double>' for 1st argument
        batch(std::initializer_list<T> data) noexcept;
        ^
/Users/habbasi/mambaforge/envs/cpp/include/xsimd/config/../types/../types/xsimd_batch.hpp:61:9: note: candidate constructor not viable: no known conversion from 'xsimd::batch_bool<double, xsimd::neon64>' to 'xsimd::batch<double>::register_type' (aka 'float64x2_t') for 1st argument
        batch(register_type reg) noexcept;
        ^
/Users/habbasi/mambaforge/envs/cpp/include/xsimd/config/../types/../types/xsimd_batch.hpp:60:18: note: explicit constructor is not a candidate
        explicit batch(batch_bool_type const& b) noexcept;
                 ^
/Users/habbasi/mambaforge/envs/cpp/include/xsimd/arch/../types/xsimd_neon_register.hpp:101:9: note: candidate function
        XSIMD_DECLARE_SIMD_REGISTER(unsigned long long int, neon, detail::neon_vector_type<unsigned long long int>);
        ^
/Users/habbasi/mambaforge/envs/cpp/include/xsimd/config/../types/xsimd_register.hpp:41:9: note: expanded from macro 'XSIMD_DECLARE_SIMD_REGISTER'
        operator register_type() const noexcept { return data; }   \
        ^
In file included from /Users/habbasi/Code/xtensor-test/main.cpp:1:
In file included from /Users/habbasi/mambaforge/envs/cpp/include/xtensor/xtensor.hpp:20:
In file included from /Users/habbasi/mambaforge/envs/cpp/include/xtensor/xcontainer.hpp:25:
In file included from /Users/habbasi/mambaforge/envs/cpp/include/xtensor/xmath.hpp:28:
In file included from /Users/habbasi/mambaforge/envs/cpp/include/xtensor/xmanipulation.hpp:13:
In file included from /Users/habbasi/mambaforge/envs/cpp/include/xtensor/xbuilder.hpp:30:
/Users/habbasi/mambaforge/envs/cpp/include/xtensor/xfunction.hpp:1045:16: error: no viable conversion from returned value of type 'xsimd::batch_bool<double, xsimd::neon64>' to function return type 'simd_return_type<double>' (aka 'xsimd::batch<double>')
        return (p_f->m_f.simd_apply)(std::get<I>(m_st). template step_simd<T>()...);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/habbasi/mambaforge/envs/cpp/include/xtensor/xfunction.hpp:1052:16: note: in instantiation of function template specialization 'xt::xfunction_stepper<xt::detail::bitwise_or, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>>::step_simd_impl<double, 0UL, 1UL>' requested here
        return step_simd_impl<T>(std::make_index_sequence<sizeof...(CT)>());
               ^
/Users/habbasi/mambaforge/envs/cpp/include/xtensor/xfunction.hpp:1045:66: note: in instantiation of function template specialization 'xt::xfunction_stepper<xt::detail::bitwise_or, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>>::step_simd<double>' requested here
        return (p_f->m_f.simd_apply)(std::get<I>(m_st). template step_simd<T>()...);
                                                                 ^
/Users/habbasi/mambaforge/envs/cpp/include/xtensor/xfunction.hpp:1052:16: note: in instantiation of function template specialization 'xt::xfunction_stepper<xt::detail::logical_not, xt::xfunction<xt::detail::bitwise_or, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>>>::step_simd_impl<double, 0UL>' requested here
        return step_simd_impl<T>(std::make_index_sequence<sizeof...(CT)>());
               ^
/Users/habbasi/mambaforge/envs/cpp/include/xtensor/xassign.hpp:972:61: note: in instantiation of function template specialization 'xt::xfunction_stepper<xt::detail::logical_not, xt::xfunction<xt::detail::bitwise_or, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>>>::step_simd<double>' requested here
                res_stepper.store_simd(fct_stepper.template step_simd<value_type>());
                                                            ^
/Users/habbasi/mambaforge/envs/cpp/include/xtensor/xassign.hpp:400:57: note: in instantiation of function template specialization 'xt::strided_loop_assigner<true>::run<xt::xtensor_container<xt::uvector<bool, xsimd::aligned_allocator<bool, 16>>, 2, xt::layout_type::row_major>, xt::xfunction<xt::detail::logical_not, xt::xfunction<xt::detail::bitwise_or, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>>>>' requested here
            strided_loop_assigner<simd_strided_assign>::run(de1, de2);
                                                        ^
/Users/habbasi/mambaforge/envs/cpp/include/xtensor/xassign.hpp:414:20: note: (skipping 2 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
        base_type::assign_data(e1, e2, trivial_broadcast);
                   ^
/Users/habbasi/mambaforge/envs/cpp/include/xtensor/xsemantic.hpp:623:13: note: in instantiation of function template specialization 'xt::assign_xexpression<xt::xtensor_container<xt::uvector<bool, xsimd::aligned_allocator<bool, 16>>, 2, xt::layout_type::row_major>, xt::xfunction<xt::detail::logical_not, xt::xfunction<xt::detail::bitwise_or, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>>>>' requested here
        xt::assign_xexpression(*this, e);
            ^
/Users/habbasi/mambaforge/envs/cpp/include/xtensor/xsemantic.hpp:489:37: note: in instantiation of function template specialization 'xt::xcontainer_semantic<xt::xtensor_container<xt::uvector<bool, xsimd::aligned_allocator<bool, 16>>, 2, xt::layout_type::row_major>>::assign_xexpression<xt::xfunction<xt::detail::logical_not, xt::xfunction<xt::detail::bitwise_or, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>>>>' requested here
        return this->derived_cast().assign_xexpression(e);
                                    ^
/Users/habbasi/mambaforge/envs/cpp/include/xtensor/xtensor.hpp:555:24: note: in instantiation of function template specialization 'xt::xsemantic_base<xt::xtensor_container<xt::uvector<bool, xsimd::aligned_allocator<bool, 16>>, 2, xt::layout_type::row_major>>::assign<xt::xfunction<xt::detail::logical_not, xt::xfunction<xt::detail::bitwise_or, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>>>>' requested here
        semantic_base::assign(e);
                       ^
/Users/habbasi/mambaforge/envs/cpp/include/xtensor/xeval.hpp:48:16: note: in instantiation of function template specialization 'xt::xtensor_container<xt::uvector<bool, xsimd::aligned_allocator<bool, 16>>, 2, xt::layout_type::row_major>::xtensor_container<xt::xfunction<xt::detail::logical_not, xt::xfunction<xt::detail::bitwise_or, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>>>>' requested here
        return std::forward<T>(t);
               ^
/Users/habbasi/Code/xtensor-test/main.cpp:6:20: note: in instantiation of function template specialization 'xt::eval<xt::xfunction<xt::detail::logical_not, xt::xfunction<xt::detail::bitwise_or, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>, xt::xfunction<xt::math::isnan_fun, const xt::xtensor_container<xt::uvector<double, xsimd::aligned_allocator<double, 16>>, 2, xt::layout_type::row_major> &>>>>' requested here
    auto out = xt::eval(!(xt::isnan(a) | xt::isnan(b)));
                   ^
/Users/habbasi/mambaforge/envs/cpp/include/xsimd/config/../types/../types/xsimd_batch.hpp:46:11: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'xsimd::batch_bool<double, xsimd::neon64>' to 'const xsimd::batch<double> &' for 1st argument
    class batch : public types::simd_register<T, A>
          ^
/Users/habbasi/mambaforge/envs/cpp/include/xsimd/config/../types/../types/xsimd_batch.hpp:46:11: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'xsimd::batch_bool<double, xsimd::neon64>' to 'xsimd::batch<double> &&' for 1st argument
/Users/habbasi/mambaforge/envs/cpp/include/xsimd/config/../types/../types/xsimd_batch.hpp:58:9: note: candidate constructor not viable: no known conversion from 'xsimd::batch_bool<double, xsimd::neon64>' to 'double' for 1st argument
        batch(T val) noexcept;
        ^
/Users/habbasi/mambaforge/envs/cpp/include/xsimd/config/../types/../types/xsimd_batch.hpp:59:9: note: candidate constructor not viable: no known conversion from 'xsimd::batch_bool<double, xsimd::neon64>' to 'std::initializer_list<double>' for 1st argument
        batch(std::initializer_list<T> data) noexcept;
        ^
/Users/habbasi/mambaforge/envs/cpp/include/xsimd/config/../types/../types/xsimd_batch.hpp:61:9: note: candidate constructor not viable: no known conversion from 'xsimd::batch_bool<double, xsimd::neon64>' to 'xsimd::batch<double>::register_type' (aka 'float64x2_t') for 1st argument
        batch(register_type reg) noexcept;
        ^
/Users/habbasi/mambaforge/envs/cpp/include/xsimd/config/../types/../types/xsimd_batch.hpp:60:18: note: explicit constructor is not a candidate
        explicit batch(batch_bool_type const& b) noexcept;
                 ^
/Users/habbasi/mambaforge/envs/cpp/include/xsimd/arch/../types/xsimd_neon_register.hpp:101:9: note: candidate function
        XSIMD_DECLARE_SIMD_REGISTER(unsigned long long int, neon, detail::neon_vector_type<unsigned long long int>);
        ^
/Users/habbasi/mambaforge/envs/cpp/include/xsimd/config/../types/xsimd_register.hpp:41:9: note: expanded from macro 'XSIMD_DECLARE_SIMD_REGISTER'
        operator register_type() const noexcept { return data; }   \
        ^
2 errors generated.
make[2]: *** [CMakeFiles/xtensor_test.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/xtensor_test.dir/all] Error 2
make: *** [all] Error 2

Compiles fine without xsimd.

hameerabbasi avatar May 15 '22 16:05 hameerabbasi

Godbolt link: https://godbolt.org/z/vj4fEGzqq

hameer-spire avatar May 16 '22 10:05 hameer-spire

Wihch version of xtensor and xsimd do you use? With xtensor 0.24.2 (and master), and xsimd 8.1.0, everything builds and works fine.

JohanMabille avatar May 18 '22 14:05 JohanMabille

Then I think the issue may be specific to ARM64/Apple Silicon. I'm on those exact versions, I'm uploading a project including an environment.yml and a ./reproduce.sh. xtensor-test.zip

hameerabbasi avatar May 18 '22 14:05 hameerabbasi

I have verified this isn't an issue on Linux/AMD64.

hameer-spire avatar Jun 27 '22 07:06 hameer-spire

I think I'm seeing the same thing with https://github.com/facebookincubator/velox

FAILED: velox/type/CMakeFiles/velox_type.dir/Filter.cpp.o
ccache /usr/bin/c++ -DBOOST_ALL_NO_LIB -DBOOST_ATOMIC_DYN_LINK -DBOOST_CONTEXT_DYN_LINK -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_PROGRAM_OPTIONS_DYN_LINK -DBOOST_REGEX_DYN_LINK -DBOOST_SYSTEM_DYN_LINK -DBOOST_THREAD_DYN_LINK -DFMT_LOCALE -DGFLAGS_IS_A_DLL=0 -I/home/ubuntu/velox/. -I/home/ubuntu/velox/velox/external/xxhash -I/home/ubuntu/velox/third_party/xsimd/include -isystem /home/ubuntu/velox/velox -isystem /home/ubuntu/velox/velox/external -isystem /home/ubuntu/velox/velox/external/duckdb -isystem /home/ubuntu/velox/velox/external/duckdb/tpch/dbgen/include -mcpu=native -std=c++17 -Wno-psabi -D USE_VELOX_COMMON_BASE -D HAS_UNCAUGHT_EXCEPTIONS -O3 -DNDEBUG -std=gnu++17 -MD -MT velox/type/CMakeFiles/velox_type.dir/Filter.cpp.o -MF velox/type/CMakeFiles/velox_type.dir/Filter.cpp.o.d -o velox/type/CMakeFiles/velox_type.dir/Filter.cpp.o -c /home/ubuntu/velox/velox/type/Filter.cpp
/home/ubuntu/velox/velox/type/Filter.cpp: In member function ‘virtual xsimd::batch_bool<long int> facebook::velox::common::BigintValuesUsingHashTable::testValues(xsimd::batch<long int>) const’:
/home/ubuntu/velox/velox/type/Filter.cpp:219:57: error: no matching function for call to ‘xsimd::batch<long unsigned int>::batch(xsimd::batch<long int>&)’
  219 |   xsimd::batch<int64_t> indices(xsimd::batch<uint64_t>(x) * M & sizeMask_);
      |                                                         ^
In file included from /home/ubuntu/velox/third_party/xsimd/include/xsimd/xsimd.hpp:61,
                 from /home/ubuntu/velox/./velox/common/base/SimdUtil.h:24,
                 from /home/ubuntu/velox/./velox/type/Filter.h:28,
                 from /home/ubuntu/velox/velox/type/Filter.cpp:25:
/home/ubuntu/velox/third_party/xsimd/include/xsimd/types/xsimd_batch.hpp:49:9: note: candidate: ‘template<class ... Ts> xsimd::batch<T, A>::batch(T, T, Ts ...) [with Ts = {Ts ...}; T = long unsigned int; A = xsimd::neon64]’
   49 |         batch(T val0, T val1, Ts... vals) noexcept;
      |         ^~~~~
/home/ubuntu/velox/third_party/xsimd/include/xsimd/types/xsimd_batch.hpp:49:9: note:   template argument deduction/substitution failed:
/home/ubuntu/velox/velox/type/Filter.cpp:219:57: note:   candidate expects at least 2 arguments, 1 provided
  219 |   xsimd::batch<int64_t> indices(xsimd::batch<uint64_t>(x) * M & sizeMask_);
      |                                                         ^
In file included from /home/ubuntu/velox/third_party/xsimd/include/xsimd/xsimd.hpp:61,
                 from /home/ubuntu/velox/./velox/common/base/SimdUtil.h:24,
                 from /home/ubuntu/velox/./velox/type/Filter.h:28,
                 from /home/ubuntu/velox/velox/type/Filter.cpp:25:
/home/ubuntu/velox/third_party/xsimd/include/xsimd/types/xsimd_batch.hpp:467:12: note: candidate: ‘xsimd::batch<T, A>::batch(xsimd::batch<T, A>::register_type) [with T = long unsigned int; A = xsimd::neon64; xsimd::batch<T, A>::register_type = std::conditional<false, __Int64x2_t, __Uint64x2_t>::type]’
  467 |     inline batch<T, A>::batch(register_type reg) noexcept
      |            ^~~~~~~~~~~
/home/ubuntu/velox/third_party/xsimd/include/xsimd/types/xsimd_batch.hpp:467:45: note:   no known conversion for argument 1 from ‘xsimd::batch<long int>’ to ‘xsimd::batch<long unsigned int>::register_type’ {aka ‘std::conditional<false, __Int64x2_t, __Uint64x2_t>::type’}
  467 |     inline batch<T, A>::batch(register_type reg) noexcept
      |                               ~~~~~~~~~~~~~~^~~
/home/ubuntu/velox/third_party/xsimd/include/xsimd/types/xsimd_batch.hpp:457:12: note: candidate: ‘xsimd::batch<T, A>::batch(const xsimd::batch_bool<T, A>&) [with T = long unsigned int; A = xsimd::neon64]’
  457 |     inline batch<T, A>::batch(batch_bool<T, A> const& b) noexcept
      |            ^~~~~~~~~~~
/home/ubuntu/velox/third_party/xsimd/include/xsimd/types/xsimd_batch.hpp:457:55: note:   no known conversion for argument 1 from ‘xsimd::batch<long int>’ to ‘const xsimd::batch_bool<long unsigned int, xsimd::neon64>&’
  457 |     inline batch<T, A>::batch(batch_bool<T, A> const& b) noexcept
      |                               ~~~~~~~~~~~~~~~~~~~~~~~~^
/home/ubuntu/velox/third_party/xsimd/include/xsimd/types/xsimd_batch.hpp:434:12: note: candidate: ‘xsimd::batch<T, A>::batch(T) [with T = long unsigned int; A = xsimd::neon64]’
  434 |     inline batch<T, A>::batch(T val) noexcept
      |            ^~~~~~~~~~~
/home/ubuntu/velox/third_party/xsimd/include/xsimd/types/xsimd_batch.hpp:434:33: note:   no known conversion for argument 1 from ‘xsimd::batch<long int>’ to ‘long unsigned int’
  434 |     inline batch<T, A>::batch(T val) noexcept
      |                               ~~^~~
In file included from /home/ubuntu/velox/third_party/xsimd/include/xsimd/xsimd.hpp:61,
                 from /home/ubuntu/velox/./velox/common/base/SimdUtil.h:24,
                 from /home/ubuntu/velox/./velox/type/Filter.h:28,
                 from /home/ubuntu/velox/velox/type/Filter.cpp:25:
/home/ubuntu/velox/third_party/xsimd/include/xsimd/types/xsimd_batch.hpp:46:9: note: candidate: ‘xsimd::batch<T, A>::batch() [with T = long unsigned int; A = xsimd::neon64]’
   46 |         batch() = default; ///< Create a batch initialized with undefined values.
      |         ^~~~~
/home/ubuntu/velox/third_party/xsimd/include/xsimd/types/xsimd_batch.hpp:46:9: note:   candidate expects 0 arguments, 1 provided
In file included from /home/ubuntu/velox/third_party/xsimd/include/xsimd/xsimd.hpp:61,
                 from /home/ubuntu/velox/./velox/common/base/SimdUtil.h:24,
                 from /home/ubuntu/velox/./velox/type/Filter.h:28,
                 from /home/ubuntu/velox/velox/type/Filter.cpp:25:
/home/ubuntu/velox/third_party/xsimd/include/xsimd/types/xsimd_batch.hpp:35:11: note: candidate: ‘constexpr xsimd::batch<long unsigned int>::batch(const xsimd::batch<long unsigned int>&)’
   35 |     class batch : public types::simd_register<T, A>
      |           ^~~~~
/home/ubuntu/velox/third_party/xsimd/include/xsimd/types/xsimd_batch.hpp:35:11: note:   no known conversion for argument 1 from ‘xsimd::batch<long int>’ to ‘const xsimd::batch<long unsigned int>&’
/home/ubuntu/velox/third_party/xsimd/include/xsimd/types/xsimd_batch.hpp:35:11: note: candidate: ‘constexpr xsimd::batch<long unsigned int>::batch(xsimd::batch<long unsigned int>&&)’
/home/ubuntu/velox/third_party/xsimd/include/xsimd/types/xsimd_batch.hpp:35:11: note:   no known conversion for argument 1 from ‘xsimd::batch<long int>’ to ‘xsimd::batch<long unsigned int>&&’

jlinford avatar Jul 20 '22 15:07 jlinford

Solution: build with -flax-vector-conversions -fsigned-char

AVX uses the same register types for signed or unsigned types, e.g:

        XSIMD_DECLARE_SIMD_REGISTER(unsigned long int, avx, __m256i);
        XSIMD_DECLARE_SIMD_REGISTER(long int, avx, __m256i);

But NEON uses different types depending on signed-ness:

            template <class T>
            using neon_vector_type = typename std::conditional<std::is_signed<T>::value,
                                                               signed_neon_vector_type<T>,
                                                               unsigned_neon_vector_type<T>>::type;
...
        XSIMD_DECLARE_SIMD_REGISTER(long int, neon, detail::neon_vector_type<long int>);
        XSIMD_DECLARE_SIMD_REGISTER(unsigned long int, neon, detail::neon_vector_type<unsigned long int>);

We need -flax-vector-conversions to let GCC permit conversions between vectors with differing element types.

In other parts of the code, the signed-ness of char is assumed as signed, but by default on Arm it is unsigned. Use -fsigned-char to work around.

jlinford avatar Jul 20 '22 19:07 jlinford

Would it be possible then to add these flags in the CMakeLists.txt? I'll try to find out over the weekend where and add them myself.

hameerabbasi avatar Jul 21 '22 05:07 hameerabbasi

flax-vector-conversions should definitely be avoided as it allows hidden implicit conversions. batch_cast should be used to fix this kind of issue (the signed / unsigned one, the batch_bool => batch seems different).

JohanMabille avatar Jul 21 '22 07:07 JohanMabille

-flax-vector-conversions is just a work-around. The "right answer" is to use the appropriate vreinterpretq calls when performing operations like

    xsimd::batch<int64_t> x = {1, 2};
    // This fails to compile with ARM64 gcc 12.1
    // but it succeeds with x86-64 gcc 12.1
    xsimd::batch<uint64_t> y(x);

I started playing around in xsimd_neon_register.hpp to see if there was a way to do this at the register level, but it might have to happen in batch. This is more a job for someone with xsimd experience, and I'm just a neon nerd.

jlinford avatar Jul 21 '22 17:07 jlinford

@jlinford we have xsimd::bitwise_cast<T0>(xsimd::batch<T1,A>) to perform a reinterpret_cast between two different types. But when you just want to do a static_cast (which does not imply a vreinterpretq but ana ctual conversion). I checked and we don't have that particular cast, but we should, I'll add this.

serge-sans-paille avatar Mar 02 '23 20:03 serge-sans-paille