Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Suyu
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Suyu
Commits
edc52250
There was an error fetching the commit references. Please try again later.
Commit
edc52250
authored
6 years ago
by
bunnei
Browse files
Options
Downloads
Patches
Plain Diff
core: Run all CPU cores separately, even in single-thread mode.
parent
fbd7afef
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/core/core.cpp
+20
-6
20 additions, 6 deletions
src/core/core.cpp
src/core/core.h
+3
-7
3 additions, 7 deletions
src/core/core.h
with
23 additions
and
13 deletions
src/core/core.cpp
+
20
−
6
View file @
edc52250
...
...
@@ -34,6 +34,19 @@ static void RunCpuCore(std::shared_ptr<Cpu> cpu_state) {
}
}
Cpu
&
System
::
CurrentCpuCore
()
{
// If multicore is enabled, use host thread to figure out the current CPU core
if
(
Settings
::
values
.
use_multi_core
)
{
const
auto
&
search
=
thread_to_cpu
.
find
(
std
::
this_thread
::
get_id
());
ASSERT
(
search
!=
thread_to_cpu
.
end
());
ASSERT
(
search
->
second
);
return
*
search
->
second
;
}
// Otherwise, use single-threaded mode active_core variable
return
*
cpu_cores
[
active_core
];
}
System
::
ResultStatus
System
::
RunLoop
(
bool
tight_loop
)
{
status
=
ResultStatus
::
Success
;
...
...
@@ -55,7 +68,13 @@ System::ResultStatus System::RunLoop(bool tight_loop) {
}
}
cpu_cores
[
0
]
->
RunLoop
(
tight_loop
);
for
(
active_core
=
0
;
active_core
<
NUM_CPU_CORES
;
++
active_core
)
{
cpu_cores
[
active_core
]
->
RunLoop
(
tight_loop
);
if
(
Settings
::
values
.
use_multi_core
)
{
// Cores 1-3 are run on other threads in this mode
break
;
}
}
return
status
;
}
...
...
@@ -127,11 +146,6 @@ PerfStats::Results System::GetAndResetPerfStats() {
}
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
();
}
...
...
This diff is collapsed.
Click to expand it.
src/core/core.h
+
3
−
7
View file @
edc52250
...
...
@@ -160,13 +160,8 @@ public:
}
private
:
/// Returns the current CPU core based on the calling host thread
Cpu
&
CurrentCpuCore
()
{
const
auto
&
search
=
thread_to_cpu
.
find
(
std
::
this_thread
::
get_id
());
ASSERT
(
search
!=
thread_to_cpu
.
end
());
ASSERT
(
search
->
second
);
return
*
search
->
second
;
}
/// Returns the currently running CPU core
Cpu
&
CurrentCpuCore
();
/**
* Initialize the emulated system.
...
...
@@ -184,6 +179,7 @@ private:
std
::
shared_ptr
<
CpuBarrier
>
cpu_barrier
;
std
::
array
<
std
::
shared_ptr
<
Cpu
>
,
NUM_CPU_CORES
>
cpu_cores
;
std
::
array
<
std
::
unique_ptr
<
std
::
thread
>
,
NUM_CPU_CORES
-
1
>
cpu_core_threads
;
size_t
active_core
{};
///< Active core, only used in single thread mode
/// Service manager
std
::
shared_ptr
<
Service
::
SM
::
ServiceManager
>
service_manager
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment