1 //------------------------------------------------------------------------------
2 // GrB_Matrix_wait: wait for a matrix to complete
3 //------------------------------------------------------------------------------
4 
5 // SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
6 // SPDX-License-Identifier: Apache-2.0
7 
8 //------------------------------------------------------------------------------
9 
10 // Finishes all work on a matrix, followed by an OpenMP flush.
11 
12 #include "GB.h"
13 
14 #define GB_FREE_ALL ;
15 
GrB_Matrix_wait(GrB_Matrix * A)16 GrB_Info GrB_Matrix_wait    // finish all work on a matrix
17 (
18     GrB_Matrix *A
19 )
20 {
21 
22     //--------------------------------------------------------------------------
23     // check inputs
24     //--------------------------------------------------------------------------
25 
26     #pragma omp flush
27     GB_WHERE ((*A), "GrB_Matrix_wait (&A)") ;
28     GB_RETURN_IF_NULL (A) ;
29     GB_RETURN_IF_NULL_OR_FAULTY (*A) ;
30 
31     //--------------------------------------------------------------------------
32     // finish all pending work on the matrix
33     //--------------------------------------------------------------------------
34 
35     if (GB_ANY_PENDING_WORK (*A))
36     {
37         GrB_Info info ;
38         GB_BURBLE_START ("GrB_Matrix_wait") ;
39         GB_OK (GB_Matrix_wait (*A, "matrix", Context)) ;
40         GB_BURBLE_END ;
41     }
42 
43     //--------------------------------------------------------------------------
44     // return result
45     //--------------------------------------------------------------------------
46 
47     #pragma omp flush
48     return (GrB_SUCCESS) ;
49 }
50 
51