Skip to content

Aligned of data #776

Open
Open

Description

@usamec

I think all data should be aligned on 256 or 512 bit boundary (due to vectorized instructions).

Activity

  1. paddyhoran commented on Jan 19, 2020

    @paddyhoran

    FYI #771, which if adopted would address this.

  2. jturner314 commented on Jan 21, 2020

    @jturner314
    Member

    When looking at restricting the alignment of pieces of the array for the purpose of SIMD, it's unclear what restrictions are the most appropriate. Simply restricting the alignment of the first element doesn't seem especially useful except in the 1-D case. For example, if I have a row-major array and the stride between rows is not a multiple of 64 bytes, then many of the rows will not be 64-byte aligned. As a result, if I want to iterate along the rows, I'll have to deal with alignment issues regardless of whether or not the first element (i.e. the first row) is aligned. To avoid this, we'd need to insert padding between rows to make them be 64-byte aligned. There's also the question of slicing -- should we worry about the fact that slicing an array will usually make the first element no longer be 64-byte aligned?

    Does anyone have thoughts about what sort of alignment restrictions would be appropriate?

    Edit: On second thought, alignment of the first element is sufficient when the arrays being operated on are contiguous, they're in the same order, and the operation is elementwise (e.g. computing the sin of all the elements in an array or adding two arrays together) because in this case the iteration can be flattened into a single loop. This is probably the most common case, so I can understand aligning the first element when possible and not worrying about the misalignment in other cases.

  3. bluss commented on Apr 11, 2020

    @bluss
    Member

    Alignment, also of each row, would be good to eventually support, but it requires us to handle internal padding of rows - which internally means stretches of uninitialized elements in memory; and this the owned arrays don't support today.

  4. bluss commented on Apr 25, 2020

    @bluss
    Member

    Design is needed. What's the approach here? All owned arrays could be allocated with data with a minimum alignment (This requires dropping no-copy initialization from Vec). Should there be padding for rows/columns?

    What algorithms would take advantage of this? Would they also have a fallback to other alignments? Keep in mind that slices (array views) could have arbitrary other valid alignment for the element type.

    If fallbacks are implemented, and there can't be a guarantee for array views, is the status quo good enough?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    information neededMore information is needed to make progress

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions