SPU: Make SPURS limit a dynamic setting

This commit is contained in:
Elad Ashkenazi 2024-09-25 09:16:42 +03:00 committed by Elad
parent feedc183a4
commit 8b79fd3da1
3 changed files with 25 additions and 5 deletions

View file

@ -5659,6 +5659,24 @@ s64 spu_thread::get_ch_value(u32 ch)
// Don't busy-wait with TSX - memory is sensitive
if (g_use_rtm || !reservation_busy_waiting)
{
if (u32 max_threads = std::min<u32>(g_cfg.core.max_spurs_threads, group->max_num); group->max_run != max_threads)
{
constexpr std::string_view spurs_suffix = "CellSpursKernelGroup"sv;
if (group->name.ends_with(spurs_suffix) && !group->name.substr(0, group->name.size() - spurs_suffix.size()).ends_with("_libsail"))
{
// Hack: don't run more SPURS threads than specified.
if (u32 old = atomic_storage<u32>::exchange(group->max_run, max_threads); old > max_threads)
{
spu_log.success("HACK: '%s' (0x%x) limited to %u threads.", group->name, group->id, max_threads);
}
else if (u32 running = group->spurs_running; old < max_threads && running >= old && running < max_threads)
{
group->spurs_running.notify_all();
}
}
}
if (u32 work_count = g_spu_work_count)
{
const u32 true_free = utils::sub_saturate<u32>(utils::get_thread_count(), 10);