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

Various performance improvements #37

Merged
merged 6 commits into from
Nov 24, 2021
Merged

Conversation

KristofferC
Copy link
Contributor

@KristofferC KristofferC commented Nov 24, 2021

I was playing around with my own version of hyper dual numbers locally and compared against this and saw that there was some performance to be gained here so I thought I should be a good citizen and upstream the various things.

As a benchmark, consider

julia> using HyperDualNumbers, BenchmarkTools

julia> h = HyperDualNumbers.Hyper256(1.0, 2.0, 4.0, 5.0);

julia> f(x) = exp(x) / sqrt(sin(x)^3 + cos(x)^3);

julia> @btime f($h)

On master I get:

julia> @btime f($h)
  167.252 ns (0 allocations: 0 bytes)
3.1313954345926485 + 4.555797620352456ε₁ + 9.111595240704911ε₂ + 3.290579765262758ε₁ε₂

while on this branch I get:

julia> @btime f($h)
  44.958 ns (0 allocations: 0 bytes)
3.1313954345926485 + 4.555797620352456ε₁ + 9.111595240704911ε₂ + 3.2905797652627617ε₁ε₂

For example, before this change,

```
code_warntype(cos, Tuple{Hyper256})
```

showed 2 `cos` evaluations and 3 `sin` evaluations. After, there is only one cos and one sin evaluation.
@goedman goedman merged commit 9ae20ee into JuliaDiff:master Nov 24, 2021
@KristofferC KristofferC deleted the kc/perf branch November 24, 2021 14:39
@goedman
Copy link
Member

goedman commented Nov 25, 2021

Thanks Kristoffer, just merged it.

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.

2 participants