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

SIMD for calculating checksum

zoolii
Beginner
872 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
872 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

0 Kudos
zoolii
Beginner
872 Views
Hi Sergy,
Thanks for the reply. hashVal can be an unsigned int or long . pBuffer_ is an unsigned char array.
Regards
Zooli
0 Kudos
SergeyKostrov
Valued Contributor II
872 Views
You need to consider a set of SSE3 instructions for a horizontal addition.

Best regards,
Sergey
0 Kudos
SergeyKostrov
Valued Contributor II
872 Views
0 Kudos
TimP
Honored Contributor III
872 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.
0 Kudos
Reply