@@ -49,6 +49,21 @@ std::string doubleToString(double val)
4949 return ss.str ();
5050}
5151
52+ // To use the ROOT::Double_v type in the interpreter, we need to make sure that
53+ // we're using the SIMD type of the same size as in the compiled ROOT. If we
54+ // would use ROOT::Double_v directly, which aliases to native_simd, is might
55+ // choose different sized in compiled and interpreted contexts (especially if
56+ // compiling with march=native).
57+ std::string simdArgType ()
58+ {
59+ #ifdef R__HAS_STD_SIMD
60+ auto n = ROOT::Double_v::size ();
61+ return " std::experimental::resize_simd_t<" + std::to_string (n) + " , ROOT::Double_v>" ;
62+ #else
63+ return " ROOT::Double_v" ;
64+ #endif
65+ }
66+
5267} // namespace
5368
5469/* * \class TFormula TFormula.h "inc/TFormula.h"
@@ -815,7 +830,7 @@ prepareMethod(bool HasParameters, bool HasVariables, const char* FuncName,
815830 TString prototypeArguments = " " ;
816831 if (HasVariables || HasParameters) {
817832 if (IsVectorized)
818- prototypeArguments.Append (" ROOT::Double_v const*" );
833+ prototypeArguments.Append (simdArgType () + " const*" );
819834 else
820835 prototypeArguments.Append (" Double_t const*" );
821836 }
@@ -2354,7 +2369,7 @@ void TFormula::ProcessFormula(TString &formula)
23542369 if (fVectorized )
23552370 inputFormulaVecFlag += " (vectorized)" ;
23562371
2357- TString argType = fVectorized ? " ROOT::Double_v " : " Double_t" ;
2372+ TString argType = fVectorized ? simdArgType () : " Double_t" ;
23582373
23592374 // valid input formula - try to put into Cling (in case of no variables but only parameter we need to add the standard signature)
23602375 TString argumentsPrototype = TString::Format (" %s%s%s" , ( (hasVariables || hasParameters) ? (argType + " const *x" ).Data () : " " ),
0 commit comments