Skip to content

Noncontiguous View Support#245

Open
jasongraffius wants to merge 4 commits intogoogle:masterfrom
jasongraffius:noncontiguous
Open

Noncontiguous View Support#245
jasongraffius wants to merge 4 commits intogoogle:masterfrom
jasongraffius:noncontiguous

Conversation

@jasongraffius
Copy link
Collaborator

@jasongraffius jasongraffius commented Mar 4, 2026

Add support for views over non-contiguous containers, allowing direct access and mutation via iterators. Iterator access is slower than contiguous containers, as currently there is no support for communicating contiguity metadata to the Emboss runtime support, but if that information is surfaced in the future as an optimization then it can defer to contiguous MemoryAccessors for copies that are not across a contiguity boundary, which should improve performance.

This should not have an effect on existing contiguous containers as they continue to use contiguous memory access and std::copy_n will optimize to memcpy in all major compilers.

Contains the following commits:


Introduce noncontiguous container utility

Introduce a test utility type that is a non-contiguous container that is
highly configurable in structure so we can test various conditions in
upcoming features.


Add UnalignedAccessor to read/write through iterator

This enables accessing values in generic functionality that works
through any iterator, allowing transparent memcpy performance for
pointers (all major compilers will compile std::copy_n for a
char-like pointer into a memcpy), while supporting arbitrary
iterators.

Added tests that exhaustively test various possible non-contiguous
arrangements.


Introduce IteratorStorage for any iterable

Create a storage type for arbitrary iteratable types, technically
supporting contiguous buffers, though continue to keep contiguous
buffers as it is much more performant for contiguous access.


Add support for IteratorStorage to Make[Struct]View

Enable creating a struct view over non-contiguous containers using the
Make[Struct]View generated functions.

Introduce a test utility type that is a non-contiguous container that is
highly configurable in structure so we can test various conditions in
upcoming features.
This enables accessing values in generic functionality that works
through any iterator, allowing transparent `memcpy` performance for
pointers (all major compilers will compile `std::copy_n` for a
`char`-like pointer into a memcpy), while supporting arbitrary
iterators.

Added tests that exaustively test various possible non-contiguous
arrangements.
Create a storage type for arbitrary iteratable types, technically
supporting contiguous buffers, though continue to keep contiguous
buffers as it is much more performant for contiguous access.
Enable creating a struct view over non-contiguous containers using the
Make<Struct>View generated functions.
@jasongraffius jasongraffius requested a review from EricRahm March 13, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant