buf_t* b;
};
+int g_buf_size = 0;
+int g_buf_size_max = 0;
+
buf_t* buf_alloc(int n)
{
assert(n > 0);
buf_t* b = malloc(sizeof(buf_t) + sizeof(int) * n * n);
assert(b);
+ g_buf_size += n * n;
+ if (g_buf_size_max < g_buf_size)
+ g_buf_size_max = g_buf_size;
+// printf("%s(), g_buf_size: %d, g_buf_size_max: %d\n", __func__, g_buf_size, g_buf_size_max);
+
b->refs = 1;
b->n = n;
return b;
void buf_free(buf_t* b)
{
- if (b && 0 == --b->refs)
+ if (b && 0 == --b->refs) {
+
+ g_buf_size -= b->n * b->n;
+
free(b);
+ }
}
mat_t* mat_alloc(int i, int j, int n, buf_t* b)
// p1 = a * (f - h)
mat_sub(t0, f, h);
mat_mul_strassen(p1, a, t0, n_min);
-
// p2 = (a + b) * h
mat_add(t0, a, b);
mat_mul_strassen(p2, t0, h, n_min);
-
// s = p1 + p2
mat_add(s, p1, p2);
-
// p3 = (c + d) * e
mat_add(t0, c, d);
mat_mul_strassen(p3, t0, e, n_min);
-
// p4 = d * (g - e)
mat_sub(t0, g, e);
mat_mul_strassen(p4, d, t0, n_min);
-
// t = p3 + p4
mat_add(t, p3, p4);
-
// tmp mat t1
mat_t* t1 = mat_alloc(0, 0, n, NULL);
mat_add(t0, a, d);
mat_add(t1, e, h);
mat_mul_strassen(p5, t0, t1, n_min);
-
//p6 = (b - d) * (g + h)
mat_sub(t0, b, d);
mat_add(t1, g, h);
mat_mul_strassen(p6, t0, t1, n_min);
-
// r = p5 + p4 - p2 + p6
mat_add(r, p5, p4);
mat_sub(r, r, p2);
mat_sub(t0, a, c);
mat_add(t1, e, f);
mat_mul_strassen(p7, t0, t1, n_min);
-
// u = p5 + p1 -p3 -p7
mat_add(u, p5, p1);
mat_sub(u, u, p3);
break;
};
+ printf("%s(), g_buf_size_max: %d\n", __func__, g_buf_size_max);
return 0;
}