Determining the proper vectorized from a fundamental one

asked 2019-02-22 08:21:01 -0500

js4267 gravatar image

updated 2019-02-22 08:54:45 -0500


In OpenCV 3.4.x the structure V_RegTraits128 was very helpfull for who like to do vectorized codes using templates structure. At one point with the evolution of the hal section V_RegTraits128 has become V_RegTraits but it does not allow anymore to find the vectorized from a fundamentals. e.g.

    template<class T>
    struct Fma_SIMD

        static_assert(std::is_same<T,float>::value || std::is_same<T,double>::value,"Fma_SIMD Only Support Floating Point Fundamental Types");

        typedef typename cv::V_RegTraits<T>::reg vector_type; //Does not works anymore but previously does:  error: no type named ‘reg’ in ‘struct cv::hal_baseline::V_RegTraits<float>’
     typedef typename cv::V_RegTraits<T>::reg vector_type;

            nlanes = 0x10/sizeof(T)

        typedef T* pointer;
        typedef const T* const_pointer;

        static const bool haveSIMD;

        virtual ~Fms_SIMD() = default;

        virtual int operator()(const_pointer s1, const_pointer s2, const_pointer s3, pointer d, int width)const
        int x=0;

            return x;

        for(;x<=width-nlanes; x+=nlanes, s1+=nlanes, s2+=nlanes, s3+=nlanes, d+=nlanes)
            vector_type v1 = cv::vx_load(s1);
            vector_type v2 = cv::vx_load(s2);
            vector_type v3 = cv::vx_load(s3);

            vector_type vd = cv::v_fma(v1, v2, v3);

            cv::vx_store(d, vd);

        return x;


template<class T>
const bool Fms_SIMD<T>::haveSIMD = true;
const bool Fms_SIMD<T>::haveSIMD = false;

Then when I called an instance:

Fma_SIMD<float> op;

The vector type was automatically set to cv::v_float32 ... but not anymore

Is there any other data structure that can help to do that ?

edit retag flag offensive close merge delete