From: Carl Worth Date: Sat, 2 Nov 2013 21:36:47 +0000 (-0700) Subject: Fix to still print metrics when there are no per-stage cycle-count metrics X-Git-Url: https://git.cworth.org/git?p=fips;a=commitdiff_plain;h=0fee0398ec378498675d0d4fd5c0ec04ef84961a Fix to still print metrics when there are no per-stage cycle-count metrics There are at least two cases where fips will have no per-stage cycle counts: 1. The AMD_performance_monitor extension is not available 2. The extension is there, but fips cannot find any per-stage cycle counters In either case, the previous code would print no timing information. The problem is that fips was using the number of detected per-stage cycle counters (in num_shader_stages) as the basis for allocation of the results array. So with this value being 0, nothing was allocated, nothing was stored, and nothing was printed. Here, we fix this by instead allocating space for one result per operation, and ensuring that ll of the measured time is reported for that operation. --- diff --git a/metrics.c b/metrics.c index 6704572..004c339 100644 --- a/metrics.c +++ b/metrics.c @@ -579,7 +579,10 @@ print_program_metrics (metrics_t *metrics) /* Make a sorted list of the per-stage operations by time * used, and figure out the total so we can print percentages. */ - num_sorted = metrics->num_op_metrics * num_shader_stages; + if (num_shader_stages) + num_sorted = metrics->num_op_metrics * num_shader_stages; + else + num_sorted = metrics->num_op_metrics; sorted = xmalloc (sizeof (*sorted) * num_sorted); @@ -595,6 +598,14 @@ print_program_metrics (metrics_t *metrics) /* Also, find total cycles in all stages of this op. */ op_cycles = 0.0; + if (num_shader_stages == 0) { + per_stage = &sorted[i]; + per_stage->metrics = op; + per_stage->stage = NULL; + per_stage->time_ns = op->time_ns; + per_stage->active = 0.0; + } + for (j = 0; j < num_shader_stages; j++) { /* Active cycles */ group_index = info->stages[j].active_group_index;