PERF: BSplineKernelFunction::FastEvaluate(u): a faster way to evaluate BSplineKernelFunction#2716
Merged
thewtex merged 2 commits intoInsightSoftwareConsortium:masterfrom Sep 8, 2021
Conversation
Equivalent to the existing `BSplineKernelFunction::Evaluate(u)` member function. Allows writing faster code, because it is non-virtual, and because it does not require the creation of a `BSplineKernelFunction` object.
Removed the dynamically allocated `m_Kernel` data member from `BSplineInterpolationWeightFunction` and replaced the virtual function call `m_Kernel->Evaluate(x)` by a faster static member function call, to the newly added `BSplineKernelFunction::FastEvaluate` member function. May significantly improve the performance of `BSplineInterpolationWeightFunction`.
Contributor
Author
@dzenanz Not yet, but I'm pretty sure that removing both the dynamic allocation of the kernel and the virtual function call does improve the performance. Update: I just compared old style kernel->Evaluate... ...to calling the proposed static member function, FastEvaluate: Using VS2019 x64 (Release). For SplineOrder = 3, the duration was reduced by more than 8% when calling FastEvaluate. For SplineOrder = 1, the duration was even reduced by 55%! |
thewtex
approved these changes
Sep 7, 2021
ntustison
approved these changes
Sep 7, 2021
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
Sep 12, 2021
Follow-up to pull request InsightSoftwareConsortium#2716 commit 99f04d7 "ENH: Add static member function `BSplineKernelFunction::FastEvaluate(u)`"
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
Sep 12, 2021
Removed the two dynamically allocated "cubic kernel" data members from `MattesMutualInformationImageToImageMetric` and replaced the virtual `Evaluate` function calls by a faster static member function call, to the newly added `FastEvaluate` member functions. Follow-up to pull request InsightSoftwareConsortium#2716 commit c23944b "PERF: Remove BSplineInterpolationWeightFunction Kernel, use FastEvaluate"
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
Sep 13, 2021
Removed the two dynamically allocated "cubic BSpline kernel" data members from both `MattesMutualInformationImageToImageMetric` and `MattesMutualInformationImageToImageMetricv4`. Replaced the virtual `Evaluate` function calls by faster static member function calls, to the newly added `FastEvaluate` member functions of the corresponding `KernelFunction` classes. Follow-up to pull request InsightSoftwareConsortium#2716 commit c23944b "PERF: Remove BSplineInterpolationWeightFunction Kernel, use FastEvaluate"
dzenanz
pushed a commit
that referenced
this pull request
Sep 14, 2021
Removed the two dynamically allocated "cubic BSpline kernel" data members from both `MattesMutualInformationImageToImageMetric` and `MattesMutualInformationImageToImageMetricv4`. Replaced the virtual `Evaluate` function calls by faster static member function calls, to the newly added `FastEvaluate` member functions of the corresponding `KernelFunction` classes. Follow-up to pull request #2716 commit c23944b "PERF: Remove BSplineInterpolationWeightFunction Kernel, use FastEvaluate"
N-Dekker
added a commit
to SuperElastix/elastix
that referenced
this pull request
Jan 26, 2022
Paving the way for the introduction of `FastEvaluate` member functions, as introduced with ITK v5.3rc02: - ITK pull request InsightSoftwareConsortium/ITK#2716 commit InsightSoftwareConsortium/ITK@99f04d7 "ENH: Add static member function `BSplineKernelFunction::FastEvaluate(u)`" - ITK pull request InsightSoftwareConsortium/ITK#2731 commit InsightSoftwareConsortium/ITK@760ae12 "ENH: Add static `FastEvaluate(u)` to `BSplineDerivativeKernelFunction`"
N-Dekker
added a commit
to SuperElastix/elastix
that referenced
this pull request
Jan 26, 2022
Similar to the `FastEvaluate` member functions, introduced with ITK v5.3rc02: - ITK pull request InsightSoftwareConsortium/ITK#2716 commit InsightSoftwareConsortium/ITK@99f04d7 "ENH: Add static member function `BSplineKernelFunction::FastEvaluate(u)`" - ITK pull request InsightSoftwareConsortium/ITK#2731 commit InsightSoftwareConsortium/ITK@760ae12 "ENH: Add static `FastEvaluate(u)` to `BSplineDerivativeKernelFunction`"
N-Dekker
added a commit
to SuperElastix/elastix
that referenced
this pull request
Jan 27, 2022
Paving the way for the introduction of `FastEvaluate` member functions, as introduced with ITK v5.3rc02: - ITK pull request InsightSoftwareConsortium/ITK#2716 commit InsightSoftwareConsortium/ITK@99f04d7 "ENH: Add static member function `BSplineKernelFunction::FastEvaluate(u)`" - ITK pull request InsightSoftwareConsortium/ITK#2731 commit InsightSoftwareConsortium/ITK@760ae12 "ENH: Add static `FastEvaluate(u)` to `BSplineDerivativeKernelFunction`"
N-Dekker
added a commit
to SuperElastix/elastix
that referenced
this pull request
Jan 27, 2022
Similar to the `FastEvaluate` member functions, introduced with ITK v5.3rc02: - ITK pull request InsightSoftwareConsortium/ITK#2716 commit InsightSoftwareConsortium/ITK@99f04d7 "ENH: Add static member function `BSplineKernelFunction::FastEvaluate(u)`" - ITK pull request InsightSoftwareConsortium/ITK#2731 commit InsightSoftwareConsortium/ITK@760ae12 "ENH: Add static `FastEvaluate(u)` to `BSplineDerivativeKernelFunction`"
N-Dekker
added a commit
to SuperElastix/elastix
that referenced
this pull request
Feb 20, 2022
Replaced calls to the old virtual `itk::BSplineKernelFunction` member function `Evaluate` by its static member function `FastEvaluate`. Removed unnecessary `itk::BSplineKernelFunction` objects. May improve the performance of both `DistancePreservingRigidityPenaltyTerm` (from Metrics) and `BSplineSecondOrderDerivativeKernelFunction` (from Testing). This `FastEvaluate` member function was introduced by ITK pull request InsightSoftwareConsortium/ITK#2716 commit InsightSoftwareConsortium/ITK@99f04d7 "PERF: `ENH: Add static member function `BSplineKernelFunction::FastEvaluate(u)`" (merged on 8 September 2021), and included with ITK v5.3rc01.
N-Dekker
added a commit
to SuperElastix/elastix
that referenced
this pull request
Feb 20, 2022
Replaced calls to the old virtual `itk::BSplineDerivativeKernelFunction` member function `Evaluate` by its static member function `FastEvaluate`. Removed unnecessary `BSplineInterpolationWeightFunctionBase` data member, `m_DerivativeKernel`. May improve the performance of both `BSplineInterpolationDerivativeWeightFunction` and `BSplineInterpolationSecondOrderDerivativeWeightFunction` (from Common/Transforms). This `FastEvaluate` member function was introduced by ITK pull request InsightSoftwareConsortium/ITK#2716 commit InsightSoftwareConsortium/ITK@760ae12 "ENH: Add static `FastEvaluate(u)` to `BSplineDerivativeKernelFunction`" (merged on 14 September 2021), and included with ITK v5.3rc02.
N-Dekker
added a commit
to SuperElastix/elastix
that referenced
this pull request
Feb 21, 2022
Replaced calls to the old virtual `itk::BSplineKernelFunction` member function `Evaluate` by its static member function `FastEvaluate`. Removed unnecessary `itk::BSplineKernelFunction` objects. May improve the performance of both `DistancePreservingRigidityPenaltyTerm` (from Metrics) and `BSplineSecondOrderDerivativeKernelFunction` (from Testing). This `FastEvaluate` member function was introduced by ITK pull request InsightSoftwareConsortium/ITK#2716 commit InsightSoftwareConsortium/ITK@99f04d7 "PERF: `ENH: Add static member function `BSplineKernelFunction::FastEvaluate(u)`" (merged on 8 September 2021), and included with ITK v5.3rc01.
N-Dekker
added a commit
to SuperElastix/elastix
that referenced
this pull request
Feb 21, 2022
Replaced calls to the old virtual `itk::BSplineDerivativeKernelFunction` member function `Evaluate` by its static member function `FastEvaluate`. Removed unnecessary `BSplineInterpolationWeightFunctionBase` data member, `m_DerivativeKernel`. May improve the performance of both `BSplineInterpolationDerivativeWeightFunction` and `BSplineInterpolationSecondOrderDerivativeWeightFunction` (from Common/Transforms). This `FastEvaluate` member function was introduced by ITK pull request InsightSoftwareConsortium/ITK#2716 commit InsightSoftwareConsortium/ITK@760ae12 "ENH: Add static `FastEvaluate(u)` to `BSplineDerivativeKernelFunction`" (merged on 14 September 2021), and included with ITK v5.3rc02.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Added a static member function
BSplineKernelFunction::FastEvaluate(u). Equivalent to the existingBSplineKernelFunction::Evaluate(u)member function. Allows writing faster code, because it is non-virtual, andbecause it does not require the creation of a
BSplineKernelFunctionobject.Removed the dynamically allocated
m_Kerneldata member fromBSplineInterpolationWeightFunctionand replaced the virtual function callm_Kernel->Evaluate(x)by a faster static member function call, to the newly addedBSplineKernelFunction::FastEvaluatemember function.