Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inconsistency between explicit constructors and assignement ope… #460

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions include/ddc/detail/tagged_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,22 +290,6 @@ class TaggedVector : public TaggedVectorConversionOperators<TaggedVector<Element

KOKKOS_DEFAULTED_FUNCTION TaggedVector& operator=(TaggedVector&& other) = default;

template <class... OTags>
KOKKOS_FUNCTION constexpr TaggedVector& operator=(
TaggedVector<ElementType, OTags...> const& other) noexcept
{
((this->get<Tags>() = other.template get<Tags>()), ...);
return *this;
}

template <class... OTags>
KOKKOS_FUNCTION constexpr TaggedVector& operator=(
TaggedVector<ElementType, OTags...>&& other) noexcept
{
((this->get<Tags>() = std::move(other.template get<Tags>())), ...);
return *this;
}

/// Returns a reference to the underlying `std::array`
KOKKOS_FUNCTION constexpr std::array<ElementType, sizeof...(Tags)>& array() noexcept
{
Expand Down
19 changes: 0 additions & 19 deletions include/ddc/discrete_domain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,25 +100,6 @@ class DiscreteDomain

KOKKOS_DEFAULTED_FUNCTION DiscreteDomain& operator=(DiscreteDomain&& x) = default;

/**
* @brief Copy a DiscreteDomain by reordering and slicing.
*
* An assign operator to build a DiscreteDomain from another compatible domain.
* A domain is compatible if it either contains the same dimensions as this
* domain (even if they are in a different order) or if it contains at
* the dimensions of this domain plus some additional dimensions which will
* be unused here.
*
* @param domain A compatible domain.
*/
template <class... ODDims>
DiscreteDomain& KOKKOS_FUNCTION operator=(DiscreteDomain<ODDims...> const& domain)
{
m_element_begin = DiscreteElement<DDims...>(domain.front());
m_element_end = m_element_begin + DiscreteVector<DDims...>(domain.extents());
return *this;
}

template <class... ODims>
KOKKOS_FUNCTION constexpr bool operator==(DiscreteDomain<ODims...> const& other) const
{
Expand Down
15 changes: 0 additions & 15 deletions include/ddc/discrete_element.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,21 +192,6 @@ class DiscreteElement

KOKKOS_DEFAULTED_FUNCTION DiscreteElement& operator=(DiscreteElement&& other) = default;

template <class... OTags>
KOKKOS_FUNCTION constexpr DiscreteElement& operator=(
DiscreteElement<OTags...> const& other) noexcept
{
m_values = other.m_values;
return *this;
}

template <class... OTags>
KOKKOS_FUNCTION constexpr DiscreteElement& operator=(DiscreteElement<OTags...>&& other) noexcept
{
m_values = std::move(other.m_values);
return *this;
}

template <class QueryTag>
KOKKOS_FUNCTION constexpr value_type const& uid_or(value_type const& default_value) const&
{
Expand Down
15 changes: 0 additions & 15 deletions include/ddc/discrete_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,21 +300,6 @@ class DiscreteVector : public detail::DiscreteVectorConversionOperators<Discrete

KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteVector& operator=(DiscreteVector&& other) = default;

template <class... OTags>
KOKKOS_FUNCTION constexpr DiscreteVector& operator=(
DiscreteVector<OTags...> const& other) noexcept
{
m_values = other.m_values;
return *this;
}

template <class... OTags>
KOKKOS_FUNCTION constexpr DiscreteVector& operator=(DiscreteVector<OTags...>&& other) noexcept
{
m_values = std::move(other.m_values);
return *this;
}

template <class... OTags>
KOKKOS_FUNCTION constexpr bool operator==(DiscreteVector<OTags...> const& rhs) const noexcept
{
Expand Down
16 changes: 0 additions & 16 deletions tests/discrete_domain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,19 +252,3 @@ TEST(ProductMDomainTest, Transpose3DConstructor)
EXPECT_EQ(ddc::select<DDimY>(dom_x_y_z.back()), ddc::select<DDimY>(dom_z_y_x.back()));
EXPECT_EQ(ddc::select<DDimZ>(dom_x_y_z.back()), ddc::select<DDimZ>(dom_z_y_x.back()));
}

TEST(ProductMDomainTest, Transpose3DAssign)
{
DDomX const dom_x(lbound_x, nelems_x);
DDomY const dom_y(lbound_y, nelems_y);
DDomZ const dom_z(lbound_z, nelems_z);
DDomXYZ const dom_x_y_z(dom_x, dom_y, dom_z);
DDomZYX dom_z_y_x;
dom_z_y_x = dom_x_y_z;
EXPECT_EQ(ddc::select<DDimX>(dom_x_y_z.front()), ddc::select<DDimX>(dom_z_y_x.front()));
EXPECT_EQ(ddc::select<DDimY>(dom_x_y_z.front()), ddc::select<DDimY>(dom_z_y_x.front()));
EXPECT_EQ(ddc::select<DDimZ>(dom_x_y_z.front()), ddc::select<DDimZ>(dom_z_y_x.front()));
EXPECT_EQ(ddc::select<DDimX>(dom_x_y_z.back()), ddc::select<DDimX>(dom_z_y_x.back()));
EXPECT_EQ(ddc::select<DDimY>(dom_x_y_z.back()), ddc::select<DDimY>(dom_z_y_x.back()));
EXPECT_EQ(ddc::select<DDimZ>(dom_x_y_z.back()), ddc::select<DDimZ>(dom_z_y_x.back()));
}
13 changes: 13 additions & 0 deletions tests/discrete_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ TEST(DiscreteElementXYZTest, ConstructorFromDiscreteElements)
EXPECT_EQ(ixyz.uid<DDimZ>(), uid_z);
}

TEST(DiscreteElementXYZTest, CopyAssignment)
{
std::size_t const uid_x = 7;
std::size_t const uid_y = 13;
std::size_t const uid_z = 4;
DElemXYZ const ixyz(uid_x, uid_y, uid_z);
DElemXYZ ixyz2(0, 0, 0);
ixyz2 = ixyz;
EXPECT_EQ(ixyz2.uid<DDimX>(), uid_x);
EXPECT_EQ(ixyz2.uid<DDimY>(), uid_y);
EXPECT_EQ(ixyz2.uid<DDimZ>(), uid_z);
}

TEST(DiscreteElementXTest, PreIncrement)
{
DElemX const ix0(3);
Expand Down
18 changes: 0 additions & 18 deletions tests/tagged_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,6 @@ TEST(TaggedVector, Assignment)
EXPECT_EQ(a.get<float>(), b.get<float>());
}

TEST(TaggedVector, ReorderingAssignment)
{
ddc::detail::TaggedVector<int, double, float> const a(1, 2);
ddc::detail::TaggedVector<int, float, double> b;
b = a;
EXPECT_EQ(a.get<double>(), b.get<double>());
EXPECT_EQ(a.get<float>(), b.get<float>());
}

TEST(TaggedVector, MoveAssignment)
{
ddc::detail::TaggedVector<int, double, float> a(1, 2);
Expand All @@ -105,15 +96,6 @@ TEST(TaggedVector, MoveAssignment)
EXPECT_EQ(2, b.get<float>());
}

TEST(TaggedVector, ReorderingMoveAssignment)
{
ddc::detail::TaggedVector<int, double, float> a(1, 2);
ddc::detail::TaggedVector<int, float, double> b;
b = std::move(a);
EXPECT_EQ(1, b.get<double>());
EXPECT_EQ(2, b.get<float>());
}

TEST(TaggedVector, Conversion)
{
ddc::detail::TaggedVector<int, float, double> const a(1, 2);
Expand Down