Skip to content

Commit

Permalink
Upgrade to clang-format 18
Browse files Browse the repository at this point in the history
  • Loading branch information
tpadioleau committed Sep 6, 2024
1 parent 49fcca9 commit 0ce130c
Show file tree
Hide file tree
Showing 37 changed files with 670 additions and 696 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
source: 'benchmarks/ examples/ include/ddc/ tests/'
exclude: ''
extensions: 'hpp,cpp'
clangFormatVersion: 12
clangFormatVersion: 18
- name: Find trailing whitespaces
run: find . -not -path './vendor/*' -type f \( -name '*.[c|h]pp' -o -name 'CMakeLists.txt' -o -name '*.cmake' -o -name '*.md' -o -name '*.py' \) -exec ./bin/trailing_spaces --Werror '{}' '+'
- name: REUSE Compliance Check
Expand Down
49 changes: 24 additions & 25 deletions benchmarks/deepcopy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,44 +12,43 @@

#include <benchmark/benchmark.h>

namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(DEEPCOPY_CPP)
namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(DEEPCOPY_CPP) {
struct DDimX
{
struct DDimX
{
};
using DElemX = ddc::DiscreteElement<DDimX>;
using DVectX = ddc::DiscreteVector<DDimX>;
using DDomX = ddc::DiscreteDomain<DDimX>;
};
using DElemX = ddc::DiscreteElement<DDimX>;
using DVectX = ddc::DiscreteVector<DDimX>;
using DDomX = ddc::DiscreteDomain<DDimX>;

template <class Datatype>
using ChunkSpanX = ddc::ChunkSpan<Datatype, DDomX>;
template <class Datatype>
using ChunkSpanX = ddc::ChunkSpan<Datatype, DDomX>;


struct DDimY
{
};
struct DDimY
{
};


using DElemXY = ddc::DiscreteElement<DDimX, DDimY>;
using DVectXY = ddc::DiscreteVector<DDimX, DDimY>;
using DDomXY = ddc::DiscreteDomain<DDimX, DDimY>;
using DElemXY = ddc::DiscreteElement<DDimX, DDimY>;
using DVectXY = ddc::DiscreteVector<DDimX, DDimY>;
using DDomXY = ddc::DiscreteDomain<DDimX, DDimY>;

template <class Datatype>
using ChunkSpanXY = ddc::ChunkSpan<Datatype, DDomXY>;
template <class Datatype>
using ChunkSpanXY = ddc::ChunkSpan<Datatype, DDomXY>;


// Let say 1MB cache
static std::size_t constexpr small_dim1_2D = 400;
static std::size_t constexpr small_dim2_2D = small_dim1_2D;
// Let say 1MB cache
static std::size_t constexpr small_dim1_2D = 400;
static std::size_t constexpr small_dim2_2D = small_dim1_2D;

static std::size_t constexpr small_dim1_1D = small_dim1_2D * small_dim1_2D;
static std::size_t constexpr small_dim1_1D = small_dim1_2D * small_dim1_2D;

static std::size_t constexpr large_dim1_2D = 2000;
static std::size_t constexpr large_dim2_2D = large_dim1_2D;
static std::size_t constexpr large_dim1_2D = 2000;
static std::size_t constexpr large_dim2_2D = large_dim1_2D;

static std::size_t constexpr large_dim1_1D = large_dim1_2D * large_dim1_2D;
static std::size_t constexpr large_dim1_1D = large_dim1_2D * large_dim1_2D;

} // namespace )
} // namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(DEEPCOPY_CPP)


static void memcpy_1d(benchmark::State& state)
Expand Down
53 changes: 26 additions & 27 deletions benchmarks/splines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,39 @@

static const ddc::SplineSolver Backend = ddc::SplineSolver::LAPACK;

namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(SPLINES_CPP)
namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(SPLINES_CPP) {
struct X
{
struct X
{
static constexpr bool PERIODIC = true;
};
static constexpr bool PERIODIC = true;
};

template <typename NonUniform, std::size_t s_degree_x>
struct BSplinesX
: std::conditional_t<
NonUniform::value,
ddc::NonUniformBSplines<X, s_degree_x>,
ddc::UniformBSplines<X, s_degree_x>>
{
};
template <typename NonUniform, std::size_t s_degree_x>
struct BSplinesX
: std::conditional_t<
NonUniform::value,
ddc::NonUniformBSplines<X, s_degree_x>,
ddc::UniformBSplines<X, s_degree_x>>
{
};

template <typename NonUniform, std::size_t s_degree_x>
using GrevillePoints = ddc::GrevilleInterpolationPoints<
BSplinesX<NonUniform, s_degree_x>,
ddc::BoundCond::PERIODIC,
ddc::BoundCond::PERIODIC>;
template <typename NonUniform, std::size_t s_degree_x>
using GrevillePoints = ddc::GrevilleInterpolationPoints<
BSplinesX<NonUniform, s_degree_x>,
ddc::BoundCond::PERIODIC,
ddc::BoundCond::PERIODIC>;

template <typename NonUniform, std::size_t s_degree_x>
struct DDimX : GrevillePoints<NonUniform, s_degree_x>::interpolation_discrete_dimension_type
{
};
template <typename NonUniform, std::size_t s_degree_x>
struct DDimX : GrevillePoints<NonUniform, s_degree_x>::interpolation_discrete_dimension_type
{
};

struct Y;
struct Y;

struct DDimY : ddc::UniformPointSampling<Y>
{
};
struct DDimY : ddc::UniformPointSampling<Y>
{
};

} // namespace )
} // namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(SPLINES_CPP)

// Function to monitor GPU memory asynchronously
void monitorMemoryAsync(std::mutex& mutex, bool& monitorFlag, size_t& maxUsedMem)
Expand Down
9 changes: 5 additions & 4 deletions include/ddc/chunk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,12 @@ class Chunk<ElementType, DiscreteDomain<DDims...>, Allocator>
};

template <class... DDims, class Allocator>
Chunk(std::string const&, DiscreteDomain<DDims...> const&, Allocator)
-> Chunk<typename Allocator::value_type, DiscreteDomain<DDims...>, Allocator>;
Chunk(std::string const&,
DiscreteDomain<DDims...> const&,
Allocator) -> Chunk<typename Allocator::value_type, DiscreteDomain<DDims...>, Allocator>;

template <class... DDims, class Allocator>
Chunk(DiscreteDomain<DDims...> const&, Allocator)
-> Chunk<typename Allocator::value_type, DiscreteDomain<DDims...>, Allocator>;
Chunk(DiscreteDomain<DDims...> const&,
Allocator) -> Chunk<typename Allocator::value_type, DiscreteDomain<DDims...>, Allocator>;

} // namespace ddc
23 changes: 13 additions & 10 deletions include/ddc/chunk_span.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ class ChunkSpan;

template <class ElementType, class SupportType, class LayoutStridedPolicy, class MemorySpace>
inline constexpr bool
enable_chunk<ChunkSpan<ElementType, SupportType, LayoutStridedPolicy, MemorySpace>> = true;
enable_chunk<ChunkSpan<ElementType, SupportType, LayoutStridedPolicy, MemorySpace>>
= true;

template <class ElementType, class SupportType, class LayoutStridedPolicy, class MemorySpace>
inline constexpr bool enable_borrowed_chunk<
ChunkSpan<ElementType, SupportType, LayoutStridedPolicy, MemorySpace>> = true;
inline constexpr bool
enable_borrowed_chunk<ChunkSpan<ElementType, SupportType, LayoutStridedPolicy, MemorySpace>>
= true;

template <class ElementType, class... DDims, class LayoutStridedPolicy, class MemorySpace>
class ChunkSpan<ElementType, DiscreteDomain<DDims...>, LayoutStridedPolicy, MemorySpace>
Expand Down Expand Up @@ -231,8 +233,8 @@ class ChunkSpan<ElementType, DiscreteDomain<DDims...>, LayoutStridedPolicy, Memo
KokkosView const& view,
discrete_domain_type const& domain) noexcept
: ChunkSpan(
detail::build_mdspan(view, std::make_index_sequence<sizeof...(DDims)> {}),
domain)
detail::build_mdspan(view, std::make_index_sequence<sizeof...(DDims)> {}),
domain)
{
}

