Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[scsynth][supernova] fix Windows not guarding denormals #4504

Merged
merged 2 commits into from
Feb 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 8 additions & 16 deletions server/scsynth/SC_World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@

#include "malloc_aligned.hpp"

#include <boost/predef/hardware.h>

#ifdef BOOST_HW_SIMD_AVAILABLE >= BOOST_HW_SIMD_X86_SSE_VERSION
# include <xmmintrin.h>
#endif

// undefine the shadowed scfft functions
#undef scfft_create
#undef scfft_dofft
Expand Down Expand Up @@ -148,26 +154,12 @@ void zfree(void* ptr) { return free_alig(ptr); }
////////////////////////////////////////////////////////////////////////////////

// Set denormal FTZ mode on CPUs that need/support it.
void sc_SetDenormalFlags();

#ifdef __SSE2__
# include <xmmintrin.h>

void sc_SetDenormalFlags() {
#if BOOST_HW_SIMD_X86 >= BOOST_HW_SIMD_X86_SSE_VERSION
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
_mm_setcsr(_mm_getcsr() | 0x40); // DAZ
}

#elif defined(__SSE__)
# include <xmmintrin.h>

void sc_SetDenormalFlags() { _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); }

#else

void sc_SetDenormalFlags() {}

#endif
}

////////////////////////////////////////////////////////////////////////////////

Expand Down
4 changes: 3 additions & 1 deletion server/supernova/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
# include <CoreAudio/CoreAudioTypes.h>
#endif

#include <boost/predef/hardware.h>

namespace nova {

class nova_server* instance = nullptr;
Expand Down Expand Up @@ -207,7 +209,7 @@ static void name_current_thread(int thread_index) {
}

static void set_daz_ftz(void) {
#ifdef __SSE__
#if BOOST_HW_SIMD_X86 >= BOOST_X86_SSE_VERSION
/* denormal handling */
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
_mm_setcsr(_mm_getcsr() | 0x40);
Expand Down