From 75e883141476e621932ad356cefd9a9cdf8f3eb9 Mon Sep 17 00:00:00 2001 From: Thomas Padioleau Date: Sat, 8 Mar 2025 12:44:26 +0100 Subject: [PATCH] Improve splines tests (#798) * Move solver type ifdef * Reuse tags for interpolation dimensions * Remove 4D, 3D should be enough --- tests/splines/batched_2d_spline_builder.cpp | 42 ++-- tests/splines/batched_spline_builder.cpp | 186 +++--------------- ...ultiple_batch_domain_2d_spline_builder.cpp | 26 +-- .../multiple_batch_domain_spline_builder.cpp | 37 ++-- 4 files changed, 66 insertions(+), 225 deletions(-) diff --git a/tests/splines/batched_2d_spline_builder.cpp b/tests/splines/batched_2d_spline_builder.cpp index 815ade764..b7bc0ae2c 100644 --- a/tests/splines/batched_2d_spline_builder.cpp +++ b/tests/splines/batched_2d_spline_builder.cpp @@ -39,11 +39,6 @@ struct DimY { static constexpr bool PERIODIC = true; }; - -struct DimZ -{ - static constexpr bool PERIODIC = true; -}; #else struct DimX @@ -55,11 +50,6 @@ struct DimY { static constexpr bool PERIODIC = false; }; - -struct DimZ -{ - static constexpr bool PERIODIC = false; -}; #endif struct DDimBatch @@ -631,7 +621,7 @@ TEST(SUFFIX(Batched2dSplineDevice), 2DXY) DDimGPS>(); } -TEST(SUFFIX(Batched2dSplineHost), 3DXY) +TEST(SUFFIX(Batched2dSplineHost), 3DXYB) { Batched2dSplineTest< Kokkos::DefaultHostExecutionSpace, @@ -643,31 +633,31 @@ TEST(SUFFIX(Batched2dSplineHost), 3DXY) DDimBatch>(); } -TEST(SUFFIX(Batched2dSplineHost), 3DXZ) +TEST(SUFFIX(Batched2dSplineHost), 3DXBY) { Batched2dSplineTest< Kokkos::DefaultHostExecutionSpace, Kokkos::DefaultHostExecutionSpace::memory_space, DDimGPS, - DDimGPS, + DDimGPS, DDimGPS, DDimBatch, - DDimGPS>(); + DDimGPS>(); } -TEST(SUFFIX(Batched2dSplineHost), 3DYZ) +TEST(SUFFIX(Batched2dSplineHost), 3DBXY) { Batched2dSplineTest< Kokkos::DefaultHostExecutionSpace, Kokkos::DefaultHostExecutionSpace::memory_space, + DDimGPS, DDimGPS, - DDimGPS, DDimBatch, - DDimGPS, - DDimGPS>(); + DDimGPS, + DDimGPS>(); } -TEST(SUFFIX(Batched2dSplineDevice), 3DXY) +TEST(SUFFIX(Batched2dSplineDevice), 3DXYB) { Batched2dSplineTest< Kokkos::DefaultExecutionSpace, @@ -679,26 +669,26 @@ TEST(SUFFIX(Batched2dSplineDevice), 3DXY) DDimBatch>(); } -TEST(SUFFIX(Batched2dSplineDevice), 3DXZ) +TEST(SUFFIX(Batched2dSplineDevice), 3DXBY) { Batched2dSplineTest< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space, DDimGPS, - DDimGPS, + DDimGPS, DDimGPS, DDimBatch, - DDimGPS>(); + DDimGPS>(); } -TEST(SUFFIX(Batched2dSplineDevice), 3DYZ) +TEST(SUFFIX(Batched2dSplineDevice), 3DBXY) { Batched2dSplineTest< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space, + DDimGPS, DDimGPS, - DDimGPS, DDimBatch, - DDimGPS, - DDimGPS>(); + DDimGPS, + DDimGPS>(); } diff --git a/tests/splines/batched_spline_builder.cpp b/tests/splines/batched_spline_builder.cpp index 9e3827186..0914597b6 100644 --- a/tests/splines/batched_spline_builder.cpp +++ b/tests/splines/batched_spline_builder.cpp @@ -29,42 +29,12 @@ struct DimX { static constexpr bool PERIODIC = true; }; - -struct DimY -{ - static constexpr bool PERIODIC = true; -}; - -struct DimZ -{ - static constexpr bool PERIODIC = true; -}; - -struct DimT -{ - static constexpr bool PERIODIC = true; -}; #else struct DimX { static constexpr bool PERIODIC = false; }; - -struct DimY -{ - static constexpr bool PERIODIC = false; -}; - -struct DimZ -{ - static constexpr bool PERIODIC = false; -}; - -struct DimT -{ - static constexpr bool PERIODIC = false; -}; #endif struct DDimBatch1 @@ -75,10 +45,6 @@ struct DDimBatch2 { }; -struct DDimBatch3 -{ -}; - constexpr std::size_t s_degree_x = DEGREE_X; #if defined(BC_PERIODIC) @@ -123,6 +89,12 @@ using DVect = ddc::DiscreteVector; template using Coord = ddc::Coordinate; +#if defined(SOLVER_LAPACK) +constexpr ddc::SplineSolver s_spline_solver = ddc::SplineSolver::LAPACK; +#elif defined(SOLVER_GINKGO) +constexpr ddc::SplineSolver s_spline_solver = ddc::SplineSolver::GINKGO; +#endif + // Templated function giving first coordinate of the mesh in given dimension. template KOKKOS_FUNCTION Coord x0() @@ -203,12 +175,7 @@ void BatchedSplineTest() DDimI, s_bcl, s_bcr, -#if defined(SOLVER_LAPACK) - ddc::SplineSolver::LAPACK -#elif defined(SOLVER_GINKGO) - ddc::SplineSolver::GINKGO -#endif - > const spline_builder(interpolation_domain); + s_spline_solver> const spline_builder(interpolation_domain); // Compute useful domains (dom_interpolation, dom_batch, dom_bsplines and dom_spline) ddc::DiscreteDomain const dom_interpolation = spline_builder.interpolation_domain(); @@ -432,7 +399,7 @@ TEST(SUFFIX(BatchedSplineDevice), 1DX) DDimGPS>(); } -TEST(SUFFIX(BatchedSplineHost), 2DX) +TEST(SUFFIX(BatchedSplineHost), 2DXB1) { BatchedSplineTest< Kokkos::DefaultHostExecutionSpace, @@ -442,17 +409,17 @@ TEST(SUFFIX(BatchedSplineHost), 2DX) DDimBatch1>(); } -TEST(SUFFIX(BatchedSplineHost), 2DY) +TEST(SUFFIX(BatchedSplineHost), 2DB1X) { BatchedSplineTest< Kokkos::DefaultHostExecutionSpace, Kokkos::DefaultHostExecutionSpace::memory_space, - DDimGPS, + DDimGPS, DDimBatch1, - DDimGPS>(); + DDimGPS>(); } -TEST(SUFFIX(BatchedSplineDevice), 2DX) +TEST(SUFFIX(BatchedSplineDevice), 2DXB1) { BatchedSplineTest< Kokkos::DefaultExecutionSpace, @@ -462,17 +429,17 @@ TEST(SUFFIX(BatchedSplineDevice), 2DX) DDimBatch1>(); } -TEST(SUFFIX(BatchedSplineDevice), 2DY) +TEST(SUFFIX(BatchedSplineDevice), 2DB1X) { BatchedSplineTest< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space, - DDimGPS, + DDimGPS, DDimBatch1, - DDimGPS>(); + DDimGPS>(); } -TEST(SUFFIX(BatchedSplineHost), 3DX) +TEST(SUFFIX(BatchedSplineHost), 3DXB1B2) { BatchedSplineTest< Kokkos::DefaultHostExecutionSpace, @@ -483,29 +450,29 @@ TEST(SUFFIX(BatchedSplineHost), 3DX) DDimBatch2>(); } -TEST(SUFFIX(BatchedSplineHost), 3DY) +TEST(SUFFIX(BatchedSplineHost), 3DB1XB2) { BatchedSplineTest< Kokkos::DefaultHostExecutionSpace, Kokkos::DefaultHostExecutionSpace::memory_space, - DDimGPS, + DDimGPS, DDimBatch1, - DDimGPS, + DDimGPS, DDimBatch2>(); } -TEST(SUFFIX(BatchedSplineHost), 3DZ) +TEST(SUFFIX(BatchedSplineHost), 3DB1B2X) { BatchedSplineTest< Kokkos::DefaultHostExecutionSpace, Kokkos::DefaultHostExecutionSpace::memory_space, - DDimGPS, + DDimGPS, DDimBatch1, DDimBatch2, - DDimGPS>(); + DDimGPS>(); } -TEST(SUFFIX(BatchedSplineDevice), 3DX) +TEST(SUFFIX(BatchedSplineDevice), 3DXB1B2) { BatchedSplineTest< Kokkos::DefaultExecutionSpace, @@ -516,121 +483,24 @@ TEST(SUFFIX(BatchedSplineDevice), 3DX) DDimBatch2>(); } -TEST(SUFFIX(BatchedSplineDevice), 3DY) -{ - BatchedSplineTest< - Kokkos::DefaultExecutionSpace, - Kokkos::DefaultExecutionSpace::memory_space, - DDimGPS, - DDimBatch1, - DDimGPS, - DDimBatch2>(); -} - -TEST(SUFFIX(BatchedSplineDevice), 3DZ) +TEST(SUFFIX(BatchedSplineDevice), 3DB1XB2) { BatchedSplineTest< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space, - DDimGPS, - DDimBatch1, - DDimBatch2, - DDimGPS>(); -} - - -TEST(SUFFIX(BatchedSplineHost), 4DX) -{ - BatchedSplineTest< - Kokkos::DefaultHostExecutionSpace, - Kokkos::DefaultHostExecutionSpace::memory_space, DDimGPS, - DDimGPS, - DDimBatch1, - DDimBatch2, - DDimBatch3>(); -} - -TEST(SUFFIX(BatchedSplineHost), 4DY) -{ - BatchedSplineTest< - Kokkos::DefaultHostExecutionSpace, - Kokkos::DefaultHostExecutionSpace::memory_space, - DDimGPS, - DDimBatch1, - DDimGPS, - DDimBatch2, - DDimBatch3>(); -} - -TEST(SUFFIX(BatchedSplineHost), 4DZ) -{ - BatchedSplineTest< - Kokkos::DefaultHostExecutionSpace, - Kokkos::DefaultHostExecutionSpace::memory_space, - DDimGPS, - DDimBatch1, - DDimBatch2, - DDimGPS, - DDimBatch3>(); -} - -TEST(SUFFIX(BatchedSplineHost), 4DT) -{ - BatchedSplineTest< - Kokkos::DefaultHostExecutionSpace, - Kokkos::DefaultHostExecutionSpace::memory_space, - DDimGPS, DDimBatch1, - DDimBatch2, - DDimBatch3, - DDimGPS>(); -} - -TEST(SUFFIX(BatchedSplineDevice), 4DX) -{ - BatchedSplineTest< - Kokkos::DefaultExecutionSpace, - Kokkos::DefaultExecutionSpace::memory_space, - DDimGPS, DDimGPS, - DDimBatch1, - DDimBatch2, - DDimBatch3>(); -} - -TEST(SUFFIX(BatchedSplineDevice), 4DY) -{ - BatchedSplineTest< - Kokkos::DefaultExecutionSpace, - Kokkos::DefaultExecutionSpace::memory_space, - DDimGPS, - DDimBatch1, - DDimGPS, - DDimBatch2, - DDimBatch3>(); -} - -TEST(SUFFIX(BatchedSplineDevice), 4DZ) -{ - BatchedSplineTest< - Kokkos::DefaultExecutionSpace, - Kokkos::DefaultExecutionSpace::memory_space, - DDimGPS, - DDimBatch1, - DDimBatch2, - DDimGPS, - DDimBatch3>(); + DDimBatch2>(); } -TEST(SUFFIX(BatchedSplineDevice), 4DT) +TEST(SUFFIX(BatchedSplineDevice), 3DB1B2X) { BatchedSplineTest< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space, - DDimGPS, + DDimGPS, DDimBatch1, DDimBatch2, - DDimBatch3, - DDimGPS>(); + DDimGPS>(); } diff --git a/tests/splines/multiple_batch_domain_2d_spline_builder.cpp b/tests/splines/multiple_batch_domain_2d_spline_builder.cpp index 6bb4fb355..65e1e071b 100644 --- a/tests/splines/multiple_batch_domain_2d_spline_builder.cpp +++ b/tests/splines/multiple_batch_domain_2d_spline_builder.cpp @@ -40,11 +40,6 @@ struct DimY { static constexpr bool PERIODIC = true; }; - -struct DimZ -{ - static constexpr bool PERIODIC = true; -}; #else struct DimX @@ -56,11 +51,6 @@ struct DimY { static constexpr bool PERIODIC = false; }; - -struct DimZ -{ - static constexpr bool PERIODIC = false; -}; #endif struct DDimBatch @@ -720,7 +710,7 @@ TEST(SUFFIX(MultipleBatchDomain2dSpline), 2DXY) DDimGPS>(); } -TEST(SUFFIX(MultipleBatchDomain2dSpline), 3DXY) +TEST(SUFFIX(MultipleBatchDomain2dSpline), 3DXYB) { MultipleBatchDomain2dSplineTest< Kokkos::DefaultExecutionSpace, @@ -732,26 +722,26 @@ TEST(SUFFIX(MultipleBatchDomain2dSpline), 3DXY) DDimBatch>(); } -TEST(SUFFIX(MultipleBatchDomain2dSpline), 3DXZ) +TEST(SUFFIX(MultipleBatchDomain2dSpline), 3DXBY) { MultipleBatchDomain2dSplineTest< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space, DDimGPS, - DDimGPS, + DDimGPS, DDimGPS, DDimBatch, - DDimGPS>(); + DDimGPS>(); } -TEST(SUFFIX(MultipleBatchDomain2dSpline), 3DYZ) +TEST(SUFFIX(MultipleBatchDomain2dSpline), 3DBXY) { MultipleBatchDomain2dSplineTest< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space, + DDimGPS, DDimGPS, - DDimGPS, DDimBatch, - DDimGPS, - DDimGPS>(); + DDimGPS, + DDimGPS>(); } diff --git a/tests/splines/multiple_batch_domain_spline_builder.cpp b/tests/splines/multiple_batch_domain_spline_builder.cpp index 1b59685dc..a15399078 100644 --- a/tests/splines/multiple_batch_domain_spline_builder.cpp +++ b/tests/splines/multiple_batch_domain_spline_builder.cpp @@ -30,25 +30,15 @@ struct DimX { static constexpr bool PERIODIC = true; }; - -struct DimY -{ - static constexpr bool PERIODIC = true; -}; #else struct DimX { static constexpr bool PERIODIC = false; }; - -struct DimY -{ - static constexpr bool PERIODIC = false; -}; #endif -struct DDimBatch1 +struct DDimBatch { }; @@ -100,6 +90,12 @@ using DVect = ddc::DiscreteVector; template using Coord = ddc::Coordinate; +#if defined(SOLVER_LAPACK) +constexpr ddc::SplineSolver s_spline_solver = ddc::SplineSolver::LAPACK; +#elif defined(SOLVER_GINKGO) +constexpr ddc::SplineSolver s_spline_solver = ddc::SplineSolver::GINKGO; +#endif + // Templated function giving first coordinate of the mesh in given dimension. template KOKKOS_FUNCTION Coord x0() @@ -345,12 +341,7 @@ void MultipleBatchDomainSplineTest() DDimI, s_bcl, s_bcr, -#if defined(SOLVER_LAPACK) - ddc::SplineSolver::LAPACK -#elif defined(SOLVER_GINKGO) - ddc::SplineSolver::GINKGO -#endif - > const spline_builder(interpolation_domain); + s_spline_solver> const spline_builder(interpolation_domain); // Instantiate a SplineEvaluator over interest dimension #if defined(BC_PERIODIC) @@ -464,22 +455,22 @@ TEST(SUFFIX(MultipleBatchDomainSpline), 1DX) DDimGPS>(); } -TEST(SUFFIX(MultipleBatchDomainSpline), 2DX) +TEST(SUFFIX(MultipleBatchDomainSpline), 2DXB) { MultipleBatchDomainSplineTest< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space, DDimGPS, DDimGPS, - DDimBatch1>(); + DDimBatch>(); } -TEST(SUFFIX(MultipleBatchDomainSpline), 2DY) +TEST(SUFFIX(MultipleBatchDomainSpline), 2DBX) { MultipleBatchDomainSplineTest< Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space, - DDimGPS, - DDimBatch1, - DDimGPS>(); + DDimGPS, + DDimBatch, + DDimGPS>(); }