Mesa (master): i965/fs: When doing no work for live interval calculation, do no allocation.

Eric Anholt anholt at kemper.freedesktop.org
Tue May 15 00:01:36 UTC 2012


Module: Mesa
Branch: master
Commit: f7a71e2570053205eb603aa04b8c52d4f54d8e4c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f7a71e2570053205eb603aa04b8c52d4f54d8e4c

Author: Eric Anholt <eric at anholt.net>
Date:   Tue May  8 13:40:44 2012 -0700

i965/fs: When doing no work for live interval calculation, do no allocation.

When I had a bug causing the backend to never finish optimizing, it
also sent me deep into swap.  This avoids extra memory allocation per
trip through optimization, and thus may reduce the peak memory
allocation of the driver even in the success case.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 .../drivers/dri/i965/brw_fs_live_variables.cpp     |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
index c6f0fbc..c7ee582 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
@@ -163,12 +163,17 @@ void
 fs_visitor::calculate_live_intervals()
 {
    int num_vars = this->virtual_grf_next;
-   int *def = ralloc_array(mem_ctx, int, num_vars);
-   int *use = ralloc_array(mem_ctx, int, num_vars);
 
    if (this->live_intervals_valid)
       return;
 
+   int *def = ralloc_array(mem_ctx, int, num_vars);
+   int *use = ralloc_array(mem_ctx, int, num_vars);
+   ralloc_free(this->virtual_grf_def);
+   ralloc_free(this->virtual_grf_use);
+   this->virtual_grf_def = def;
+   this->virtual_grf_use = use;
+
    for (int i = 0; i < num_vars; i++) {
       def[i] = MAX_INSTRUCTION;
       use[i] = -1;
@@ -215,11 +220,6 @@ fs_visitor::calculate_live_intervals()
       }
    }
 
-   ralloc_free(this->virtual_grf_def);
-   ralloc_free(this->virtual_grf_use);
-   this->virtual_grf_def = def;
-   this->virtual_grf_use = use;
-
    this->live_intervals_valid = true;
 }
 




More information about the mesa-commit mailing list