Skip to content

Commit

Permalink
Remove the batch dimensions from the SplineBuilder and SplineEvaluato…
Browse files Browse the repository at this point in the history
…r class templates (#792)

* Remove the batch dimensions from SplineBuilder
- Remove the batch dimensions in class template of the SplineBuilder and
  SplineBuilder2D classes, and template the operator() instead
- Update the relevant tests and examples accordingly

* Update some of the documentation comments

* Remove batch dimensions in SplineEvaluator
- Remove the batch dimensions from the SplineEvaluator class template
- Template the operator() and eval/deriv and integrate functions over
  the batch dimensions (the batched dims cannot be deduced from the
  arguments of the integrate function)

* Remove batch dimensions in SplineEvaluator2D

* Remove the variadic templates for batch dimensions
- The use of variadic templates for the batch dimensions caused issue
  when compiling with nvcc
- Replaced the variadic template on the dimensions by a single template
  argument for the corresponding DiscreteDomain

* Update the spline benchmark and fix formatting
- Update the splines benchmark code
- Fix formatting of a few examples
- Fix a documentation typo in one of SplineEvaluator2D's constructor

* Add test for the reuse of SplineBuilder/Evaluator
- Add tests where a SplineBuilder and a SplineEvaluator are reused for
  another interpolation with a different batch pattern
- Change the tests, example and benchmark to use the SplineBuilder
  constructor taking the interpolation domain as argument

* Fix some unused variable warnings

* Add a missing const qualifier
- Make one of the variables const as reported by clang-tidy

* Reduce the memory footprint of the test compilation
- Remove the hosts test for the MultipleBatchDomain tests
- Remove the high dimension (3D, 4D) tests for the 1D MultipleBatchDomain
  tests

* Rename the DDom template parameter
- Rename the template parameters for the discrete domain to improve
  readability
- Change the AUTHORS file
  • Loading branch information
tretre91 authored Mar 7, 2025
1 parent f97f92d commit 446b2a5
Show file tree
Hide file tree
Showing 17 changed files with 1,988 additions and 443 deletions.
3 changes: 3 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ Baptiste Legouix - CEA (baptiste.legouix@cea.fr)
Thierry Antoun - CEA (thierry.antoun@cea.fr)
* Work on Documentation
* Work on adding new features

Trévis Morvany - CEA (trevis.morvany@cea.fr)
* Work on splines
13 changes: 5 additions & 8 deletions benchmarks/splines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,25 +160,22 @@ void characteristics_advection_unitary(benchmark::State& state)
DDimX<IsNonUniform, s_degree_x>,
ddc::BoundCond::PERIODIC,
ddc::BoundCond::PERIODIC,
Backend,
DDimX<IsNonUniform, s_degree_x>,
DDimY> const spline_builder(x_mesh, cols_per_chunk, preconditioner_max_block_size);
Backend> const spline_builder(x_domain, cols_per_chunk, preconditioner_max_block_size);
ddc::PeriodicExtrapolationRule<X> const periodic_extrapolation;
ddc::SplineEvaluator<
ExecSpace,
typename ExecSpace::memory_space,
BSplinesX<IsNonUniform, s_degree_x>,
DDimX<IsNonUniform, s_degree_x>,
ddc::PeriodicExtrapolationRule<X>,
ddc::PeriodicExtrapolationRule<X>,
DDimX<IsNonUniform, s_degree_x>,
DDimY> const spline_evaluator(periodic_extrapolation, periodic_extrapolation);
ddc::PeriodicExtrapolationRule<X>> const
spline_evaluator(periodic_extrapolation, periodic_extrapolation);
ddc::Chunk coef_alloc(
spline_builder.batched_spline_domain(),
spline_builder.batched_spline_domain(x_mesh),
ddc::KokkosAllocator<double, typename ExecSpace::memory_space>());
ddc::ChunkSpan const coef = coef_alloc.span_view();
ddc::Chunk feet_coords_alloc(
spline_builder.batched_interpolation_domain(),
spline_builder.batched_interpolation_domain(x_mesh),
ddc::KokkosAllocator<ddc::Coordinate<X>, typename ExecSpace::memory_space>());
ddc::ChunkSpan const feet_coords = feet_coords_alloc.span_view();

Expand Down
14 changes: 6 additions & 8 deletions examples/characteristics_advection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,29 +207,27 @@ int main(int argc, char** argv)
DDimX,
BoundCond,
BoundCond,
ddc::SplineSolver::LAPACK,
DDimX,
DDimY> const spline_builder(x_mesh);
ddc::SplineSolver::LAPACK> const spline_builder(x_domain);
ExtrapolationRule const extrapolation_rule;
ddc::SplineEvaluator<
Kokkos::DefaultExecutionSpace,
Kokkos::DefaultExecutionSpace::memory_space,
BSplinesX,
DDimX,
ExtrapolationRule,
ExtrapolationRule,
DDimX,
DDimY> const spline_evaluator(extrapolation_rule, extrapolation_rule);
ExtrapolationRule> const spline_evaluator(extrapolation_rule, extrapolation_rule);
//! [instantiate solver]

//! [instantiate intermediate chunks]
// Instantiate chunk of spline coefs to receive output of spline_builder
ddc::Chunk coef_alloc(spline_builder.batched_spline_domain(), ddc::DeviceAllocator<double>());
ddc::Chunk coef_alloc(
spline_builder.batched_spline_domain(x_mesh),
ddc::DeviceAllocator<double>());
ddc::ChunkSpan const coef = coef_alloc.span_view();

// Instantiate chunk to receive feet coords
ddc::Chunk feet_coords_alloc(
spline_builder.batched_interpolation_domain(),
spline_builder.batched_interpolation_domain(x_mesh),
ddc::DeviceAllocator<ddc::Coordinate<X>>());
ddc::ChunkSpan const feet_coords = feet_coords_alloc.span_view();
//! [instantiate intermediate chunks]
Expand Down
Loading

0 comments on commit 446b2a5

Please sign in to comment.