Skip to content

Commit

Permalink
Fix anonymous namespace issue on for HIP
Browse files Browse the repository at this point in the history
  • Loading branch information
tpadioleau committed May 26, 2024
1 parent 8e7862f commit 2a84936
Show file tree
Hide file tree
Showing 18 changed files with 511 additions and 500 deletions.
50 changes: 25 additions & 25 deletions benchmarks/deepcopy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,44 +12,44 @@

#include <benchmark/benchmark.h>

namespace {

struct DDimX
namespace DDC_HIP_5_7_ANONYMOUS_NAMESPACE_WORKAROUND(DEEPCOPY_CPP)
{
};
using DElemX = ddc::DiscreteElement<DDimX>;
using DVectX = ddc::DiscreteVector<DDimX>;
using DDomX = ddc::DiscreteDomain<DDimX>;
struct 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 )


static void memcpy_1d(benchmark::State& state)
Expand Down
41 changes: 21 additions & 20 deletions benchmarks/splines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,32 @@

#include <benchmark/benchmark.h>

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<X, s_degree_x>
{
};
using GrevillePoints = ddc::
GrevilleInterpolationPoints<BSplinesX, ddc::BoundCond::PERIODIC, ddc::BoundCond::PERIODIC>;
struct DDimX : GrevillePoints::interpolation_mesh_type
{
};
struct X
{
static constexpr bool PERIODIC = true;
};

struct Y;
struct DDimY : ddc::UniformPointSampling<Y>
{
};
struct BSplinesX : ddc::UniformBSplines<X, s_degree_x>
{
};
using GrevillePoints = ddc::GrevilleInterpolationPoints<
BSplinesX,
ddc::BoundCond::PERIODIC,
ddc::BoundCond::PERIODIC>;
struct DDimX : GrevillePoints::interpolation_mesh_type
{
};

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

} // namespace
} // namespace )

// Function to monitor GPU memory asynchronously
void monitorMemoryAsync(std::mutex& mutex, bool& monitorFlag, size_t& maxUsedMem)
Expand Down
9 changes: 9 additions & 0 deletions include/ddc/detail/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
106 changes: 53 additions & 53 deletions tests/chunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,80 +10,80 @@

#include <gtest/gtest.h>

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 <class Datatype>
using Chunk0D = ddc::Chunk<Datatype, DDom0D>;
template <class Datatype>
using ChunkSpan0D = ddc::ChunkSpan<Datatype, DDom0D>;

template <class Datatype>
using Chunk0D = ddc::Chunk<Datatype, DDom0D>;
template <class Datatype>
using ChunkSpan0D = ddc::ChunkSpan<Datatype, DDom0D>;

struct DDimX
{
};
using DElemX = ddc::DiscreteElement<DDimX>;
using DVectX = ddc::DiscreteVector<DDimX>;
using DDomX = ddc::DiscreteDomain<DDimX>;

struct DDimX
{
};
using DElemX = ddc::DiscreteElement<DDimX>;
using DVectX = ddc::DiscreteVector<DDimX>;
using DDomX = ddc::DiscreteDomain<DDimX>;
template <class Datatype>
using ChunkX = ddc::Chunk<Datatype, DDomX>;

template <class Datatype>
using ChunkX = ddc::Chunk<Datatype, DDomX>;

struct DDimY
{
};
using DElemY = ddc::DiscreteElement<DDimY>;
using DVectY = ddc::DiscreteVector<DDimY>;
using DDomY = ddc::DiscreteDomain<DDimY>;

struct DDimY
{
};
using DElemY = ddc::DiscreteElement<DDimY>;
using DVectY = ddc::DiscreteVector<DDimY>;
using DDomY = ddc::DiscreteDomain<DDimY>;
template <class Datatype>
using ChunkY = ddc::Chunk<Datatype, DDomY>;

template <class Datatype>
using ChunkY = ddc::Chunk<Datatype, DDomY>;


struct DDimZ
{
};
using DElemZ = ddc::DiscreteElement<DDimZ>;
using DVectZ = ddc::DiscreteVector<DDimZ>;
using DDomZ = ddc::DiscreteDomain<DDimZ>;
struct DDimZ
{
};
using DElemZ = ddc::DiscreteElement<DDimZ>;
using DVectZ = ddc::DiscreteVector<DDimZ>;
using DDomZ = ddc::DiscreteDomain<DDimZ>;


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 ChunkXY = ddc::Chunk<Datatype, DDomXY>;
template <class Datatype>
using ChunkXY = ddc::Chunk<Datatype, DDomXY>;


using DElemYX = ddc::DiscreteElement<DDimY, DDimX>;
using DVectYX = ddc::DiscreteVector<DDimY, DDimX>;
using DDomYX = ddc::DiscreteDomain<DDimY, DDimX>;
using DElemYX = ddc::DiscreteElement<DDimY, DDimX>;
using DVectYX = ddc::DiscreteVector<DDimY, DDimX>;
using DDomYX = ddc::DiscreteDomain<DDimY, DDimX>;

template <class Datatype>
using ChunkYX = ddc::Chunk<Datatype, DDomYX>;
template <class Datatype>
using ChunkYX = ddc::Chunk<Datatype, DDomYX>;


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 \{

Expand Down
Loading

0 comments on commit 2a84936

Please sign in to comment.