Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Determining the proper vectorized from a fundamental one

Hello

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; //Do not work 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;
                                              ^~~~~~~~~~~

        enum
        {
            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;

        if(!haveSIMD128)
            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>
#ifdef CV_ENABLE_INTRINSICS
const bool Fms_SIMD<T>::haveSIMD = true;
#else
const bool Fms_SIMD<T>::haveSIMD = false;
#endif

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 ?

Determining the proper vectorized from a fundamental one

Hello

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; //Do not work 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;
                                              ^~~~~~~~~~~

        enum
        {
            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;

        if(!haveSIMD128)
if(!haveSIMD)
            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>
#ifdef CV_ENABLE_INTRINSICS
const bool Fms_SIMD<T>::haveSIMD = true;
#else
const bool Fms_SIMD<T>::haveSIMD = false;
#endif

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 ?

Determining the proper vectorized from a fundamental one

Hello

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; //Do not work 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;
                                              ^~~~~~~~~~~

        enum
        {
            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;

        if(!haveSIMD)
            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>
#ifdef CV_ENABLE_INTRINSICS
const bool Fms_SIMD<T>::haveSIMD = true;
#else
const bool Fms_SIMD<T>::haveSIMD = false;
#endif

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 ?

Determining the proper vectorized from a fundamental one

Hello

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; //Do //Does not work 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;
                                              ^~~~~~~~~~~

        enum
        {
            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;

        if(!haveSIMD)
            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>
#ifdef CV_ENABLE_INTRINSICS
const bool Fms_SIMD<T>::haveSIMD = true;
#else
const bool Fms_SIMD<T>::haveSIMD = false;
#endif

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 ?