Align all arrays in mjData's buffer to 64 byte boundaries.
The introduction of additional mjData arrays for the implicit integrator caused in a shift in data alignment in memory. In certain combinations of machines and models, this change resulted in ~5% performance regression that appears to be attributable to L2 cache misses. This change aligns all arrays in mjData to the boundary of a typical L2 cache line size. Benchmarking shows that this resolves the performance regression on a Broadwell machine. PiperOrigin-RevId: 451652783 Change-Id: I4ed2c2d03453a83a0b4a9b8e224e2fd7c0dadea9
This commit is contained in:
committed by
Copybara-Service
parent
981fa22302
commit
5cc73c30bf
@@ -187,7 +187,7 @@ void mju_warning_s(const char* msg, const char* text) {
|
||||
|
||||
//------------------------------ malloc and free ---------------------------------------------------
|
||||
|
||||
// allocate memory; byte-align on 8; pad size to multiple of 8
|
||||
// allocate memory; byte-align on 64; pad size to multiple of 64
|
||||
void* mju_malloc(size_t size) {
|
||||
void* ptr = 0;
|
||||
|
||||
@@ -198,13 +198,13 @@ void* mju_malloc(size_t size) {
|
||||
|
||||
// default allocator
|
||||
else {
|
||||
// pad size to multiple of 8
|
||||
if ((size%8)) {
|
||||
size += 8 - (size%8);
|
||||
// pad size to multiple of 64
|
||||
if ((size%64)) {
|
||||
size += 64 - (size%64);
|
||||
}
|
||||
|
||||
// allocate
|
||||
ptr = mju_alignedMalloc(size, 8);
|
||||
ptr = mju_alignedMalloc(size, 64);
|
||||
}
|
||||
|
||||
// error if null pointer
|
||||
|
||||
Reference in New Issue
Block a user