Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alignment and performance

Tags:

c++

c

linux

libc

sse

Routines strcmp for comparing char * and memcmp for everything else, do they run faster on memory block (on x86_64) which is somehow aligned (how?)? Does libc use SSE for this routines?

like image 298
Cartesius00 Avatar asked Jan 31 '12 10:01

Cartesius00


1 Answers

It depends, but on architectures where alignment matters or where SIMD instructions are available, typically the routines will operate on leading bytes, then do as many wide aligned operations as the data allows, then operate on trailing bytes.

Whether the leading and trailing bytes are contributing significantly to the processing time for your data can be determined by experiment.

like image 199
Pete Kirkham Avatar answered Sep 27 '22 03:09

Pete Kirkham