Expand Down Expand Up @@ -345,11 +347,12 @@ template <
class KokkosView,
class... DDims,
class = std::enable_if_t<Kokkos::is_view<KokkosView>::value>>
ChunkSpan(KokkosView const& view, DiscreteDomain<DDims...> domain) -> ChunkSpan<
detail::kokkos_to_mdspan_element_t<typename KokkosView::data_type>,
DiscreteDomain<DDims...>,
detail::kokkos_to_mdspan_layout_t<typename KokkosView::array_layout>,
typename KokkosView::memory_space>;
ChunkSpan(KokkosView const& view, DiscreteDomain<DDims...> domain)
-> ChunkSpan<
detail::kokkos_to_mdspan_element_t<typename KokkosView::data_type>,
DiscreteDomain<DDims...>,
detail::kokkos_to_mdspan_layout_t<typename KokkosView::array_layout>,
typename KokkosView::memory_space>;

template <
class ElementType,
Expand Down
5 changes: 3 additions & 2 deletions include/ddc/chunk_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ inline constexpr bool is_chunk_v = enable_chunk<std::remove_const_t<std::remove_

template <class T>
inline constexpr bool is_borrowed_chunk_v
= is_chunk_v<
T> && (std::is_lvalue_reference_v<T> || enable_borrowed_chunk<std::remove_cv_t<std::remove_reference_t<T>>>);
= is_chunk_v<T>
&& (std::is_lvalue_reference_v<T>
|| enable_borrowed_chunk<std::remove_cv_t<std::remove_reference_t<T>>>);

