diff options
| author | 2018-05-03 00:34:54 -0400 | |
|---|---|---|
| committer | 2018-05-10 19:34:47 -0400 | |
| commit | 9bf2a428f9e9359763be1bfd90c32371044c711e (patch) | |
| tree | 89188fea0b3457421fe203cc7a2754523d0acf04 /src/core/core.cpp | |
| parent | core: Support session close with multicore. (diff) | |
| download | yuzu-9bf2a428f9e9359763be1bfd90c32371044c711e.tar.gz yuzu-9bf2a428f9e9359763be1bfd90c32371044c711e.tar.xz yuzu-9bf2a428f9e9359763be1bfd90c32371044c711e.zip | |
core: Add a configuration setting for use_multi_core.
Diffstat (limited to 'src/core/core.cpp')
| -rw-r--r-- | src/core/core.cpp | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 1e6be34c8..59c8940f7 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -126,6 +126,21 @@ PerfStats::Results System::GetAndResetPerfStats() { | |||
| 126 | return perf_stats.GetAndResetStats(CoreTiming::GetGlobalTimeUs()); | 126 | return perf_stats.GetAndResetStats(CoreTiming::GetGlobalTimeUs()); |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | 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); | ||
| 136 | return cpu_cores[core_index]->Scheduler(); | ||
| 137 | } | ||
| 138 | |||
| 139 | ARM_Interface& System::ArmInterface(size_t core_index) { | ||
| 140 | ASSERT(core_index < NUM_CPU_CORES); | ||
| 141 | return cpu_cores[core_index]->ArmInterface(); | ||
| 142 | } | ||
| 143 | |||
| 129 | System::ResultStatus System::Init(EmuWindow* emu_window, u32 system_mode) { | 144 | System::ResultStatus System::Init(EmuWindow* emu_window, u32 system_mode) { |
| 130 | NGLOG_DEBUG(HW_Memory, "initialized OK"); | 145 | NGLOG_DEBUG(HW_Memory, "initialized OK"); |
| 131 | 146 | ||
| @@ -154,9 +169,12 @@ System::ResultStatus System::Init(EmuWindow* emu_window, u32 system_mode) { | |||
| 154 | // Create threads for CPU cores 1-3, and build thread_to_cpu map | 169 | // Create threads for CPU cores 1-3, and build thread_to_cpu map |
| 155 | // CPU core 0 is run on the main thread | 170 | // CPU core 0 is run on the main thread |
| 156 | thread_to_cpu[std::this_thread::get_id()] = cpu_cores[0]; | 171 | thread_to_cpu[std::this_thread::get_id()] = cpu_cores[0]; |
| 157 | for (size_t index = 0; index < cpu_core_threads.size(); ++index) { | 172 | if (Settings::values.use_multi_core) { |
| 158 | cpu_core_threads[index] = std::make_unique<std::thread>(RunCpuCore, cpu_cores[index + 1]); | 173 | for (size_t index = 0; index < cpu_core_threads.size(); ++index) { |
| 159 | thread_to_cpu[cpu_core_threads[index]->get_id()] = cpu_cores[index + 1]; | 174 | cpu_core_threads[index] = |
| 175 | std::make_unique<std::thread>(RunCpuCore, cpu_cores[index + 1]); | ||
| 176 | thread_to_cpu[cpu_core_threads[index]->get_id()] = cpu_cores[index + 1]; | ||
| 177 | } | ||
| 160 | } | 178 | } |
| 161 | 179 | ||
| 162 | NGLOG_DEBUG(Core, "Initialized OK"); | 180 | NGLOG_DEBUG(Core, "Initialized OK"); |
| @@ -190,9 +208,11 @@ void System::Shutdown() { | |||
| 190 | 208 | ||
| 191 | // Close all CPU/threading state | 209 | // Close all CPU/threading state |
| 192 | cpu_barrier->NotifyEnd(); | 210 | cpu_barrier->NotifyEnd(); |
| 193 | for (auto& thread : cpu_core_threads) { | 211 | if (Settings::values.use_multi_core) { |
| 194 | thread->join(); | 212 | for (auto& thread : cpu_core_threads) { |
| 195 | thread.reset(); | 213 | thread->join(); |
| 214 | thread.reset(); | ||
| 215 | } | ||
| 196 | } | 216 | } |
| 197 | thread_to_cpu.clear(); | 217 | thread_to_cpu.clear(); |
| 198 | for (auto& cpu_core : cpu_cores) { | 218 | for (auto& cpu_core : cpu_cores) { |