Core timing 2.0 (#4913)
* Core::Timing: Add multiple timer, one for each core * revert clang-format; work on tests for CoreTiming * Kernel:: Add support for multiple cores, asserts in HandleSyncRequest because Thread->status == WaitIPC * Add some TRACE_LOGs * fix tests * make some adjustments to qt-debugger, cheats and gdbstub(probably still broken) * Make ARM_Interface::id private, rework ARM_Interface ctor * ReRename TimingManager to Timing for smaler diff * addressed review comments
This commit is contained in:
parent
e3dbdcbdff
commit
55ec7031cc
32 changed files with 760 additions and 535 deletions
|
@ -15,9 +15,9 @@ static Memory::PageTable* page_table = nullptr;
|
|||
TestEnvironment::TestEnvironment(bool mutable_memory_)
|
||||
: mutable_memory(mutable_memory_), test_memory(std::make_shared<TestMemory>(this)) {
|
||||
|
||||
timing = std::make_unique<Core::Timing>();
|
||||
timing = std::make_unique<Core::Timing>(1);
|
||||
memory = std::make_unique<Memory::MemorySystem>();
|
||||
kernel = std::make_unique<Kernel::KernelSystem>(*memory, *timing, [] {}, 0);
|
||||
kernel = std::make_unique<Kernel::KernelSystem>(*memory, *timing, [] {}, 0, 1);
|
||||
|
||||
kernel->SetCurrentProcess(kernel->CreateProcess(kernel->CreateCodeSet("", 0)));
|
||||
page_table = &kernel->GetCurrentProcess()->vm_manager.page_table;
|
||||
|
|
|
@ -23,7 +23,7 @@ TEST_CASE("ARM_DynCom (vfp): vadd", "[arm_dyncom]") {
|
|||
test_env.SetMemory32(0, 0xEE321A03); // vadd.f32 s2, s4, s6
|
||||
test_env.SetMemory32(4, 0xEAFFFFFE); // b +#0
|
||||
|
||||
ARM_DynCom dyncom(nullptr, test_env.GetMemory(), USER32MODE);
|
||||
ARM_DynCom dyncom(nullptr, test_env.GetMemory(), USER32MODE, 0, nullptr);
|
||||
|
||||
std::vector<VfpTestCase> test_cases{{
|
||||
#include "vfp_vadd_f32.inc"
|
||||
|
|
|
@ -34,16 +34,16 @@ static void AdvanceAndCheck(Core::Timing& timing, u32 idx, int downcount, int ex
|
|||
expected_callback = CB_IDS[idx];
|
||||
lateness = expected_lateness;
|
||||
|
||||
timing.AddTicks(timing.GetDowncount() -
|
||||
cpu_downcount); // Pretend we executed X cycles of instructions.
|
||||
timing.Advance();
|
||||
timing.GetTimer(0)->AddTicks(timing.GetTimer(0)->GetDowncount() -
|
||||
cpu_downcount); // Pretend we executed X cycles of instructions.
|
||||
timing.GetTimer(0)->Advance();
|
||||
|
||||
REQUIRE(decltype(callbacks_ran_flags)().set(idx) == callbacks_ran_flags);
|
||||
REQUIRE(downcount == timing.GetDowncount());
|
||||
REQUIRE(downcount == timing.GetTimer(0)->GetDowncount());
|
||||
}
|
||||
|
||||
TEST_CASE("CoreTiming[BasicOrder]", "[core]") {
|
||||
Core::Timing timing;
|
||||
Core::Timing timing(1);
|
||||
|
||||
Core::TimingEventType* cb_a = timing.RegisterEvent("callbackA", CallbackTemplate<0>);
|
||||
Core::TimingEventType* cb_b = timing.RegisterEvent("callbackB", CallbackTemplate<1>);
|
||||
|
@ -52,60 +52,19 @@ TEST_CASE("CoreTiming[BasicOrder]", "[core]") {
|
|||
Core::TimingEventType* cb_e = timing.RegisterEvent("callbackE", CallbackTemplate<4>);
|
||||
|
||||
// Enter slice 0
|
||||
timing.Advance();
|
||||
timing.GetTimer(0)->Advance();
|
||||
|
||||
// D -> B -> C -> A -> E
|
||||
timing.ScheduleEvent(1000, cb_a, CB_IDS[0]);
|
||||
REQUIRE(1000 == timing.GetDowncount());
|
||||
timing.ScheduleEvent(500, cb_b, CB_IDS[1]);
|
||||
REQUIRE(500 == timing.GetDowncount());
|
||||
timing.ScheduleEvent(800, cb_c, CB_IDS[2]);
|
||||
REQUIRE(500 == timing.GetDowncount());
|
||||
timing.ScheduleEvent(100, cb_d, CB_IDS[3]);
|
||||
REQUIRE(100 == timing.GetDowncount());
|
||||
timing.ScheduleEvent(1200, cb_e, CB_IDS[4]);
|
||||
REQUIRE(100 == timing.GetDowncount());
|
||||
|
||||
AdvanceAndCheck(timing, 3, 400);
|
||||
AdvanceAndCheck(timing, 1, 300);
|
||||
AdvanceAndCheck(timing, 2, 200);
|
||||
AdvanceAndCheck(timing, 0, 200);
|
||||
AdvanceAndCheck(timing, 4, MAX_SLICE_LENGTH);
|
||||
}
|
||||
|
||||
TEST_CASE("CoreTiming[Threadsave]", "[core]") {
|
||||
Core::Timing timing;
|
||||
|
||||
Core::TimingEventType* cb_a = timing.RegisterEvent("callbackA", CallbackTemplate<0>);
|
||||
Core::TimingEventType* cb_b = timing.RegisterEvent("callbackB", CallbackTemplate<1>);
|
||||
Core::TimingEventType* cb_c = timing.RegisterEvent("callbackC", CallbackTemplate<2>);
|
||||
Core::TimingEventType* cb_d = timing.RegisterEvent("callbackD", CallbackTemplate<3>);
|
||||
Core::TimingEventType* cb_e = timing.RegisterEvent("callbackE", CallbackTemplate<4>);
|
||||
|
||||
// Enter slice 0
|
||||
timing.Advance();
|
||||
|
||||
// D -> B -> C -> A -> E
|
||||
timing.ScheduleEventThreadsafe(1000, cb_a, CB_IDS[0]);
|
||||
// Manually force since ScheduleEventThreadsafe doesn't call it
|
||||
timing.ForceExceptionCheck(1000);
|
||||
REQUIRE(1000 == timing.GetDowncount());
|
||||
timing.ScheduleEventThreadsafe(500, cb_b, CB_IDS[1]);
|
||||
// Manually force since ScheduleEventThreadsafe doesn't call it
|
||||
timing.ForceExceptionCheck(500);
|
||||
REQUIRE(500 == timing.GetDowncount());
|
||||
timing.ScheduleEventThreadsafe(800, cb_c, CB_IDS[2]);
|
||||
// Manually force since ScheduleEventThreadsafe doesn't call it
|
||||
timing.ForceExceptionCheck(800);
|
||||
REQUIRE(500 == timing.GetDowncount());
|
||||
timing.ScheduleEventThreadsafe(100, cb_d, CB_IDS[3]);
|
||||
// Manually force since ScheduleEventThreadsafe doesn't call it
|
||||
timing.ForceExceptionCheck(100);
|
||||
REQUIRE(100 == timing.GetDowncount());
|
||||
timing.ScheduleEventThreadsafe(1200, cb_e, CB_IDS[4]);
|
||||
// Manually force since ScheduleEventThreadsafe doesn't call it
|
||||
timing.ForceExceptionCheck(1200);
|
||||
REQUIRE(100 == timing.GetDowncount());
|
||||
timing.ScheduleEvent(1000, cb_a, CB_IDS[0], 0);
|
||||
REQUIRE(1000 == timing.GetTimer(0)->GetDowncount());
|
||||
timing.ScheduleEvent(500, cb_b, CB_IDS[1], 0);
|
||||
REQUIRE(500 == timing.GetTimer(0)->GetDowncount());
|
||||
timing.ScheduleEvent(800, cb_c, CB_IDS[2], 0);
|
||||
REQUIRE(500 == timing.GetTimer(0)->GetDowncount());
|
||||
timing.ScheduleEvent(100, cb_d, CB_IDS[3], 0);
|
||||
REQUIRE(100 == timing.GetTimer(0)->GetDowncount());
|
||||
timing.ScheduleEvent(1200, cb_e, CB_IDS[4], 0);
|
||||
REQUIRE(100 == timing.GetTimer(0)->GetDowncount());
|
||||
|
||||
AdvanceAndCheck(timing, 3, 400);
|
||||
AdvanceAndCheck(timing, 1, 300);
|
||||
|
@ -131,7 +90,7 @@ void FifoCallback(u64 userdata, s64 cycles_late) {
|
|||
TEST_CASE("CoreTiming[SharedSlot]", "[core]") {
|
||||
using namespace SharedSlotTest;
|
||||
|
||||
Core::Timing timing;
|
||||
Core::Timing timing(1);
|
||||
|
||||
Core::TimingEventType* cb_a = timing.RegisterEvent("callbackA", FifoCallback<0>);
|
||||
Core::TimingEventType* cb_b = timing.RegisterEvent("callbackB", FifoCallback<1>);
|
||||
|
@ -139,36 +98,36 @@ TEST_CASE("CoreTiming[SharedSlot]", "[core]") {
|
|||
Core::TimingEventType* cb_d = timing.RegisterEvent("callbackD", FifoCallback<3>);
|
||||
Core::TimingEventType* cb_e = timing.RegisterEvent("callbackE", FifoCallback<4>);
|
||||
|
||||
timing.ScheduleEvent(1000, cb_a, CB_IDS[0]);
|
||||
timing.ScheduleEvent(1000, cb_b, CB_IDS[1]);
|
||||
timing.ScheduleEvent(1000, cb_c, CB_IDS[2]);
|
||||
timing.ScheduleEvent(1000, cb_d, CB_IDS[3]);
|
||||
timing.ScheduleEvent(1000, cb_e, CB_IDS[4]);
|
||||
timing.ScheduleEvent(1000, cb_a, CB_IDS[0], 0);
|
||||
timing.ScheduleEvent(1000, cb_b, CB_IDS[1], 0);
|
||||
timing.ScheduleEvent(1000, cb_c, CB_IDS[2], 0);
|
||||
timing.ScheduleEvent(1000, cb_d, CB_IDS[3], 0);
|
||||
timing.ScheduleEvent(1000, cb_e, CB_IDS[4], 0);
|
||||
|
||||
// Enter slice 0
|
||||
timing.Advance();
|
||||
REQUIRE(1000 == timing.GetDowncount());
|
||||
timing.GetTimer(0)->Advance();
|
||||
REQUIRE(1000 == timing.GetTimer(0)->GetDowncount());
|
||||
|
||||
callbacks_ran_flags = 0;
|
||||
counter = 0;
|
||||
lateness = 0;
|
||||
timing.AddTicks(timing.GetDowncount());
|
||||
timing.Advance();
|
||||
REQUIRE(MAX_SLICE_LENGTH == timing.GetDowncount());
|
||||
timing.GetTimer(0)->AddTicks(timing.GetTimer(0)->GetDowncount());
|
||||
timing.GetTimer(0)->Advance();
|
||||
REQUIRE(MAX_SLICE_LENGTH == timing.GetTimer(0)->GetDowncount());
|
||||
REQUIRE(0x1FULL == callbacks_ran_flags.to_ullong());
|
||||
}
|
||||
|
||||
TEST_CASE("CoreTiming[PredictableLateness]", "[core]") {
|
||||
Core::Timing timing;
|
||||
Core::Timing timing(1);
|
||||
|
||||
Core::TimingEventType* cb_a = timing.RegisterEvent("callbackA", CallbackTemplate<0>);
|
||||
Core::TimingEventType* cb_b = timing.RegisterEvent("callbackB", CallbackTemplate<1>);
|
||||
|
||||
// Enter slice 0
|
||||
timing.Advance();
|
||||
timing.GetTimer(0)->Advance();
|
||||
|
||||
timing.ScheduleEvent(100, cb_a, CB_IDS[0]);
|
||||
timing.ScheduleEvent(200, cb_b, CB_IDS[1]);
|
||||
timing.ScheduleEvent(100, cb_a, CB_IDS[0], 0);
|
||||
timing.ScheduleEvent(200, cb_b, CB_IDS[1], 0);
|
||||
|
||||
AdvanceAndCheck(timing, 0, 90, 10, -10); // (100 - 10)
|
||||
AdvanceAndCheck(timing, 1, MAX_SLICE_LENGTH, 50, -50);
|
||||
|
@ -190,7 +149,7 @@ static void RescheduleCallback(Core::Timing& timing, u64 userdata, s64 cycles_la
|
|||
TEST_CASE("CoreTiming[ChainScheduling]", "[core]") {
|
||||
using namespace ChainSchedulingTest;
|
||||
|
||||
Core::Timing timing;
|
||||
Core::Timing timing(1);
|
||||
|
||||
Core::TimingEventType* cb_a = timing.RegisterEvent("callbackA", CallbackTemplate<0>);
|
||||
Core::TimingEventType* cb_b = timing.RegisterEvent("callbackB", CallbackTemplate<1>);
|
||||
|
@ -201,28 +160,30 @@ TEST_CASE("CoreTiming[ChainScheduling]", "[core]") {
|
|||
});
|
||||
|
||||
// Enter slice 0
|
||||
timing.Advance();
|
||||
timing.GetTimer(0)->Advance();
|
||||
|
||||
timing.ScheduleEvent(800, cb_a, CB_IDS[0]);
|
||||
timing.ScheduleEvent(1000, cb_b, CB_IDS[1]);
|
||||
timing.ScheduleEvent(2200, cb_c, CB_IDS[2]);
|
||||
timing.ScheduleEvent(1000, cb_rs, reinterpret_cast<u64>(cb_rs));
|
||||
REQUIRE(800 == timing.GetDowncount());
|
||||
timing.ScheduleEvent(800, cb_a, CB_IDS[0], 0);
|
||||
timing.ScheduleEvent(1000, cb_b, CB_IDS[1], 0);
|
||||
timing.ScheduleEvent(2200, cb_c, CB_IDS[2], 0);
|
||||
timing.ScheduleEvent(1000, cb_rs, reinterpret_cast<u64>(cb_rs), 0);
|
||||
REQUIRE(800 == timing.GetTimer(0)->GetDowncount());
|
||||
|
||||
reschedules = 3;
|
||||
AdvanceAndCheck(timing, 0, 200); // cb_a
|
||||
AdvanceAndCheck(timing, 1, 1000); // cb_b, cb_rs
|
||||
REQUIRE(2 == reschedules);
|
||||
|
||||
timing.AddTicks(timing.GetDowncount());
|
||||
timing.Advance(); // cb_rs
|
||||
timing.GetTimer(0)->AddTicks(timing.GetTimer(0)->GetDowncount());
|
||||
timing.GetTimer(0)->Advance(); // cb_rs
|
||||
REQUIRE(1 == reschedules);
|
||||
REQUIRE(200 == timing.GetDowncount());
|
||||
REQUIRE(200 == timing.GetTimer(0)->GetDowncount());
|
||||
|
||||
AdvanceAndCheck(timing, 2, 800); // cb_c
|
||||
|
||||
timing.AddTicks(timing.GetDowncount());
|
||||
timing.Advance(); // cb_rs
|
||||
timing.GetTimer(0)->AddTicks(timing.GetTimer(0)->GetDowncount());
|
||||
timing.GetTimer(0)->Advance(); // cb_rs
|
||||
REQUIRE(0 == reschedules);
|
||||
REQUIRE(MAX_SLICE_LENGTH == timing.GetDowncount());
|
||||
REQUIRE(MAX_SLICE_LENGTH == timing.GetTimer(0)->GetDowncount());
|
||||
}
|
||||
|
||||
// TODO: Add tests for multiple timers
|
||||
|
|
|
@ -21,9 +21,9 @@ static std::shared_ptr<Object> MakeObject(Kernel::KernelSystem& kernel) {
|
|||
}
|
||||
|
||||
TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel]") {
|
||||
Core::Timing timing;
|
||||
Core::Timing timing(1);
|
||||
Memory::MemorySystem memory;
|
||||
Kernel::KernelSystem kernel(memory, timing, [] {}, 0);
|
||||
Kernel::KernelSystem kernel(memory, timing, [] {}, 0, 1);
|
||||
auto [server, client] = kernel.CreateSessionPair();
|
||||
HLERequestContext context(kernel, std::move(server), nullptr);
|
||||
|
||||
|
@ -233,9 +233,9 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
|
|||
}
|
||||
|
||||
TEST_CASE("HLERequestContext::WriteToOutgoingCommandBuffer", "[core][kernel]") {
|
||||
Core::Timing timing;
|
||||
Core::Timing timing(1);
|
||||
Memory::MemorySystem memory;
|
||||
Kernel::KernelSystem kernel(memory, timing, [] {}, 0);
|
||||
Kernel::KernelSystem kernel(memory, timing, [] {}, 0, 1);
|
||||
auto [server, client] = kernel.CreateSessionPair();
|
||||
HLERequestContext context(kernel, std::move(server), nullptr);
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
#include "core/memory.h"
|
||||
|
||||
TEST_CASE("Memory::IsValidVirtualAddress", "[core][memory]") {
|
||||
Core::Timing timing;
|
||||
Core::Timing timing(1);
|
||||
Memory::MemorySystem memory;
|
||||
Kernel::KernelSystem kernel(memory, timing, [] {}, 0);
|
||||
Kernel::KernelSystem kernel(memory, timing, [] {}, 0, 1);
|
||||
SECTION("these regions should not be mapped on an empty process") {
|
||||
auto process = kernel.CreateProcess(kernel.CreateCodeSet("", 0));
|
||||
CHECK(Memory::IsValidVirtualAddress(*process, Memory::PROCESS_IMAGE_VADDR) == false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue