From 049e392a9702543b485f51d4064b7739edd9d723 Mon Sep 17 00:00:00 2001 From: Eladash Date: Wed, 5 Feb 2020 06:44:10 +0200 Subject: [PATCH] Make preferred spu threads dynamically adjustable --- rpcs3/Emu/Cell/SPUThread.cpp | 7 +++---- rpcs3/Emu/System.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index b8d431fd83..4a7e6f0a81 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -113,9 +113,8 @@ namespace spu std::array, 65536> atomic_instruction_table = {}; constexpr u32 native_jiffy_duration_us = 1500; //About 1ms resolution with a half offset - void acquire_pc_address(spu_thread& spu, u32 pc, u32 timeout_ms = 3) + void acquire_pc_address(spu_thread& spu, u32 pc, u32 timeout_ms, u32 max_concurrent_instructions) { - const u32 max_concurrent_instructions = g_cfg.core.preferred_spu_threads; const u32 pc_offset = pc >> 2; if (atomic_instruction_table[pc_offset].load(std::memory_order_consume) >= max_concurrent_instructions) @@ -173,9 +172,9 @@ namespace spu concurrent_execution_watchdog(spu_thread& spu) :pc(spu.pc) { - if (g_cfg.core.preferred_spu_threads > 0) + if (const u32 max_concurrent_instructions = g_cfg.core.preferred_spu_threads) { - acquire_pc_address(spu, pc, g_cfg.core.spu_delay_penalty); + acquire_pc_address(spu, pc, g_cfg.core.spu_delay_penalty, max_concurrent_instructions); active = true; } } diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index d424113f9a..f898335e88 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -404,7 +404,7 @@ struct cfg_root : cfg::node cfg::_enum spu_decoder{this, "SPU Decoder", spu_decoder_type::llvm}; cfg::_bool lower_spu_priority{this, "Lower SPU thread priority"}; cfg::_bool spu_debug{this, "SPU Debug"}; - cfg::_int<0, 6> preferred_spu_threads{this, "Preferred SPU Threads", 0}; //Numnber of hardware threads dedicated to heavy simultaneous spu tasks + cfg::_int<0, 6> preferred_spu_threads{this, "Preferred SPU Threads", 0, true}; //Numnber of hardware threads dedicated to heavy simultaneous spu tasks cfg::_int<0, 16> spu_delay_penalty{this, "SPU delay penalty", 3}; //Number of milliseconds to block a thread if a virtual 'core' isn't free cfg::_bool spu_loop_detection{this, "SPU loop detection", true}; //Try to detect wait loops and trigger thread yield cfg::_int<0, 6> max_spurs_threads{this, "Max SPURS Threads", 6}; // HACK. If less then 6, max number of running SPURS threads in each thread group.