// Control register bit mask to disable denormals on the hardware. #ifdefined(WEBRTC_DENORMAL_DISABLER_X86_SUPPORTED) // On x86 two bits are used: flush-to-zero (FTZ) and denormals-are-zero (DAZ).
constexpr int kDenormalBitMask = 0x8040; #elifdefined(WEBRTC_ARCH_ARM_FAMILY) // On ARM one bit is used: flush-to-zero (FTZ).
constexpr int kDenormalBitMask = 1 << 24; #endif
// Reads the relevant CPU control register and returns its value for supported // architectures and compilers. Otherwise returns `kUnspecifiedStatusWord`.
int ReadStatusWord() {
int result = kUnspecifiedStatusWord; #ifdefined(WEBRTC_DENORMAL_DISABLER_X86_SUPPORTED) asmvolatile("stmxcsr %0" : "=m"(result)); #elifdefined(WEBRTC_ARCH_ARM_FAMILY) && defined(WEBRTC_ARCH_32_BITS) asmvolatile("vmrs %[result], FPSCR" : [result] "=r"(result)); #elifdefined(WEBRTC_ARCH_ARM_FAMILY) && defined(WEBRTC_ARCH_64_BITS) asmvolatile("mrs %x[result], FPCR" : [result] "=r"(result)); #endif return result;
}
// Writes `status_word` in the relevant CPU control register if the architecture // and the compiler are supported. void SetStatusWord(int status_word) { #ifdefined(WEBRTC_DENORMAL_DISABLER_X86_SUPPORTED) asmvolatile("ldmxcsr %0" : : "m"(status_word)); #elifdefined(WEBRTC_ARCH_ARM_FAMILY) && defined(WEBRTC_ARCH_32_BITS) asmvolatile("vmsr FPSCR, %[src]" : : [src] "r"(status_word)); #elifdefined(WEBRTC_ARCH_ARM_FAMILY) && defined(WEBRTC_ARCH_64_BITS) asmvolatile("msr FPCR, %x[src]" : : [src] "r"(status_word)); #endif
}
// Returns true if the status word indicates that denormals are enabled.
constexpr bool DenormalsEnabled(int status_word) { return (status_word & kDenormalBitMask) != kDenormalBitMask;
}
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.