Skip to content

Commit

Permalink
Format and fix doc
Browse files Browse the repository at this point in the history
  • Loading branch information
tpadioleau committed Mar 29, 2023
1 parent 3b5160c commit f9f51a9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 23 deletions.
42 changes: 24 additions & 18 deletions include/ddc/discrete_domain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class DiscreteDomain<>

constexpr DiscreteDomain() = default;

// Construct a DiscreteDomain from a reordered copy of `domain`
// Construct a DiscreteDomain from a reordered copy of `domain`
template <class... ODDims>
explicit constexpr DiscreteDomain(DiscreteDomain<ODDims...> const& domain)
{
Expand All @@ -259,7 +259,9 @@ class DiscreteDomain<>
* @param element_begin the lower bound in each direction
* @param size the number of points in each direction
*/
constexpr DiscreteDomain(discrete_element_type const&, mlength_type const&)
constexpr DiscreteDomain(
[[maybe_unused]] discrete_element_type const& element_begin,
[[maybe_unused]] mlength_type const& size)
{
}

Expand Down Expand Up @@ -356,29 +358,33 @@ constexpr DiscreteDomain<QueryDDims...> select(DiscreteDomain<DDims...> const& d
select<QueryDDims...>(domain.front()),
select<QueryDDims...>(domain.extents()));
}
namespace ddc_detail

namespace ddc_detail {

template <class T>
struct ConvertTypeSeqToDiscreteDomain;

template <class... DDims>
struct ConvertTypeSeqToDiscreteDomain<ddc_detail::TypeSeq<DDims...>>
{
template<class T>
struct ConvertTypeSeqToDiscreteDomain;
using type = DiscreteDomain<DDims...>;
};

template<class... DDims>
struct ConvertTypeSeqToDiscreteDomain<ddc_detail::TypeSeq<DDims...>>
{
using type = DiscreteDomain<DDims...>;
};
template <class T>
using convert_type_seq_to_discrete_domain = typename ConvertTypeSeqToDiscreteDomain<T>::type;

template<class T>
using convert_type_seq_to_discrete_domain = typename ConvertTypeSeqToDiscreteDomain<T>::type;
}
} // namespace ddc_detail

template <class... DDimsA, class... DDimsB>
constexpr auto remove_dims_of(DiscreteDomain<DDimsA...> const& DDom_a, DiscreteDomain<DDimsB...> const& DDom_b) noexcept
constexpr auto remove_dims_of(
DiscreteDomain<DDimsA...> const& DDom_a,
DiscreteDomain<DDimsB...> const& DDom_b) noexcept
{
using TagSeqA = ddc_detail::TypeSeq<DDimsA...>;
using TagSeqB = ddc_detail::TypeSeq<DDimsB...>;
using TagSeqA = ddc_detail::TypeSeq<DDimsA...>;
using TagSeqB = ddc_detail::TypeSeq<DDimsB...>;

using type_seq_r = type_seq_remove_t<TagSeqA, TagSeqB>;
return ddc_detail::convert_type_seq_to_discrete_domain<type_seq_r>(DDom_a);
using type_seq_r = type_seq_remove_t<TagSeqA, TagSeqB>;
return ddc_detail::convert_type_seq_to_discrete_domain<type_seq_r>(DDom_a);
}

template <class... QueryDDims, class... DDims>
Expand Down
8 changes: 4 additions & 4 deletions tests/discrete_domain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ TEST(ProductMDomainTest, RangeFor)
TEST(ProductMDomainTest, DiffEmpty)
{
DDomX const dom_x = DDomX();
auto const subdomain = ddc::remove_dims_of(dom_x, dom_x);
EXPECT_EQ(subdomain, ddc::DiscreteDomain<>());
auto const subdomain = ddc::remove_dims_of(dom_x, dom_x);
EXPECT_EQ(subdomain, ddc::DiscreteDomain<>());
}

TEST(ProductMDomainTest, Diff)
{
DDomX const dom_x = DDomX();
DDomXY const dom_x_y = DDomXY();
DDomZY const dom_z_y = DDomZY();
auto const subdomain = ddc::remove_dims_of(dom_x_y, dom_z_y);
EXPECT_EQ(subdomain, dom_x);
auto const subdomain = ddc::remove_dims_of(dom_x_y, dom_z_y);
EXPECT_EQ(subdomain, dom_x);
}
2 changes: 1 addition & 1 deletion tests/for_each.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ TEST(ForEachSerialHost, Empty)
ddc::ChunkSpan<int, DDomX> view(storage.data(), dom);
ddc::for_each(ddc::policies::serial_host, dom, [=](DElemX const ix) { view(ix) += 1; });
ASSERT_EQ(std::count(storage.begin(), storage.end(), 1), dom.size())
<< std::count(storage.begin(), storage.end(), 1) << std::endl;
<< std::count(storage.begin(), storage.end(), 1) << std::endl;
}

TEST(ForEachSerialHost, ZeroDimension)
Expand Down

0 comments on commit f9f51a9

Please sign in to comment.