@@ -72,7 +72,8 @@ perf: $(TARGET) | |||||
# Requires gperftools | # Requires gperftools | ||||
perf record --call-graph dwarf -o perf.data ./$< -d | perf record --call-graph dwarf -o perf.data ./$< -d | ||||
# Analyze with hotspot (https://github.com/KDAB/hotspot) for example | # Analyze with hotspot (https://github.com/KDAB/hotspot) for example | ||||
# hotspot perf.data | |||||
hotspot perf.data | |||||
rm perf.data | |||||
valgrind: $(TARGET) | valgrind: $(TARGET) | ||||
# --gen-suppressions=yes | # --gen-suppressions=yes | ||||
@@ -45,7 +45,7 @@ This derived source file is released under the zlib license. | |||||
*/ | */ | ||||
#include <emmintrin.h> | |||||
#include <x86intrin.h> | |||||
/** Generate 1.f without accessing memory */ | /** Generate 1.f without accessing memory */ | ||||
@@ -1,6 +1,6 @@ | |||||
#pragma once | #pragma once | ||||
#include <cstring> | #include <cstring> | ||||
#include <emmintrin.h> | |||||
#include <x86intrin.h> | |||||
namespace rack { | namespace rack { | ||||
@@ -132,7 +132,6 @@ struct AudioInterface : Module { | |||||
if (port.active && port.numInputs > 0) { | if (port.active && port.numInputs > 0) { | ||||
// Wait until inputs are present | // Wait until inputs are present | ||||
// Give up after a timeout in case the audio device is being unresponsive. | // Give up after a timeout in case the audio device is being unresponsive. | ||||
APP->engine->yieldWorkers(); | |||||
std::unique_lock<std::mutex> lock(port.engineMutex); | std::unique_lock<std::mutex> lock(port.engineMutex); | ||||
auto cond = [&] { | auto cond = [&] { | ||||
return (!port.inputBuffer.empty()); | return (!port.inputBuffer.empty()); | ||||
@@ -182,11 +181,12 @@ struct AudioInterface : Module { | |||||
if (outputBuffer.full()) { | if (outputBuffer.full()) { | ||||
// Wait until enough outputs are consumed | // Wait until enough outputs are consumed | ||||
// Give up after a timeout in case the audio device is being unresponsive. | // Give up after a timeout in case the audio device is being unresponsive. | ||||
APP->engine->yieldWorkers(); | |||||
std::unique_lock<std::mutex> lock(port.engineMutex); | |||||
auto cond = [&] { | auto cond = [&] { | ||||
return (port.outputBuffer.size() < (size_t) port.blockSize); | return (port.outputBuffer.size() < (size_t) port.blockSize); | ||||
}; | }; | ||||
if (!cond()) | |||||
APP->engine->yieldWorkers(); | |||||
std::unique_lock<std::mutex> lock(port.engineMutex); | |||||
auto timeout = std::chrono::milliseconds(200); | auto timeout = std::chrono::milliseconds(200); | ||||
if (port.engineCv.wait_for(lock, timeout, cond)) { | if (port.engineCv.wait_for(lock, timeout, cond)) { | ||||
// Push converted output | // Push converted output | ||||
@@ -9,8 +9,7 @@ | |||||
#include <condition_variable> | #include <condition_variable> | ||||
#include <mutex> | #include <mutex> | ||||
#include <atomic> | #include <atomic> | ||||
#include <xmmintrin.h> | |||||
#include <pmmintrin.h> | |||||
#include <x86intrin.h> | |||||
namespace rack { | namespace rack { | ||||
@@ -90,7 +89,9 @@ struct SpinBarrier { | |||||
count = 0; | count = 0; | ||||
} | } | ||||
else { | else { | ||||
while (count != 0); | |||||
while (count != 0) { | |||||
_mm_pause(); | |||||
} | |||||
} | } | ||||
} | } | ||||
}; | }; | ||||
@@ -127,6 +128,7 @@ struct HybridBarrier { | |||||
while (!yield) { | while (!yield) { | ||||
if (count == 0) | if (count == 0) | ||||
return; | return; | ||||
_mm_pause(); | |||||
} | } | ||||
// Wait on mutex | // Wait on mutex | ||||