llvmpipe: count/report time spent in LLVM compilations
authorBrian Paul <brianp@vmware.com>
Wed, 27 Jan 2010 20:49:43 +0000 (13:49 -0700)
committerBrian Paul <brianp@vmware.com>
Wed, 27 Jan 2010 20:49:43 +0000 (13:49 -0700)
src/gallium/drivers/llvmpipe/lp_perf.c
src/gallium/drivers/llvmpipe/lp_perf.h
src/gallium/drivers/llvmpipe/lp_state_fs.c

index 2628d51069b5f42b22f66a4e1feade0e42843978..042218b27fc6ac3f42f30d0eccd5803f00d55925 100644 (file)
@@ -82,5 +82,9 @@ lp_print_counters(void)
 
       debug_printf("llvmpipe: nr_empty_4x4:               %9u (%2.0f%% of %u)\n", lp_count.nr_empty_4, p1, total_4);
       debug_printf("llvmpipe: nr_non_empty_4x4:           %9u (%2.0f%% of %u)\n", lp_count.nr_non_empty_4, p2, total_4);
+
+      debug_printf("llvmpipe: nr_llvm_compiles:           %u\n", lp_count.nr_llvm_compiles);
+      debug_printf("llvmpipe: total LLVM compile time:    %.2f sec\n", lp_count.llvm_compile_time / 1000000.0);
+      debug_printf("llvmpipe: average LLVM compile time:  %.2f sec\n", lp_count.llvm_compile_time / 1000000.0 / lp_count.nr_llvm_compiles);
    }
 }
index 9886088c38ec7960a0e0337a9b7beac154e508b8..d982bcc989b345a020df42e39cc201401f20668d 100644 (file)
@@ -49,6 +49,8 @@ struct lp_counters
    unsigned nr_partially_covered_16;
    unsigned nr_empty_4;
    unsigned nr_non_empty_4;
+   unsigned nr_llvm_compiles;
+   int64_t llvm_compile_time;  /**< total, in microseconds */
 };
 
 
@@ -58,8 +60,10 @@ extern struct lp_counters lp_count;
 /** Increment the named counter (only for debug builds) */
 #ifdef DEBUG
 #define LP_COUNT(counter) lp_count.counter++
+#define LP_COUNT_ADD(counter, incr)  lp_count.counter += (incr)
 #else
 #define LP_COUNT(counter)
+#define LP_COUNT_ADD(counter, incr) (void) incr
 #endif
 
 
index 0053c1b88b74dacd1a229a15bf41c238a4af87f5..a7514ee011d7f583c082d9cfc76887e4f450f96f 100644 (file)
@@ -65,6 +65,7 @@
 #include "util/u_memory.h"
 #include "util/u_format.h"
 #include "util/u_debug_dump.h"
+#include "util/u_time.h"
 #include "pipe/internal/p_winsys_screen.h"
 #include "pipe/p_shader_tokens.h"
 #include "draw/draw_context.h"
 #include "lp_bld_swizzle.h"
 #include "lp_bld_flow.h"
 #include "lp_bld_debug.h"
-#include "lp_screen.h"
-#include "lp_context.h"
 #include "lp_buffer.h"
+#include "lp_context.h"
+#include "lp_debug.h"
+#include "lp_perf.h"
+#include "lp_screen.h"
 #include "lp_setup.h"
 #include "lp_state.h"
 #include "lp_tex_sample.h"
-#include "lp_debug.h"
 
 
 static const unsigned char quad_offset_x[4] = {0, 1, 0, 1};
@@ -1108,9 +1110,19 @@ llvmpipe_update_fs(struct llvmpipe_context *lp)
       variant = variant->next;
    }
 
-   if(!variant)
+   if (!variant) {
+      struct util_time t0, t1;
+      int64_t dt;
+      util_time_get(&t0);
+
       variant = generate_variant(lp, shader, &key);
 
+      util_time_get(&t1);
+      dt = util_time_diff(&t0, &t1);
+      LP_COUNT_ADD(llvm_compile_time, dt);
+      LP_COUNT_ADD(nr_llvm_compiles, 2);  /* emit vs. omit in/out test */
+   }
+
    shader->current = variant;
 
    /* TODO: put this in the variant */