diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 786a165e..efb267c6 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -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") diff --git a/benchmarks/lbm/src/D3Q19.h b/benchmarks/lbm/src/D3Q19.h index 07d7c163..422a69d3 100644 --- a/benchmarks/lbm/src/D3Q19.h +++ b/benchmarks/lbm/src/D3Q19.h @@ -32,7 +32,7 @@ struct D3Q19 using Self = D3Q19::Registers; - static constexpr Neon::index_3d stencil[Q]{ + static constexpr std::array stencil{ /*! 0 */ Neon::index_3d(-1, 0, 0), /*! 1 */ Neon::index_3d(0, -1, 0), /*! 2 */ Neon::index_3d(0, 0, -1), @@ -54,31 +54,10 @@ struct D3Q19 /*! 18 */ Neon::index_3d(0, 1, -1)}; template - 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(); + return Self::stencil[qIdx].template getComponent(); } static constexpr int center = 9; /** Position of direction {0,0,0} */ @@ -210,21 +189,21 @@ struct D3Q19 template - NEON_CUDA_HOST_DEVICE static constexpr auto mapToRegisters() + static constexpr auto mapToRegisters() -> int { return memoryToRegister[go]; } template - NEON_CUDA_HOST_DEVICE static constexpr auto mapToMemory() + static constexpr auto mapToMemory() -> int { return registerToMemory[go]; } template - NEON_CUDA_HOST_DEVICE static constexpr auto getOpposite() + static constexpr auto getOpposite() -> int { return opposite[go]; diff --git a/benchmarks/lbm/src/D3Q27.h b/benchmarks/lbm/src/D3Q27.h index 4512ef83..59a97850 100644 --- a/benchmarks/lbm/src/D3Q27.h +++ b/benchmarks/lbm/src/D3Q27.h @@ -60,39 +60,10 @@ struct D3Q27 /* 26 */ Neon::index_3d(1, -1, -1)}; template - static constexpr inline NEON_CUDA_HOST_DEVICE auto + static constexpr inline auto getComponentOfDirection() -> int { - constexpr std::array 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} */ diff --git a/benchmarks/lbm/src/DeviceD3QXX.h b/benchmarks/lbm/src/DeviceD3QXX.h index b7f487a2..fc275308 100644 --- a/benchmarks/lbm/src/DeviceD3QXX.h +++ b/benchmarks/lbm/src/DeviceD3QXX.h @@ -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(); - }); +// Neon::ConstexprFor<0, 6, 1>([&](auto i) { +// Pi[i] += fneq[q] * Lattice::Registers::template getMomentByDirection(); +// }); + Pi[0] += fneq[q] * Lattice::Registers::template getMomentByDirection(); + Pi[1] += fneq[q] * Lattice::Registers::template getMomentByDirection(); + Pi[2] += fneq[q] * Lattice::Registers::template getMomentByDirection(); + Pi[3] += fneq[q] * Lattice::Registers::template getMomentByDirection(); + Pi[4] += fneq[q] * Lattice::Registers::template getMomentByDirection(); + Pi[5] += fneq[q] * Lattice::Registers::template getMomentByDirection(); }); // fdecompose_shear diff --git a/benchmarks/lbm/src/RunCavityTwoPop.cu b/benchmarks/lbm/src/RunCavityTwoPop.cu index 3503e8ef..67ba0ca3 100644 --- a/benchmarks/lbm/src/RunCavityTwoPop.cu +++ b/benchmarks/lbm/src/RunCavityTwoPop.cu @@ -139,7 +139,11 @@ auto runFilterCollision(Config& config, NEON_THROW(e); } testCode << "_kbc"; - return runFilterMethod(config, report, testCode); + using Precision = Precision; + using L = D3Q27; + if constexpr (std::is_same_v) { + return runFilterMethod(config, report, testCode); + } } NEON_DEV_UNDER_CONSTRUCTION(""); }