Skip to content

WIP: Improve BoutExpr CPU performance#3403

Open
bendudson wants to merge 2 commits into
nextfrom
boutexpr-performance
Open

WIP: Improve BoutExpr CPU performance#3403
bendudson wants to merge 2 commits into
nextfrom
boutexpr-performance

Conversation

@bendudson

Copy link
Copy Markdown
Contributor

Some small improvements to encourage vectorization in BoutExpr::evaluate for common cases.

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.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

#define BOUT_FORCEINLINE inline
#endif

#if defined(_MSC_VER)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: preprocessor condition can be written more concisely using '#ifdef' [readability-use-concise-preprocessor-directives]

Suggested change
#if defined(_MSC_VER)
#ifdef _MSC_VER

#define BOUT_ASSUME(condition) __assume(condition)
#elif defined(__clang__)
#if __has_builtin(__builtin_assume)
#define BOUT_ASSUME(condition) __builtin_assume(condition)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function-like macro 'BOUT_ASSUME' used; consider a 'constexpr' template function [cppcoreguidelines-macro-usage]

#define BOUT_ASSUME(condition) __builtin_assume(condition)
        ^

Comment thread include/bout/field3d.hxx
class Field3DParallel;

namespace bout::detail {
const Region<Ind3D>& getField3DRegion(const Mesh* mesh, std::optional<size_t> regionID);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: redundant 'getField3DRegion' declaration [readability-redundant-declaration]

Suggested change
const Region<Ind3D>& getField3DRegion(const Mesh* mesh, std::optional<size_t> regionID);
Additional context

include/bout/fieldops.hxx:27: previously declared here

const Region<Ind3D>& getField3DRegion(const Mesh* mesh, std::optional<size_t> regionID);
                     ^

Comment thread include/bout/field3d.hxx
this->mul = mul;
this->div = div;
template <typename Mul, typename Div>
View& setScale(Mul, Div) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: all parameters should be named in a function [readability-named-parameter]

Suggested change
View& setScale(Mul, Div) {
View& setScale(Mul /*unused*/, Div /*unused*/) {

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.

1 participant