Repository navigation
Conversation
| GRB_TRY(GrB_eWiseAdd(K, GrB_NULL, GrB_NULL, GrB_LOR, K, next_frontier, GrB_NULL)); | ||
| GRB_TRY(GrB_Matrix_nvals(&states, next_frontier)); | ||
|
|
||
| if (iteration > 3000) |
There was a problem hiding this comment.
I agree that this line of code at least deserves a named #defined or a constant MAX_ITERATIONS at the beginning of the file :)
This comment was marked as outdated.
This comment was marked as outdated.
Matrix reshape from |V|*|V| to 1*|V*V| triggered 32-bit indexing overflow when V*V > 2^32. The library correctly detects potential overflow (Cj_is_32=false), but the in-place reshape operation (in_place=true) inherits T->j_is_32=true from the original matrix, causing J_work_is_32 to become true and overflow to occur. Solution: use matrix_reshape_dup instead of matrix_reshape to create a new matrix (in_place=false), so J_work_is_32 correctly evaluates to false and 64-bit indexing is used.
This comment was marked as outdated.
This comment was marked as outdated.
|
Algorithm: |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
Experiment's design and result: |
Replace the reshapeDup/free helper with in-place GxB_Matrix_reshape and pass GrB_Matrix handles directly instead of GrB_Matrix pointers.
Accumulate W = R_A^T * P per nonterminal instead of recomputing it in Phase 4.
…matrix Replace M_term/M_nonterm/M_return with a single |Q*V|*|V| accumulator, reshaped once per iteration instead of per product.
| for (size_t i = 0; i < num_terminals; ++i) | ||
| if (G_a[i] != GrB_NULL) | ||
| LG_TRY(LAGraph_CheckGraph(G_a[i], msg)) | ||
|
|
||
| for (size_t i = 0; i < num_terminals; ++i) | ||
| if (N_a[i] != GrB_NULL) | ||
| LG_TRY(LAGraph_CheckGraph(N_a[i], msg)) | ||
|
|
||
| for (size_t i = 0; i < num_nonterminals; ++i) | ||
| if (N_S[i] != GrB_NULL) | ||
| LG_TRY(LAGraph_CheckGraph(N_S[i], msg)) | ||
|
|
||
| for (size_t i = 0; i < num_nonterminals; ++i) | ||
| if (Call_S[i] != GrB_NULL) | ||
| LG_TRY(LAGraph_CheckGraph(Call_S[i], msg)) | ||
|
|
||
| for (size_t i = 0; i < num_nonterminals; ++i) | ||
| if (Ret_S[i] != GrB_NULL) | ||
| LG_TRY(LAGraph_CheckGraph(Ret_S[i], msg)) | ||
|
|
||
| LG_TRY(LAGraph_Malloc((void **)&A_a, num_terminals, sizeof(GrB_Matrix), msg)) | ||
| for (size_t i = 0; i < num_terminals; ++i) | ||
| { | ||
| if (G_a[i] == GrB_NULL) | ||
| A_a[i] = GrB_NULL; | ||
| else | ||
| A_a[i] = G_a[i]->A; | ||
| } | ||
| LG_TRY(LAGraph_Malloc((void **)&B_a, num_terminals, sizeof(GrB_Matrix), msg)) | ||
| for (size_t i = 0; i < num_terminals; ++i) | ||
| { | ||
| if (N_a[i] == GrB_NULL) | ||
| B_a[i] = GrB_NULL; | ||
| else | ||
| B_a[i] = N_a[i]->A; | ||
| } | ||
| LG_TRY(LAGraph_Malloc((void **)&B_S, num_nonterminals, sizeof(GrB_Matrix), msg)) | ||
| for (size_t i = 0; i < num_nonterminals; ++i) | ||
| { | ||
| if (N_S[i] == GrB_NULL) | ||
| B_S[i] = GrB_NULL; | ||
| else | ||
| B_S[i] = N_S[i]->A; | ||
| } | ||
| LG_TRY(LAGraph_Malloc((void **)&B_call, num_nonterminals, sizeof(GrB_Matrix), msg)) | ||
| for (size_t i = 0; i < num_nonterminals; ++i) | ||
| { | ||
| if (Call_S[i] == GrB_NULL) | ||
| B_call[i] = GrB_NULL; | ||
| else | ||
| B_call[i] = Call_S[i]->A; | ||
| } | ||
| LG_TRY(LAGraph_Malloc((void **)&B_ret, num_nonterminals, sizeof(GrB_Matrix), msg)) | ||
| for (size_t i = 0; i < num_nonterminals; ++i) | ||
| { | ||
| if (Ret_S[i] == GrB_NULL) | ||
| B_ret[i] = GrB_NULL; | ||
| else | ||
| B_ret[i] = Ret_S[i]->A; | ||
| } |
There was a problem hiding this comment.
Nit: that's a huge amount of work for (almost) the same code! Can we add a #define macro that would, basically, 1) verify the graph, 2) extract matrices out of it, 70 lines of code is quite a few.
| if (B_ret[i] == GrB_NULL || B_call[i] == GrB_NULL || B_S[i] == GrB_NULL) | ||
| continue; | ||
|
|
||
| GRB_TRY(GrB_Matrix_clear(M_ret)); |
There was a problem hiding this comment.
No need for a separate Matrix_clear call: just use GrB_DESC_RT0 (add R) on line 536. R means "replace".
There was a problem hiding this comment.
Same for the next line, use GrB_DESC_RS on line 545 instead.
There was a problem hiding this comment.
Ok, I think it is a general recommendation for all the clear()'s in the main procedure.
This patch implements a context-free path query algorithm using recursive state machines (RSMs) over edge-labeled directed graphs. It extends the approach of the previously unified regular path search algorithm by using linear algebra operations on adjacency matrices, as presented in https://arxiv.org/abs/2412.10287.