]> git.cworth.org Git - fips/commitdiff
Fix to still print metrics when there are no per-stage cycle-count metrics
authorCarl Worth <cworth@cworth.org>
Sat, 2 Nov 2013 21:36:47 +0000 (14:36 -0700)
committerCarl Worth <cworth@cworth.org>
Mon, 4 Nov 2013 23:43:20 +0000 (15:43 -0800)
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.

metrics.c

index 6704572533a41b901fa93cf481d731c23f408707..004c3399522ce907533a73f0a75d297f895316a4 100644 (file)
--- 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;