diff options
| author | 2018-05-07 22:57:39 -0400 | |
|---|---|---|
| committer | 2018-05-10 19:34:53 -0400 | |
| commit | edc52250b8157a9d2b8c909225114c98c7ea609e (patch) | |
| tree | ecef7f8e5405ccc6221de2ec713df1baac226eee /src/core/core.cpp | |
| parent | thread: Support core change on ResumeFromWait and improve ChangeCore. (diff) | |
| download | yuzu-edc52250b8157a9d2b8c909225114c98c7ea609e.tar.gz yuzu-edc52250b8157a9d2b8c909225114c98c7ea609e.tar.xz yuzu-edc52250b8157a9d2b8c909225114c98c7ea609e.zip | |
core: Run all CPU cores separately, even in single-thread mode.
Diffstat (limited to 'src/core/core.cpp')
| -rw-r--r-- | src/core/core.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 6cbfc3035..84ab876cc 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -34,6 +34,19 @@ static void RunCpuCore(std::shared_ptr<Cpu> cpu_state) { | |||
| 34 | } | 34 | } |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | Cpu& System::CurrentCpuCore() { | ||
| 38 | // If multicore is enabled, use host thread to figure out the current CPU core | ||
| 39 | if (Settings::values.use_multi_core) { | ||
| 40 | const auto& search = thread_to_cpu.find(std::this_thread::get_id()); | ||
| 41 | ASSERT(search != thread_to_cpu.end()); | ||
| 42 | ASSERT(search->second); | ||
| 43 | return *search->second; | ||
| 44 | } | ||
| 45 | |||
| 46 | // Otherwise, use single-threaded mode active_core variable | ||
| 47 | return *cpu_cores[active_core]; | ||
| 48 | } | ||
| 49 | |||
| 37 | System::ResultStatus System::RunLoop(bool tight_loop) { | 50 | System::ResultStatus System::RunLoop(bool tight_loop) { |
| 38 | status = ResultStatus::Success; | 51 | status = ResultStatus::Success; |
| 39 | 52 | ||
| @@ -55,7 +68,13 @@ System::ResultStatus System::RunLoop(bool tight_loop) { | |||
| 55 | } | 68 | } |
| 56 | } | 69 | } |
| 57 | 70 | ||
| 58 | cpu_cores[0]->RunLoop(tight_loop); | 71 | for (active_core = 0; active_core < NUM_CPU_CORES; ++active_core) { |
| 72 | cpu_cores[active_core]->RunLoop(tight_loop); | ||
| 73 | if (Settings::values.use_multi_core) { | ||
| 74 | // Cores 1-3 are run on other threads in this mode | ||
| 75 | break; | ||
| 76 | } | ||
| 77 | } | ||
| 59 | 78 | ||
| 60 | return status; | 79 | return status; |
| 61 | } | 80 | } |
| @@ -127,11 +146,6 @@ PerfStats::Results System::GetAndResetPerfStats() { | |||
| 127 | } | 146 | } |
| 128 | 147 | ||
| 129 | const std::shared_ptr<Kernel::Scheduler>& System::Scheduler(size_t core_index) { | 148 | const std::shared_ptr<Kernel::Scheduler>& System::Scheduler(size_t core_index) { |
| 130 | if (!Settings::values.use_multi_core) { | ||
| 131 | // Always use Core 0 scheduler when multicore is disabled | ||
| 132 | return cpu_cores[0]->Scheduler(); | ||
| 133 | } | ||
| 134 | |||
| 135 | ASSERT(core_index < NUM_CPU_CORES); | 149 | ASSERT(core_index < NUM_CPU_CORES); |
| 136 | return cpu_cores[core_index]->Scheduler(); | 150 | return cpu_cores[core_index]->Scheduler(); |
| 137 | } | 151 | } |