WIP: Custom NVector for GPU #3390
Conversation
| } | ||
| } | ||
|
|
||
| void Field2D::swapData(Field2D& other) { std::swap(data, other.data); } |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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;
^| template <typename T> | ||
| struct Content { | ||
| T& field; | ||
| const bool own; |
There was a problem hiding this comment.
warning: member 'own' of type 'const bool' is const qualified [cppcoreguidelines-avoid-const-or-ref-data-members]
const bool own;
^| struct Content { | ||
| T& field; | ||
| const bool own; | ||
| const bool evolve_bndry; |
There was a problem hiding this comment.
warning: member 'evolve_bndry' of type 'const bool' is const qualified [cppcoreguidelines-avoid-const-or-ref-data-members]
const bool evolve_bndry;
^| T& field; | ||
| const bool own; | ||
| const bool evolve_bndry; | ||
| const sunindextype length; |
There was a problem hiding this comment.
warning: member 'length' of type 'const sunindextype' (aka 'const int') is const qualified [cppcoreguidelines-avoid-const-or-ref-data-members]
const sunindextype length;
^| length(all_reduce(getRegion().size())) {} | ||
|
|
||
| auto getRegion() const { | ||
| return field.getRegion(evolve_bndry ? RGN_ALL : RGN_NOBNDRY); |
There was a problem hiding this comment.
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>| length(all_reduce(getRegion().size())) {} | ||
|
|
||
| auto getRegion() const { | ||
| return field.getRegion(evolve_bndry ? RGN_ALL : RGN_NOBNDRY); |
There was a problem hiding this comment.
warning: no header providing "RGN_NOBNDRY" is directly included [misc-include-cleaner]
return field.getRegion(evolve_bndry ? RGN_ALL : RGN_NOBNDRY);
^
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.