class KahanSum; namespace sc::op
{ // Checkout available optimization options. // Note that it turned out to be problematic to support CPU-specific code // that's not guaranteed to be available on that specific platform (see // git commit 2d36e7f5186ba5215f2b228b98c24520bd4f2882). SSE2 is guaranteed on // x86_64 and it is our baseline requirement for x86 on Windows, so SSE2 use is // hardcoded on those platforms. // Whenever we raise baseline to e.g. AVX, this may get // replaced with AVX code (get it from mentioned git commit). // Do it similarly with other platforms. #ifdefined(X86_64) || (defined(INTEL) && defined(_WIN32)) #define SC_USE_SSE2 1
KahanSum executeSSE2(size_t& i, size_t nSize, constdouble* pCurrent); #else #define SC_USE_SSE2 0 #endif
}
/** *AddsavaluetothesumusingKahansummation. *@paramfSum
*/ inlinevoid add(const KahanSum& fSum)
{ #if SC_USE_SSE2
add(fSum.m_fSum + fSum.m_fError);
add(fSum.m_fMem); #else // Without SSE2 the sum+compensation value fails badly. Continue // keeping the old though slightly off (see tdf#156985) explicit // addition of the compensation value. double sum = fSum.m_fSum; double err = fSum.m_fError; if (fSum.m_fMem != 0.0)
sumNeumaierNormal(sum, err, fSum.m_fMem);
add(sum);
add(err); #endif
}
// Check the same condition as rtl::math::approxAdd() and if true // return 0.0, if false use another Kahan summation adding m_fMem. if (((m_fMem < 0.0 && fTotal > 0.0) || (fTotal < 0.0 && m_fMem > 0.0))
&& rtl::math::approxEqual(m_fMem, -fTotal))
{ /* TODO: should we reset all values to zero here for further
* summation, or is it better to keep them as they are? */ return0.0;
}
// The actual argument passed to add() here does not matter as long as // it is not 0, m_fMem is not 0 and will be added anyway, see add(). const_cast<KahanSum*>(this)->add(m_fMem); const_cast<KahanSum*>(this)->m_fMem = 0.0; return m_fSum + m_fError;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.