-
Notifications
You must be signed in to change notification settings - Fork 6
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
Reduce cost of bounds checks in transforms #43
base: main
Are you sure you want to change the base?
Conversation
b8d408f
to
7585ddd
Compare
@@ -159,7 +159,7 @@ impl ModularTransform for XYZtoLAB { | |||
|
|||
struct ClutOnly { | |||
clut: Box<[f32]>, | |||
grid_size: u16, | |||
grid_size: u8, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was the motivation for this? Avoiding the casts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the natural size for it, as read from the input.
I hoped it would also explain to LLVM that grid_size.pow(4) can't overflow, but unfortunately that didn't have any effect.
Is this code showing up in profiles for you? It should only be used when building a lookup table during transform creation. The actual color transformation should be using a fast path. |
The first 3 commits are queued for landing. https://bugzilla.mozilla.org/show_bug.cgi?id=1947889 The other 3 seem ok but I'd like to understand the motivation a little better before landing them. |
chunks_exact(3).nth() has a fast path, and needs 1 check for 3 pixels
Yes, on small images (<640px) the time to build the lookup table takes more time than the transformation itself. Reduction in bounds checks also made the code a bit smaller. |
I've landed the grid size patch. The other two commits cause:
when running |
I'll make it so that it runs tests in github actions when I get a chance. |
According to llvm-mca estimate, the 4x3 transform function
before:
uOps Per Cycle: 2.70
IPC: 1.97
Block RThroughput: 159.3
after:
uOps Per Cycle: 3.48
IPC: 2.69
Block RThroughput: 279.8