p_x_ at June 17th, 2014 01:54 — #1
As I'm developing my current game, I was wondering how is the application affected by different memory alignment? What gain can I expect to see when memory alignment is optimized for as opposed to when it's not?
Having said that, what's the technique to use in C++ to ensure that memory alignment is optimal? Example code would be great. Thx!
vilem_otte at June 17th, 2014 05:05 — #2
I would say that it depends on what are you working on.
For example, when you're creating a renderer (software one), them keeping your memory aligned at 16-bytes and using SIMD SSE is a must (of course assuming you want to see some solid performance).
Creating a scripting lanugage and writing a code for working with that language - then it's most likely not worth it (as it won't speed you up at parts where you will be terribly slow).
Gimme few minutes - I will make some example code to show where memory alignment can help...
EDIT: Uhm... wanted to create some example, but I will link to one - http://www.cortstratton.org/articles/OptimizingForSSE.php - here you can see at some point that memory alignment helps, especially considering computations with matrices and vectors.