Skip to content
GitLab
Menu
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
8935e919
Commit
8935e919
authored
Apr 06, 2013
by
Pedro Gonnet
Browse files
only re-build queues if needed.
Former-commit-id: 609b7ad602364c31eefc085a208db6f1552409c4
parent
e83aa571
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/engine.c
View file @
8935e919
...
...
@@ -61,7 +61,7 @@
void
engine_prepare
(
struct
engine
*
e
)
{
int
j
,
k
,
qid
;
int
j
,
k
,
qid
,
rebuild
;
struct
space
*
s
=
e
->
s
;
struct
queue
*
q
;
...
...
@@ -69,24 +69,36 @@ void engine_prepare ( struct engine *e ) {
/* Rebuild the space. */
// tic = getticks();
space_prepare
(
e
->
s
);
rebuild
=
(
space_prepare
(
e
->
s
)
||
e
->
step
==
0
);
// printf( "engine_prepare: space_prepare took %.3f ms.\n" , (double)(getticks() - tic) / CPU_TPS * 1000 );
// tic = getticks();
/* Init the queues (round-robin). */
for
(
qid
=
0
;
qid
<
e
->
nr_queues
;
qid
++
)
queue_init
(
&
e
->
queues
[
qid
]
,
s
->
nr_tasks
,
s
->
tasks
);
/* Fill the queues (round-robin). */
for
(
qid
=
0
,
k
=
0
;
k
<
s
->
nr_tasks
;
k
++
)
{
if
(
s
->
tasks
[
s
->
tasks_ind
[
k
]
].
skip
)
continue
;
q
=
&
e
->
queues
[
qid
];
qid
=
(
qid
+
1
)
%
e
->
nr_queues
;
q
->
tid
[
q
->
count
]
=
s
->
tasks_ind
[
k
];
q
->
count
+=
1
;
/* The queues only need to be re-built if we have variable time-steps
or the space was rebuilt. */
if
(
!
(
e
->
policy
&
engine_policy_fixdt
)
||
rebuild
)
{
// tic = getticks();
/* Init the queues (round-robin). */
for
(
qid
=
0
;
qid
<
e
->
nr_queues
;
qid
++
)
queue_init
(
&
e
->
queues
[
qid
]
,
s
->
nr_tasks
,
s
->
tasks
);
/* Fill the queues (round-robin). */
for
(
qid
=
0
,
k
=
0
;
k
<
s
->
nr_tasks
;
k
++
)
{
if
(
s
->
tasks
[
s
->
tasks_ind
[
k
]
].
skip
)
continue
;
q
=
&
e
->
queues
[
qid
];
qid
=
(
qid
+
1
)
%
e
->
nr_queues
;
q
->
tid
[
q
->
count
]
=
s
->
tasks_ind
[
k
];
q
->
count
+=
1
;
}
// printf( "engine_prepare: re-filling queues took %.3f ms.\n" , (double)(getticks() - tic) / CPU_TPS * 1000 );
}
/* Otherwise, just re-set them. */
else
{
for
(
qid
=
0
;
qid
<
e
->
nr_queues
;
qid
++
)
e
->
queues
[
qid
].
next
=
0
;
}
// printf( "engine_prepare: re-filling queues took %.3f ms.\n" , (double)(getticks() - tic) / CPU_TPS * 1000 );
/* Run throught the tasks and get all the waits right. */
// tic = getticks();
...
...
@@ -492,12 +504,11 @@ void engine_step ( struct engine *e , int sort_queues ) {
// printf( "engine_step: total entropic function is %e .\n", ent ); fflush(stdout);
printf
(
"engine_step: updated %i parts (dt_step=%.3e).
\n
"
,
count
,
dt_step
);
fflush
(
stdout
);
/* Increase the step counter. */
e
->
step
+=
1
;
/* Does the time step need adjusting? */
if
(
e
->
policy
&
engine_policy_fixdt
)
if
(
e
->
policy
&
engine_policy_fixdt
)
{
e
->
dt
=
e
->
dt_orig
;
e
->
step
+=
1
;
}
else
{
if
(
e
->
dt
==
0
)
{
e
->
dt
=
e
->
dt_orig
;
...
...
@@ -518,6 +529,7 @@ void engine_step ( struct engine *e , int sort_queues ) {
e
->
step
/=
2
;
printf
(
"engine_step: dt_min is larger than twice the time step, adjusting to dt=%e.
\n
"
,
e
->
dt
);
}
e
->
step
+=
1
;
}
}
...
...
src/space.c
View file @
8935e919
...
...
@@ -161,7 +161,7 @@ int space_marktasks ( struct space *s ) {
* cell tree for those tasks and triggers a rebuild if necessary.
*/
void
space_prepare
(
struct
space
*
s
)
{
int
space_prepare
(
struct
space
*
s
)
{
int
k
,
rebuild
;
// struct task *t;
...
...
@@ -216,6 +216,9 @@ void space_prepare ( struct space *s ) {
printf( " skipped=%i ]\n" , counts[ task_type_count ] ); fflush(stdout);
printf( "space_prepare: task counting took %.3f ms.\n" , (double)(getticks() - tic) / CPU_TPS * 1000 ); */
/* Let whoever cares know if we rebuilt. */
return
rebuild
;
}
...
...
src/space.h
View file @
8935e919
...
...
@@ -114,7 +114,7 @@ void space_maketasks ( struct space *s , int do_sort );
void
space_map_cells_pre
(
struct
space
*
s
,
int
full
,
void
(
*
fun
)(
struct
cell
*
c
,
void
*
data
)
,
void
*
data
);
void
space_map_parts
(
struct
space
*
s
,
void
(
*
fun
)(
struct
part
*
p
,
struct
cell
*
c
,
void
*
data
)
,
void
*
data
);
void
space_map_cells_post
(
struct
space
*
s
,
int
full
,
void
(
*
fun
)(
struct
cell
*
c
,
void
*
data
)
,
void
*
data
);
void
space_prepare
(
struct
space
*
s
);
int
space_prepare
(
struct
space
*
s
);
void
space_ranktasks
(
struct
space
*
s
);
void
space_rebuild
(
struct
space
*
s
,
double
h_max
);
void
space_recycle
(
struct
space
*
s
,
struct
cell
*
c
);
...
...
Write
Preview
Supports
Markdown
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