GraphBLAS / LAGraph

This is a library plus a test harness for collecting algorithms that use the GraphBLAS. For test coverage reports, see https://graphblas.org/LAGraph/ . Documentation: https://lagraph.readthedocs.org
Other
229 stars 61 forks source link

LAGraph_binwrite frees matrix #103

Closed szarnyasg closed 3 years ago

szarnyasg commented 3 years ago

~I noticed that LAGraph_binwrite frees the matrix after serializing it:~ https://github.com/GraphBLAS/LAGraph/blob/75ec0c86276901f105c84bc490f30166b40b608a/Experimental/Utility/LAGraph_binwrite.c#L46

~Is this the intended behaviour? It seems contradictory as the function re-imports the matrix after writing the binary output.~

I realized that the issue was in my code. The only slightly unexpected thing in the behaviour LAGraph_binwrite is that it changes the pointer due to the re-import.

DrTimothyAldenDavis commented 3 years ago

It doesn't free the matrix, unless an error occurs. The import/export acts like a C++ move constructor, taking O(1) time and space. So when the matrix is exported, the GrB_Matrix content is ripped out of the matrix, and the GrB_Matrix A is destroyed. Then the matrix is re-imported back into A (also taking O(1) time and space) after the contents are dumped to the file.

It's not ideal. A better method would allow GraphBLAS to serialize a GrB_Matrix and GrB_Vector (and even the GxB_Scalar), as a stream of bytes that the user application could do something with (send to a file, an MPI message, gzip, whatever). Then the matrix could be read-only.

On Sun, Nov 1, 2020 at 12:14 PM Gabor Szarnyas notifications@github.com wrote:

Closed #103 https://github.com/GraphBLAS/LAGraph/issues/103.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/GraphBLAS/LAGraph/issues/103#event-3945446052, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEYIIOO5G4ZGWFNXMDBXJ73SNWQP7ANCNFSM4TGT2KZA .