Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
02379f18
Commit
02379f18
authored
12 years ago
by
Pedro Gonnet
Browse files
Options
Downloads
Patches
Plain Diff
assign queues according to proximity of the cpuid when affinity is set.
Former-commit-id: 79f6a5f294829fbf0a5f119d89d5ebefa4b8e5f7
parent
e031bc48
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/engine.c
+8
-1
8 additions, 1 deletion
src/engine.c
src/runner.c
+2
-2
2 additions, 2 deletions
src/runner.c
src/runner.h
+3
-0
3 additions, 0 deletions
src/runner.h
with
13 additions
and
3 deletions
src/engine.c
+
8
−
1
View file @
02379f18
...
@@ -798,13 +798,20 @@ void engine_init ( struct engine *e , struct space *s , float dt , int nr_thread
...
@@ -798,13 +798,20 @@ void engine_init ( struct engine *e , struct space *s , float dt , int nr_thread
if
(
pthread_create
(
&
e
->
runners
[
k
].
thread
,
NULL
,
&
runner_main
,
&
e
->
runners
[
k
]
)
!=
0
)
if
(
pthread_create
(
&
e
->
runners
[
k
].
thread
,
NULL
,
&
runner_main
,
&
e
->
runners
[
k
]
)
!=
0
)
error
(
"Failed to create runner thread."
);
error
(
"Failed to create runner thread."
);
#if defined(HAVE_SETAFFINITY)
#if defined(HAVE_SETAFFINITY)
/* Set a reasonable queue ID. */
e
->
runners
[
k
].
qid
=
cpuid
[
k
]
*
nr_queues
/
nr_threads
;
/* Set the cpu mask to zero | e->id. */
/* Set the cpu mask to zero | e->id. */
CPU_ZERO
(
&
cpuset
);
CPU_ZERO
(
&
cpuset
);
CPU_SET
(
cpuid
[
e
->
runners
[
k
].
id
]
,
&
cpuset
);
CPU_SET
(
cpuid
[
k
]
,
&
cpuset
);
/* Apply this mask to the runner's pthread. */
/* Apply this mask to the runner's pthread. */
if
(
pthread_setaffinity_np
(
e
->
runners
[
k
].
thread
,
sizeof
(
cpu_set_t
)
,
&
cpuset
)
!=
0
)
if
(
pthread_setaffinity_np
(
e
->
runners
[
k
].
thread
,
sizeof
(
cpu_set_t
)
,
&
cpuset
)
!=
0
)
error
(
"Failed to set thread affinity."
);
error
(
"Failed to set thread affinity."
);
#else
e
->
runners
[
k
].
qid
=
k
%
nr_queues
;
#endif
#endif
}
}
...
...
This diff is collapsed.
Click to expand it.
src/runner.c
+
2
−
2
View file @
02379f18
...
@@ -768,7 +768,7 @@ void *runner_main ( void *data ) {
...
@@ -768,7 +768,7 @@ void *runner_main ( void *data ) {
struct
runner
*
r
=
(
struct
runner
*
)
data
;
struct
runner
*
r
=
(
struct
runner
*
)
data
;
struct
engine
*
e
=
r
->
e
;
struct
engine
*
e
=
r
->
e
;
struct
scheduler
*
sched
=
&
e
->
sched
;
struct
scheduler
*
sched
=
&
e
->
sched
;
int
threadID
=
r
->
id
;
int
qid
=
r
->
q
id
;
struct
task
*
t
;
struct
task
*
t
;
struct
cell
*
ci
,
*
cj
;
struct
cell
*
ci
,
*
cj
;
...
@@ -783,7 +783,7 @@ void *runner_main ( void *data ) {
...
@@ -783,7 +783,7 @@ void *runner_main ( void *data ) {
/* Get a task, how and from where depends on the policy. */
/* Get a task, how and from where depends on the policy. */
TIMER_TIC
TIMER_TIC
t
=
scheduler_gettask
(
sched
,
threadID
);
t
=
scheduler_gettask
(
sched
,
qid
);
TIMER_TOC
(
timer_getpair
);
TIMER_TOC
(
timer_getpair
);
/* Did I get anything? */
/* Did I get anything? */
...
...
This diff is collapsed.
Click to expand it.
src/runner.h
+
3
−
0
View file @
02379f18
...
@@ -62,6 +62,9 @@ struct runner {
...
@@ -62,6 +62,9 @@ struct runner {
/* The thread which it is running. */
/* The thread which it is running. */
pthread_t
thread
;
pthread_t
thread
;
/* The queue to use to get tasks. */
int
qid
;
/* The underlying runner. */
/* The underlying runner. */
struct
engine
*
e
;
struct
engine
*
e
;
...
...
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