Skip to content

Commit

Permalink
Merge branch 'fixingCompilerIssue' into lattice-benchmark-lbm
Browse files Browse the repository at this point in the history
  • Loading branch information
massimim committed Sep 13, 2023
2 parents e4f43c4 + 74a0ae0 commit ea655c3
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 64 deletions.
2 changes: 1 addition & 1 deletion benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

# add_subdirectory(lbm)
add_subdirectory(lbm)
# add_subdirectory("lbm-lid-driven-cavity-flow")
# add_subdirectory("lbm-flow-over-sphere")
33 changes: 6 additions & 27 deletions benchmarks/lbm/src/D3Q19.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct D3Q19

using Self = D3Q19<Precision>::Registers;

static constexpr Neon::index_3d stencil[Q]{
static constexpr std::array<const Neon::index_3d, Q> stencil{
/*! 0 */ Neon::index_3d(-1, 0, 0),
/*! 1 */ Neon::index_3d(0, -1, 0),
/*! 2 */ Neon::index_3d(0, 0, -1),
Expand All @@ -54,31 +54,10 @@ struct D3Q19
/*! 18 */ Neon::index_3d(0, 1, -1)};

template <int qIdx, int cIdx>
NEON_CUDA_HOST_DEVICE static constexpr auto
static constexpr inline auto
getComponentOfDirection() -> int
{
constexpr Neon::index_3d s[Q]{
/*! 0 */ Neon::index_3d(-1, 0, 0),
/*! 1 */ Neon::index_3d(0, -1, 0),
/*! 2 */ Neon::index_3d(0, 0, -1),
/*! 3 */ Neon::index_3d(-1, -1, 0),
/*! 4 */ Neon::index_3d(-1, 1, 0),
/*! 5 */ Neon::index_3d(-1, 0, -1),
/*! 6 */ Neon::index_3d(-1, 0, 1),
/*! 7 */ Neon::index_3d(0, -1, -1),
/*! 8 */ Neon::index_3d(0, -1, 1),
/*! 9 */ Neon::index_3d(0, 0, 0),
/*! 10 */ Neon::index_3d(1, 0, 0),
/*! 11 */ Neon::index_3d(0, 1, 0),
/*! 12 */ Neon::index_3d(0, 0, 1),
/*! 13 */ Neon::index_3d(1, 1, 0),
/*! 14 */ Neon::index_3d(1, -1, 0),
/*! 15 */ Neon::index_3d(1, 0, 1),
/*! 16 */ Neon::index_3d(1, 0, -1),
/*! 17 */ Neon::index_3d(0, 1, 1),
/*! 18 */ Neon::index_3d(0, 1, -1)};

return s[qIdx].template getComponent<cIdx>();
return Self::stencil[qIdx].template getComponent<cIdx>();
}

static constexpr int center = 9; /** Position of direction {0,0,0} */
Expand Down Expand Up @@ -210,21 +189,21 @@ struct D3Q19


template <int go>
NEON_CUDA_HOST_DEVICE static constexpr auto mapToRegisters()
static constexpr auto mapToRegisters()
-> int
{
return memoryToRegister[go];
}

template <int go>
NEON_CUDA_HOST_DEVICE static constexpr auto mapToMemory()
static constexpr auto mapToMemory()
-> int
{
return registerToMemory[go];
}

template <int go>
NEON_CUDA_HOST_DEVICE static constexpr auto getOpposite()
static constexpr auto getOpposite()
-> int
{
return opposite[go];
Expand Down
33 changes: 2 additions & 31 deletions benchmarks/lbm/src/D3Q27.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,39 +60,10 @@ struct D3Q27
/* 26 */ Neon::index_3d(1, -1, -1)};

template <int qIdx, int cIdx>
static constexpr inline NEON_CUDA_HOST_DEVICE auto
static constexpr inline auto
getComponentOfDirection() -> int
{
constexpr std::array<const Neon::index_3d, Q> s{
/* 00 */ Neon::index_3d(-1, 0, 0),
/* 01 */ Neon::index_3d(0, -1, 0),
/* 02 */ Neon::index_3d(0, 0, -1),
/* 03 */ Neon::index_3d(-1, -1, 0),
/* 04 */ Neon::index_3d(-1, 1, 0),
/* 05 */ Neon::index_3d(-1, 0, -1),
/* 06 */ Neon::index_3d(-1, 0, 1),
/* 07 */ Neon::index_3d(0, -1, -1),
/* 08 */ Neon::index_3d(0, -1, 1),
/* 09 */ Neon::index_3d(-1, -1, -1),
/* 00 */ Neon::index_3d(-1, -1, 1),
/* 11 */ Neon::index_3d(-1, 1, -1),
/* 12 */ Neon::index_3d(-1, 1, 1),
/* 13 */ Neon::index_3d(0, 0, 0),
/* 14 */ Neon::index_3d(1, 0, 0),
/* 15 */ Neon::index_3d(0, 1, 0),
/* 16 */ Neon::index_3d(0, 0, 1),
/* 17 */ Neon::index_3d(1, 1, 0),
/* 18 */ Neon::index_3d(1, -1, 0),
/* 19 */ Neon::index_3d(1, 0, 1),
/* 20 */ Neon::index_3d(1, 0, -1),
/* 21 */ Neon::index_3d(0, 1, 1),
/* 22 */ Neon::index_3d(0, 1, -1),
/* 23 */ Neon::index_3d(1, 1, 1),
/* 24 */ Neon::index_3d(1, 1, -1),
/* 25 */ Neon::index_3d(1, -1, 1),
/* 26 */ Neon::index_3d(1, -1, -1)};

return s[qIdx].v[cIdx];
return Self::stencil[qIdx].v[cIdx];
}

static constexpr int center = 13; /** Position of direction {0,0,0} */
Expand Down
12 changes: 9 additions & 3 deletions benchmarks/lbm/src/DeviceD3QXX.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,15 @@ struct DeviceD3QXX

// momentum_flux
Neon::ConstexprFor<0, Lattice::Q, 1>([&](auto q) {
Neon::ConstexprFor<0, 6, 1>([&](auto i) {
Pi[i] += fneq[q] * Lattice::Registers::template getMomentByDirection<q, i>();
});
// Neon::ConstexprFor<0, 6, 1>([&](auto i) {
// Pi[i] += fneq[q] * Lattice::Registers::template getMomentByDirection<q, i>();
// });
Pi[0] += fneq[q] * Lattice::Registers::template getMomentByDirection<q, 0>();
Pi[1] += fneq[q] * Lattice::Registers::template getMomentByDirection<q, 1>();
Pi[2] += fneq[q] * Lattice::Registers::template getMomentByDirection<q, 2>();
Pi[3] += fneq[q] * Lattice::Registers::template getMomentByDirection<q, 3>();
Pi[4] += fneq[q] * Lattice::Registers::template getMomentByDirection<q, 4>();
Pi[5] += fneq[q] * Lattice::Registers::template getMomentByDirection<q, 5>();
});

// fdecompose_shear
Expand Down
6 changes: 5 additions & 1 deletion benchmarks/lbm/src/RunCavityTwoPop.cu
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,11 @@ auto runFilterCollision(Config& config,
NEON_THROW(e);
}
testCode << "_kbc";
return runFilterMethod<Collision::kbc, Lattice, Grid, Storage, double>(config, report, testCode);
using Precision = Precision<Storage, Compute>;
using L = D3Q27<Precision>;
if constexpr (std::is_same_v<Lattice, L>) {
return runFilterMethod<Collision::kbc, Lattice, Grid, Storage, double>(config, report, testCode);
}
}
NEON_DEV_UNDER_CONSTRUCTION("");
}
Expand Down
2 changes: 1 addition & 1 deletion libNeonDomain/include/Neon/domain/tools/SpaceCurves.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ class Encoder
-> uint64_t
{
uint64_t mortonEncoded = mortonEncode(dim, idx);
uint64_t bits = std::ceil(std::log2(dim.newType<uint64_t>().rMax()));
uint64_t bits = uint64_t(std::ceil(std::log2(dim.newType<uint64_t>().rMax())));
return mortonToHilbert3D(mortonEncoded, bits);
}

Expand Down

0 comments on commit ea655c3

Please sign in to comment.