Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
c974d3d5
Commit
c974d3d5
authored
Feb 15, 2016
by
Matthieu Schaller
Browse files
More engine policies and more robust way to test for policies
parent
638b1f6a
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/engine.c
View file @
c974d3d5
...
...
@@ -55,9 +55,10 @@
#include
"part.h"
#include
"timers.h"
const
char
*
engine_policy_names
[
10
]
=
{
"none"
,
"rand"
,
"steal"
,
"keep"
,
"block"
,
"fix_dt"
,
"cpu_tight"
,
"mpi"
,
"numa_affinity"
};
const
char
*
engine_policy_names
[
12
]
=
{
"none"
,
"rand"
,
"steal"
,
"keep"
,
"block"
,
"fix_dt"
,
"cpu_tight"
,
"mpi"
,
"numa_affinity"
,
"hydro"
,
"self_gravity"
,
"external_gravity"
};
/** The rank of the engine as a global variable (for messages). */
int
engine_rank
;
...
...
@@ -1326,7 +1327,7 @@ int engine_marktasks(struct engine *e) {
// ticks tic = getticks();
/* Much less to do here if we're on a fixed time-step. */
if
(
e
->
policy
&
engine_policy_fixdt
)
{
if
(
(
e
->
policy
&
engine_policy_fixdt
)
==
engine_policy_fixdt
)
{
/* Run through the tasks and mark as skip or not. */
for
(
k
=
0
;
k
<
nr_tasks
;
k
++
)
{
...
...
@@ -2060,7 +2061,7 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
int
nr_cores
=
sysconf
(
_SC_NPROCESSORS_ONLN
);
int
j
,
cpuid
[
nr_cores
];
cpu_set_t
cpuset
;
if
(
policy
&
engine_policy_cputight
)
{
if
(
(
policy
&
engine_policy_cputight
)
==
engine_policy_cputight
)
{
for
(
k
=
0
;
k
<
nr_cores
;
k
++
)
cpuid
[
k
]
=
k
;
}
else
{
/* Get next highest power of 2. */
...
...
@@ -2166,7 +2167,7 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
engine_print_policy
(
e
);
/* Deal with timestep */
if
(
e
->
policy
&
engine_policy_fixdt
)
{
if
(
(
e
->
policy
&
engine_policy_fixdt
)
==
engine_policy_fixdt
)
{
e
->
dt_min
=
e
->
dt_max
;
}
...
...
@@ -2211,7 +2212,7 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
if
(
pthread_create
(
&
e
->
runners
[
k
].
thread
,
NULL
,
&
runner_main
,
&
e
->
runners
[
k
])
!=
0
)
error
(
"Failed to create runner thread."
);
if
(
e
->
policy
&
engine_policy_setaffinity
)
{
if
(
(
e
->
policy
&
engine_policy_setaffinity
)
==
engine_policy_setaffinity
)
{
#if defined(HAVE_SETAFFINITY)
/* Set a reasonable queue ID. */
...
...
src/engine.h
View file @
c974d3d5
...
...
@@ -41,14 +41,17 @@
/* Some constants. */
enum
engine_policy
{
engine_policy_none
=
0
,
engine_policy_rand
=
1
,
engine_policy_steal
=
2
,
engine_policy_keep
=
4
,
engine_policy_block
=
8
,
engine_policy_fixdt
=
16
,
engine_policy_cputight
=
32
,
engine_policy_mpi
=
64
,
engine_policy_setaffinity
=
128
engine_policy_rand
=
(
1
<<
0
),
engine_policy_steal
=
(
1
<<
1
),
engine_policy_keep
=
(
1
<<
2
),
engine_policy_block
=
(
1
<<
3
),
engine_policy_fixdt
=
(
1
<<
4
),
engine_policy_cputight
=
(
1
<<
5
),
engine_policy_mpi
=
(
1
<<
6
),
engine_policy_setaffinity
=
(
1
<<
7
),
engine_policy_hydro
=
(
1
<<
8
),
engine_policy_self_gravity
=
(
1
<<
9
),
engine_policy_external_gravity
=
(
1
<<
10
)
};
extern
const
char
*
engine_policy_names
[];
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment