summaryrefslogtreecommitdiffstats
path: root/src/mesa/program/register_allocate.c
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2013-02-19 17:01:41 -0800
committerEric Anholt <[email protected]>2013-03-11 12:11:54 -0700
commit11b8df0c0141c5759025985ba99e782a2dfd720c (patch)
tree7424e0529ff34b6ad6d20388e4fdafc8cb4db708 /src/mesa/program/register_allocate.c
parent6aa3afbfd6b737350351e9ea22ba9de1accda52d (diff)
mesa: Reduce memory usage for reg alloc with many graph nodes (part 2).
After the previous fix that almost removes an allocation of 4*n^2 bytes, we can use a bitset to reduce another allocation from n^2 bytes to n^2/8 bytes. Between the previous commit and this one, the peak heap size for an oglconform ARB_fragment_program max instructions test on i965 goes from 4GB to 255MB. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=55825 Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/program/register_allocate.c')
-rw-r--r--src/mesa/program/register_allocate.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/mesa/program/register_allocate.c b/src/mesa/program/register_allocate.c
index 5862c78661a..a9064c38ca2 100644
--- a/src/mesa/program/register_allocate.c
+++ b/src/mesa/program/register_allocate.c
@@ -75,6 +75,7 @@
#include "main/imports.h"
#include "main/macros.h"
#include "main/mtypes.h"
+#include "main/bitset.h"
#include "register_allocate.h"
#define NO_REG ~0
@@ -118,7 +119,7 @@ struct ra_node {
* List of which nodes this node interferes with. This should be
* symmetric with the other node.
*/
- GLboolean *adjacency;
+ BITSET_WORD *adjacency;
unsigned int *adjacency_list;
unsigned int adjacency_list_size;
unsigned int adjacency_count;
@@ -307,7 +308,7 @@ ra_set_finalize(struct ra_regs *regs, unsigned int **q_values)
static void
ra_add_node_adjacency(struct ra_graph *g, unsigned int n1, unsigned int n2)
{
- g->nodes[n1].adjacency[n2] = GL_TRUE;
+ BITSET_SET(g->nodes[n1].adjacency, n2);
if (g->nodes[n1].adjacency_count >=
g->nodes[n1].adjacency_list_size) {
@@ -335,11 +336,14 @@ ra_alloc_interference_graph(struct ra_regs *regs, unsigned int count)
g->stack = rzalloc_array(g, unsigned int, count);
for (i = 0; i < count; i++) {
- g->nodes[i].adjacency = rzalloc_array(g, GLboolean, count);
+ int bitset_count = ALIGN(count, BITSET_WORDBITS) / BITSET_WORDBITS;
+ g->nodes[i].adjacency = rzalloc_array(g, BITSET_WORD, bitset_count);
+
g->nodes[i].adjacency_list_size = 4;
g->nodes[i].adjacency_list =
ralloc_array(g, unsigned int, g->nodes[i].adjacency_list_size);
g->nodes[i].adjacency_count = 0;
+
ra_add_node_adjacency(g, i, i);
g->nodes[i].reg = NO_REG;
}
@@ -358,7 +362,7 @@ void
ra_add_node_interference(struct ra_graph *g,
unsigned int n1, unsigned int n2)
{
- if (!g->nodes[n1].adjacency[n2]) {
+ if (!BITSET_TEST(g->nodes[n1].adjacency, n2)) {
ra_add_node_adjacency(g, n1, n2);
ra_add_node_adjacency(g, n2, n1);
}