Skip to content

Use logf and powf intrinsics - #12

Closed
sgt0 wants to merge 1 commit into
Jaded-Encoding-Thaumaturgy:masterfrom
sgt0:replace-log-pow
Closed

Use logf and powf intrinsics#12
sgt0 wants to merge 1 commit into
Jaded-Encoding-Thaumaturgy:masterfrom
sgt0:replace-log-pow

Conversation

@sgt0

@sgt0 sgt0 commented Sep 17, 2025

Copy link
Copy Markdown
Member

This handles edge cases like a pow base of 0 better than the exp(log(x) * y) identity did.

Fixes #11

This handles edge cases like a `pow` base of 0 better than the
`exp(log(x) * y)` identity did.

Fixes Jaded-Encoding-Thaumaturgy#11
@yuygfgg

yuygfgg commented Sep 18, 2025

Copy link
Copy Markdown

It seems that this PR is calling cmath functions for log and pow operations instead of using LLVM intrinsics? It might negatively impact the performance since function callings are very hard to vectorize.

@sgt0

sgt0 commented Sep 18, 2025

Copy link
Copy Markdown
Member Author

I just followed what upstream swiftshader was doing. Since your version performs better and it's a smaller diff, we can go with it instead.

clip = core.std.BlankClip(None, 1920, 1080, vs.GRAY16, 30000)

set_output(core.std.Expr(clip, "x 1.5 pow"), "std")
set_output(core.akarin.Expr(clip, "x 1.5 pow"), "akarin")
  • std: Output 30000 frames in 10.10 seconds (2970.32 fps)
  • your PR: Output 30000 frames in 10.04 seconds (2989.49 fps)
  • my PR: Output 30000 frames in 11.15 seconds (2691.45 fps)

yuygfgg added a commit to yuygfgg/akarin-vapoursynth-plugin that referenced this pull request Sep 18, 2025
The tests were originally written by sgt0 in Jaded-Encoding-Thaumaturgy#12.

Co-authored-by: sgt0 <140186177+sgt0@users.noreply.github.com>
yuygfgg added a commit to yuygfgg/akarin-vapoursynth-plugin that referenced this pull request Sep 18, 2025
From Jaded-Encoding-Thaumaturgy#12 by sgt0.

Co-authored-by: sgt0 <140186177+sgt0@users.noreply.github.com>
@Mr-Z-2697

Mr-Z-2697 commented Sep 22, 2025

Copy link
Copy Markdown

the speed is worse than halved using the expression from original issue

core.std.BlankClip(width=1920,height=1080,format=vs.GRAY16,length=1e5).std.Expr('x 32768 / 0.86 pow 65535 *').set_output()

std: Output 100000 frames in 29.47 seconds (3392.89 fps)
pr: Output 100000 frames in 67.19 seconds (1488.38 fps)
(both pr have similar speed)

@sgt0

sgt0 commented Sep 22, 2025

Copy link
Copy Markdown
Member Author

Seems like it comes down to the exponent being between 0 and 1 (i.e. if I make it 1.86 pow instead, I get 13% better perf)? So I guess now we know why the plugin wasn't using the intrinsics. But, the upstream plugin is outputting incorrect values for that expr (for clips that aren't just blank), so IMO its better perf is moot.

@sgt0

sgt0 commented Sep 22, 2025

Copy link
Copy Markdown
Member Author

Erm, idk why I brought up upstream when we're comparing to std. Anyways, closing this PR since I think we either take yuygfgg's or try to improve the current pow/log implementation.

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.

The "pow" in akarin.Expr is broken.

3 participants