Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rav1dFrameContext_frame_thread::pal: Make into an AlignedVec #732

Merged
merged 4 commits into from
Feb 22, 2024

Conversation

randomPoison
Copy link
Collaborator

@randomPoison randomPoison commented Feb 7, 2024

This also adds AlignedVec64 to have the Vec aligned, since a Vec<Align64<T>> would add extra padding between each element since it would align each element, and we only want to align the whole Vec/slice.

src/internal.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@kkysen kkysen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rinon made a good point about the alignment; we should use Align64. Also, the pal_sz field can now be folded into pal.len(), after adjusting by 16 * 16.

src/internal.rs Outdated Show resolved Hide resolved
src/decode.rs Outdated Show resolved Hide resolved
src/decode.rs Show resolved Hide resolved
@randomPoison randomPoison force-pushed the legare/ravidframecontext_frame_thread/pal branch from 3505492 to b1ffbf9 Compare February 9, 2024 17:45
@randomPoison randomPoison force-pushed the legare/ravidframecontext_frame_thread/cbi branch from 47bf8ed to 90fa006 Compare February 9, 2024 17:46
Base automatically changed from legare/ravidframecontext_frame_thread/cbi to main February 9, 2024 17:58
Copy link
Collaborator

@kkysen kkysen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think you meant pal_sz instead of pal_idx in the commit message.

kkysen
kkysen previously approved these changes Feb 9, 2024
@randomPoison randomPoison force-pushed the legare/ravidframecontext_frame_thread/pal branch 3 times, most recently from 74f5904 to 5a4a50d Compare February 13, 2024 22:51
@randomPoison randomPoison dismissed kkysen’s stale review February 13, 2024 22:51

Additional changes have been made that need review.

Copy link
Collaborator

@kkysen kkysen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also #744 for a discussion of how to approach this for all aligned allocs.

src/align.rs Outdated Show resolved Hide resolved
src/align.rs Show resolved Hide resolved
@randomPoison randomPoison force-pushed the legare/ravidframecontext_frame_thread/pal branch from c36f010 to 2f0be62 Compare February 16, 2024 22:59
@randomPoison
Copy link
Collaborator Author

@kkysen @rinon I've changed to the custom allocator approach proposed in #744. Please give this another look!

Copy link
Collaborator

@kkysen kkysen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking a look at this again, I realized we don't actually need bounds on T for safe transmutability, since we leave the u8s uninitialized and only ever initialize things as Ts. I had a bunch of other comments, though, and I thought of a way to make it generic over the alignment.

src/align.rs Outdated Show resolved Hide resolved
src/align.rs Outdated Show resolved Hide resolved
src/align.rs Show resolved Hide resolved
src/align.rs Outdated Show resolved Hide resolved
src/align.rs Outdated Show resolved Hide resolved
src/align.rs Outdated Show resolved Hide resolved
src/align.rs Outdated Show resolved Hide resolved
src/align.rs Show resolved Hide resolved
src/align.rs Outdated Show resolved Hide resolved
src/align.rs Show resolved Hide resolved
@randomPoison randomPoison force-pushed the legare/ravidframecontext_frame_thread/pal branch 2 times, most recently from d91cd0b to 55dc06d Compare February 21, 2024 00:48
src/align.rs Outdated Show resolved Hide resolved
src/align.rs Show resolved Hide resolved
src/align.rs Show resolved Hide resolved
src/align.rs Show resolved Hide resolved
src/decode.rs Outdated Show resolved Hide resolved
src/align.rs Outdated Show resolved Hide resolved
src/align.rs Show resolved Hide resolved
src/align.rs Show resolved Hide resolved
src/align.rs Show resolved Hide resolved
Copy link
Collaborator

@kkysen kkysen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It mostly looks very good now! Though I had a bunch of suggestions for some comments, and a few other little things.

src/align.rs Outdated Show resolved Hide resolved
@kkysen kkysen changed the title Rav1dFrameContext_frame_thread::pal: Make into a Vec Rav1dFrameContext_frame_thread::pal: Make into an aligned Vec Feb 21, 2024
src/align.rs Outdated Show resolved Hide resolved
@rinon
Copy link
Collaborator

rinon commented Feb 22, 2024

LGTM overall, minor nitpicks aside.

@randomPoison randomPoison force-pushed the legare/ravidframecontext_frame_thread/pal branch from 55dc06d to c23b4ed Compare February 22, 2024 17:53
The original C logic was doing an aligned allocation, so we use the `Align64` wrapper type to enforce that same alignment.
@randomPoison randomPoison force-pushed the legare/ravidframecontext_frame_thread/pal branch from c23b4ed to 7129605 Compare February 22, 2024 18:04
@randomPoison randomPoison merged commit 48b5909 into main Feb 22, 2024
34 checks passed
@randomPoison randomPoison deleted the legare/ravidframecontext_frame_thread/pal branch February 22, 2024 21:02
@kkysen kkysen changed the title Rav1dFrameContext_frame_thread::pal: Make into an aligned Vec Rav1dFrameContext_frame_thread::pal: Make into an AlignedVec Feb 27, 2024
@kkysen
Copy link
Collaborator

kkysen commented Feb 27, 2024

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.

3 participants