This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to optimize comparation of large byte array

Hi all,

I'm writting a program to sampling data, the size of one frame is larger than 1000 bytes, a byte is one sampling point.  there's two compare operations:

1, compare each sampling point's value with the same point of previous frame, and merge the two frames by get larger point value (the compared value saved to previous frame).

2, compare each sampling point's value with threshhold value, if  value less than threshhod value, set value of the point to zero, otherwise subtrack the value with threshhold value.

now i want to optimize the two comparation, what i think is convert byte comparation to word32 comparation. i do not know if it is posible ? or there's other way to do optimization?

regards,

vaughn.

  • If you are using CortexA8 than you can easily optimize your code with NEON SIMD(single instruction multiple data) instruction set.  I guess you can optimize your code upto 83% or more than that (may be).

    You just need to dive in to assembly for neon instruction set.

    with 

    /// At the beginning of the file:
    #ifdef __ARM_NEON__
    #include <arm_neon.h>
    #endif
     
     
    /// In the main function space:
     
    /**
     * @brief This function multiplies two floats.
     *
     * This function is optimized for the ARM NEON instruction set. However
     * a standard C fallback version is present as well (e.g. for x86 systems).
     *
     * @param f1 The first float number
     * @param f2 The second float number
     * @return The two floats multiplied
     **/
     
    float optimized_function(float f1, float f2) {
    #ifdef __ARM_NEON__
     
    /// ARM NEON Code implementation
     
    #else
     
    /// Standard implementation
    return f1 * f2;
     
    #endif
     
    }

  • thanks for your help and sample code snippet,rudani.

    i'm not familar with SIMD instruction set. i'll study with it and try.