From 2a84936df3c5e3df022a704491fcafb2d19d2995 Mon Sep 17 00:00:00 2001 From: Thomas Padioleau Date: Sun, 26 May 2024 14:43:09 +0200 Subject: [PATCH] Fix anonymous namespace issue on for HIP --- benchmarks/deepcopy.cpp | 50 +++---- benchmarks/splines.cpp | 41 +++--- include/ddc/detail/macros.hpp | 9 ++ tests/chunk.cpp | 106 +++++++-------- tests/discrete_domain.cpp | 106 +++++++-------- tests/discrete_element.cpp | 46 +++---- tests/discrete_space.cpp | 12 +- tests/discrete_vector.cpp | 32 ++--- tests/for_each.cpp | 66 +++++----- tests/multiple_discrete_dimensions.cpp | 72 +++++----- tests/non_uniform_point_sampling.cpp | 40 +++--- tests/parallel_deepcopy.cpp | 46 +++---- tests/parallel_fill.cpp | 46 +++---- tests/parallel_for_each.cpp | 174 ++++++++++++------------- tests/single_discretization.cpp | 18 +-- tests/splines/matrix.cpp | 97 +++++++------- tests/type_seq.cpp | 20 +-- tests/uniform_point_sampling.cpp | 30 ++--- 18 files changed, 511 insertions(+), 500 deletions(-) diff --git a/benchmarks/deepcopy.cpp b/benchmarks/deepcopy.cpp index d4518e415..0d195d8ec 100644 --- a/benchmarks/deepcopy.cpp +++ b/benchmarks/deepcopy.cpp @@ -12,44 +12,44 @@ #include -namespace { - -struct DDimX +namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(DEEPCOPY_CPP) { -}; -using DElemX = ddc::DiscreteElement; -using DVectX = ddc::DiscreteVector; -using DDomX = ddc::DiscreteDomain; + struct DDimX + { + }; + using DElemX = ddc::DiscreteElement; + using DVectX = ddc::DiscreteVector; + using DDomX = ddc::DiscreteDomain; -template -using ChunkSpanX = ddc::ChunkSpan; + template + using ChunkSpanX = ddc::ChunkSpan; -struct DDimY -{ -}; + struct DDimY + { + }; -using DElemXY = ddc::DiscreteElement; -using DVectXY = ddc::DiscreteVector; -using DDomXY = ddc::DiscreteDomain; + using DElemXY = ddc::DiscreteElement; + using DVectXY = ddc::DiscreteVector; + using DDomXY = ddc::DiscreteDomain; -template -using ChunkSpanXY = ddc::ChunkSpan; + template + using ChunkSpanXY = ddc::ChunkSpan; -// 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 ) static void memcpy_1d(benchmark::State& state) diff --git a/benchmarks/splines.cpp b/benchmarks/splines.cpp index 4a7e9f2b4..f6bda61f0 100644 --- a/benchmarks/splines.cpp +++ b/benchmarks/splines.cpp @@ -14,31 +14,32 @@ #include -namespace { - -static constexpr std::size_t s_degree_x = 3; - -struct X +namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(SPLINES_CPP) { - static constexpr bool PERIODIC = true; -}; + static constexpr std::size_t s_degree_x = 3; -struct BSplinesX : ddc::UniformBSplines -{ -}; -using GrevillePoints = ddc:: - GrevilleInterpolationPoints; -struct DDimX : GrevillePoints::interpolation_mesh_type -{ -}; + struct X + { + static constexpr bool PERIODIC = true; + }; -struct Y; -struct DDimY : ddc::UniformPointSampling -{ -}; + struct BSplinesX : ddc::UniformBSplines + { + }; + using GrevillePoints = ddc::GrevilleInterpolationPoints< + BSplinesX, + ddc::BoundCond::PERIODIC, + ddc::BoundCond::PERIODIC>; + struct DDimX : GrevillePoints::interpolation_mesh_type + { + }; + struct Y; + struct DDimY : ddc::UniformPointSampling + { + }; -} // namespace +} // namespace ) // Function to monitor GPU memory asynchronously void monitorMemoryAsync(std::mutex& mutex, bool& monitorFlag, size_t& maxUsedMem) diff --git a/include/ddc/detail/macros.hpp b/include/ddc/detail/macros.hpp index 46f9ed1ed..cdfe357fa 100644 --- a/include/ddc/detail/macros.hpp +++ b/include/ddc/detail/macros.hpp @@ -43,3 +43,12 @@ #else #define DDC_CURRENT_KOKKOS_SPACE Kokkos::HostSpace #endif + +#if defined(__HIPCC__) +#define DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(NAME) \ + DDC_NAMESPACE_##NAME {} \ + using namespace DDC_NAMESPACE_##NAME; \ + namespace DDC_NAMESPACE_##NAME +#else +#define DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(NAME) +#endif diff --git a/tests/chunk.cpp b/tests/chunk.cpp index b3801c660..dc5670db9 100644 --- a/tests/chunk.cpp +++ b/tests/chunk.cpp @@ -10,80 +10,80 @@ #include -namespace { +namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(CHUNK_CPP) +{ + using DElem0D = ddc::DiscreteElement<>; + using DVect0D = ddc::DiscreteVector<>; + using DDom0D = ddc::DiscreteDomain<>; -using DElem0D = ddc::DiscreteElement<>; -using DVect0D = ddc::DiscreteVector<>; -using DDom0D = ddc::DiscreteDomain<>; + template + using Chunk0D = ddc::Chunk; + template + using ChunkSpan0D = ddc::ChunkSpan; -template -using Chunk0D = ddc::Chunk; -template -using ChunkSpan0D = ddc::ChunkSpan; + struct DDimX + { + }; + using DElemX = ddc::DiscreteElement; + using DVectX = ddc::DiscreteVector; + using DDomX = ddc::DiscreteDomain; -struct DDimX -{ -}; -using DElemX = ddc::DiscreteElement; -using DVectX = ddc::DiscreteVector; -using DDomX = ddc::DiscreteDomain; + template + using ChunkX = ddc::Chunk; -template -using ChunkX = ddc::Chunk; + struct DDimY + { + }; + using DElemY = ddc::DiscreteElement; + using DVectY = ddc::DiscreteVector; + using DDomY = ddc::DiscreteDomain; -struct DDimY -{ -}; -using DElemY = ddc::DiscreteElement; -using DVectY = ddc::DiscreteVector; -using DDomY = ddc::DiscreteDomain; + template + using ChunkY = ddc::Chunk; -template -using ChunkY = ddc::Chunk; - -struct DDimZ -{ -}; -using DElemZ = ddc::DiscreteElement; -using DVectZ = ddc::DiscreteVector; -using DDomZ = ddc::DiscreteDomain; + struct DDimZ + { + }; + using DElemZ = ddc::DiscreteElement; + using DVectZ = ddc::DiscreteVector; + using DDomZ = ddc::DiscreteDomain; -using DElemXY = ddc::DiscreteElement; -using DVectXY = ddc::DiscreteVector; -using DDomXY = ddc::DiscreteDomain; + using DElemXY = ddc::DiscreteElement; + using DVectXY = ddc::DiscreteVector; + using DDomXY = ddc::DiscreteDomain; -template -using ChunkXY = ddc::Chunk; + template + using ChunkXY = ddc::Chunk; -using DElemYX = ddc::DiscreteElement; -using DVectYX = ddc::DiscreteVector; -using DDomYX = ddc::DiscreteDomain; + using DElemYX = ddc::DiscreteElement; + using DVectYX = ddc::DiscreteVector; + using DDomYX = ddc::DiscreteDomain; -template -using ChunkYX = ddc::Chunk; + template + using ChunkYX = ddc::Chunk; -static DElem0D constexpr lbound_0d {}; -static DVect0D constexpr nelems_0d {}; -static DDom0D constexpr dom_0d(lbound_0d, nelems_0d); + static DElem0D constexpr lbound_0d {}; + static DVect0D constexpr nelems_0d {}; + static DDom0D constexpr dom_0d(lbound_0d, nelems_0d); -static DElemX constexpr lbound_x(50); -static DVectX constexpr nelems_x(3); -static DDomX constexpr dom_x(lbound_x, nelems_x); + static DElemX constexpr lbound_x(50); + static DVectX constexpr nelems_x(3); + static DDomX constexpr dom_x(lbound_x, nelems_x); -static DElemY constexpr lbound_y(4); -static DVectY constexpr nelems_y(12); + static DElemY constexpr lbound_y(4); + static DVectY constexpr nelems_y(12); -static DElemXY constexpr lbound_x_y(lbound_x, lbound_y); -static DVectXY constexpr nelems_x_y(nelems_x, nelems_y); -static DDomXY constexpr dom_x_y(lbound_x_y, nelems_x_y); + static DElemXY constexpr lbound_x_y(lbound_x, lbound_y); + static DVectXY constexpr nelems_x_y(nelems_x, nelems_y); + static DDomXY constexpr dom_x_y(lbound_x_y, nelems_x_y); -} // namespace +} // namespace ) // Member types of Chunk 1D \{ diff --git a/tests/discrete_domain.cpp b/tests/discrete_domain.cpp index e830eecca..e0af8fbf2 100644 --- a/tests/discrete_domain.cpp +++ b/tests/discrete_domain.cpp @@ -6,80 +6,80 @@ #include -namespace { - -struct DDimX +namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(DISCRETE_DOMAIN_CPP) { -}; -using DElemX = ddc::DiscreteElement; -using DVectX = ddc::DiscreteVector; -using DDomX = ddc::DiscreteDomain; + struct DDimX + { + }; + using DElemX = ddc::DiscreteElement; + using DVectX = ddc::DiscreteVector; + using DDomX = ddc::DiscreteDomain; -struct DDimY -{ -}; -using DElemY = ddc::DiscreteElement; -using DVectY = ddc::DiscreteVector; -using DDomY = ddc::DiscreteDomain; + struct DDimY + { + }; + using DElemY = ddc::DiscreteElement; + using DVectY = ddc::DiscreteVector; + using DDomY = ddc::DiscreteDomain; -struct DDimZ -{ -}; -using DElemZ = ddc::DiscreteElement; -using DVectZ = ddc::DiscreteVector; -using DDomZ = ddc::DiscreteDomain; + struct DDimZ + { + }; + using DElemZ = ddc::DiscreteElement; + using DVectZ = ddc::DiscreteVector; + using DDomZ = ddc::DiscreteDomain; -using DElemXY = ddc::DiscreteElement; -using DVectXY = ddc::DiscreteVector; -using DDomXY = ddc::DiscreteDomain; + using DElemXY = ddc::DiscreteElement; + using DVectXY = ddc::DiscreteVector; + using DDomXY = ddc::DiscreteDomain; -using DElemYX = ddc::DiscreteElement; -using DVectYX = ddc::DiscreteVector; -using DDomYX = ddc::DiscreteDomain; + using DElemYX = ddc::DiscreteElement; + using DVectYX = ddc::DiscreteVector; + using DDomYX = ddc::DiscreteDomain; -using DElemXZ = ddc::DiscreteElement; -using DVectXZ = ddc::DiscreteVector; -using DDomXZ = ddc::DiscreteDomain; + using DElemXZ = ddc::DiscreteElement; + using DVectXZ = ddc::DiscreteVector; + using DDomXZ = ddc::DiscreteDomain; -using DElemZY = ddc::DiscreteElement; -using DVectZY = ddc::DiscreteVector; -using DDomZY = ddc::DiscreteDomain; + using DElemZY = ddc::DiscreteElement; + using DVectZY = ddc::DiscreteVector; + using DDomZY = ddc::DiscreteDomain; -using DElemXYZ = ddc::DiscreteElement; -using DVectXYZ = ddc::DiscreteVector; -using DDomXYZ = ddc::DiscreteDomain; + using DElemXYZ = ddc::DiscreteElement; + using DVectXYZ = ddc::DiscreteVector; + using DDomXYZ = ddc::DiscreteDomain; -using DElemZYX = ddc::DiscreteElement; -using DVectZYX = ddc::DiscreteVector; -using DDomZYX = ddc::DiscreteDomain; + using DElemZYX = ddc::DiscreteElement; + using DVectZYX = ddc::DiscreteVector; + using DDomZYX = ddc::DiscreteDomain; -static DElemX constexpr lbound_x(50); -static DVectX constexpr nelems_x(3); -static DElemX constexpr sentinel_x(lbound_x + nelems_x); -static DElemX constexpr ubound_x(sentinel_x - 1); + static DElemX constexpr lbound_x(50); + static DVectX constexpr nelems_x(3); + static DElemX constexpr sentinel_x(lbound_x + nelems_x); + static DElemX constexpr ubound_x(sentinel_x - 1); -static DElemY constexpr lbound_y(4); -static DVectY constexpr nelems_y(12); -static DElemY constexpr sentinel_y(lbound_y + nelems_y); -static DElemY constexpr ubound_y(sentinel_y - 1); + static DElemY constexpr lbound_y(4); + static DVectY constexpr nelems_y(12); + static DElemY constexpr sentinel_y(lbound_y + nelems_y); + static DElemY constexpr ubound_y(sentinel_y - 1); -static DElemZ constexpr lbound_z(7); -static DVectZ constexpr nelems_z(15); + static DElemZ constexpr lbound_z(7); + static DVectZ constexpr nelems_z(15); -static DElemXY constexpr lbound_x_y(lbound_x, lbound_y); -static DVectXY constexpr nelems_x_y(nelems_x, nelems_y); -static DElemXY constexpr ubound_x_y(ubound_x, ubound_y); + static DElemXY constexpr lbound_x_y(lbound_x, lbound_y); + static DVectXY constexpr nelems_x_y(nelems_x, nelems_y); + static DElemXY constexpr ubound_x_y(ubound_x, ubound_y); -static DElemXZ constexpr lbound_x_z(lbound_x, lbound_z); -static DVectXZ constexpr nelems_x_z(nelems_x, nelems_z); + static DElemXZ constexpr lbound_x_z(lbound_x, lbound_z); + static DVectXZ constexpr nelems_x_z(nelems_x, nelems_z); -} // namespace +} // namespace ) TEST(DiscreteDomainTest, Constructor) { diff --git a/tests/discrete_element.cpp b/tests/discrete_element.cpp index bf4128f57..7ac413994 100644 --- a/tests/discrete_element.cpp +++ b/tests/discrete_element.cpp @@ -8,41 +8,41 @@ #include -namespace { - -struct DDimX +namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(DISCRETE_ELEMENT_CPP) { -}; -using DElemX = ddc::DiscreteElement; -using DVectX = ddc::DiscreteVector; + struct DDimX + { + }; + using DElemX = ddc::DiscreteElement; + using DVectX = ddc::DiscreteVector; -struct DDimY -{ -}; -using DElemY = ddc::DiscreteElement; -using DVectY = ddc::DiscreteVector; + struct DDimY + { + }; + using DElemY = ddc::DiscreteElement; + using DVectY = ddc::DiscreteVector; -struct DDimZ -{ -}; -using DElemZ = ddc::DiscreteElement; -using DVectZ = ddc::DiscreteVector; + struct DDimZ + { + }; + using DElemZ = ddc::DiscreteElement; + using DVectZ = ddc::DiscreteVector; -using DElemXY = ddc::DiscreteElement; -using DVectXY = ddc::DiscreteVector; + using DElemXY = ddc::DiscreteElement; + using DVectXY = ddc::DiscreteVector; -using DElemYX = ddc::DiscreteElement; -using DVectYX = ddc::DiscreteVector; + using DElemYX = ddc::DiscreteElement; + using DVectYX = ddc::DiscreteVector; -using DElemXYZ = ddc::DiscreteElement; -using DVectXYZ = ddc::DiscreteVector; + using DElemXYZ = ddc::DiscreteElement; + using DVectXYZ = ddc::DiscreteVector; -} // namespace +} // namespace ) TEST(DiscreteElementXYZTest, ConstructorFromDiscreteElements) { diff --git a/tests/discrete_space.cpp b/tests/discrete_space.cpp index 1400b991a..41b79d196 100644 --- a/tests/discrete_space.cpp +++ b/tests/discrete_space.cpp @@ -6,14 +6,14 @@ #include -namespace { - -struct DimX; -struct DDimX : ddc::UniformPointSampling +namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(DISCRETE_SPACE_CPP) { -}; + struct DimX; + struct DDimX : ddc::UniformPointSampling + { + }; -} // namespace +} // namespace ) TEST(DiscreteSpace, IsDiscreteSpaceInitialized) { diff --git a/tests/discrete_vector.cpp b/tests/discrete_vector.cpp index a4f95c715..ea0bd9afe 100644 --- a/tests/discrete_vector.cpp +++ b/tests/discrete_vector.cpp @@ -8,32 +8,32 @@ #include -namespace { - -struct DDimX +namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(DISCRETE_VECTOR_CPP) { -}; -using DVectX = ddc::DiscreteVector; + struct DDimX + { + }; + using DVectX = ddc::DiscreteVector; -struct DDimY -{ -}; -using DVectY = ddc::DiscreteVector; + struct DDimY + { + }; + using DVectY = ddc::DiscreteVector; -struct DDimZ -{ -}; -using DVectZ = ddc::DiscreteVector; + struct DDimZ + { + }; + using DVectZ = ddc::DiscreteVector; -using DVectXZ = ddc::DiscreteVector; + using DVectXZ = ddc::DiscreteVector; -using DVectXYZ = ddc::DiscreteVector; + using DVectXYZ = ddc::DiscreteVector; -} // namespace +} // namespace ) TEST(DiscreteVectorXYZTest, ConstructorFromDiscreteVectors) { diff --git a/tests/for_each.cpp b/tests/for_each.cpp index 947337b0b..fd01bb683 100644 --- a/tests/for_each.cpp +++ b/tests/for_each.cpp @@ -11,40 +11,40 @@ #include -namespace { - -using DElem0D = ddc::DiscreteElement<>; -using DVect0D = ddc::DiscreteVector<>; -using DDom0D = ddc::DiscreteDomain<>; - -struct DDimX +namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(FOR_EACH_CPP) { -}; -using DElemX = ddc::DiscreteElement; -using DVectX = ddc::DiscreteVector; -using DDomX = ddc::DiscreteDomain; - -struct DDimY -{ -}; -using DElemY = ddc::DiscreteElement; -using DVectY = ddc::DiscreteVector; -using DDomY = ddc::DiscreteDomain; - -using DElemXY = ddc::DiscreteElement; -using DVectXY = ddc::DiscreteVector; -using DDomXY = ddc::DiscreteDomain; - -static DElemX constexpr lbound_x(0); -static DVectX constexpr nelems_x(10); - -static DElemY constexpr lbound_y(0); -static DVectY constexpr nelems_y(12); - -static DElemXY constexpr lbound_x_y(lbound_x, lbound_y); -static DVectXY constexpr nelems_x_y(nelems_x, nelems_y); - -} // namespace + using DElem0D = ddc::DiscreteElement<>; + using DVect0D = ddc::DiscreteVector<>; + using DDom0D = ddc::DiscreteDomain<>; + + struct DDimX + { + }; + using DElemX = ddc::DiscreteElement; + using DVectX = ddc::DiscreteVector; + using DDomX = ddc::DiscreteDomain; + + struct DDimY + { + }; + using DElemY = ddc::DiscreteElement; + using DVectY = ddc::DiscreteVector; + using DDomY = ddc::DiscreteDomain; + + using DElemXY = ddc::DiscreteElement; + using DVectXY = ddc::DiscreteVector; + using DDomXY = ddc::DiscreteDomain; + + static DElemX constexpr lbound_x(0); + static DVectX constexpr nelems_x(10); + + static DElemY constexpr lbound_y(0); + static DVectY constexpr nelems_y(12); + + static DElemXY constexpr lbound_x_y(lbound_x, lbound_y); + static DVectXY constexpr nelems_x_y(nelems_x, nelems_y); + +} // namespace ) TEST(ForEachSerialHost, Empty) { diff --git a/tests/multiple_discrete_dimensions.cpp b/tests/multiple_discrete_dimensions.cpp index 1a99be69f..a00686528 100644 --- a/tests/multiple_discrete_dimensions.cpp +++ b/tests/multiple_discrete_dimensions.cpp @@ -8,57 +8,57 @@ #include -namespace { - -class SingleValueDiscreteDimension +namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(MULTIPLE_DISCRETE_DIMENSIONS_CPP) { -public: - using discrete_dimension_type = SingleValueDiscreteDimension; - -public: - template - class Impl + class SingleValueDiscreteDimension { - template - friend class Impl; - - private: - int m_value; - public: using discrete_dimension_type = SingleValueDiscreteDimension; - Impl() = default; + public: + template + class Impl + { + template + friend class Impl; - Impl(Impl const&) = delete; + private: + int m_value; - template - explicit Impl(Impl const& impl) : m_value(impl.m_value) - { - } + public: + using discrete_dimension_type = SingleValueDiscreteDimension; - Impl(Impl&&) = default; + Impl() = default; - explicit Impl(int value) : m_value(value) {} + Impl(Impl const&) = delete; - ~Impl() = default; + template + explicit Impl(Impl const& impl) : m_value(impl.m_value) + { + } - KOKKOS_FUNCTION int value() const noexcept - { - return m_value; - } + Impl(Impl&&) = default; + + explicit Impl(int value) : m_value(value) {} + + ~Impl() = default; + + KOKKOS_FUNCTION int value() const noexcept + { + return m_value; + } + }; }; -}; -struct SVDD1 : SingleValueDiscreteDimension -{ -}; + struct SVDD1 : SingleValueDiscreteDimension + { + }; -struct SVDD2 : SingleValueDiscreteDimension -{ -}; + struct SVDD2 : SingleValueDiscreteDimension + { + }; -} // namespace +} // namespace ) TEST(MultipleDiscreteDimensions, Value) { diff --git a/tests/non_uniform_point_sampling.cpp b/tests/non_uniform_point_sampling.cpp index 0801c037d..afb250bad 100644 --- a/tests/non_uniform_point_sampling.cpp +++ b/tests/non_uniform_point_sampling.cpp @@ -24,34 +24,34 @@ ddc::Coordinate(0.4) \ } -namespace { - -struct DimX; -struct DimY; - -struct DDimX : ddc::NonUniformPointSampling +namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(NON_UNIFORM_POINT_SAMPLING_CPP) { -}; + struct DimX; + struct DimY; -struct DDimY : ddc::NonUniformPointSampling -{ -}; + struct DDimX : ddc::NonUniformPointSampling + { + }; + + struct DDimY : ddc::NonUniformPointSampling + { + }; -static std::array const array_points_x VALUES_X; -static std::vector const vector_points_x VALUES_X; + static std::array const array_points_x VALUES_X; + static std::vector const vector_points_x VALUES_X; -static std::vector const vector_points_y VALUES_Y; + static std::vector const vector_points_y VALUES_Y; -static ddc::DiscreteElement constexpr point_ix(2); -static ddc::Coordinate constexpr point_rx(0.3); + static ddc::DiscreteElement constexpr point_ix(2); + static ddc::Coordinate constexpr point_rx(0.3); -static ddc::DiscreteElement constexpr point_iy(1); -static ddc::Coordinate constexpr point_ry(0.2); + static ddc::DiscreteElement constexpr point_iy(1); + static ddc::Coordinate constexpr point_ry(0.2); -static ddc::DiscreteElement constexpr point_ixy(2, 1); -static ddc::Coordinate constexpr point_rxy(0.3, 0.2); + static ddc::DiscreteElement constexpr point_ixy(2, 1); + static ddc::Coordinate constexpr point_rxy(0.3, 0.2); -} // namespace +} // namespace ) TEST(NonUniformPointSamplingTest, ListConstructor) { diff --git a/tests/parallel_deepcopy.cpp b/tests/parallel_deepcopy.cpp index f216fafd7..d8c7e44cb 100644 --- a/tests/parallel_deepcopy.cpp +++ b/tests/parallel_deepcopy.cpp @@ -9,36 +9,36 @@ #include -namespace { - -struct DDimX +namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(PARALLEL_DEEPCOPY_CPP) { -}; -using DElemX = ddc::DiscreteElement; -using DVectX = ddc::DiscreteVector; -using DDomX = ddc::DiscreteDomain; + struct DDimX + { + }; + using DElemX = ddc::DiscreteElement; + using DVectX = ddc::DiscreteVector; + using DDomX = ddc::DiscreteDomain; -struct DDimY -{ -}; -using DElemY = ddc::DiscreteElement; -using DVectY = ddc::DiscreteVector; -using DDomY = ddc::DiscreteDomain; + struct DDimY + { + }; + using DElemY = ddc::DiscreteElement; + using DVectY = ddc::DiscreteVector; + using DDomY = ddc::DiscreteDomain; -using DElemXY = ddc::DiscreteElement; -using DVectXY = ddc::DiscreteVector; -using DDomXY = ddc::DiscreteDomain; + using DElemXY = ddc::DiscreteElement; + using DVectXY = ddc::DiscreteVector; + using DDomXY = ddc::DiscreteDomain; -static DElemX constexpr lbound_x(0); -static DVectX constexpr nelems_x(2); + static DElemX constexpr lbound_x(0); + static DVectX constexpr nelems_x(2); -static DElemY constexpr lbound_y(0); -static DVectY constexpr nelems_y(2); + static DElemY constexpr lbound_y(0); + static DVectY constexpr nelems_y(2); -static DElemXY constexpr lbound_x_y(lbound_x, lbound_y); -static DVectXY constexpr nelems_x_y(nelems_x, nelems_y); + static DElemXY constexpr lbound_x_y(lbound_x, lbound_y); + static DVectXY constexpr nelems_x_y(nelems_x, nelems_y); -} // namespace +} // namespace ) TEST(ParallelDeepcopy, TwoDimensions) { diff --git a/tests/parallel_fill.cpp b/tests/parallel_fill.cpp index af7be3fe7..e3ae91444 100644 --- a/tests/parallel_fill.cpp +++ b/tests/parallel_fill.cpp @@ -9,36 +9,36 @@ #include -namespace { - -struct DDimX +namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(PARALLEL_FILL_CPP) { -}; -using DElemX = ddc::DiscreteElement; -using DVectX = ddc::DiscreteVector; -using DDomX = ddc::DiscreteDomain; + struct DDimX + { + }; + using DElemX = ddc::DiscreteElement; + using DVectX = ddc::DiscreteVector; + using DDomX = ddc::DiscreteDomain; -struct DDimY -{ -}; -using DElemY = ddc::DiscreteElement; -using DVectY = ddc::DiscreteVector; -using DDomY = ddc::DiscreteDomain; + struct DDimY + { + }; + using DElemY = ddc::DiscreteElement; + using DVectY = ddc::DiscreteVector; + using DDomY = ddc::DiscreteDomain; -using DElemXY = ddc::DiscreteElement; -using DVectXY = ddc::DiscreteVector; -using DDomXY = ddc::DiscreteDomain; + using DElemXY = ddc::DiscreteElement; + using DVectXY = ddc::DiscreteVector; + using DDomXY = ddc::DiscreteDomain; -static DElemX constexpr lbound_x(0); -static DVectX constexpr nelems_x(10); + static DElemX constexpr lbound_x(0); + static DVectX constexpr nelems_x(10); -static DElemY constexpr lbound_y(0); -static DVectY constexpr nelems_y(12); + static DElemY constexpr lbound_y(0); + static DVectY constexpr nelems_y(12); -static DElemXY constexpr lbound_x_y(lbound_x, lbound_y); -static DVectXY constexpr nelems_x_y(nelems_x, nelems_y); + static DElemXY constexpr lbound_x_y(lbound_x, lbound_y); + static DVectXY constexpr nelems_x_y(nelems_x, nelems_y); -} // namespace +} // namespace ) TEST(ParallelFill, OneDimension) { diff --git a/tests/parallel_for_each.cpp b/tests/parallel_for_each.cpp index ddedd0341..3aa7e5cb2 100644 --- a/tests/parallel_for_each.cpp +++ b/tests/parallel_for_each.cpp @@ -11,40 +11,40 @@ #include -namespace { - -using DElem0D = ddc::DiscreteElement<>; -using DVect0D = ddc::DiscreteVector<>; -using DDom0D = ddc::DiscreteDomain<>; - -struct DDimX +namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(PARALLEL_FOR_EACH_CPP) { -}; -using DElemX = ddc::DiscreteElement; -using DVectX = ddc::DiscreteVector; -using DDomX = ddc::DiscreteDomain; + using DElem0D = ddc::DiscreteElement<>; + using DVect0D = ddc::DiscreteVector<>; + using DDom0D = ddc::DiscreteDomain<>; -struct DDimY -{ -}; -using DElemY = ddc::DiscreteElement; -using DVectY = ddc::DiscreteVector; -using DDomY = ddc::DiscreteDomain; + struct DDimX + { + }; + using DElemX = ddc::DiscreteElement; + using DVectX = ddc::DiscreteVector; + using DDomX = ddc::DiscreteDomain; + + struct DDimY + { + }; + using DElemY = ddc::DiscreteElement; + using DVectY = ddc::DiscreteVector; + using DDomY = ddc::DiscreteDomain; -using DElemXY = ddc::DiscreteElement; -using DVectXY = ddc::DiscreteVector; -using DDomXY = ddc::DiscreteDomain; + using DElemXY = ddc::DiscreteElement; + using DVectXY = ddc::DiscreteVector; + using DDomXY = ddc::DiscreteDomain; -static DElemX constexpr lbound_x(0); -static DVectX constexpr nelems_x(10); + static DElemX constexpr lbound_x(0); + static DVectX constexpr nelems_x(10); -static DElemY constexpr lbound_y(0); -static DVectY constexpr nelems_y(12); + static DElemY constexpr lbound_y(0); + static DVectY constexpr nelems_y(12); -static DElemXY constexpr lbound_x_y(lbound_x, lbound_y); -static DVectXY constexpr nelems_x_y(nelems_x, nelems_y); + static DElemXY constexpr lbound_x_y(lbound_x, lbound_y); + static DVectXY constexpr nelems_x_y(nelems_x, nelems_y); -} // namespace +} // namespace ) TEST(ParallelForEachParallelHost, ZeroDimension) { @@ -79,81 +79,81 @@ TEST(ParallelForEachParallelHost, TwoDimensions) EXPECT_EQ(std::count(storage.begin(), storage.end(), 1), dom.size()); } -namespace { - -void TestParallelForEachParallelDeviceZeroDimension() +namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(PARALLEL_FOR_EACH_CPP) { - DDom0D const dom; - ddc::Chunk> storage(dom); - Kokkos::deep_copy(storage.allocation_kokkos_view(), 0); - ddc::ChunkSpan const view(storage.span_view()); - ddc::parallel_for_each( - dom, - KOKKOS_LAMBDA(DElem0D const i) { view(i) += 1; }); - int const* const ptr = storage.data_handle(); - int sum; - Kokkos::parallel_reduce( - dom.size(), - KOKKOS_LAMBDA(std::size_t i, int& local_sum) { local_sum += ptr[i]; }, - Kokkos::Sum(sum)); - EXPECT_EQ(sum, dom.size()); -} - -} // namespace + void TestParallelForEachParallelDeviceZeroDimension() + { + DDom0D const dom; + ddc::Chunk> storage(dom); + Kokkos::deep_copy(storage.allocation_kokkos_view(), 0); + ddc::ChunkSpan const view(storage.span_view()); + ddc::parallel_for_each( + dom, + KOKKOS_LAMBDA(DElem0D const i) { view(i) += 1; }); + int const* const ptr = storage.data_handle(); + int sum; + Kokkos::parallel_reduce( + dom.size(), + KOKKOS_LAMBDA(std::size_t i, int& local_sum) { local_sum += ptr[i]; }, + Kokkos::Sum(sum)); + EXPECT_EQ(sum, dom.size()); + } + +} // namespace ) TEST(ParallelForEachParallelDevice, ZeroDimension) { TestParallelForEachParallelDeviceZeroDimension(); } -namespace { - -void TestParallelForEachParallelDeviceOneDimension() +namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(PARALLEL_FOR_EACH_CPP) { - DDomX const dom(lbound_x, nelems_x); - ddc::Chunk> storage(dom); - Kokkos::deep_copy(storage.allocation_kokkos_view(), 0); - ddc::ChunkSpan const view(storage.span_view()); - ddc::parallel_for_each( - dom, - KOKKOS_LAMBDA(DElemX const ix) { view(ix) += 1; }); - int const* const ptr = storage.data_handle(); - int sum; - Kokkos::parallel_reduce( - dom.size(), - KOKKOS_LAMBDA(std::size_t i, int& local_sum) { local_sum += ptr[i]; }, - Kokkos::Sum(sum)); - EXPECT_EQ(sum, dom.size()); -} - -} // namespace + void TestParallelForEachParallelDeviceOneDimension() + { + DDomX const dom(lbound_x, nelems_x); + ddc::Chunk> storage(dom); + Kokkos::deep_copy(storage.allocation_kokkos_view(), 0); + ddc::ChunkSpan const view(storage.span_view()); + ddc::parallel_for_each( + dom, + KOKKOS_LAMBDA(DElemX const ix) { view(ix) += 1; }); + int const* const ptr = storage.data_handle(); + int sum; + Kokkos::parallel_reduce( + dom.size(), + KOKKOS_LAMBDA(std::size_t i, int& local_sum) { local_sum += ptr[i]; }, + Kokkos::Sum(sum)); + EXPECT_EQ(sum, dom.size()); + } + +} // namespace ) TEST(ParallelForEachParallelDevice, OneDimension) { TestParallelForEachParallelDeviceOneDimension(); } -namespace { - -void TestParallelForEachParallelDeviceTwoDimensions() +namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(PARALLEL_FOR_EACH_CPP) { - DDomXY const dom(lbound_x_y, nelems_x_y); - ddc::Chunk> storage(dom); - Kokkos::deep_copy(storage.allocation_kokkos_view(), 0); - ddc::ChunkSpan const view(storage.span_view()); - ddc::parallel_for_each( - dom, - KOKKOS_LAMBDA(DElemXY const ixy) { view(ixy) += 1; }); - int const* const ptr = storage.data_handle(); - int sum; - Kokkos::parallel_reduce( - dom.size(), - KOKKOS_LAMBDA(std::size_t i, int& local_sum) { local_sum += ptr[i]; }, - Kokkos::Sum(sum)); - EXPECT_EQ(sum, dom.size()); -} - -} // namespace + void TestParallelForEachParallelDeviceTwoDimensions() + { + DDomXY const dom(lbound_x_y, nelems_x_y); + ddc::Chunk> storage(dom); + Kokkos::deep_copy(storage.allocation_kokkos_view(), 0); + ddc::ChunkSpan const view(storage.span_view()); + ddc::parallel_for_each( + dom, + KOKKOS_LAMBDA(DElemXY const ixy) { view(ixy) += 1; }); + int const* const ptr = storage.data_handle(); + int sum; + Kokkos::parallel_reduce( + dom.size(), + KOKKOS_LAMBDA(std::size_t i, int& local_sum) { local_sum += ptr[i]; }, + Kokkos::Sum(sum)); + EXPECT_EQ(sum, dom.size()); + } + +} // namespace ) TEST(ParallelForEachParallelDevice, TwoDimensions) { diff --git a/tests/single_discretization.cpp b/tests/single_discretization.cpp index 13642be27..ebfe09498 100644 --- a/tests/single_discretization.cpp +++ b/tests/single_discretization.cpp @@ -10,19 +10,19 @@ namespace ddcexp = ddc::experimental; -namespace { - -class DimX; +namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(SINGLE_DISCRETIZATION_CPP) +{ + class DimX; -using CoordX = ddc::Coordinate; + using CoordX = ddc::Coordinate; -struct DDimX : ddcexp::SingleDiscretization -{ -}; + struct DDimX : ddcexp::SingleDiscretization + { + }; -using DElemX = ddc::DiscreteElement; + using DElemX = ddc::DiscreteElement; -} // namespace +} // namespace ) TEST(SingleDiscretization, ClassSize) { diff --git a/tests/splines/matrix.cpp b/tests/splines/matrix.cpp index 906e1c48d..27500b401 100644 --- a/tests/splines/matrix.cpp +++ b/tests/splines/matrix.cpp @@ -16,69 +16,70 @@ #include "test_utils.hpp" -namespace { - -void fill_identity( - ddc::detail::SplinesLinearProblem::MultiRHS mat) +namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(MATRIX_CPP) { - assert(mat.extent(0) == mat.extent(1)); - for (std::size_t i(0); i < mat.extent(0); ++i) { - for (std::size_t j(0); j < mat.extent(1); ++j) { - mat(i, j) = int(i == j); + void fill_identity( + ddc::detail::SplinesLinearProblem::MultiRHS mat) + { + assert(mat.extent(0) == mat.extent(1)); + for (std::size_t i(0); i < mat.extent(0); ++i) { + for (std::size_t j(0); j < mat.extent(1); ++j) { + mat(i, j) = int(i == j); + } } } -} -void copy_matrix( - ddc::detail::SplinesLinearProblem::MultiRHS copy, - std::unique_ptr>& mat) -{ - assert(mat->size() == copy.extent(0)); - assert(mat->size() == copy.extent(1)); + void copy_matrix( + ddc::detail::SplinesLinearProblem::MultiRHS copy, + std::unique_ptr> & mat) + { + assert(mat->size() == copy.extent(0)); + assert(mat->size() == copy.extent(1)); - for (std::size_t i(0); i < copy.extent(0); ++i) { - for (std::size_t j(0); j < copy.extent(1); ++j) { - copy(i, j) = mat->get_element(i, j); + for (std::size_t i(0); i < copy.extent(0); ++i) { + for (std::size_t j(0); j < copy.extent(1); ++j) { + copy(i, j) = mat->get_element(i, j); + } } } -} - -void check_inverse( - ddc::detail::SplinesLinearProblem::MultiRHS matrix, - ddc::detail::SplinesLinearProblem::MultiRHS inv) -{ - double TOL = 1e-10; - std::size_t N = matrix.extent(0); - for (std::size_t i(0); i < N; ++i) { - for (std::size_t j(0); j < N; ++j) { - double id_val = 0.0; - for (std::size_t k(0); k < N; ++k) { - id_val += matrix(i, k) * inv(k, j); + void check_inverse( + ddc::detail::SplinesLinearProblem::MultiRHS matrix, + ddc::detail::SplinesLinearProblem::MultiRHS inv) + { + double TOL = 1e-10; + std::size_t N = matrix.extent(0); + + for (std::size_t i(0); i < N; ++i) { + for (std::size_t j(0); j < N; ++j) { + double id_val = 0.0; + for (std::size_t k(0); k < N; ++k) { + id_val += matrix(i, k) * inv(k, j); + } + EXPECT_NEAR(id_val, static_cast(i == j), TOL); } - EXPECT_NEAR(id_val, static_cast(i == j), TOL); } } -} - -void check_inverse_transpose( - ddc::detail::SplinesLinearProblem::MultiRHS matrix, - ddc::detail::SplinesLinearProblem::MultiRHS inv) -{ - double TOL = 1e-10; - std::size_t N = matrix.extent(0); - for (std::size_t i(0); i < N; ++i) { - for (std::size_t j(0); j < N; ++j) { - double id_val = 0.0; - for (std::size_t k(0); k < N; ++k) { - id_val += matrix(i, k) * inv(j, k); + void check_inverse_transpose( + ddc::detail::SplinesLinearProblem::MultiRHS matrix, + ddc::detail::SplinesLinearProblem::MultiRHS inv) + { + double TOL = 1e-10; + std::size_t N = matrix.extent(0); + + for (std::size_t i(0); i < N; ++i) { + for (std::size_t j(0); j < N; ++j) { + double id_val = 0.0; + for (std::size_t k(0); k < N; ++k) { + id_val += matrix(i, k) * inv(j, k); + } + EXPECT_NEAR(id_val, static_cast(i == j), TOL); } - EXPECT_NEAR(id_val, static_cast(i == j), TOL); } } -} -} // namespace + +} // namespace ) TEST(MatrixSparse, Formatting) { diff --git a/tests/type_seq.cpp b/tests/type_seq.cpp index df83d3a65..2e1f8c6f7 100644 --- a/tests/type_seq.cpp +++ b/tests/type_seq.cpp @@ -8,17 +8,17 @@ #include -namespace { - -struct a; -struct b; -struct c; -struct d; -struct e; -struct y; -struct z; +namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(TYPE_SED_CPP) +{ + struct a; + struct b; + struct c; + struct d; + struct e; + struct y; + struct z; -} // namespace +} // namespace ) TEST(TypeSeqTest, Rank) { diff --git a/tests/uniform_point_sampling.cpp b/tests/uniform_point_sampling.cpp index e3a8f6e96..01f078383 100644 --- a/tests/uniform_point_sampling.cpp +++ b/tests/uniform_point_sampling.cpp @@ -10,25 +10,25 @@ #include -namespace { - -struct DimX; -struct DimY; - -struct DDimX : ddc::UniformPointSampling +namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(UNIFORM_POINT_SAMPLING_CPP) { -}; + struct DimX; + struct DimY; -struct DDimY : ddc::UniformPointSampling -{ -}; + struct DDimX : ddc::UniformPointSampling + { + }; + + struct DDimY : ddc::UniformPointSampling + { + }; -static ddc::Coordinate constexpr origin(-1.); -static ddc::Real constexpr step = 0.5; -static ddc::DiscreteElement constexpr point_ix(2); -static ddc::Coordinate constexpr point_rx(0.); + static ddc::Coordinate constexpr origin(-1.); + static ddc::Real constexpr step = 0.5; + static ddc::DiscreteElement constexpr point_ix(2); + static ddc::Coordinate constexpr point_rx(0.); -} // namespace +} // namespace ) TEST(UniformPointSamplingTest, Constructor) {