Skip to content

Add spline compatibility check helper #878

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

yasahi-hpc
Copy link
Member

This PR aims at a helper to check the consistency of spline builder and evaluator.
For some reason, I need double parentheses to use ASSERT_FALSE like
ASSERT_FALSE((ddc::is_spline_compatible_v<Builder2D_1, Builder2D_1>));

Copy link

codecov bot commented Jun 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.94%. Comparing base (e5a1bf8) to head (67967c7).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #878   +/-   ##
=======================================
  Coverage   89.94%   89.94%           
=======================================
  Files          55       55           
  Lines        2863     2863           
  Branches      976      976           
=======================================
  Hits         2575     2575           
  Misses         91       91           
  Partials      197      197           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yasahi-hpc
Copy link
Member Author

@tpadioleau

Following changes are needed?

  1. Only expose is_<check>_v
  2. Add docs to is_<check>_v
  3. Use parentheses to &&?
template <class Builder, class Evaluator>
 struct is_spline_compatible<Builder, Evaluator,
        std::enable_if_t<is_spline_builder_v<Builder> && is_spline_evaluator_v<Evaluator>
                         || is_spline_builder_v<Evaluator> && is_spline_evaluator_v<Builder> >>

Should be

template <class Builder, class Evaluator>
 struct is_spline_compatible<Builder, Evaluator,
        std::enable_if_t<(is_spline_builder_v<Builder> && is_spline_evaluator_v<Evaluator>)
                         || (is_spline_builder_v<Evaluator> && is_spline_evaluator_v<Builder>) >>

@tpadioleau
Copy link
Member

@tpadioleau

Following changes are needed?

  1. Only expose is_<check>_v

You can keep is_<check> in the current namespace as the other traits. We can put them in a detail namespace later.

  1. Add docs to is_<check>_v

Yes please

  1. Use parentheses to &&?

Yes I guess the point of the linter is to clarify the intent.

@yasahi-hpc
Copy link
Member Author

@tpadioleau
Following changes are needed?

  1. Only expose is_<check>_v

You can keep is_<check> in the current namespace as the other traits. We can put them in a detail namespace later.

OK

  1. Add docs to is_<check>_v

Yes please

What kind of docstrings do you prefer?
I could not see docs for these constants.
is_chunk_v

  1. Use parentheses to &&?

Yes I guess the point of the linter is to clarify the intent.

OK

};

template <class Builder, class Evaluator>
struct is_spline_compatible<Builder, Evaluator,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this name is very explicit. I would expect it to check if a spline is compatible with a builder or if a spline is compatible with an evaluator, not if a spline builder is compatible with an evaluator

I'm not sure what to suggest instead though

Suggested change
struct is_spline_compatible<Builder, Evaluator,
struct is_spline_interpolation_possible<Builder, Evaluator,
Suggested change
struct is_spline_compatible<Builder, Evaluator,
struct is_interpolation_possible<Builder, Evaluator,

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have a strong preference.
But, I would prefer to include a term spline at least and ideally not too long

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I definitely agree that it should not be too long.

I'm not sure it is important to include spline though? If you had a different intermediate representation it is likely that you would still need a similar check for a compatible Builder and Evaluator. That is why I suggested is_interpolation_possible

If splines are important then maybe shares_spline_basis? But this doesn't cover the Memory/Execution space aspects

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After some discussion, we decided to rename it as is_evaluator_admissible<Builder, Evaluator> and we do not accept is_evaluator_admissible<Evaluator, Builder>

@yasahi-hpc yasahi-hpc force-pushed the check-compatibility-of-splines branch from 64b4312 to b33f82c Compare June 23, 2025 14:20
@yasahi-hpc
Copy link
Member Author

@tpadioleau Can you format this
clangformat 20 is unavailable on my env

@tpadioleau
Copy link
Member

@tpadioleau Can you format this clangformat 20 is unavailable on my env

Done

@yasahi-hpc yasahi-hpc requested a review from tpadioleau June 23, 2025 16:09
Copy link
Member

@tpadioleau tpadioleau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! Just a few comments about the form. Can you also add your name to the authors ?

#include "spline_evaluator_2d.hpp"

namespace ddc {
template <class T>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
template <class T>
template <class T>

Comment on lines +7 to +14
#include <cassert>
#include <cstddef>
#include <memory>
#include <optional>
#include <stdexcept>
#include <tuple>
#include <type_traits>
#include <utility>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the list of headers ?

inline constexpr bool is_spline_builder_v = is_spline_builder<T>::value;

template <class T>
struct is_spline_builder2D : std::false_type
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
struct is_spline_builder2D : std::false_type
struct is_spline_builder2d : std::false_type

ddc::BoundCond BcLower2,
ddc::BoundCond BcUpper2,
ddc::SplineSolver Solver>
struct is_spline_builder2D<SplineBuilder2D<
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
struct is_spline_builder2D<SplineBuilder2D<
struct is_spline_builder2d<SplineBuilder2D<

* @tparam T The type to be checked if is a SplineBuilder2D
*/
template <class T>
inline constexpr bool is_spline_builder2D_v = is_spline_builder2D<T>::value;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
inline constexpr bool is_spline_builder2D_v = is_spline_builder2D<T>::value;
inline constexpr bool is_spline_builder2d_v = is_spline_builder2d<T>::value;

inline constexpr bool is_spline_evaluator_v = is_spline_evaluator<T>::value;

template <class T>
struct is_spline_evaluator2D : std::false_type
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
struct is_spline_evaluator2D : std::false_type
struct is_spline_evaluator2d : std::false_type

class UpperExtrapolationRule1,
class LowerExtrapolationRule2,
class UpperExtrapolationRule2>
struct is_spline_evaluator2D<SplineEvaluator2D<
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
struct is_spline_evaluator2D<SplineEvaluator2D<
struct is_spline_evaluator2d<SplineEvaluator2D<

* @tparam T The type to be checked if is a SplineEvaluator2D
*/
template <class T>
inline constexpr bool is_spline_evaluator2D_v = is_spline_evaluator2D<T>::value;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
inline constexpr bool is_spline_evaluator2D_v = is_spline_evaluator2D<T>::value;
inline constexpr bool is_spline_evaluator2d_v = is_spline_evaluator2D<T>::value;

Comment on lines +5 to +7
#include <cstddef>
#include <stdexcept>
#include <vector>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the list of headers ?


#include "test_utils.hpp"

struct DimX
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put struct DimX, DDimX, DimY, DDimY and BSplinesTraits in an inline namespace ?

inline namespace anonymous_namespace_workaround_spline_traits_cpp { }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants