[SCM] Gerris Flow Solver branch, upstream, updated. e8f73a07832050124d2b8bf6c6f35b33180e65a8
Stephane Popinet
popinet at users.sf.net
Tue Nov 24 12:24:33 UTC 2009
The following commit has been merged in the upstream branch:
commit 33ca3dd148cecf4a1fd071da912957da214758ae
Author: Stephane Popinet <popinet at users.sf.net>
Date: Tue Jul 14 17:18:56 2009 +1000
A few fixes for OutputTiming
darcs-hash:20090714071856-d4795-0b3e2a832a63984a7e0f9a17e3b558867c174304.gz
diff --git a/src/moving.c b/src/moving.c
index f20d701..db87026 100644
--- a/src/moving.c
+++ b/src/moving.c
@@ -669,7 +669,7 @@ static void move_solids (GfsSimulation * sim)
GfsVariable * old_solid = GFS_SIMULATION_MOVING (sim)->old_solid;
GfsVariable * sold2[FTT_NEIGHBORS];
- gfs_domain_timer_start (domain, "Move_solids");
+ gfs_domain_timer_start (domain, "move_solids");
gfs_domain_cell_traverse (domain, FTT_PRE_ORDER, FTT_TRAVERSE_ALL, -1,
(FttCellTraverseFunc) set_old_solid, old_solid);
@@ -703,7 +703,8 @@ static void move_solids (GfsSimulation * sim)
gts_object_destroy (GTS_OBJECT (sold2[d]));
GFS_SIMULATION_MOVING (sim)->sold2 = NULL;
}
- gfs_domain_timer_stop (domain, "Move_solids");
+
+ gfs_domain_timer_stop (domain, "move_solids");
}
typedef struct {
diff --git a/src/output.c b/src/output.c
index 6ef8ecf..a2156ae 100644
--- a/src/output.c
+++ b/src/output.c
@@ -822,54 +822,48 @@ GfsOutputClass * gfs_output_adapt_stats_class (void)
/* GfsOutputTiming: Object */
typedef struct {
- gdouble min, max, mean, stddev, sum;
+ GfsTimer * t;
gchar * name;
} Timer;
static int compare_timer (const void * a, const void * b)
{
- Timer t1 = *(Timer *)a;
- Timer t2 = *(Timer *)b;
- return (t1.mean > t2.mean) ? 0 : 1 ;
+ Timer * t1 = (Timer *) a;
+ Timer * t2 = (Timer *) b;
+ return (t1->t->r.sum < t2->t->r.sum) ? -1 : 1 ;
}
static void get_timer (gchar * name, GfsTimer * t, gpointer * data)
{
- GtsRange * r = &t->r;
Timer * timing = data[0];
- guint * count = data[1];
-
- timing[*count].min = r->min;
- timing[*count].max = r->max;
- timing[*count].mean = r->mean;
- timing[*count].stddev = r->stddev;
- timing[*count].sum = r->sum;
+ gint * count = data[1];
+ timing[*count].t = t;
timing[*count].name = name;
-
- *count = *count + 1;
+ (*count)++;
}
-static void print_timing (GHashTable * timers, GfsDomain * domain, FILE * fp)
+static void print_timing (GHashTable * timers, GfsDomain * domain, FILE * fp)
{
- Timer timing[g_hash_table_size (timers)];
- guint count = 0;
+ Timer * timing = g_malloc (sizeof (Timer)*g_hash_table_size (timers));
+ gint count = 0;
gpointer data[2];
-
- data[0] = &timing;
- data[1] = &count;
-
+
+ data[0] = timing;
+ data[1] = &count;
g_hash_table_foreach (domain->timers, (GHFunc) get_timer, data);
- qsort(timing, g_hash_table_size (timers), sizeof(Timer), compare_timer);
-
- for (count = 0; count < g_hash_table_size (timers);count++) {
- fprintf (fp, " %s:\n", timing[count].name);
- fprintf (fp,
- " min: %9.3f avg: %9.3f (%4.1f%%) | %7.3f max: %9.3f\n",
- timing[count].min,
- timing[count].mean, domain->timestep.sum > 0. ? 100.*timing[count].sum/domain->timestep.sum : 0.,
- timing[count].stddev,
- timing[count].max);
- }
+ qsort (timing, count, sizeof (Timer), compare_timer);
+ while (--count >= 0)
+ if (timing[count].t->r.sum > 0.)
+ fprintf (fp,
+ " %s:\n"
+ " min: %9.3f avg: %9.3f (%4.1f%%) | %7.3f max: %9.3f\n",
+ timing[count].name,
+ timing[count].t->r.min,
+ timing[count].t->r.mean,
+ domain->timestep.sum > 0. ? 100.*timing[count].t->r.sum/domain->timestep.sum : 0.,
+ timing[count].t->r.stddev,
+ timing[count].t->r.max);
+ g_free (timing);
}
static gboolean timing_event (GfsEvent * event, GfsSimulation * sim)
@@ -879,8 +873,6 @@ static gboolean timing_event (GfsEvent * event, GfsSimulation * sim)
FILE * fp = GFS_OUTPUT (event)->file->fp;
if (domain->timestep.mean > 0.) {
- gpointer data[2];
-
fprintf (fp,
"Timing summary: %u timesteps %.0f node.timestep/s\n"
" timestep:\n"
@@ -899,10 +891,7 @@ static gboolean timing_event (GfsEvent * event, GfsSimulation * sim)
domain->size.stddev,
domain->size.max,
gfs_domain_variables_number (domain));
- data[0] = fp;
- data[1] = domain;
-
- print_timing (domain->timers ,domain ,fp);
+ print_timing (domain->timers, domain, fp);
if (domain->mpi_messages.n > 0)
fprintf (fp,
"Message passing summary\n"
--
Gerris Flow Solver
More information about the debian-science-commits
mailing list