From 239c15845aaaec72b10603cf0f0039696ba40125 Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 23 Sep 2013 11:17:43 +0100 Subject: [PATCH] New method: FloatVectorOperations::enableFlushToZeroMode() --- .../buffers/juce_FloatVectorOperations.cpp | 9 +++++++++ .../buffers/juce_FloatVectorOperations.h | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp index 53dd00b55d..abf1d8f0d6 100644 --- a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp +++ b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp @@ -332,3 +332,12 @@ float JUCE_CALLTYPE FloatVectorOperations::findMaximum (const float* src, int nu return juce::findMaximum (src, num); #endif } + +void JUCE_CALLTYPE FloatVectorOperations::enableFlushToZeroMode (bool shouldEnable) noexcept +{ + #if JUCE_USE_SSE_INTRINSICS + if (FloatVectorHelpers::isSSE2Available()) + _MM_SET_FLUSH_ZERO_MODE (shouldEnable ? _MM_FLUSH_ZERO_ON : _MM_FLUSH_ZERO_OFF); + #endif + (void) shouldEnable; +} diff --git a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h index 79b54b0205..a021eebf91 100644 --- a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h +++ b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h @@ -73,6 +73,11 @@ public: /** Finds the maximum value in the given array. */ static float JUCE_CALLTYPE findMaximum (const float* src, int numValues) noexcept; + + /** On Intel CPUs, this method enables or disables the SSE flush-to-zero mode. + Effectively, this is a wrapper around a call to _MM_SET_FLUSH_ZERO_MODE + */ + static void JUCE_CALLTYPE enableFlushToZeroMode (bool shouldEnable) noexcept; };