summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-05-03 06:34:54 +0200
committerbunnei <bunneidev@gmail.com>2018-05-11 01:34:47 +0200
commit9bf2a428f9e9359763be1bfd90c32371044c711e (patch)
tree89188fea0b3457421fe203cc7a2754523d0acf04 /src/core
parentcore: Support session close with multicore. (diff)
downloadyuzu-9bf2a428f9e9359763be1bfd90c32371044c711e.tar
yuzu-9bf2a428f9e9359763be1bfd90c32371044c711e.tar.gz
yuzu-9bf2a428f9e9359763be1bfd90c32371044c711e.tar.bz2
yuzu-9bf2a428f9e9359763be1bfd90c32371044c711e.tar.lz
yuzu-9bf2a428f9e9359763be1bfd90c32371044c711e.tar.xz
yuzu-9bf2a428f9e9359763be1bfd90c32371044c711e.tar.zst
yuzu-9bf2a428f9e9359763be1bfd90c32371044c711e.zip
Diffstat (limited to '')
-rw-r--r--src/core/core.cpp32
-rw-r--r--src/core/core.h10
-rw-r--r--src/core/core_cpu.cpp11
-rw-r--r--src/core/settings.h1
-rw-r--r--src/core/telemetry_session.cpp2
5 files changed, 39 insertions, 17 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() {
return perf_stats.GetAndResetStats(CoreTiming::GetGlobalTimeUs());
}
+const std::shared_ptr<Kernel::Scheduler>& System::Scheduler(size_t core_index) {
+ if (!Settings::values.use_multi_core) {
+ // Always use Core 0 scheduler when multicore is disabled
+ return cpu_cores[0]->Scheduler();
+ }
+
+ ASSERT(core_index < NUM_CPU_CORES);
+ return cpu_cores[core_index]->Scheduler();
+}
+
+ARM_Interface& System::ArmInterface(size_t core_index) {
+ ASSERT(core_index < NUM_CPU_CORES);
+ return cpu_cores[core_index]->ArmInterface();
+}
+
System::ResultStatus System::Init(EmuWindow* emu_window, u32 system_mode) {
NGLOG_DEBUG(HW_Memory, "initialized OK");
@@ -154,9 +169,12 @@ System::ResultStatus System::Init(EmuWindow* emu_window, u32 system_mode) {
// Create threads for CPU cores 1-3, and build thread_to_cpu map
// CPU core 0 is run on the main thread
thread_to_cpu[std::this_thread::get_id()] = cpu_cores[0];
- for (size_t index = 0; index < cpu_core_threads.size(); ++index) {
- cpu_core_threads[index] = std::make_unique<std::thread>(RunCpuCore, cpu_cores[index + 1]);
- thread_to_cpu[cpu_core_threads[index]->get_id()] = cpu_cores[index + 1];
+ if (Settings::values.use_multi_core) {
+ for (size_t index = 0; index < cpu_core_threads.size(); ++index) {
+ cpu_core_threads[index] =
+ std::make_unique<std::thread>(RunCpuCore, cpu_cores[index + 1]);
+ thread_to_cpu[cpu_core_threads[index]->get_id()] = cpu_cores[index + 1];
+ }
}
NGLOG_DEBUG(Core, "Initialized OK");
@@ -190,9 +208,11 @@ void System::Shutdown() {
// Close all CPU/threading state
cpu_barrier->NotifyEnd();
- for (auto& thread : cpu_core_threads) {
- thread->join();
- thread.reset();
+ if (Settings::values.use_multi_core) {
+ for (auto& thread : cpu_core_threads) {
+ thread->join();
+ thread.reset();
+ }
}
thread_to_cpu.clear();
for (auto& cpu_core : cpu_cores) {
diff --git a/src/core/core.h b/src/core/core.h
index 561e7b48f..115061932 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -112,10 +112,7 @@ public:
return CurrentCpuCore().ArmInterface();
}
- ARM_Interface& ArmInterface(size_t core_index) {
- ASSERT(core_index < NUM_CPU_CORES);
- return cpu_cores[core_index]->ArmInterface();
- }
+ ARM_Interface& ArmInterface(size_t core_index);
Tegra::GPU& GPU() {
return *gpu_core;
@@ -125,10 +122,7 @@ public:
return *CurrentCpuCore().Scheduler();
}
- const std::shared_ptr<Kernel::Scheduler>& Scheduler(size_t core_index) {
- ASSERT(core_index < NUM_CPU_CORES);
- return cpu_cores[core_index]->Scheduler();
- }
+ const std::shared_ptr<Kernel::Scheduler>& Scheduler(size_t core_index);
Kernel::SharedPtr<Kernel::Process>& CurrentProcess() {
return current_process;
diff --git a/src/core/core_cpu.cpp b/src/core/core_cpu.cpp
index bd9869d28..099f2bb1a 100644
--- a/src/core/core_cpu.cpp
+++ b/src/core/core_cpu.cpp
@@ -26,9 +26,12 @@ void CpuBarrier::NotifyEnd() {
}
bool CpuBarrier::Rendezvous() {
- if (end) {
- return false;
- } else {
+ if (!Settings::values.use_multi_core) {
+ // Meaningless when running in single-core mode
+ return true;
+ }
+
+ if (!end) {
std::unique_lock<std::mutex> lock(mutex);
--cores_waiting;
@@ -41,6 +44,8 @@ bool CpuBarrier::Rendezvous() {
condition.wait(lock);
return true;
}
+
+ return false;
}
Cpu::Cpu(std::shared_ptr<CpuBarrier> cpu_barrier, size_t core_index)
diff --git a/src/core/settings.h b/src/core/settings.h
index cfec63c21..a7f1e5fa0 100644
--- a/src/core/settings.h
+++ b/src/core/settings.h
@@ -121,6 +121,7 @@ struct Values {
// Core
bool use_cpu_jit;
+ bool use_multi_core;
// Data Storage
bool use_virtual_sd;
diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp
index 02c52bb55..a60aa1143 100644
--- a/src/core/telemetry_session.cpp
+++ b/src/core/telemetry_session.cpp
@@ -155,6 +155,8 @@ TelemetrySession::TelemetrySession() {
// Log user configuration information
AddField(Telemetry::FieldType::UserConfig, "Core_UseCpuJit", Settings::values.use_cpu_jit);
+ AddField(Telemetry::FieldType::UserConfig, "Core_UseMultiCore",
+ Settings::values.use_multi_core);
AddField(Telemetry::FieldType::UserConfig, "Renderer_ResolutionFactor",
Settings::values.resolution_factor);
AddField(Telemetry::FieldType::UserConfig, "Renderer_ToggleFramelimit",