Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aligning doubles on 8-byte boundaries?

Is there a common portable idiom in numerics code (I'm writing in D, but language-agnostic, C and C++ answers would be useful to me, too) to ensure that all stack-allocated doubles that are accessed frequently are aligned on 8-byte boundaries? I'm currently optimizing some numerics code where misaligned stack-allocated doubles (only aligned on 4-byte boundaries) is causing about a 1.5 to 2x performance hit.

like image 796
dsimcha Avatar asked Dec 23 '22 05:12

dsimcha


1 Answers

This is compiler specific. With GCC on x86, you'd use

-malign-double
like image 181
Christoph Avatar answered Jan 02 '23 02:01

Christoph