template <class T>
struct chunk_traits
Expand Down
14 changes: 7 additions & 7 deletions include/ddc/detail/tagged_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,19 +200,19 @@ template <
class HeadTaggedVector,
class... TailTaggedVectors,
std::enable_if_t<
is_tagged_vector_v<
HeadTaggedVector> && (is_tagged_vector_v<TailTaggedVectors> && ...),
int> = 1>
is_tagged_vector_v<HeadTaggedVector>
&& (is_tagged_vector_v<TailTaggedVectors> && ...),
int>
= 1>
KOKKOS_FUNCTION constexpr auto const& take(
HeadTaggedVector const& head,
TailTaggedVectors const&... tail)
{
DDC_IF_NVCC_THEN_PUSH_AND_SUPPRESS(implicit_return_from_non_void_function)
if constexpr (type_seq_contains_v<detail::TypeSeq<QueryTag>, to_type_seq_t<HeadTaggedVector>>) {
static_assert(
(!type_seq_contains_v<
detail::TypeSeq<QueryTag>,
to_type_seq_t<TailTaggedVectors>> && ...),
(!type_seq_contains_v<detail::TypeSeq<QueryTag>, to_type_seq_t<TailTaggedVectors>>
&& ...),
"ERROR: tag redundant");
return head;
} else {
Expand All @@ -232,7 +232,7 @@ template <class ElementType, class Tag>
class TaggedVectorConversionOperators<TaggedVector<ElementType, Tag>>
{
public:
KOKKOS_FUNCTION constexpr operator ElementType const &() const noexcept
KOKKOS_FUNCTION constexpr operator ElementType const&() const noexcept
{
return static_cast<TaggedVector<ElementType, Tag> const*>(this)->m_values[0];
}
Expand Down
15 changes: 7 additions & 8 deletions include/ddc/detail/type_seq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,20 +178,19 @@ template <class TypeSeq, class OTypeSeq>
constexpr bool type_seq_contains_v = false;

template <class TypeSeq, class B>
constexpr bool type_seq_same_v = type_seq_contains_v<TypeSeq, B>&& type_seq_contains_v<B, TypeSeq>;
constexpr bool type_seq_same_v = type_seq_contains_v<TypeSeq, B> && type_seq_contains_v<B, TypeSeq>;

template <class QueryTag, class... Tags>
constexpr bool in_tags_v<QueryTag, detail::TypeSeq<Tags...>> = detail::
TypeSeqRank<detail::SingleType<QueryTag>, detail::TypeSeq<Tags...>>::present;
constexpr bool in_tags_v<QueryTag, detail::TypeSeq<Tags...>>
= detail::TypeSeqRank<detail::SingleType<QueryTag>, detail::TypeSeq<Tags...>>::present;

template <class... Tags, class OTypeSeq>
constexpr bool type_seq_contains_v<
detail::TypeSeq<Tags...>,
OTypeSeq> = ((detail::TypeSeqRank<detail::SingleType<Tags>, OTypeSeq>::present) && ...);
constexpr bool type_seq_contains_v<detail::TypeSeq<Tags...>, OTypeSeq>
= ((detail::TypeSeqRank<detail::SingleType<Tags>, OTypeSeq>::present) && ...);

template <class QueryTag, class... Tags>
constexpr std::size_t type_seq_rank_v<QueryTag, detail::TypeSeq<Tags...>> = detail::
TypeSeqRank<detail::SingleType<QueryTag>, detail::TypeSeq<Tags...>>::val;
constexpr std::size_t type_seq_rank_v<QueryTag, detail::TypeSeq<Tags...>>
= detail::TypeSeqRank<detail::SingleType<QueryTag>, detail::TypeSeq<Tags...>>::val;

template <std::size_t I, class TagSeq>
using type_seq_element_t = typename detail::TypeSeqElement<I, TagSeq>::type;
Expand Down
11 changes: 6 additions & 5 deletions include/ddc/discrete_element.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ template <
class... TailDElems,
std::enable_if_t<
is_discrete_element_v<HeadDElem> && (is_discrete_element_v<TailDElems> && ...),
int> = 1>
int>
= 1>
KOKKOS_FUNCTION constexpr auto const& take(HeadDElem const& head, TailDElems const&... tail)
{
DDC_IF_NVCC_THEN_PUSH_AND_SUPPRESS(implicit_return_from_non_void_function)
Expand Down Expand Up @@ -265,7 +266,7 @@ class DiscreteElement
template <class... OTags>
KOKKOS_FUNCTION constexpr DiscreteElement& operator+=(DiscreteVector<OTags...> const& rhs)
{
static_assert(((type_seq_contains_v<detail::TypeSeq<OTags>, tags_seq>)&&...));
static_assert(((type_seq_contains_v<detail::TypeSeq<OTags>, tags_seq>) && ...));
((m_values[type_seq_rank_v<OTags, tags_seq>] += rhs.template get<OTags>()), ...);
return *this;
}
Expand All @@ -284,7 +285,7 @@ class DiscreteElement
template <class... OTags>
KOKKOS_FUNCTION constexpr DiscreteElement& operator-=(DiscreteVector<OTags...> const& rhs)
{
static_assert(((type_seq_contains_v<detail::TypeSeq<OTags>, tags_seq>)&&...));
static_assert(((type_seq_contains_v<detail::TypeSeq<OTags>, tags_seq>) && ...));
((m_values[type_seq_rank_v<OTags, tags_seq>] -= rhs.template get<OTags>()), ...);
return *this;
}
Expand Down Expand Up @@ -377,7 +378,7 @@ KOKKOS_FUNCTION constexpr DiscreteElement<Tags...> operator+(
DiscreteVector<OTags...> const& rhs)
{
using detail::TypeSeq;
static_assert(((type_seq_contains_v<TypeSeq<OTags>, TypeSeq<Tags...>>)&&...));
static_assert(((type_seq_contains_v<TypeSeq<OTags>, TypeSeq<Tags...>>) && ...));
DiscreteElement<Tags...> result(lhs);
result += rhs;
return result;
Expand All @@ -401,7 +402,7 @@ KOKKOS_FUNCTION constexpr DiscreteElement<Tags...> operator-(
DiscreteVector<OTags...> const& rhs)
{
using detail::TypeSeq;
static_assert(((type_seq_contains_v<TypeSeq<OTags>, TypeSeq<Tags...>>)&&...));
static_assert(((type_seq_contains_v<TypeSeq<OTags>, TypeSeq<Tags...>>) && ...));
DiscreteElement<Tags...> result(lhs);
result -= rhs;
return result;
Expand Down
Loading

0 comments on commit 0ce130c

Please sign in to comment.