New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Core timing 2.0 #4913
Core timing 2.0 #4913
Conversation
ci failure is unrelated |
@@ -115,7 +115,7 @@ void RO::Initialize(Kernel::HLERequestContext& ctx) { | |||
return; | |||
} | |||
|
|||
CROHelper crs(crs_address, *process, system.Memory(), system.CPU()); | |||
CROHelper crs(crs_address, *process, system.Memory(), system.GetRunningCore()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should invalidate the cache of all core instead of just the current one.
src/core/rpc/rpc_server.cpp
Outdated
Core::CPU().InvalidateCacheRange(address, data_size); | ||
|
||
// Is current core correct here? | ||
Core::GetRunningCore().InvalidateCacheRange(address, data_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto, this should invalidate cache of all cores
src/core/hle/kernel/thread.cpp
Outdated
@@ -33,13 +33,19 @@ void Thread::Acquire(Thread* thread) { | |||
ASSERT_MSG(!ShouldWait(thread), "object unavailable!"); | |||
} | |||
|
|||
u32 ThreadManager::next_thread_id = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please let this live in the kernel object instead of putting it as a global state.
src/core/core_timing.h
Outdated
}; | ||
|
||
using SharedTimer = std::shared_ptr<Timing::Timer>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH I feel this typedef is pretty useless and actually add to the difficulty when reading and understanding the code.
src/core/hle/kernel/kernel.cpp
Outdated
void KernelSystem::SetCPUs(std::vector<std::shared_ptr<ARM_Interface>> cpus) { | ||
ASSERT(cpus.size() == thread_managers.size()); | ||
u32 i = 0; | ||
for (auto cpu : cpus) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (auto cpu : cpus) { | |
for (auto& cpu : cpus) { |
src/core/hle/kernel/kernel.cpp
Outdated
current_process = process; | ||
SetCurrentMemoryPageTable(&process->vm_manager.page_table); | ||
} else { | ||
stored_processes[core_id]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eh.. what is this? I feel like this isn't doing anything
src/core/core.cpp
Outdated
@@ -177,31 +229,50 @@ void System::Reschedule() { | |||
} | |||
|
|||
reschedule_pending = false; | |||
kernel->GetThreadManager().Reschedule(); | |||
for (auto core : cpu_cores) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (auto core : cpu_cores) { | |
for (const auto& core : cpu_cores) { |
src/core/core_timing.h
Outdated
// executing the first cycle of each slice to prepare the slice length and downcount for | ||
// that slice. | ||
bool is_global_timer_sane = true; | ||
std::unordered_map<std::size_t, std::shared_ptr<Timer>> timers; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel this can just be a vector
src/core/core_timing.h
Outdated
u64 idled_cycles; | ||
}; | ||
|
||
Timing(std::size_t num_cores); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Timing(std::size_t num_cores); | |
explicit Timing(std::size_t num_cores); |
src/core/core_timing.h
Outdated
@@ -125,6 +125,8 @@ inline u64 cyclesToMs(s64 cycles) { | |||
|
|||
namespace Core { | |||
|
|||
class System; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this used?
src/core/core_timing.cpp
Outdated
@@ -7,19 +7,27 @@ | |||
#include <tuple> | |||
#include "common/assert.h" | |||
#include "common/logging/log.h" | |||
#include "core/core.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems unnecessary
thread->status = ThreadStatus::Dormant; | ||
thread->entry_point = entry_point; | ||
thread->stack_top = stack_top; | ||
thread->nominal_priority = thread->current_priority = priority; | ||
thread->last_running_ticks = timing.GetTicks(); | ||
thread->last_running_ticks = timing.GetGlobalTicks(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is global ticks used here? Should this be the ticks of the target processer, or the current core instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to go with GlobalTicks which is the ticks of the core thats advanced the most. The reason for this is because in any other case it would always create a thread in the past either for the current core or the target one. We could also take tha max of ticks from current core and target core but I think the overall max is fine too
Tested my first game with this "SMT Devil Survivor Overclocked" The game refused to process the fmv that comes after the intro logo's, thus you cant go any farther into the game. Edit: Log Output |
Fixes |
src/core/core.h
Outdated
@@ -248,6 +266,8 @@ class System { | |||
return registered_swkbd; | |||
} | |||
|
|||
bool initalized = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be private
After looking into the threads Edit: List of all threads created:
|
This comment has been minimized.
This comment has been minimized.
… because Thread->status == WaitIPC
f33464e
to
58b2abd
Compare
Rebased and addressed comments. I hope I didn't miss anything |
As long as it doesn't break anything. LGTM |
This is a rewrite of Core::CoreTiming. The goal was to be able to emulate multiple cores on a single host thread
What Changed?
What is not in this PR?
What I'm not sure of
What does it fix? Why do we need this?
Sorry that it became such a big PR...
This change is