Commit 0bd48ce9 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Eradicate the use of CPU_TPS in all code, replacing with clocks

functions. CPU_TPS is now only found in one Makefile.am and one
file, clocks.c.

Many of the uses are commented out or protected by TIMER_VERBOSE.
TIMER_VERBOSE no longer compiles, so these changes are untested
and just aim to guide the future...
parent e7b70154
......@@ -1117,7 +1117,7 @@ int engine_marktasks(struct engine *e) {
}
}
// message( "took %.3f ms." , (double)(getticks() - tic)/CPU_TPS*1000 );
// message( "took %.3f ms." , clocks_from_ticks(getticks() - tic));
/* All is well... */
return 0;
......@@ -1168,29 +1168,29 @@ void engine_rebuild(struct engine *e) {
/* Re-build the space. */
// tic = getticks();
space_rebuild(e->s, 0.0, e->nodeID == 0);
// message( "space_rebuild took %.3f ms." , (double)(getticks() -
// tic)/CPU_TPS*1000 );
// message( "space_rebuild took %.3f ms." ,
//clocks_from_ticks(getticks() - tic));
/* If in parallel, exchange the cell structure. */
#ifdef WITH_MPI
// tic = getticks();
engine_exchange_cells(e);
// message( "engine_exchange_cells took %.3f ms." , (double)(getticks() -
// tic)/CPU_TPS*1000 );
// message( "engine_exchange_cells took %.3f ms." ,
//clocks_from_ticks(getticks() - tic));
#endif
/* Re-build the tasks. */
// tic = getticks();
engine_maketasks(e);
// message( "engine_maketasks took %.3f ms." , (double)(getticks() -
// tic)/CPU_TPS*1000 );
// message( "engine_maketasks took %.3f ms." ,
//clocks_from_ticks(getticks() - tic));
/* Run through the tasks and mark as skip or not. */
// tic = getticks();
if (engine_marktasks(e))
error("engine_marktasks failed after space_rebuild.");
// message( "engine_marktasks took %.3f ms." , (double)(getticks() -
// tic)/CPU_TPS*1000 );
// message( "engine_marktasks took %.3f ms." ,
//clocks_from_ticks(getticks() - tic));
/* Print the status of the system */
engine_print(e);
......@@ -1211,8 +1211,8 @@ void engine_prepare(struct engine *e) {
/* Run through the tasks and mark as skip or not. */
// tic = getticks();
rebuild = (e->forcerebuild || engine_marktasks(e));
// message( "space_marktasks took %.3f ms." , (double)(getticks() -
// tic)/CPU_TPS*1000 );
// message( "space_marktasks took %.3f ms." ,
//clocks_from_ticks((getticks() - tic)));
/* Collect the values of rebuild from all nodes. */
#ifdef WITH_MPI
......@@ -1222,8 +1222,8 @@ void engine_prepare(struct engine *e) {
MPI_SUCCESS)
error("Failed to aggregate the rebuild flag across nodes.");
rebuild = buff;
// message( "rebuild allreduce took %.3f ms." , (double)(getticks() -
// tic)/CPU_TPS*1000 );
// message( "rebuild allreduce took %.3f ms." ,
//clocks_from_ticks(getticks() - tic));
#endif
e->tic_step = getticks();
......@@ -1231,16 +1231,16 @@ void engine_prepare(struct engine *e) {
if (rebuild) {
// tic = getticks();
engine_rebuild(e);
// message( "engine_rebuild took %.3f ms." , (double)(getticks() -
// tic)/CPU_TPS*1000 );
// message( "engine_rebuild took %.3f ms." ,
//clocks_from_ticks(getticks() - tic));
}
/* Re-rank the tasks every now and then. */
if (e->tasks_age % engine_tasksreweight == 1) {
// tic = getticks();
scheduler_reweight(&e->sched);
// message( "scheduler_reweight took %.3f ms." , (double)(getticks() -
// tic)/CPU_TPS*1000 );
// message( "scheduler_reweight took %.3f ms." ,
//clocks_from_ticks(getticks() -tic));
}
e->tasks_age += 1;
......@@ -1627,7 +1627,7 @@ void engine_step(struct engine *e) {
clocks_gettime(&time2);
e->wallclock_time_ticks =
((double)timers[timer_count - 1]) / clocks_cpufreq() * 1000;
((double)timers[timer_count - 1]) / clocks_get_cpufreq() * 1000;
e->wallclock_time = (float) clocks_diff(&time1, &time2);
// printParticle(e->s->parts, e->s->xparts,1000, e->s->nr_parts);
......
......@@ -320,7 +320,7 @@ void runner_dosort(struct runner *r, struct cell *c, int flags, int clock) {
(flags & 0x80) >> 7, (flags & 0x40) >> 6, (flags & 0x20) >> 5,
(flags & 0x10) >> 4, (flags & 0x8) >> 3, (flags & 0x4) >> 2,
(flags & 0x2) >> 1, (flags & 0x1) >> 0,
((double)TIMER_TOC(timer_dosort)) / CPU_TPS * 1000);
clocks_from_ticks(TIMER_TOC(timer_dosort)));
fflush(stdout);
#else
if (clock) TIMER_TOC(timer_dosort);
......@@ -478,7 +478,7 @@ void runner_dogsort(struct runner *r, struct cell *c, int flags, int clock) {
(flags & 0x80) >> 7, (flags & 0x40) >> 6, (flags & 0x20) >> 5,
(flags & 0x10) >> 4, (flags & 0x8) >> 3, (flags & 0x4) >> 2,
(flags & 0x2) >> 1, (flags & 0x1) >> 0,
((double)TIMER_TOC(timer_dosort)) / CPU_TPS * 1000);
clocks_from_ticks(TIMER_TOC(timer_dosort)));
fflush(stdout);
#else
if (clock) TIMER_TOC(timer_dosort);
......@@ -525,7 +525,7 @@ void runner_doinit(struct runner *r, struct cell *c, int timer) {
if (timer) {
#ifdef TIMER_VERBOSE
message("runner %02i: %i parts at depth %i took %.3f ms.", r->id, c->count,
c->depth, ((double)TIMER_TOC(timer_init)) / CPU_TPS * 1000);
c->depth, clocks_from_ticks(TIMER_TOC(timer_init)));
fflush(stdout);
#else
TIMER_TOC(timer_init);
......@@ -681,7 +681,7 @@ void runner_doghost(struct runner *r, struct cell *c) {
#ifdef TIMER_VERBOSE
message("runner %02i: %i parts at depth %i took %.3f ms.", r->id, c->count,
c->depth, ((double)TIMER_TOC(timer_doghost)) / CPU_TPS * 1000);
c->depth, clocks_from_ticks(TIMER_TOC(timer_doghost)));
fflush(stdout);
#else
TIMER_TOC(timer_doghost);
......@@ -782,7 +782,7 @@ void runner_dodrift(struct runner *r, struct cell *c, int timer) {
if (timer) {
#ifdef TIMER_VERBOSE
message("runner %02i: %i parts at depth %i took %.3f ms.", r->id, c->count,
c->depth, ((double)TIMER_TOC(timer_drift)) / CPU_TPS * 1000);
c->depth, clocks_from_ticks(TIMER_TOC(timer_drift)));
fflush(stdout);
#else
TIMER_TOC(timer_drift);
......@@ -994,7 +994,7 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) {
if (timer) {
#ifdef TIMER_VERBOSE
message("runner %02i: %i parts at depth %i took %.3f ms.", r->id, c->count,
c->depth, ((double)TIMER_TOC(timer_kick)) / CPU_TPS * 1000);
c->depth, clocks_from_ticks(TIMER_TOC(timer_kick)));
fflush(stdout);
#else
TIMER_TOC(timer_kick);
......
......@@ -207,7 +207,7 @@ void DOPAIR_NAIVE(struct runner *r, struct cell *restrict ci,
"runner_dopair_naive[%02i]: %i/%i parts at depth %i (r_max=%.3f/%.3f) "
"took %.3f ms.\n",
r->id, count_i, count_j, ci->depth, ci->h_max, cj->h_max,
((double)TIMER_TOC(TIMER_DOPAIR)) / CPU_TPS * 1000);
clocks_from_ticks(TIMER_TOC(TIMER_DOPAIR)));
#else
TIMER_TOC(TIMER_DOPAIR);
#endif
......@@ -307,7 +307,7 @@ void DOSELF_NAIVE(struct runner *r, struct cell *restrict c) {
#ifdef TIMER_VERBOSE
printf("runner_doself[%02i]: %i parts at depth %i took %.3f ms.\n", r->id,
count, c->depth, ((double)TIMER_TOC(TIMER_DOSELF)) / CPU_TPS * 1000);
count, c->depth, clocks_from_ticks(TIMER_TOC(TIMER_DOSELF)));
#else
TIMER_TOC(TIMER_DOSELF);
#endif
......@@ -515,7 +515,7 @@ void DOPAIR_SUBSET(struct runner *r, struct cell *restrict ci,
"runner_dopair_subset[%02i]: %i/%i parts at depth %i (r_max=%.3f/%.3f) "
"took %.3f ms.\n",
r->id, count, count_j, ci->depth, ci->h_max, cj->h_max,
((double)TIMER_TOC(TIMER_DOPAIR)) / CPU_TPS * 1000);
clocks_from_ticks(TIMER_TOC(TIMER_DOPAIR)));
#else
TIMER_TOC(timer_dopair_subset);
#endif
......@@ -635,7 +635,7 @@ void DOPAIR_SUBSET_NAIVE(struct runner *r, struct cell *restrict ci,
"runner_dopair_subset[%02i]: %i/%i parts at depth %i (r_max=%.3f/%.3f) "
"took %.3f ms.\n",
r->id, count, count_j, ci->depth, ci->h_max, cj->h_max,
((double)TIMER_TOC(TIMER_DOPAIR)) / CPU_TPS * 1000);
clocks_from_ticks(TIMER_TOC(TIMER_DOPAIR)));
#else
TIMER_TOC(timer_dopair_subset);
#endif
......@@ -744,7 +744,7 @@ void DOSELF_SUBSET(struct runner *r, struct cell *restrict ci,
#ifdef TIMER_VERBOSE
printf("runner_doself_subset[%02i]: %i/%i parts at depth %i took %.3f ms.\n",
r->id, count, ci->count, ci->depth,
((double)TIMER_TOC(TIMER_DOSELF)) / CPU_TPS * 1000);
clocks_from_ticks(TIMER_TOC(TIMER_DOSELF)));
#else
TIMER_TOC(timer_dopair_subset);
#endif
......@@ -871,7 +871,7 @@ void DOPAIR1(struct runner *r, struct cell *ci, struct cell *cj) {
} /* loop over the parts in ci. */
/* printf( "runner_dopair: first half took %.3f ms...\n" ,
((double)(getticks() - tic)) / CPU_TPS * 1000 );
clocks_from_ticks(getticks() - tic));
tic = getticks(); */
/* Loop over the parts in cj. */
......@@ -947,7 +947,7 @@ void DOPAIR1(struct runner *r, struct cell *ci, struct cell *cj) {
"took %.3f ms.\n",
r->id, count_i, count_j, ci->depth, ci->h_max, cj->h_max,
fmax(ci->h[0], fmax(ci->h[1], ci->h[2])),
((double)(TIMER_TOC(TIMER_DOPAIR))) / CPU_TPS * 1000);
clocks_from_ticks(TIMER_TOC(TIMER_DOPAIR)));
#else
TIMER_TOC(TIMER_DOPAIR);
#endif
......@@ -1183,7 +1183,7 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj) {
} /* loop over the parts in ci. */
/* printf( "runner_dopair: first half took %.3f ms...\n" ,
((double)(getticks() - tic)) / CPU_TPS * 1000 );
clocks_from_ticks(getticks() - tic));
tic = getticks(); */
/* Loop over the parts in cj. */
......@@ -1342,7 +1342,7 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj) {
"took %.3f ms.\n",
r->id, count_i, count_j, ci->depth, ci->h_max, cj->h_max,
fmax(ci->h[0], fmax(ci->h[1], ci->h[2])),
((double)(TIMER_TOC(TIMER_DOPAIR))) / CPU_TPS * 1000);
clocks_from_ticks(TIMER_TOC(TIMER_DOPAIR)));
#else
TIMER_TOC(TIMER_DOPAIR);
#endif
......@@ -1572,7 +1572,7 @@ void DOSELF1(struct runner *r, struct cell *restrict c) {
#ifdef TIMER_VERBOSE
printf("runner_doself1[%02i]: %i parts at depth %i took %.3f ms.\n", r->id,
count, c->depth, ((double)TIMER_TOC(TIMER_DOSELF)) / CPU_TPS * 1000);
count, c->depth, clocks_from_ticks(TIMER_TOC(TIMER_DOSELF)));
#else
TIMER_TOC(TIMER_DOSELF);
#endif
......@@ -1769,7 +1769,7 @@ void DOSELF2(struct runner *r, struct cell *restrict c) {
#ifdef TIMER_VERBOSE
printf("runner_doself2[%02i]: %i parts at depth %i took %.3f ms.\n", r->id,
count, c->depth, ((double)TIMER_TOC(TIMER_DOSELF)) / CPU_TPS * 1000);
count, c->depth, clocks_from_ticks(TIMER_TOC(TIMER_DOSELF)));
#else
TIMER_TOC(TIMER_DOSELF);
#endif
......@@ -2057,7 +2057,7 @@ void DOSUB1(struct runner *r, struct cell *ci, struct cell *cj, int sid,
if (gettimer)
#ifdef TIMER_VERBOSE
printf("runner_dosub1[%02i]: flags=%i at depth %i took %.3f ms.\n", r->id,
sid, ci->depth, ((double)TIMER_TOC(TIMER_DOSUB)) / CPU_TPS * 1000);
sid, ci->depth, clocks_from_ticks(TIMER_TOC(TIMER_DOSUB)));
#else
TIMER_TOC(TIMER_DOSUB);
#endif
......@@ -2332,7 +2332,7 @@ void DOSUB2(struct runner *r, struct cell *ci, struct cell *cj, int sid,
if (gettimer)
#ifdef TIMER_VERBOSE
printf("runner_dosub2[%02i]: flags=%i at depth %i took %.3f ms.\n", r->id,
sid, ci->depth, ((double)TIMER_TOC(TIMER_DOSUB)) / CPU_TPS * 1000);
sid, ci->depth, clocks_from_ticks(TIMER_TOC(TIMER_DOSUB)));
#else
TIMER_TOC(TIMER_DOSUB);
#endif
......@@ -2936,7 +2936,7 @@ void DOSUB_SUBSET(struct runner *r, struct cell *ci, struct part *parts,
if (gettimer)
#ifdef TIMER_VERBOSE
printf("runner_dosub[%02i]: flags=%i at depth %i took %.3f ms.\n", r->id,
sid, ci->depth, ((double)TIMER_TOC(TIMER_DOSUB)) / CPU_TPS * 1000);
sid, ci->depth, clocks_from_ticks(TIMER_TOC(TIMER_DOSUB)));
#else
TIMER_TOC(TIMER_DOSUB);
#endif
......
......@@ -21,6 +21,7 @@
/* Includes. */
#include "cell.h"
#include "clocks.h"
#include "part.h"
/**
......@@ -198,7 +199,7 @@ void runner_dopair_grav_new(struct runner *r, struct cell *ci,
"took %.3f ms.\n",
r->id, count_i, count_j, ci->depth, ci->h_max, cj->h_max,
fmax(ci->h[0], fmax(ci->h[1], ci->h[2])),
((double)(TIMER_TOC(TIMER_DOPAIR))) / CPU_TPS * 1000);
clocks_from_ticks(TIMER_TOC(TIMER_DOPAIR)));
#else
TIMER_TOC(TIMER_DOPAIR);
#endif
......@@ -434,7 +435,7 @@ void runner_dopair_grav(struct runner *r, struct cell *restrict ci,
"runner_dopair_naive_grav[%02i]: %i/%i parts at depth %i "
"(r_max=%.3f/%.3f) took %.3f ms.\n",
r->id, count_i, count_j, ci->depth, ci->h_max, cj->h_max,
((double)TIMER_TOC(TIMER_DOPAIR)) / CPU_TPS * 1000);
clocks_from_ticks(TIMER_TOC(TIMER_DOPAIR)));
#else
TIMER_TOC(timer_dopair_grav);
#endif
......@@ -530,7 +531,7 @@ void runner_doself_grav(struct runner *r, struct cell *restrict c) {
"runner_doself_grav[%02i]: %i/%i parts at depth %i (r_max=%.3f/%.3f) "
"took %.3f ms.\n",
r->id, count_i, count_j, ci->depth, ci->h_max, cj->h_max,
((double)TIMER_TOC(TIMER_DOPAIR)) / CPU_TPS * 1000);
clocks_from_ticks(TIMER_TOC(TIMER_DOPAIR)));
#else
TIMER_TOC(timer_doself_grav);
#endif
......@@ -619,7 +620,7 @@ void runner_dosub_grav(struct runner *r, struct cell *ci, struct cell *cj,
if (gettimer)
#ifdef TIMER_VERBOSE
printf("runner_dosub_grav[%02i]: at depth %i took %.3f ms.\n", r->id,
ci->depth, ((double)TIMER_TOC(TIMER_DOSUB)) / CPU_TPS * 1000);
ci->depth, clocks_from_ticks(TIMER_TOC(TIMER_DOSUB)));
#else
TIMER_TOC(timer_dosub_grav);
#endif
......
......@@ -936,8 +936,8 @@ void scheduler_reweight(struct scheduler *s) {
if (t->type == task_type_send) t->weight = INT_MAX / 8;
if (t->type == task_type_recv) t->weight *= 1.41;
}
// message( "weighting tasks took %.3f ms." , (double)( getticks() - tic ) /
// CPU_TPS * 1000 );
// message( "weighting tasks took %.3f ms." ,
//clocks_from_ticks( getticks() - tic ));
/* int min = tasks[0].weight, max = tasks[0].weight;
for ( k = 1 ; k < nr_tasks ; k++ )
......@@ -973,8 +973,8 @@ void scheduler_start(struct scheduler *s, unsigned int mask,
s->tasks[k].wait = 1;
s->tasks[k].rid = -1;
}
// message( "waiting tasks took %.3f ms." , (double)( getticks() - tic ) /
// CPU_TPS * 1000 );
// message( "waiting tasks took %.3f ms." ,
//clocks_from_ticks( getticks() - tic ) );
/* Enqueue a set of extraenous tasks to set the task waits. */
struct task *rewait_tasks = &s->tasks[s->nr_tasks];
......@@ -1017,7 +1017,7 @@ void scheduler_start(struct scheduler *s, unsigned int mask,
}
pthread_mutex_unlock(&s->sleep_mutex);
/* message("waiting tasks took %.3f ms.",
(double)(getticks() - tic) / CPU_TPS * 1000); */
clocks_from_ticks(getticks() - tic));*/
s->mask = mask;
s->submask = submask | (1 << task_subtype_none);
......@@ -1033,8 +1033,8 @@ void scheduler_start(struct scheduler *s, unsigned int mask,
}
}
// message( "enqueueing tasks took %.3f ms." , (double)( getticks() - tic ) /
// CPU_TPS * 1000 );
// message( "enqueueing tasks took %.3f ms." ,
//clocks_from_ticks( getticks() - tic ));
}
/**
......
......@@ -264,8 +264,8 @@ void space_regrid(struct space *s, double cell_max, int verbose) {
fflush(stdout);
} /* re-build upper-level cells? */
// message( "rebuilding upper-level cells took %.3f ms." , (double)(getticks()
// - tic) / CPU_TPS * 1000 );
// message( "rebuilding upper-level cells took %.3f ms." ,
// clocks_from_ticks(double)(getticks() - tic));
/* Otherwise, just clean up the cells. */
else {
......@@ -343,8 +343,8 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
cell_getid(cdim, p->x[0] * ih[0], p->x[1] * ih[1], p->x[2] * ih[2]);
cells[ind[k]].count++;
}
// message( "getting particle indices took %.3f ms." , (double)(getticks() -
// tic) / CPU_TPS * 1000 );
// message( "getting particle indices took %.3f ms." ,
//clocks_from_ticks(getticks() - tic)):
#ifdef WITH_MPI
/* Move non-local parts to the end of the list. */
......@@ -396,8 +396,8 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
/* Sort the parts according to their cells. */
// tic = getticks();
space_parts_sort(s, ind, nr_parts, 0, s->nr_cells - 1);
// message( "parts_sort took %.3f ms." , (double)(getticks() - tic) / CPU_TPS
// * 1000 );
// message( "parts_sort took %.3f ms." ,
//clocks_from_ticks(getticks() - tic));
/* Re-link the gparts. */
for (k = 0; k < nr_parts; k++)
......@@ -431,16 +431,16 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
cell_getid(cdim, gp->x[0] * ih[0], gp->x[1] * ih[1], gp->x[2] * ih[2]);
cells[ind[k]].gcount++;
}
// message( "getting particle indices took %.3f ms." , (double)(getticks() -
// tic) / CPU_TPS * 1000 );
// message( "getting particle indices took %.3f ms." ,
//clocks_from_ticks(getticks() - tic));
/* TODO: Here we should exchange the gparts as well! */
/* Sort the parts according to their cells. */
// tic = getticks();
gparts_sort(s->gparts, ind, nr_gparts, 0, s->nr_cells - 1);
// message( "gparts_sort took %.3f ms." , (double)(getticks() - tic) / CPU_TPS
// * 1000 );
// message( "gparts_sort took %.3f ms." ,
//clocks_from_ticks(getticks() - tic));
/* Re-link the parts. */
for (k = 0; k < nr_gparts; k++)
......@@ -463,8 +463,8 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
xfinger = &xfinger[c->count];
gfinger = &gfinger[c->gcount];
}
// message( "hooking up cells took %.3f ms." , (double)(getticks() - tic) /
// CPU_TPS * 1000 );
// message( "hooking up cells took %.3f ms." ,
//clocks_from_ticks(getticks() - tic));
/* At this point, we have the upper-level cells, old or new. Now make
sure that the parts in each cell are ok. */
......@@ -475,8 +475,8 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
0, &cells[k], NULL, 0);
engine_launch(s->e, s->e->nr_threads, 1 << task_type_split_cell, 0);
// message( "space_split took %.3f ms." , (double)(getticks() - tic) / CPU_TPS
// * 1000 );
// message( "space_split took %.3f ms." ,
//clocks_from_ticks(getticks() - tic));
}
/**
......
......@@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Add the source directory and debug to CFLAGS
AM_CFLAGS = -I../src -DCPU_TPS=2.67e9 $(HDF5_CPPFLAGS) -DTIMER
AM_CFLAGS = -I../src $(HDF5_CPPFLAGS) -DTIMER
AM_LDFLAGS = ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS)
......
......@@ -40,11 +40,6 @@
/* Local headers. */
#include "swift.h"
/* Ticks per second on this machine. */
#ifndef CPU_TPS
#define CPU_TPS 2.67e9
#endif
/* Engine policy flags. */
#ifndef ENGINE_POLICY
#define ENGINE_POLICY engine_policy_none
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment