Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Further allocation reduction in power computations #361
Further allocation reduction in power computations #361
Changes from 7 commits
dbdbcc1
a34ce7b
c04d9f8
5d3d57d
a9c770b
5bcccf4
6cce90a
a205dcd
e44811c
2e4e60a
f581b21
27c3d0e
dc6a68c
364faf7
99e3061
efa02a1
d9af8ca
68bf845
8610e21
ba30e7a
ea15252
21c876b
702fbac
6264eae
4f613d6
ad18057
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
An equivalent method
mul!(a::Taylor1{T}, b::Taylor1{T}) where {T<:Number})
could be useful for the extension ofpow!
forTaylor1{TaylorN{T}}
?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.
It would indeed by useful, I've added the corresponding method, thanks!
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.
Not sure if this is a good proposal, but here it goes: the code for the next method of
mul!
could be simplified using the new one proposed in this PR, e.g., by copyinga
intores
, and then usingmul!(res, b)
.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.
I understand that this change helps avoiding the allocation of
z
. Yet, I think the idea is to usez
(stored in the stack) instead of looking for the value ofcoeffs[1]
and zeroing it inside thefor
, helps wrt performance. I may be wrong, just want to make sure the idea behind the code is clear.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.
Same comment as above
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.
I guess we would need similar fixes in
Taylor1
andHomogeneousPolynomial
...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.
Could an equivalent method be added for
Taylor1
inputs? Or are they not necessary?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.
I think it would be useful, yes, I've added it, thanks!
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.
Perhaps adding
power_by_squaring(x::$T, ::Val{3})
could be useful too, since it includes the "odd" powers part of the function.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.
You mean adding something along the lines of
power_by_squaring(x::$T, ::Val{3}) = x*square(x)
?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.
Good point... I guess this is the kind of question that we should define in terms of performance. My naive guess is that
x*square(x)
will allocate more than the direct call topower_by_squaring
, but we should definetily check this.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.
I just checked this, and it turns out doing
x*square(x)
allocates less thanpower_by_squaring(x)
(!), do you think it's worth then to add the::Val{3}
method?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.
Have you also teste with intervals? I would choose the case that behaves better wrt allocations.
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.
With intervals
power_by_squaring(x, 3)
onTaylor1{Interval{Float64}}
allocates around half asx*square(x)
, while forTaylorN{Interval{Float64}}
allocations are essentially the sameThere 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.
I think these methods are defined above in lines 104-106...