4 ms·
I still firmly believe the compiler should transpose your code from array-of-structs to struct-of-arrays, and optimise for temporal and spacial cache utilisatio
by Bancakes 5y ago
I still firmly believe the compiler should transpose your code from array-of-structs to struct-of-arrays, and optimise for temporal and spacial cache utilisation. After all, it is the tool that knows every CPU arch on the planet and can run millions of code transformations per second.
This could be achieved with C/C++ compiler directives, then pass some PGO.
- ratww 5y agoTransposing the data structures is trivial, but transposing the code that access them might be impossible: inside your methods you're still doing random access. You'd have to not only break your "Update" method into many, but also call those broken parts separately.
- astrange 5y agoRearranging memory accesses is very difficult due to usually not having enough info to do the alias analysis. Also, C/C++ compilers really don't know that much about their target architectures, especially not their memory performance - they barely do scheduling anymore since it's better to let the CPU reorder it.