@@ -156,7 +156,16 @@ typedef struct Matrix {
156
156
} Matrix ;
157
157
158
158
void matrix_update (Matrix * matrix ) {
159
- GrB_Matrix_nvals (& matrix -> nvals , matrix -> base );
159
+ if (matrix -> base_matrices_count == 0 ) {
160
+ GrB_Matrix_nvals (& matrix -> nvals , matrix -> base );
161
+ } else {
162
+ size_t new_nnz = 0 ;
163
+ for (size_t i = 0 ; i < matrix -> base_matrices_count ; i ++ ) {
164
+ new_nnz += matrix -> base_matrices [i ].nvals ;
165
+ }
166
+
167
+ matrix -> nvals = new_nnz ;
168
+ }
160
169
GrB_Matrix_nrows (& matrix -> size , matrix -> base );
161
170
// GrB_get(matrix->base, &matrix->format, GrB_STORAGE_ORIENTATION_HINT);
162
171
}
@@ -166,7 +175,7 @@ Matrix matrix_from_base(GrB_Matrix matrix) {
166
175
result .base = matrix ;
167
176
result .base_row = matrix ;
168
177
result .base_col = NULL ;
169
- result .base_matrices = malloc (sizeof (Matrix ) * 10 );
178
+ result .base_matrices = malloc (sizeof (Matrix ) * 40 );
170
179
result .base_matrices_count = 0 ;
171
180
result .nvals = 0 ;
172
181
result .size = 0 ;
@@ -346,6 +355,10 @@ GrB_Info matrix_mxm_lazy(Matrix *output, Matrix *first, Matrix *second, bool acc
346
355
matrix_wise_empty (& acc_matrix , & acc_matrix , & acc_matrices [i ], false);
347
356
}
348
357
358
+ if (accum ) {
359
+ return matrix_wise_empty (output , output , & acc_matrix , false);
360
+ }
361
+
349
362
return matrix_dup_empty (output , & acc_matrix );
350
363
}
351
364
@@ -520,7 +533,8 @@ void matrix_print_lazy(Matrix *A) {
520
533
matrix_wise_empty (& temp , & temp , & A -> base_matrices [i ], false);
521
534
}
522
535
523
- GxB_print (temp .base , 1 );
536
+ A = & temp ;
537
+ GxB_print (A -> base , 1 );
524
538
}
525
539
526
540
// LAGraph_CFL_reachability: Context-Free Language Reachability Matrix-Based Algorithm
@@ -842,6 +856,9 @@ GrB_Info LAGraph_CFL_reachability_adv(
842
856
Matrix * C = & temp_matrices [bin_rule .nonterm ];
843
857
844
858
mxm (C , A , B , false, false);
859
+ // matrix_print_lazy(A);
860
+ // matrix_print_lazy(B);
861
+ // matrix_print_lazy(C);
845
862
}
846
863
TIMER_STOP ("MXM 1" , & mxm1 );
847
864
@@ -851,6 +868,8 @@ GrB_Info LAGraph_CFL_reachability_adv(
851
868
Matrix * C = & matrices [i ];
852
869
853
870
wise (C , C , A , false);
871
+ // matrix_print_lazy(A);
872
+ // matrix_print_lazy(C);
854
873
}
855
874
TIMER_STOP ("WISE 1" , & wise1 );
856
875
@@ -860,8 +879,11 @@ GrB_Info LAGraph_CFL_reachability_adv(
860
879
Matrix * A = & matrices [bin_rule .prod_B ];
861
880
Matrix * B = & delta_matrices [bin_rule .prod_A ];
862
881
Matrix * C = & temp_matrices [bin_rule .nonterm ];
863
-
882
+ // printf("ITER: %ld\n", i);
864
883
mxm (C , A , B , true, true);
884
+ // matrix_print_lazy(A);
885
+ // matrix_print_lazy(B);
886
+ // matrix_print_lazy(C);
865
887
}
866
888
TIMER_STOP ("MXM 2" , & mxm2 );
867
889
@@ -877,6 +899,8 @@ GrB_Info LAGraph_CFL_reachability_adv(
877
899
Matrix * C = & delta_matrices [i ];
878
900
879
901
rsub (C , A );
902
+ // matrix_print_lazy(A);
903
+ // matrix_print_lazy(C);
880
904
}
881
905
TIMER_STOP ("WISE 3 (MASK)" , & rsubt );
882
906
@@ -915,7 +939,20 @@ GrB_Info LAGraph_CFL_reachability_adv(
915
939
#endif
916
940
917
941
for (int32_t i = 0 ; i < nonterms_count ; i ++ ) {
918
- outputs [i ] = matrices [i ].base ;
942
+ if (matrices [i ].base_matrices_count == 0 ) {
943
+ outputs [i ] = matrices [i ].base ;
944
+ } else {
945
+ GrB_Matrix _acc ;
946
+ GrB_Matrix_new (& _acc , GrB_BOOL , matrices [i ].size , matrices [i ].size );
947
+ Matrix acc = matrix_from_base (_acc );
948
+
949
+ for (size_t j = 0 ; j < matrices [i ].base_matrices_count ; j ++ ) {
950
+ matrix_wise_empty (& acc , & acc , & matrices [i ].base_matrices [j ], false);
951
+ }
952
+
953
+ outputs [i ] = acc .base ;
954
+ }
955
+ // outputs[i] = matrices[i].base;
919
956
}
920
957
921
958
LG_FREE_WORK ;
0 commit comments