Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions GPU/GPUTracking/TPCClusterFinder/ClusterAccumulator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,26 @@ GPUd() void ClusterAccumulator::finalize(const CfChargePos& pos, const Charge q,
{
mQtot += q;

#ifdef __METAL__
// Metal's fast-math division and sqrt are not correctly rounded, which moves
// widths that sit within an ulp of a packing step. Do the operations the
// arm64 -ffast-math CPU build does here: reciprocal, products, fused variance.
const float invQ = metal::precise::divide(1.f, mQtot);
mPadMean *= invQ;
mTimeMean *= invQ;
const float padMean2 = mPadMean * mPadMean;
const float timeMean2 = mTimeMean * mTimeMean;
mPadSigma = metal::precise::sqrt(metal::fma(mPadSigma, invQ, -padMean2));
mTimeSigma = metal::precise::sqrt(metal::fma(mTimeSigma, invQ, -timeMean2));
#else
mPadMean /= mQtot;
mTimeMean /= mQtot;
mPadSigma /= mQtot;
mTimeSigma /= mQtot;

mPadSigma = CAMath::Sqrt(mPadSigma - mPadMean * mPadMean);
mTimeSigma = CAMath::Sqrt(mTimeSigma - mTimeMean * mTimeMean);
#endif

Pad pad = pos.pad();
mPadMean += pad;
Expand Down
Loading