@@ -100,6 +100,7 @@ GrB_Info matrix_clear_empty(Matrix *A, int8_t optimizations) {
100100 return matrix_clear_format (A , optimizations );
101101 }
102102
103+ CFL_matrix_update (A );
103104 if (A -> nvals == 0 ) {
104105 return GrB_SUCCESS ;
105106 }
@@ -127,6 +128,8 @@ GrB_Info matrix_dup_format(Matrix *output, Matrix *input, int8_t optimizations)
127128 }
128129
129130 if (!output -> is_both ) {
131+ CFL_matrix_update (output );
132+ CFL_matrix_update (input );
130133 Matrix * larger = output -> nvals > input -> nvals ? output : input ;
131134
132135 matrix_to_format (output , larger -> format , false);
@@ -151,6 +154,7 @@ GrB_Info matrix_dup_empty(Matrix *output, Matrix *input, int8_t optimizations) {
151154 return matrix_dup_format (output , input , optimizations );
152155 }
153156
157+ CFL_matrix_update (input );
154158 if (input -> nvals == 0 ) {
155159 return matrix_clear_empty (output , optimizations );
156160 }
@@ -197,6 +201,8 @@ GrB_Info block_matrix_hyper_rotate_i(Matrix *matrix, enum CFL_Matrix_block forma
197201 GrB_Scalar_new (& scalar_true , GrB_BOOL );
198202 GrB_Scalar_setElement_BOOL (scalar_true , true);
199203
204+ CFL_matrix_update (matrix );
205+
200206 if (matrix -> block_type == VEC_VERT ) {
201207 // fix: change to lagraph malloc
202208 GrB_Index * nrows = malloc (matrix -> nvals * sizeof (GrB_Index ));
@@ -254,6 +260,8 @@ void block_matrix_to_diag(Matrix *diag, Matrix *input) {
254260 GrB_Scalar_new (& scalar_true , GrB_BOOL );
255261 GrB_Scalar_setElement_BOOL (scalar_true , true);
256262
263+ CFL_matrix_update (input );
264+
257265 GrB_Index * rows = malloc (input -> nvals * sizeof (GrB_Index ));
258266 GrB_Index * cols = malloc (input -> nvals * sizeof (GrB_Index ));
259267 GrB_Matrix_extractTuples_BOOL (rows , cols , NULL , & input -> nvals , input -> base );
@@ -286,6 +294,8 @@ void block_matrix_reduce(Matrix *matrix, Matrix *input, int8_t optimizations) {
286294 GrB_Scalar_new (& scalar_true , GrB_BOOL );
287295 GrB_Scalar_setElement_BOOL (scalar_true , true);
288296
297+ CFL_matrix_update (input );
298+
289299 GrB_Index * rows = malloc (input -> nvals * sizeof (GrB_Index ));
290300 GrB_Index * cols = malloc (input -> nvals * sizeof (GrB_Index ));
291301 GrB_Matrix_extractTuples_BOOL (rows , cols , NULL , & input -> nvals , input -> base );
@@ -329,9 +339,12 @@ GrB_Info matrix_wise_empty(Matrix *output, Matrix *first, Matrix *second, bool a
329339GrB_Info matrix_sort_lazy (Matrix * A , bool reverse ) {
330340 for (size_t i = 0 ; i < A -> base_matrices_count ; i ++ ) {
331341 for (size_t j = i + 1 ; j < A -> base_matrices_count ; j ++ ) {
332- Matrix first = reverse ? A -> base_matrices [i ] : A -> base_matrices [j ];
333- Matrix second = reverse ? A -> base_matrices [j ] : A -> base_matrices [i ];
334- if (first .nvals < second .nvals ) {
342+ Matrix * first = reverse ? & A -> base_matrices [i ] : & A -> base_matrices [j ];
343+ Matrix * second = reverse ? & A -> base_matrices [j ] : & A -> base_matrices [i ];
344+ CFL_matrix_update (first );
345+ CFL_matrix_update (second );
346+
347+ if (first -> nvals < second -> nvals ) {
335348 Matrix temp = A -> base_matrices [i ];
336349 A -> base_matrices [i ] = A -> base_matrices [j ];
337350 A -> base_matrices [j ] = temp ;
@@ -363,6 +376,7 @@ GrB_Info matrix_combine_lazy(Matrix *A, size_t threshold, int8_t optimizations)
363376 matrix_sort_lazy (A , false);
364377
365378 for (size_t i = 0 ; i < A -> base_matrices_count ; i ++ ) {
379+ CFL_matrix_update (& A -> base_matrices [i ]);
366380 if (new_size == 0 || A -> base_matrices [i ].nvals > threshold ) {
367381 new_matrices [new_size ++ ] = A -> base_matrices [i ];
368382 continue ;
@@ -381,7 +395,6 @@ GrB_Info matrix_combine_lazy(Matrix *A, size_t threshold, int8_t optimizations)
381395}
382396
383397// create and update methods
384-
385398void CFL_matrix_update (Matrix * matrix ) {
386399 if (!matrix -> is_lazy ) {
387400 GrB_Matrix_nvals (& matrix -> nvals , matrix -> base );
@@ -483,6 +496,8 @@ GrB_Info matrix_mxm_format(Matrix *output, Matrix *first, Matrix *second, bool a
483496 return matrix_mxm (output , first , second , accum , swap );
484497 }
485498
499+ CFL_matrix_update (first );
500+ CFL_matrix_update (second );
486501 GrB_Index left_nvals = swap ? second -> nvals : first -> nvals ;
487502 GrB_Index right_nvals = swap ? first -> nvals : second -> nvals ;
488503
@@ -507,11 +522,15 @@ GrB_Info matrix_mxm_empty(Matrix *output, Matrix *first, Matrix *second, bool ac
507522 return matrix_mxm_format (output , first , second , accum , swap , optimizations );
508523 }
509524
525+ CFL_matrix_update (first );
526+ CFL_matrix_update (second );
527+
510528 if (first -> nvals == 0 || second -> nvals == 0 ) {
511529 if (accum ) {
512530 return GrB_SUCCESS ;
513531 }
514532
533+ CFL_matrix_update (output );
515534 if (output -> nvals == 0 ) {
516535 return GrB_SUCCESS ;
517536 }
@@ -532,6 +551,8 @@ GrB_Info matrix_mxm_lazy(Matrix *output, Matrix *first, Matrix *second, bool acc
532551 return matrix_mxm_empty (output , first , second , accum , swap , optimizations );
533552 }
534553
554+ CFL_matrix_update (second );
555+
535556 matrix_combine_lazy (first , second -> nvals , optimizations );
536557 matrix_sort_lazy (first , false);
537558
@@ -549,7 +570,9 @@ GrB_Info matrix_mxm_lazy(Matrix *output, Matrix *first, Matrix *second, bool acc
549570 }
550571
551572 for (size_t i = 0 ; i < first -> base_matrices_count ; i ++ ) {
573+ CFL_matrix_update (& acc_matrices [i ]);
552574 for (size_t j = i + 1 ; j < first -> base_matrices_count ; j ++ ) {
575+ CFL_matrix_update (& acc_matrices [j ]);
553576 if (acc_matrices [i ].nvals > acc_matrices [j ].nvals ) {
554577 Matrix temp = acc_matrices [i ];
555578 acc_matrices [i ] = acc_matrices [j ];
@@ -654,6 +677,10 @@ GrB_Info matrix_wise_format(Matrix *output, Matrix *first, Matrix *second, bool
654677 }
655678
656679 if (!output -> is_both ) {
680+ CFL_matrix_update (output );
681+ CFL_matrix_update (first );
682+ CFL_matrix_update (second );
683+
657684 Matrix * larger = output -> nvals > first -> nvals ? output : first ;
658685 larger = larger -> nvals > second -> nvals ? larger : second ;
659686
@@ -685,6 +712,10 @@ GrB_Info matrix_wise_empty(Matrix *output, Matrix *first, Matrix *second, bool a
685712 return matrix_wise_format (output , first , second , accum , optimizations );
686713 }
687714
715+ CFL_matrix_update (first );
716+ CFL_matrix_update (second );
717+ CFL_matrix_update (output );
718+
688719 if (output == first ) {
689720 if (first -> nvals == 0 ) {
690721 return matrix_dup_empty (first , second , optimizations );
@@ -754,6 +785,7 @@ GrB_Info matrix_wise_lazy(Matrix *output, Matrix *first, Matrix *second, bool ac
754785 bool found = false;
755786
756787 for (size_t i = 0 ; i < first -> base_matrices_count ; i ++ ) {
788+ CFL_matrix_update (& first -> base_matrices [i ]);
757789 size_t self_nvals =
758790 first -> base_matrices [i ].nvals >= 10 ? first -> base_matrices [i ].nvals : 10 ;
759791
@@ -846,6 +878,9 @@ GrB_Info matrix_rsub_format(Matrix *output, Matrix *mask, int8_t optimizations)
846878 return matrix_rsub (output , mask );
847879 }
848880
881+ CFL_matrix_update (output );
882+ CFL_matrix_update (mask );
883+
849884 Matrix * larger_matrix = output -> nvals > mask -> nvals ? output : mask ;
850885 matrix_to_format (output , larger_matrix -> format , false);
851886 matrix_to_format (mask , larger_matrix -> format , false);
@@ -872,6 +907,8 @@ GrB_Info matrix_rsub_empty(Matrix *output, Matrix *mask, int8_t optimizations) {
872907 return matrix_rsub_format (output , mask , optimizations );
873908 }
874909
910+ CFL_matrix_update (mask );
911+ CFL_matrix_update (output );
875912 if (mask -> nvals == 0 || output -> nvals == 0 ) {
876913 return GrB_SUCCESS ;
877914 }
@@ -888,6 +925,7 @@ GrB_Info matrix_rsub_lazy(Matrix *output, Matrix *mask, int8_t optimizations) {
888925 return matrix_rsub_empty (output , mask , optimizations );
889926 }
890927
928+ CFL_matrix_update (output );
891929 matrix_combine_lazy (mask , output -> nvals , optimizations );
892930 matrix_sort_lazy (mask , true);
893931
@@ -946,6 +984,7 @@ GrB_Info matrix_rsub_block(Matrix *output, Matrix *mask, int8_t optimizations) {
946984
947985// A = &temp;
948986// GxB_print(A->base, pr);
987+ // CFL_matrix_update(A);
949988// // printf("nnz: %ld\n", A->nvals);
950989// GrB_free(&_temp);
951990// }
0 commit comments