[SCM] Gerris Flow Solver branch, upstream, updated. e8f73a07832050124d2b8bf6c6f35b33180e65a8
Sebastien Delaux
s.delaux at niwa.co.nz
Tue Nov 24 12:24:32 UTC 2009
The following commit has been merged in the upstream branch:
commit cd58e34de7d51b85c0a5d60ee81a62ef38874ec9
Author: Sebastien Delaux <s.delaux at niwa.co.nz>
Date: Tue Jul 14 13:58:43 2009 +1000
Output timing now outputs sorted timings
darcs-hash:20090714035843-118cf-522e176958ae09d472e3b54c33ef0269007e98fe.gz
diff --git a/src/moving.c b/src/moving.c
index 8921ca1..f20d701 100644
--- a/src/moving.c
+++ b/src/moving.c
@@ -436,13 +436,11 @@ static void reinit_solid_fractions (GfsSimulation * sim)
GfsDomain * domain = GFS_DOMAIN (sim);;
GSList * solids = gfs_simulation_get_solids (sim);
if (solids) {
- gfs_domain_timer_start (domain, "solid_fractions");
sim->thin = domain_reinit_solid_fractions (sim, solids);
g_slist_free (solids);
gfs_domain_match (domain);
gfs_domain_traverse_mixed (domain, FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS,
(FttCellTraverseFunc) set_permanent, NULL);
- gfs_domain_timer_stop (domain, "solid_fractions");
}
gts_container_foreach (GTS_CONTAINER (sim), (GtsFunc) check_solid_fractions, &nf);
if (nf > 0) {
@@ -671,6 +669,8 @@ 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_cell_traverse (domain, FTT_PRE_ORDER, FTT_TRAVERSE_ALL, -1,
(FttCellTraverseFunc) set_old_solid, old_solid);
@@ -703,6 +703,7 @@ 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");
}
typedef struct {
diff --git a/src/output.c b/src/output.c
index c0377b9..6ef8ecf 100644
--- a/src/output.c
+++ b/src/output.c
@@ -821,23 +821,55 @@ GfsOutputClass * gfs_output_adapt_stats_class (void)
/* GfsOutputTiming: Object */
-static void timing_print (GtsRange * r, gdouble total, FILE * fp)
+typedef struct {
+ gdouble min, max, mean, stddev, sum;
+ gchar * name;
+} Timer;
+
+static int compare_timer (const void * a, const void * b)
{
- fprintf (fp,
- " min: %9.3f avg: %9.3f (%4.1f%%) | %7.3f max: %9.3f\n",
- r->min,
- r->mean, total > 0. ? 100.*r->sum/total : 0.,
- r->stddev,
- r->max);
+ Timer t1 = *(Timer *)a;
+ Timer t2 = *(Timer *)b;
+ return (t1.mean > t2.mean) ? 0 : 1 ;
}
-static void timer_print (gchar * name, GfsTimer * t, gpointer * data)
+static void get_timer (gchar * name, GfsTimer * t, gpointer * data)
{
- FILE * fp = data[0];
- GfsDomain * domain = data[1];
+ 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;
+ timing[*count].name = name;
+
+ *count = *count + 1;
+}
- fprintf (fp, " %s:\n", name);
- timing_print (&t->r, domain->timestep.sum, fp);
+static void print_timing (GHashTable * timers, GfsDomain * domain, FILE * fp)
+{
+ Timer timing[g_hash_table_size (timers)];
+ guint count = 0;
+ gpointer data[2];
+
+ 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);
+ }
}
static gboolean timing_event (GfsEvent * event, GfsSimulation * sim)
@@ -845,7 +877,7 @@ static gboolean timing_event (GfsEvent * event, GfsSimulation * sim)
if ((* GFS_EVENT_CLASS (gfs_output_class())->event) (event, sim)) {
GfsDomain * domain = GFS_DOMAIN (sim);
FILE * fp = GFS_OUTPUT (event)->file->fp;
-
+
if (domain->timestep.mean > 0.) {
gpointer data[2];
@@ -869,7 +901,8 @@ static gboolean timing_event (GfsEvent * event, GfsSimulation * sim)
gfs_domain_variables_number (domain));
data[0] = fp;
data[1] = domain;
- g_hash_table_foreach (domain->timers, (GHFunc) timer_print, data);
+
+ 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