
98 GPGPU Programming for Games and Science
}
m12 8 number ;
} ;
The general rule for alignment of a struct is that it is equal to the largest
alignment of its components. In this case,
m128 is 16-byte aligned which
guarantees that
MyTuple4 is 16-byte aligned.
The alignment of the struct is based on stack location. In the
MyTuple4
version with m128 number,aMyTuple4 object declared on the stack is 16-
byte aligned; that is, its address is a multiple of 16 bytes. However, if you
were to dynamically allocate the object using
new or malloc, the address is not
guaranteed to be 16-byte aligned. Fortunately with Microsoft Visual Studio
2013, warnings are generated ...