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
52ed7796
Commit
52ed7796
authored
Mar 02, 2016
by
Peter W. Draper
Browse files
Revert "Use clock_gettime() to time steps"
This reverts commit
4654968d
. Teach me to do more than one thing at a time...
parent
4654968d
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/engine.c
View file @
52ed7796
...
...
@@ -28,7 +28,6 @@
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
#include
<time.h>
#include
<unistd.h>
#include
<stdbool.h>
...
...
@@ -1465,29 +1464,6 @@ void engine_init_particles(struct engine *e) {
e
->
step
=
-
1
;
}
/**
* brief Get difference in milli-seconds between two timespecs.
*
* @param start the start time.
* @param end the end time.
*
* @return the difference in milli-secinds.
*/
static
double
time_diff
(
struct
timespec
start
,
struct
timespec
end
)
{
struct
timespec
temp
;
if
((
end
.
tv_nsec
-
start
.
tv_nsec
)
<
0
)
{
temp
.
tv_sec
=
end
.
tv_sec
-
start
.
tv_sec
-
1
;
temp
.
tv_nsec
=
1000000000
+
end
.
tv_nsec
-
start
.
tv_nsec
;
}
else
{
temp
.
tv_sec
=
end
.
tv_sec
-
start
.
tv_sec
;
temp
.
tv_nsec
=
end
.
tv_nsec
-
start
.
tv_nsec
;
}
return
(
double
)
temp
.
tv_sec
*
1000
.
0
+
(
double
)
temp
.
tv_nsec
*
1.0E-6
;
}
/**
* @brief Let the #engine loose to compute the forces.
*
...
...
@@ -1506,9 +1482,6 @@ void engine_step(struct engine *e) {
TIMER_TIC2
;
struct
timespec
time1
,
time2
;
clock_gettime
(
CLOCK_REALTIME
,
&
time1
);
/* Collect the cell data. */
for
(
k
=
0
;
k
<
s
->
nr_cells
;
k
++
)
if
(
s
->
cells
[
k
].
nodeID
==
e
->
nodeID
)
{
...
...
@@ -1580,8 +1553,8 @@ void engine_step(struct engine *e) {
if
(
e
->
nodeID
==
0
)
{
/* Print some information to the screen */
printf
(
"%d %e %e %d
%.3f
%.3f
\n
"
,
e
->
step
,
e
->
time
,
e
->
timeStep
,
updates
,
e
->
wallclock_time
,
e
->
wallclock_time_ticks
);
printf
(
"%d %e %e %d %.3f
\n
"
,
e
->
step
,
e
->
time
,
e
->
timeStep
,
updates
,
e
->
wallclock_time
);
fflush
(
stdout
);
/* Write some energy statistics */
...
...
@@ -1647,11 +1620,7 @@ void engine_step(struct engine *e) {
TIMER_TOC2
(
timer_step
);
clock_gettime
(
CLOCK_REALTIME
,
&
time2
);
e
->
wallclock_time_ticks
=
((
double
)
timers
[
timer_count
-
1
])
/
CPU_TPS
*
1000
;
e
->
wallclock_time
=
(
float
)
time_diff
(
time1
,
time2
);
e
->
wallclock_time
=
((
double
)
timers
[
timer_count
-
1
])
/
CPU_TPS
*
1000
;
// printParticle(e->s->parts, e->s->xparts,1000, e->s->nr_parts);
// printParticle(e->s->parts, e->s->xparts,515050, e->s->nr_parts);
}
...
...
src/engine.h
View file @
52ed7796
...
...
@@ -147,7 +147,6 @@ struct engine {
/* Wallclock time of the last time-step */
float
wallclock_time
;
float
wallclock_time_ticks
;
/* Force the engine to rebuild? */
int
forcerebuild
;
...
...
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