diff options
| author | 2018-08-12 22:31:55 -0400 | |
|---|---|---|
| committer | 2018-08-12 22:31:55 -0400 | |
| commit | fecffeb0ddedeef0f6223e8a2c53cca3baac70ad (patch) | |
| tree | ebd7cbbb35fd07e34f6397cde76027533d7200f4 /src | |
| parent | Merge pull request #1036 from lioncash/thread (diff) | |
| parent | CPU/Timing: Use an approximated amortized amount of ticks when advancing timing. (diff) | |
| download | yuzu-fecffeb0ddedeef0f6223e8a2c53cca3baac70ad.tar.gz yuzu-fecffeb0ddedeef0f6223e8a2c53cca3baac70ad.tar.xz yuzu-fecffeb0ddedeef0f6223e8a2c53cca3baac70ad.zip | |
Merge pull request #1043 from Subv/timing
Use an approximated amortized amount of ticks when advancing timing.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic.cpp | 11 | ||||
| -rw-r--r-- | src/core/core_cpu.cpp | 1 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 1 |
3 files changed, 11 insertions, 2 deletions
diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp index ceb3f7683..0996f129c 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic.cpp | |||
| @@ -86,7 +86,16 @@ public: | |||
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | void AddTicks(u64 ticks) override { | 88 | void AddTicks(u64 ticks) override { |
| 89 | CoreTiming::AddTicks(ticks - num_interpreted_instructions); | 89 | // Divide the number of ticks by the amount of CPU cores. TODO(Subv): This yields only a |
| 90 | // rough approximation of the amount of executed ticks in the system, it may be thrown off | ||
| 91 | // if not all cores are doing a similar amount of work. Instead of doing this, we should | ||
| 92 | // device a way so that timing is consistent across all cores without increasing the ticks 4 | ||
| 93 | // times. | ||
| 94 | u64 amortized_ticks = (ticks - num_interpreted_instructions) / Core::NUM_CPU_CORES; | ||
| 95 | // Always execute at least one tick. | ||
| 96 | amortized_ticks = std::max<u64>(amortized_ticks, 1); | ||
| 97 | |||
| 98 | CoreTiming::AddTicks(amortized_ticks); | ||
| 90 | num_interpreted_instructions = 0; | 99 | num_interpreted_instructions = 0; |
| 91 | } | 100 | } |
| 92 | u64 GetTicksRemaining() override { | 101 | u64 GetTicksRemaining() override { |
diff --git a/src/core/core_cpu.cpp b/src/core/core_cpu.cpp index 9b306faf6..b042ee02b 100644 --- a/src/core/core_cpu.cpp +++ b/src/core/core_cpu.cpp | |||
| @@ -91,6 +91,7 @@ void Cpu::RunLoop(bool tight_loop) { | |||
| 91 | LOG_TRACE(Core, "Core-{} idling", core_index); | 91 | LOG_TRACE(Core, "Core-{} idling", core_index); |
| 92 | 92 | ||
| 93 | if (IsMainCore()) { | 93 | if (IsMainCore()) { |
| 94 | // TODO(Subv): Only let CoreTiming idle if all 4 cores are idling. | ||
| 94 | CoreTiming::Idle(); | 95 | CoreTiming::Idle(); |
| 95 | CoreTiming::Advance(); | 96 | CoreTiming::Advance(); |
| 96 | } | 97 | } |
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 5818cc06d..b24f409b3 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -532,7 +532,6 @@ static ResultCode CreateThread(Handle* out_handle, VAddr entry_point, u64 arg, V | |||
| 532 | CASCADE_RESULT(thread->guest_handle, g_handle_table.Create(thread)); | 532 | CASCADE_RESULT(thread->guest_handle, g_handle_table.Create(thread)); |
| 533 | *out_handle = thread->guest_handle; | 533 | *out_handle = thread->guest_handle; |
| 534 | 534 | ||
| 535 | Core::System::GetInstance().PrepareReschedule(); | ||
| 536 | Core::System::GetInstance().CpuCore(thread->processor_id).PrepareReschedule(); | 535 | Core::System::GetInstance().CpuCore(thread->processor_id).PrepareReschedule(); |
| 537 | 536 | ||
| 538 | LOG_TRACE(Kernel_SVC, | 537 | LOG_TRACE(Kernel_SVC, |