Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
6fbda22d
Commit
6fbda22d
authored
Jul 18, 2018
by
eqy
Committed by
Tianqi Chen
Jul 18, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use SetAffinity when logical cores > physical cores (hyperthreading) (#1453)
parent
8dbe7794
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
5 deletions
+8
-5
src/runtime/thread_pool.cc
+0
-3
src/runtime/threading_backend.cc
+8
-2
No files found.
src/runtime/thread_pool.cc
View file @
6fbda22d
...
@@ -253,9 +253,6 @@ class ThreadPool {
...
@@ -253,9 +253,6 @@ class ThreadPool {
num_workers_
,
[
this
](
int
worker_id
)
{
this
->
RunWorker
(
worker_id
);
},
num_workers_
,
[
this
](
int
worker_id
)
{
this
->
RunWorker
(
worker_id
);
},
exclude_worker0_
/* include_main_thread */
));
exclude_worker0_
/* include_main_thread */
));
num_workers_used_
=
threads_
->
Configure
(
threading
::
ThreadGroup
::
kBig
,
0
,
exclude_worker0_
);
num_workers_used_
=
threads_
->
Configure
(
threading
::
ThreadGroup
::
kBig
,
0
,
exclude_worker0_
);
// if MaxConcurrency restricted the number of workers (e.g., due to
// hyperthreading), respect the restriction
num_workers_used_
=
std
::
min
(
num_workers_
,
num_workers_used_
);
}
}
~
ThreadPool
()
{
~
ThreadPool
()
{
for
(
std
::
unique_ptr
<
SpscTaskQueue
>&
q
:
queues_
)
{
for
(
std
::
unique_ptr
<
SpscTaskQueue
>&
q
:
queues_
)
{
...
...
src/runtime/threading_backend.cc
View file @
6fbda22d
...
@@ -54,10 +54,16 @@ class ThreadGroup::Impl {
...
@@ -54,10 +54,16 @@ class ThreadGroup::Impl {
if
(
nthreads
)
{
if
(
nthreads
)
{
num_workers_used
=
nthreads
;
num_workers_used
=
nthreads
;
}
}
// if MaxConcurrency restricted the number of workers (e.g., due to
// hyperthreading), respect the restriction. On CPUs with N logical cores
// and N/2 physical cores this will set affinity to the first N/2 logical
// ones.
num_workers_used
=
std
::
min
(
num_workers_
,
num_workers_used
);
const
char
*
val
=
getenv
(
"TVM_BIND_THREADS"
);
const
char
*
val
=
getenv
(
"TVM_BIND_THREADS"
);
if
(
val
==
nullptr
||
atoi
(
val
)
==
1
)
{
if
(
val
==
nullptr
||
atoi
(
val
)
==
1
)
{
//
Skip if sorted_order.size() is bigger than the number of workers (threads_)
//
Do not set affinity if there are more workers than found cores
if
(
!
(
sorted_order_
.
size
()
>
static_cast
<
unsigned
int
>
(
num_workers_
)
))
{
if
(
sorted_order_
.
size
()
>=
static_cast
<
unsigned
int
>
(
num_workers_
))
{
SetAffinity
(
exclude_worker0
,
mode
==
kLittle
);
SetAffinity
(
exclude_worker0
,
mode
==
kLittle
);
}
else
{
}
else
{
LOG
(
WARNING
)
LOG
(
WARNING
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment