Skip to content

Ambiguous fma/fnma calls #1071

@Martmists-GH

Description

@Martmists-GH

Seems to only happen on exp and log, error:

/home/mart/git/kotlin/kt-ndarray-simd/xsimd/include/xsimd/types/xsimd_api.hpp:958:16: error: call to 'fnma' is ambiguous
        return kernel::fnma<A>(x, y, z, A {});
               ^~~~~~~~~~~~~~~
/home/mart/git/kotlin/kt-ndarray-simd/xsimd/include/xsimd/arch/./generic/xsimd_generic_math.hpp:816:26: note: in instantiation of function template specialization 'xsimd::fnma<double, xsimd::fma4>' requested here
                    hi = fnma(k, constants::log_2hi<batch_type>(), a);
                         ^
/home/mart/git/kotlin/kt-ndarray-simd/xsimd/include/xsimd/arch/./generic/xsimd_generic_math.hpp:903:43: note: in instantiation of member function 'xsimd::kernel::detail::exp_reduction<double, xsimd::fma4, xsimd::kernel::detail::exp_tag>::reduce' requested here
                batch_type k = reducer_t::reduce(self, hi, lo, x);
                                          ^
/home/mart/git/kotlin/kt-ndarray-simd/xsimd/include/xsimd/arch/./generic/xsimd_generic_math.hpp:915:28: note: in instantiation of function template specialization 'xsimd::kernel::detail::exp<xsimd::kernel::detail::exp_tag, xsimd::fma4>' requested here
            return detail::exp<detail::exp_tag>(self);
                           ^
/home/mart/git/kotlin/kt-ndarray-simd/xsimd/include/xsimd/types/xsimd_api.hpp:720:24: note: in instantiation of function template specialization 'xsimd::kernel::exp<xsimd::fma4, double>' requested here
        return kernel::exp<A>(x, A {});
                       ^
/home/mart/git/kotlin/kt-ndarray-simd/src/lib/arch/../cpp/math_priv.h:96:27: note: in instantiation of function template specialization 'xsimd::exp<double, xsimd::fma4>' requested here
        auto res = xsimd::exp(va);
                          ^
/home/mart/git/kotlin/kt-ndarray-simd/xsimd/include/xsimd/arch/./xsimd_fma4.hpp:32:39: note: candidate function [with A = xsimd::fma4]
        XSIMD_INLINE batch<double, A> fnma(simd_register<double, A> const& x, simd_register<double, A> const& y, simd_register<double, A> const& z, requires_arch<fma4>) noexcept
                                      ^
/home/mart/git/kotlin/kt-ndarray-simd/xsimd/include/xsimd/arch/./generic/xsimd_generic_arithmetic.hpp:102:34: note: candidate function [with A = xsimd::fma4, T = double]
        XSIMD_INLINE batch<T, A> fnma(batch<T, A> const& x, batch<T, A> const& y, batch<T, A> const& z, requires_arch<generic>) noexcept
                                 ^

Code:

struct _vec_exp { template <class Arch> void operator()(Arch, double* a, int n); };
static auto _vec_exp_dispatcher = xsimd::dispatch<arch_list>(_vec_exp{});
// extern for each arch here
template <class Arch> void _vec_exp::operator()(Arch, double* a, int n) {
    using batch = xsimd::batch<double, Arch>;

    std::size_t size = n - n % batch::size;

    for (std::size_t i = 0; i < size; i += batch::size) {
        auto va = batch::load_unaligned(&a[i]);
        auto res = xsimd::exp(va);
        xsimd::store_unaligned(&a[i], res);
    }

    for (std::size_t i = size; i < n; ++i) {
        a[i] = std::exp(a[i]);
    }
}

xsimd version 13.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions