Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

query a matrix, vector, or scalar if GrB_wait will do anything to it #75

Open
DrTimothyAldenDavis opened this issue Jan 3, 2023 · 3 comments
Milestone

Comments

@DrTimothyAldenDavis
Copy link
Member

RedisGraph requires a method to query a matrix, vector, or scalar to see if it has any pending operations. That is, it returns true

Roi (@swilly22) has one solution: DrTimothyAldenDavis/GraphBLAS#172 . This proposed method has signature (for the GrB_Matrix case):

GrB_Info GxB_Matrix_pending (GrB_Matrix A, bool *has_pending_operations) ;

An alternative would be to include this query in GrB_get, as the _Generic signature:

GrB_Info GrB_get (GrB_Matrix A, GrB_Something whatever, bool *has_pending_operations) ;

where "whatever" would be an enum value like "GrB_PENDING" or "GrB_WILL_WAIT" or whatever.

Any thoughts? Can you consider this for the v2.1 C API?

@BenBrock
Copy link
Collaborator

BenBrock commented Jan 3, 2023

I think adding this functionality is a good idea. As I understand, what you're essentially asking is whether the function call GrB_Wait(A, GrB_COMPLETE) would return immediately?

Given the API already includes the term "complete" for this, you might also consider GrB_Is_complete or GrB_Is_ready as names.

Another bit of prior art to consider is the syntax used by futures, including C++'s std::future. std::future has wait and wait_for, which waits for a certain period of time. Many other C++ future implementations, including my BCL implementations, have is_ready() or check() methods that immediately return a boolean value.

@tgmattso
Copy link
Collaborator

tgmattso commented Jan 4, 2023 via email

@DrTimothyAldenDavis
Copy link
Member Author

GrB_MATERIALIZE, you mean? That's what I want to test. I want to query in O(1) time without any change to the matrix A if GrB_wait (A, GrB_MATERIALIZE) would do anything to the matrix A.

GrB_wait (A, GrB_COMPLETE) only means "A is ready to pass to another thread". It doesn't mean that A contains no pending work. Thread 1 can pass a matrix to thread 2, and safely leave work in the matrix A for thread 2 to do. That's what GrB_wait (A, GrB_COMPLETE), means, if thread 1 does it.

Currently, my GrB_wait (A, GrB_COMPLETE) only does one thing: #pragma omp flush. Nothing else.

I don't need a GrB_test_wait (A, GrB_COMPLETE), but I suppose that's useful. Better would be the syntax:

GrB_Info GrB_test_wait (GrB_Matrix A, GrB_WaitMode mode, bool &result) ;
and result would be true if GrB_wait (A, mode) would do nothing, or false if GrB_wait (A,mode) has work to do.

If there were a GrB_test_wait (A, GrB_COMPLETE, &result), then I guess I would have to keep track of whether or not #pragma omp flush has been on on the thread that wrote to the matrix? Seems awkward. I don't keep that state inside matrix.

@jim22k jim22k added the maybe This issue may be considered for the given milestone label Mar 29, 2023
@jim22k jim22k added this to the v2.1 milestone Mar 29, 2023
@jim22k jim22k modified the milestones: v2.1, v3.0 Jun 28, 2023
@jim22k jim22k removed the maybe This issue may be considered for the given milestone label Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants