Skip to content

Commit 342bcbf

Browse files
committed
some clean up
1 parent 1ef408a commit 342bcbf

45 files changed

Lines changed: 170 additions & 191 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

include/expr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ typedef struct expr
6363
// general quantities
6464
// ------------------------------------------------------------------------
6565
int d1, d2, size, n_vars, refcount, var_id;
66-
size_t memory_bytes;
66+
size_t bytes;
6767
bool visited;
6868
struct expr *left;
6969
struct expr *right;

include/problem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ typedef struct
3838
int nnz_hessian;
3939
int n_vars;
4040
int total_constraint_size;
41-
size_t memory_bytes;
41+
size_t bytes;
4242
} Diff_engine_stats;
4343

4444
typedef struct problem

include/utils/COO_Matrix.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ void free_coo_matrix(COO_Matrix *matrix);
4343

4444
/* Returns total bytes used by rows, cols, x, value_map arrays
4545
(0 if A is NULL) */
46-
size_t coo_memory_bytes(const COO_Matrix *A);
46+
size_t coo_bytes(const COO_Matrix *A);
4747

4848
#endif /* COO_MATRIX_H */

include/utils/CSC_Matrix.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ CSR_Matrix *csc_to_csr_alloc(const CSC_Matrix *A, int *iwork, size_t *mem);
6363
void csc_to_csr_fill_values(const CSC_Matrix *A, CSR_Matrix *C, int *iwork);
6464

6565
/* Returns total bytes used by p, i, x arrays (0 if A is NULL) */
66-
size_t csc_memory_bytes(const CSC_Matrix *A);
66+
size_t csc_bytes(const CSC_Matrix *A);
6767

6868
#endif /* CSC_MATRIX_H */

include/utils/CSR_Matrix.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void insert_idx(int idx, int *arr, int len);
5252
double csr_get_value(const CSR_Matrix *A, int row, int col);
5353

5454
/* Returns total bytes used by p, i, x arrays (0 if A is NULL) */
55-
size_t csr_memory_bytes(const CSR_Matrix *A);
55+
size_t csr_bytes(const CSR_Matrix *A);
5656

5757
/* Expand symmetric CSR matrix A to full matrix C. A is assumed to store
5858
only upper triangle. C must be pre-allocated with sufficient nnz */

include/utils/linalg_dense_sparse_matmuls.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/* C = (I_p kron A) @ J via the polymorphic Matrix interface.
99
* A is dense m x n, J is (n*p) x k in CSC, C is (m*p) x k in CSC. */
1010
// TODO: maybe we can replace these with I_kron_X functionality?
11-
CSC_Matrix *I_kron_A_alloc(const Matrix *A, const CSC_Matrix *J, int p);
11+
CSC_Matrix *I_kron_A_alloc(const Matrix *A, const CSC_Matrix *J, int p, size_t *mem);
1212
void I_kron_A_fill_values(const Matrix *A, const CSC_Matrix *J, CSC_Matrix *C);
1313

1414
/* Sparsity and values of C = (Y^T kron I_m) @ J where Y is k x n, J is (m*k) x p,

include/utils/linalg_sparse_matmuls.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
* Mathematically it corresponds to C = [A @ J1; A @ J2; ...; A @ Jp],
1515
where J = [J1; J2; ...; Jp]
1616
*/
17-
CSC_Matrix *block_left_multiply_fill_sparsity(const CSR_Matrix *A,
18-
const CSC_Matrix *J, int p);
17+
CSC_Matrix *block_left_multiply_alloc(const CSR_Matrix *A, const CSC_Matrix *J,
18+
int p, size_t *mem);
1919

2020
void block_left_multiply_fill_values(const CSR_Matrix *A, const CSC_Matrix *J,
2121
CSC_Matrix *C);

include/utils/matrix.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ typedef struct Matrix
2828
void (*block_left_mult_vec)(const struct Matrix *self, const double *x,
2929
double *y, int p);
3030
CSC_Matrix *(*block_left_mult_sparsity)(const struct Matrix *self,
31-
const CSC_Matrix *J, int p);
31+
const CSC_Matrix *J, int p, size_t *mem);
3232
void (*block_left_mult_values)(const struct Matrix *self, const CSC_Matrix *J,
3333
CSC_Matrix *C);
3434
void (*free_fn)(struct Matrix *self);

src/atoms/affine/add.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ static void jacobian_init_impl(expr *node)
4242

4343
/* we never have to store more than the sum of children's nnz */
4444
int nnz_max = node->left->jacobian->nnz + node->right->jacobian->nnz;
45-
node->jacobian =
46-
new_csr_matrix(node->size, node->n_vars, nnz_max, &node->memory_bytes);
45+
node->jacobian = new_csr_matrix(node->size, node->n_vars, nnz_max, &node->bytes);
4746

4847
/* fill sparsity pattern */
4948
sum_csr_alloc(node->left->jacobian, node->right->jacobian, node->jacobian);
@@ -68,7 +67,7 @@ static void wsum_hess_init_impl(expr *node)
6867
/* we never have to store more than the sum of children's nnz */
6968
int nnz_max = node->left->wsum_hess->nnz + node->right->wsum_hess->nnz;
7069
node->wsum_hess =
71-
new_csr_matrix(node->n_vars, node->n_vars, nnz_max, &node->memory_bytes);
70+
new_csr_matrix(node->n_vars, node->n_vars, nnz_max, &node->bytes);
7271

7372
/* fill sparsity pattern of hessian */
7473
sum_csr_alloc(node->left->wsum_hess, node->right->wsum_hess, node->wsum_hess);

src/atoms/affine/broadcast.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static void jacobian_init_impl(expr *node)
9393
}
9494

9595
node->jacobian =
96-
new_csr_matrix(node->size, node->n_vars, total_nnz, &node->memory_bytes);
96+
new_csr_matrix(node->size, node->n_vars, total_nnz, &node->bytes);
9797

9898
// ---------------------------------------------------------------------
9999
// fill sparsity pattern
@@ -192,11 +192,11 @@ static void wsum_hess_init_impl(expr *node)
192192
wsum_hess_init(x);
193193

194194
/* Same sparsity as child - weights get summed */
195-
node->wsum_hess = new_csr_copy_sparsity(x->wsum_hess, &node->memory_bytes);
195+
node->wsum_hess = new_csr_copy_sparsity(x->wsum_hess, &node->bytes);
196196

197197
/* allocate space for weight vector */
198198
node->work->dwork = malloc(node->size * sizeof(double));
199-
node->memory_bytes += node->size * sizeof(double);
199+
node->bytes += node->size * sizeof(double);
200200
}
201201

202202
static void eval_wsum_hess(expr *node, const double *w)

0 commit comments

Comments
 (0)