Use g_fxo for jit_core_allocator

This commit is contained in:
Nekotekina 2019-08-25 17:27:38 +03:00
parent 3dd6961ee5
commit 4ec3e968ff
1 changed files with 8 additions and 7 deletions

View File

@ -1445,11 +1445,14 @@ extern void ppu_initialize(const ppu_module& info)
struct jit_core_allocator struct jit_core_allocator
{ {
::semaphore<0x7fffffff> sem; const s32 thread_count = g_cfg.core.llvm_threads ? std::min<s32>(g_cfg.core.llvm_threads, limit()) : limit();
jit_core_allocator(s32 arg) // Initialize global semaphore with the max number of threads
: sem(arg) ::semaphore<0x7fffffff> sem{std::max<s32>(thread_count, 1)};
static s32 limit()
{ {
return static_cast<s32>(std::thread::hardware_concurrency());
} }
}; };
@ -1462,10 +1465,8 @@ extern void ppu_initialize(const ppu_module& info)
// Compiler mutex (global) // Compiler mutex (global)
static shared_mutex jmutex; static shared_mutex jmutex;
// Initialize global semaphore with the max number of threads // Get jit core allocator instance
u32 max_threads = static_cast<u32>(g_cfg.core.llvm_threads); const auto jcores = g_fxo->get<jit_core_allocator>();
s32 thread_count = max_threads > 0 ? std::min(max_threads, std::thread::hardware_concurrency()) : std::thread::hardware_concurrency();
const auto jcores = fxm::get_always<jit_core_allocator>(std::max<s32>(thread_count, 1));
// Worker threads // Worker threads
std::vector<std::thread> jthreads; std::vector<std::thread> jthreads;