Community
cancel
Showing results for 
Search instead for 
Did you mean: 
zoolii
Beginner
77 Views

SIMD for calculating checksum

Hi Experts,

Can we optimize following checksum calculation using SIMD somehow ?


for(int i = 0 ; i < buffSize_ ; i++) {
hashVal = (hashVal<<5) + hashVal + pBuffer_;
}




Thank you
Zooli
0 Kudos
5 Replies
SergeyKostrov
Valued Contributor II
77 Views

Quoting zoolii
Hi Experts,

Can we optimize following checksum calculation using SIMD somehow ?

for(int i = 0 ; i < buffSize_ ; i++) {
hashVal = (hashVal<<5) + hashVal + pBuffer_;
}


Thank you
Zooli


Yes, with and without SSE. Also, you didn't specifytypes of'hashVal' and'pBuffer_'variables.

Best regards,
Sergey

zoolii
Beginner
77 Views

Hi Sergy,
Thanks for the reply. hashVal can be an unsigned int or long . pBuffer_ is an unsigned char array.
Regards
Zooli
SergeyKostrov
Valued Contributor II
77 Views

You need to consider a set of SSE3 instructions for a horizontal addition.

Best regards,
Sergey
SergeyKostrov
Valued Contributor II
77 Views

TimP
Black Belt
77 Views

If the array is at all large, the vector sum reductions implemented by the compilers (nearly any compiler other than MSVC) may be superior.
Reply