Skip to content

WIP: Custom NVector for GPU #3390

Open
bendudson wants to merge 26 commits into
nextfrom
custom-nvector
Open

WIP: Custom NVector for GPU #3390
bendudson wants to merge 26 commits into
nextfrom
custom-nvector

Conversation

@bendudson

Copy link
Copy Markdown
Contributor

Intended to allow SUNDIALS to operate on BOUT++ state data without copying into vectors. The hope is to avoid copying between CPU and GPU.

Work in progress.

@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

There were too many comments to post at once. Showing the first 25 out of 42. Check the log or trigger a new build to see more.

Comment thread src/field/field2d.cxx
}
}

void Field2D::swapData(Field2D& other) { std::swap(data, other.data); }

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: no header providing "std::swap" is directly included [misc-include-cleaner]

void Field2D::swapData(Field2D& other) { std::swap(data, other.data); }
                                              ^

N_Vector nvector_from_state(const sundials::Context& ctx) {
std::vector<N_Vector> subvectors;
subvectors.reserve(f2d.size() + f3d.size());
const auto inserter = std::back_inserter(subvectors);

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: no header providing "std::back_inserter" is directly included [misc-include-cleaner]

src/solver/impls/arkode/arkode.hxx:33:

+ #include <iterator>

const auto var_str_to_nvector = [&ctx](auto &var_str) {
return BoutNVector::create(ctx, *var_str.var, var_str.evolve_bndry);
};
std::transform(f2d.cbegin(), f2d.cend(), inserter, var_str_to_nvector);

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: no header providing "std::transform" is directly included [misc-include-cleaner]

src/solver/impls/arkode/arkode.hxx:33:

+ #include <algorithm>

return BoutNVector::create(ctx, *var_str.var, var_str.evolve_bndry);
};
std::transform(f2d.cbegin(), f2d.cend(), inserter, var_str_to_nvector);
std::transform(f3d.cbegin(), f3d.cend(), inserter, var_str_to_nvector);

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: no header providing "std::transform" is directly included [misc-include-cleaner]

    std::transform(f3d.cbegin(), f3d.cend(), inserter, var_str_to_nvector);
         ^

return BoutNVector::create(ctx, subvectors);
}

void swap_state(const N_Vector u) {

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: 'u' declared with a const-qualified typedef; results in the type being '_generic_N_Vector *const' instead of 'const _generic_N_Vector *' [misc-misplaced-const]

  void swap_state(const N_Vector u) {
                                 ^
Additional context

/usr/include/sundials/sundials_nvector.h:91: typedef declared here

typedef _SUNDIALS_STRUCT_ _generic_N_Vector* N_Vector;
                                             ^

Comment thread src/solver/nvector.hxx
template <typename T>
struct Content {
T& field;
const bool own;

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: member 'own' of type 'const bool' is const qualified [cppcoreguidelines-avoid-const-or-ref-data-members]

    const bool own;
               ^

Comment thread src/solver/nvector.hxx
struct Content {
T& field;
const bool own;
const bool evolve_bndry;

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: member 'evolve_bndry' of type 'const bool' is const qualified [cppcoreguidelines-avoid-const-or-ref-data-members]

    const bool evolve_bndry;
               ^

Comment thread src/solver/nvector.hxx
T& field;
const bool own;
const bool evolve_bndry;
const sunindextype length;

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: member 'length' of type 'const sunindextype' (aka 'const int') is const qualified [cppcoreguidelines-avoid-const-or-ref-data-members]

    const sunindextype length;
                       ^

Comment thread src/solver/nvector.hxx
length(all_reduce(getRegion().size())) {}

auto getRegion() const {
return field.getRegion(evolve_bndry ? RGN_ALL : RGN_NOBNDRY);

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: no header providing "RGN_ALL" is directly included [misc-include-cleaner]

src/solver/nvector.hxx:25:

- #include <bout/field.hxx>
+ #include "bout/bout_types.hxx"
+ #include <bout/field.hxx>

Comment thread src/solver/nvector.hxx
length(all_reduce(getRegion().size())) {}

auto getRegion() const {
return field.getRegion(evolve_bndry ? RGN_ALL : RGN_NOBNDRY);

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: no header providing "RGN_NOBNDRY" is directly included [misc-include-cleaner]

      return field.getRegion(evolve_bndry ? RGN_ALL : RGN_NOBNDRY);
                                                      ^

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.

2 participants