20945, "mppf", "proposal: @aligned N attribute", "2022-11-01T15:13:30Z"
Related to:
- #10771
- #12279
- https://github.com/Cray/chapel-private/issues/3728
- https://github.com/Cray/chapel-private/issues/2175
Over on issue #14141 we have some agreement to use an attribute to request particular alignment of a field.
This issue proposes a specific way of doing so.
Here is a sketch:
record R {
@aligned 64
var x: int;
var y: int;
}
@aligned 64 just before the x field indicates that the x field should always be allocated with 64 byte alignment. As a result, the whole R record will also need 64 byte alignment.
To implement the alignment:
- Compute the maximum alignment of any field. That is the alignment for the aggregate.
- Add padding so that, assuming the aggregate is aligned (as above step would suggest), each field is aligned as requested
Design Questions:
- Should alignment for class fields cause the
newon the class to do an aligned allocation? - Is the syntax OK here?