Added flush to zero
This commit is contained in:
parent
35ad102a6a
commit
a885bf0c72
2 changed files with 44 additions and 1 deletions
|
|
@ -1,7 +1,16 @@
|
|||
#pragma once
|
||||
#include <bits/stdint-uintn.h>
|
||||
#include <cstdint>
|
||||
#include <random>
|
||||
#include <signal.h>
|
||||
#include <string_view>
|
||||
#ifdef HAVE_X86INTRIN_H
|
||||
#include <x86intrin.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_INTRIN_H
|
||||
#include <intrin.h>
|
||||
#endif
|
||||
|
||||
inline void trimInPlace(std::string_view& s)
|
||||
{
|
||||
|
|
@ -168,4 +177,36 @@ private:
|
|||
LeakDetector<Class> leakDetector;
|
||||
#else
|
||||
#define LEAK_DETECTOR(Class)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
class ScopedFTZ {
|
||||
|
||||
public:
|
||||
ScopedFTZ()
|
||||
{
|
||||
#if (HAVE_X86INTRIN_H || HAVE_INTRIN_H)
|
||||
unsigned mask = _MM_DENORMALS_ZERO_MASK | _MM_FLUSH_ZERO_MASK;
|
||||
registerState = _mm_getcsr();
|
||||
_mm_setcsr((registerState & (~mask)) | mask);
|
||||
#elif HAVE_ARM_NEON_H
|
||||
intptr_t mask = (1 << 24);
|
||||
asm volatile("vmrs %0, fpscr"
|
||||
: "=r"(registerState));
|
||||
asm volatile("vmsr fpscr, %0"
|
||||
:
|
||||
: "ri"((registerState & (~mask)) | mask));
|
||||
#endif
|
||||
}
|
||||
~ScopedFTZ()
|
||||
{
|
||||
#if (HAVE_X86INTRIN_H || HAVE_INTRIN_H)
|
||||
_mm_setcsr(registerState);
|
||||
#elif HAVE_ARM_NEON_H
|
||||
asm volatile("vmsr %0, fpscr"
|
||||
: "=r"(registerState));
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned registerState;
|
||||
};
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
#include "Parser.h"
|
||||
#include "Region.h"
|
||||
#include "SfzHelpers.h"
|
||||
#include "Helpers.h"
|
||||
#include "StereoSpan.h"
|
||||
#include "absl/types/span.h"
|
||||
#include <chrono>
|
||||
|
|
@ -59,6 +60,7 @@ public:
|
|||
|
||||
void renderBlock(StereoSpan<float> buffer)
|
||||
{
|
||||
ScopedFTZ ftz;
|
||||
buffer.fill(0.0f);
|
||||
|
||||
StereoSpan<float> tempSpan { tempBuffer, buffer.size() };
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue