WIP: Improve BoutExpr CPU performance#3403
Merged
Merged
Conversation
Not needed in current use, and may prevent vectorization.
If iterating over Field3D, the RegionID can be used to get the Region and so the blocks. This avoids lookup of array indices and helps vectorize simple loops.
| #define BOUT_FORCEINLINE inline | ||
| #endif | ||
|
|
||
| #if defined(_MSC_VER) |
Contributor
There was a problem hiding this comment.
warning: preprocessor condition can be written more concisely using '#ifdef' [readability-use-concise-preprocessor-directives]
Suggested change
| #if defined(_MSC_VER) | |
| #ifdef _MSC_VER |
ZedThree
requested changes
Jun 24, 2026
Comment on lines
+932
to
+939
| const Region<Ind3D>& getField3DRegion(const Mesh* mesh, std::optional<size_t> regionID) { | ||
| ASSERT1(mesh != nullptr); | ||
|
|
||
| if (regionID.has_value()) { | ||
| return mesh->getRegion(regionID.value()); | ||
| } | ||
| return mesh->getRegion("RGN_ALL"); | ||
| } |
Contributor
Author
There was a problem hiding this comment.
There is an unpleasant dependency loop: We can't call mesh->getRegion from fieldops.hxx directly, because Mesh is an incomplete type at this point. We therefore need a small helper function to call.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Peter Hill <zed.three@gmail.com>
|
|
||
| #ifdef __has_cpp_attribute | ||
| #if __has_cpp_attribute(assume) >= 202207L | ||
| #define BOUT_ASSUME(condition) [[assume(condition)]] |
Contributor
There was a problem hiding this comment.
warning: function-like macro 'BOUT_ASSUME' used; consider a 'constexpr' template function [cppcoreguidelines-macro-usage]
#define BOUT_ASSUME(condition) [[assume(condition)]]
^
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.
Some small improvements to encourage vectorization in BoutExpr::evaluate for common cases.