mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-03 21:41:26 +12:00
SPU LLVM: Notify workers prematurely if there is considerable excess
This commit is contained in:
parent
ecf7d4e59d
commit
719dafa679
1 changed files with 18 additions and 8 deletions
|
@ -4659,6 +4659,7 @@ struct spu_llvm
|
||||||
|
|
||||||
u32 worker_index = 0;
|
u32 worker_index = 0;
|
||||||
u32 notify_compile_count = 0;
|
u32 notify_compile_count = 0;
|
||||||
|
u32 compile_pending = 0;
|
||||||
std::vector<u8> notify_compile(worker_count);
|
std::vector<u8> notify_compile(worker_count);
|
||||||
|
|
||||||
m_workers = make_single<named_thread_group<spu_llvm_worker>>("SPUW.", worker_count);
|
m_workers = make_single<named_thread_group<spu_llvm_worker>>("SPUW.", worker_count);
|
||||||
|
@ -4689,7 +4690,7 @@ struct spu_llvm
|
||||||
{
|
{
|
||||||
if (notify_compile[i])
|
if (notify_compile[i])
|
||||||
{
|
{
|
||||||
(workers.begin() + (i % worker_count))->registered.notify();
|
(workers.begin() + i)->registered.notify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4700,6 +4701,7 @@ struct spu_llvm
|
||||||
add_count = 65535; // Reset count
|
add_count = 65535; // Reset count
|
||||||
std::fill(notify_compile.begin(), notify_compile.end(), 0); // Reset notification flags
|
std::fill(notify_compile.begin(), notify_compile.end(), 0); // Reset notification flags
|
||||||
notify_compile_count = 0;
|
notify_compile_count = 0;
|
||||||
|
compile_pending = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4740,18 +4742,26 @@ struct spu_llvm
|
||||||
{
|
{
|
||||||
notify_compile[worker_index % worker_count] = 1;
|
notify_compile[worker_index % worker_count] = 1;
|
||||||
notify_compile_count++;
|
notify_compile_count++;
|
||||||
|
}
|
||||||
|
|
||||||
if (notify_compile_count == notify_compile.size())
|
compile_pending++;
|
||||||
|
|
||||||
|
// Notify all before queue runs out if there is considerable excess
|
||||||
|
// Optimized that: if there are many workers, it acts soon
|
||||||
|
// If there are only a few workers, it postpones notifications until there is some more workload
|
||||||
|
if (notify_compile_count && std::min<u32>(7, utils::aligned_div<u32>(worker_count * 2, 3) + 2) <= compile_pending)
|
||||||
{
|
{
|
||||||
// Notify all
|
|
||||||
for (usz i = 0; i < worker_count; i++)
|
for (usz i = 0; i < worker_count; i++)
|
||||||
{
|
{
|
||||||
(workers.begin() + (i % worker_count))->registered.notify();
|
if (notify_compile[i])
|
||||||
|
{
|
||||||
|
(workers.begin() + i)->registered.notify();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::fill(notify_compile.begin(), notify_compile.end(), 0); // Reset notification flags
|
std::fill(notify_compile.begin(), notify_compile.end(), 0); // Reset notification flags
|
||||||
notify_compile_count = 0;
|
notify_compile_count = 0;
|
||||||
}
|
compile_pending = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
worker_index++;
|
worker_index++;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue