Replace Interpolation macros with type-safe functions#169
Replace Interpolation macros with type-safe functions#169julianlitz wants to merge 1 commit intomainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #169 +/- ##
==========================================
+ Coverage 89.41% 89.82% +0.40%
==========================================
Files 91 91
Lines 5241 5452 +211
==========================================
+ Hits 4686 4897 +211
Misses 555 555 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| #pragma omp for nowait | ||
| for (int i_r_coarse = 0; i_r_coarse < coarse_grid.numberSmootherCircles(); i_r_coarse++) { | ||
| int i_r = i_r_coarse * 2; | ||
| for (int i_theta_coarse = 0; i_theta_coarse < coarse_grid.ntheta(); i_theta_coarse++) { |
There was a problem hiding this comment.
Should a collapse be added now that the order is not important?
There was a problem hiding this comment.
It can be slightly more efficient if we define variables inside the first loop when possible, but doesn't make a big difference here.
for i=...
var = f(i)
for j= ...
var2 = g(var)
end
end
for i=...
for j= ...
var = f(i)
var2 = g(var)
end
end
I havent tried collapsing yet and I don't think it would do much.
Should be enough to parallize the outer loop and then access memory sequentially inside the 2nd loop.
There was a problem hiding this comment.
@EmilyBourne Collapsing might be interesting for gpu though
There was a problem hiding this comment.
I agree. For OpenMP it probably won't help. For GPU it will be necessary
Summary
This PR replaces the macros with inline functions to improve type safety and code maintainability without sacrificing performance. This is part of the broader effort to eliminate macro usage throughout GMGPolar.
Motivation
As discussed in #149, macros are error-prone and bypass C++'s type system, making bugs harder to catch at compile time. Macros in GMGPolar are currently used for code inlining, but modern C++ compilers handle inline functions just as efficiently in release builds while providing:
Merge Request - GuideLine Checklist
Guideline to check code before resolve WIP and approval, respectively.
As many checkboxes as possible should be ticked.
Checks by code author:
Always to be checked:
If functions were changed or functionality was added:
If new functionality was added:
If new third party software is used:
If new mathematical methods or epidemiological terms are used:
Checks by code reviewer(s):