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.

Reducing cycles for memcmp

Hi,

 I have two data blocks of large size in DDR3 to compare & I want to compare the two with minimum cycles.(memcmp takes a lot of cycles)

Is there any way out?

Regards,

  • Hi,

    the library memcmp() perform a generic byte-to-byte compare (C standard) and return the difference of the first not equal bytes (C standard), so it is very slow.

    You can do better if You can make some assumption on your data, mainly on the memory alignment. For instance, if your two data sources have same alignment you can write a 64bits compare routine (optimized by the compiler).

    Compare 16Kbytes, 8 bytes aligned, in MCSM (c6678 simulator):

    - memcmp(): 147480 cycles

    - 64bits optimized compare: 24600 cycles