Q1. I'm trying to improve my little game engine's speed, so I decided to look into memory alignment. How can I know which part of my program is automatically aligned by the compiler and which part I need to align manually.
Q2. On an MSDN website it read something like "if you are using SSE instructions then you might consider aligning data on 16 byte boundaries" Why is that? Why can't I align it on a lower power of two (lets say on the 4 or 8 byte boundary).
Q3. As I understand the reason for alignment is so that the who instruction fits into one read (I'm using 32 bit XP) of the data bus. So does that as long as no data goes over 4 bytes does not have to be aligned ex:
Expand|Select|Wrap|Line Numbers
- __declspec(align(32)) struct sAligned {
- char chr;
- short shrt1; // does not matter if the elements in this struct
- short shrt2; // are aligned because the whole thing is read in at once anyways?
- };