Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aligning memory on 16-byte and 32-byte boundaries

I'm doing several operations using SIMD instructions (SSE and AVX). As I understand, SSE instructions work best with 16-byte aligned memory, and AVX instructions work best with 32-byte aligned memory.

Would it be safe to always allocate memory aligned to 32-byte boundaries for optimal use with both SSE and AVX?

Are there ever any cases where 32-byte aligned memory is not also 16-byte aligned?

like image 374
AdorableHoneycrisp Avatar asked Oct 20 '25 11:10

AdorableHoneycrisp


1 Answers

Are there ever any cases where 32-byte aligned memory is not also 16-byte aligned?

Alignment just means that the address is a multiple of 32. Any multiple of 32 is also a multiple of 16.

The first google hit for "alignment" is wikipedia, and you can follow the links to https://en.wikipedia.org/wiki/Data_structure_alignment#Definitions, which explains this in lots of detail.

like image 181
Peter Cordes Avatar answered Oct 23 '25 10:10

Peter Cordes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!