@@ -49,6 +49,18 @@ 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+ auto n = ROOT::Double_v::size ();
60+
61+ return " std::experimental::resize_simd_t<" + std::to_string (n) + " , ROOT::Double_v>" ;
62+ }
63+
5264} // namespace
5365
5466/* * \class TFormula TFormula.h "inc/TFormula.h"
@@ -815,7 +827,7 @@ prepareMethod(bool HasParameters, bool HasVariables, const char* FuncName,
815827 TString prototypeArguments = " " ;
816828 if (HasVariables || HasParameters) {
817829 if (IsVectorized)
818- prototypeArguments.Append (" ROOT::Double_v const*" );
830+ prototypeArguments.Append (simdArgType () + " const*" );
819831 else
820832 prototypeArguments.Append (" Double_t const*" );
821833 }
@@ -2354,7 +2366,7 @@ void TFormula::ProcessFormula(TString &formula)
23542366 if (fVectorized )
23552367 inputFormulaVecFlag += " (vectorized)" ;
23562368
2357- TString argType = fVectorized ? " ROOT::Double_v " : " Double_t" ;
2369+ TString argType = fVectorized ? simdArgType () : " Double_t" ;
23582370
23592371 // valid input formula - try to put into Cling (in case of no variables but only parameter we need to add the standard signature)
23602372 TString argumentsPrototype = TString::Format (" %s%s%s" , ( (hasVariables || hasParameters) ? (argType + " const *x" ).Data () : " " ),
0 commit comments