[Mesa-dev] [PATCH 1/5] i965/fs: When doing no work for live interval calculation, do no allocation.
Kenneth Graunke
kenneth at whitecape.org
Wed May 9 00:50:10 PDT 2012
On 05/08/2012 05:59 PM, Eric Anholt wrote:
> 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.
> ---
> src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp | 14 +++++++-------
> 1 file 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;
> }
>
Simple enough and seems like a good idea.
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
More information about the mesa-dev
mailing list