This is the code I usually write:
alignas(16) __m128 myBuffer[8];
But maybe (since the object-array is 128*8 bit = 128 byte) I should write:
alignas(128) __m128 myBuffer[8];
Or, "since the first 16 byte are aligned" in the first example, the rest will be automatically aligned in memory?
It's not technically wrong, but according to documentation
__m128
is aligned to 16 bytes, so it's unnecessary to usealignas
.If your goal is to align to 128 bytes, then you can achieve it like that.
This question confuses me. If the integer is aligned, then the first byte is aligned. Rest of the bytes are offset from the first byte. In case the size is larger than alignment, some of the subsequent bytes would be aligned at offsets equal to the alignment.
Note that there is no
__m128
in standard C++.