Skip to content

Benchmarks: align malloc'ed buffers.#3794

Merged
martin-frbg merged 2 commits intoOpenMathLib:developfrom
bartoldeman:benchmark-align-malloc
Oct 21, 2022
Merged

Benchmarks: align malloc'ed buffers.#3794
martin-frbg merged 2 commits intoOpenMathLib:developfrom
bartoldeman:benchmark-align-malloc

Conversation

@bartoldeman
Copy link
Copy Markdown
Contributor

Benchmarks should allocate with cacheline (often 64 bytes) alignment to avoid unreliable timings. This technique, storing the offset in the byte before the pointer, doesn't require C11's aligned_alloc for compatibility with older compilers.

For example, Glibc's x86_64 malloc returns 16-byte aligned buffers, which is not sufficient for AVX/AVX2 (32-byte preferred) or AVX512 (64-byte).

Benchmarks should allocate with cacheline (often 64 bytes) alignment
to avoid unreliable timings. This technique, storing the offset in the
byte before the pointer, doesn't require C11's aligned_alloc for
compatibility with older compilers.

For example, Glibc's x86_64 malloc returns 16-byte aligned buffers, which is
not sufficient for AVX/AVX2 (32-byte preferred) or AVX512 (64-byte).
@martin-frbg martin-frbg added this to the 0.3.22 milestone Oct 20, 2022
@martin-frbg
Copy link
Copy Markdown
Collaborator

Thank you.

It stores the pointer, not an offset (that would be an alternative approach).
@martin-frbg martin-frbg merged commit 8c10f0a into OpenMathLib:develop Oct 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants