Skip to content

Commit

Permalink
Fieldview by value (#24)
Browse files Browse the repository at this point in the history
gridtools_verification was taking references to fields. this does not work nicely with passing gridtools data_stores by value.
  • Loading branch information
havogt authored Apr 4, 2018
1 parent ee17e1f commit de2b42d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ project(gridtools-verification CXX C)

include(ExternalProject)

set(GRIDTOOLS_VERIFICATION_VERSION_STRING "0.4")
set(GRIDTOOLS_VERIFICATION_VERSION_STRING "0.5")
set(SERIALBOX_VERSION_REQUIRED "2.2.1")

#----------------- CMake options
Expand Down
8 changes: 4 additions & 4 deletions src/core/type_erased_field.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ namespace gt_verification {
static_assert(
std::is_same< typename FieldType::storage_t::data_t, T >::value, "internal error: types do not match");

type_erased_field_view_base(FieldType &field) : field_(field) {}
type_erased_field_view_base(FieldType field) : field_(field) {}

virtual const T &access(int i, int j, int k) const noexcept override {
return make_host_view(field_)(i, j, k);
Expand Down Expand Up @@ -189,7 +189,7 @@ namespace gt_verification {
virtual void sync() noexcept override { field_.sync(); }

private:
FieldType &field_;
FieldType field_;
};

template < typename FieldType, typename T >
Expand Down Expand Up @@ -320,15 +320,15 @@ namespace gt_verification {
* @brief Create a TypeErasedFieldView from GridTools field (stores a reference to the field)
*/
template < class FieldType >
type_erased_field_view(const FieldType &field) {
type_erased_field_view(FieldType field) {
static_assert(
!internal::is_type_erased_field_view< FieldType >::value, "FieldType is not a GridTools field");

// The const cast is ugly here but the signature of this constructor needs to be the same as
// the copy constructor. Hence, we need to capture the field by const ref.. maybe this can
// be improved.
base_ = std::make_shared< internal::type_erased_field_view_base< FieldType, T > >(
const_cast< FieldType & >(field));
field);
}

/**
Expand Down

0 comments on commit de2b42d

Please sign in to comment.