Skip to content

Commit 07f43ce

Browse files
committed
[Math] Don't use scalar fallback for types like ROOT::Double_v
The fallback to the vector types being defined as scalars if `std::simd` is not available is confusing, and doesn't help anyway because the code for scalar types and `std::simd` usage has to look different.
1 parent c243979 commit 07f43ce

File tree

2 files changed

+11
-20
lines changed

2 files changed

+11
-20
lines changed

hist/hist/inc/TF1.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -718,12 +718,13 @@ namespace ROOT {
718718
void TF1Builder<Func>::Build(TF1 *f, Func func)
719719
{
720720
// check if vector interface is supported by Func
721+
#ifdef R__HAS_STD_SIMD
721722
if constexpr(std::is_invocable_r_v<Double_v, Func, Double_v*, double *>) {
722-
// if ROOT was not built with std::experimental::simd support, Double_v is just an alias for the scalar
723-
// double
724-
f->fType = std::is_same<Double_v, double>::value ? TF1::EFType::kTemplScalar : TF1::EFType::kTemplVec;
723+
f->fType = TF1::EFType::kTemplVec;
725724
f->fFunctor.reset(new TF1::TF1FunctorPointerImpl(ROOT::Math::ParamFunctorTempl<Double_v>(func)));
726-
} else {
725+
} else
726+
#endif
727+
{
727728
f->fType = TF1::EFType::kTemplScalar;
728729
f->fFunctor.reset(new TF1::TF1FunctorPointerImpl(ROOT::Math::ParamFunctorTempl<double>(func)));
729730
}
@@ -735,12 +736,13 @@ namespace ROOT {
735736
void TF1Builder<Func *>::Build(TF1 *f, Func *func)
736737
{
737738
// check if vector interface is supported by Func
739+
#ifdef R__HAS_STD_SIMD
738740
if constexpr(std::is_invocable_r_v<Double_v, Func, Double_v*, double *>) {
739-
// if ROOT was not built with std::experimental::simd support, Double_v is just an alias for the scalar
740-
// double
741-
f->fType = std::is_same<Double_v, double>::value ? TF1::EFType::kTemplScalar : TF1::EFType::kTemplVec;
741+
f->fType = TF1::EFType::kTemplVec;
742742
f->fFunctor.reset(new TF1::TF1FunctorPointerImpl(ROOT::Math::ParamFunctorTempl<Double_v>(func)));
743-
} else {
743+
} else
744+
#endif
745+
{
744746
f->fType = TF1::EFType::kTemplScalar;
745747
f->fFunctor.reset(new TF1::TF1FunctorPointerImpl(ROOT::Math::ParamFunctorTempl<double>(func)));
746748
}

math/mathcore/inc/Math/Types.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ using SIMDTag = std::experimental::simd_abi::native<T>;
1818

1919
} // namespace Internal
2020

21+
// FIXME: Should we introduce Int32_t and UInt32_t in RtypesCore.h?
2122
using Float_v = std::experimental::simd<Float_t, Internal::SIMDTag<Float_t>>;
2223
using Double_v = std::experimental::simd<Double_t, Internal::SIMDTag<Double_t>>;
2324
using Int_v = std::experimental::simd<Int_t, Internal::SIMDTag<Int_t>>;
@@ -27,18 +28,6 @@ using UInt32_v = std::experimental::simd<UInt_t, Internal::SIMDTag<UInt_t>>;
2728

2829
} // namespace ROOT
2930

30-
#else // R__HAS_STD_SIMD
31-
32-
// We do not have explicit vectorisation support enabled. Fall back to regular ROOT types.
33-
34-
namespace ROOT {
35-
using Float_v = Float_t;
36-
using Double_v = Double_t;
37-
using Int_v = Int_t;
38-
using Int32_v = Int_t; // FIXME: Should we introduce Int32_t in RtypesCore.h?
39-
using UInt_v = UInt_t;
40-
using UInt32_v = UInt_t; // FIXME: Should we introduce UInt32_t in RtypesCore.h?
41-
}
4231
#endif
4332

4433
#endif // ROOT_Math_VecTypes

0 commit comments

Comments
 (0)