Software Tuning, Performance Optimization & Platform Monitoring
Discussion around monitoring and software tuning methodologies, Performance Monitoring Unit (PMU) of Intel microprocessors, and platform monitoring

SIMD for calculating checksum

zoolii
Beginner
203 Views
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
203 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
203 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
203 Views
You need to consider a set of SSE3 instructions for a horizontal addition.

Best regards,
Sergey
SergeyKostrov
Valued Contributor II
203 Views
TimP
Black Belt
203 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