| 57 | #include "GB_atomics.h" |
| 58 | |
| 59 | GB_PUBLIC |
| 60 | GrB_Info GB_wait // finish all pending computations |
| 61 | ( |
| 62 | GrB_Matrix A, // matrix with pending computations |
| 63 | const char *name, // name of the matrix |
| 64 | GB_Context Context |
| 65 | ) |
| 66 | { |
| 67 | |
| 68 | //-------------------------------------------------------------------------- |
| 69 | // check inputs |
| 70 | //-------------------------------------------------------------------------- |
| 71 | |
| 72 | GrB_Info info = GrB_SUCCESS ; |
| 73 | struct GB_Matrix_opaque T_header, A1_header, S_header ; |
| 74 | GrB_Matrix T = NULL, A1 = NULL, S = NULL, Y = NULL ; |
| 75 | |
| 76 | ASSERT_MATRIX_OK (A, "A to wait", GB_FLIP (GB0)) ; |
| 77 | |
| 78 | if (GB_IS_FULL (A) || GB_IS_BITMAP (A)) |
| 79 | { |
| 80 | // full and bitmap matrices never have any pending work |
| 81 | ASSERT (!GB_ZOMBIES (A)) ; |
| 82 | ASSERT (!GB_JUMBLED (A)) ; |
| 83 | ASSERT (!GB_PENDING (A)) ; |
| 84 | ASSERT (A->nvec_nonempty >= 0) ; |
| 85 | // ensure the matrix is written to memory |
| 86 | #pragma omp flush |
| 87 | return (GrB_SUCCESS) ; |
| 88 | } |
| 89 | |
| 90 | // only sparse and hypersparse matrices can have pending work |
| 91 | ASSERT (GB_IS_SPARSE (A) || GB_IS_HYPERSPARSE (A)) ; |
| 92 | ASSERT (GB_ZOMBIES_OK (A)) ; |
| 93 | ASSERT (GB_JUMBLED_OK (A)) ; |
| 94 | ASSERT (GB_PENDING_OK (A)) ; |
| 95 | |
| 96 | //-------------------------------------------------------------------------- |
| 97 | // get the zombie and pending count, and burble if work needs to be done |
| 98 | //-------------------------------------------------------------------------- |
| 99 | |
| 100 | int64_t nzombies = A->nzombies ; |
| 101 | int64_t npending = GB_Pending_n (A) ; |
| 102 | const bool A_iso = A->iso ; |
| 103 | if (nzombies > 0 || npending > 0 || A->jumbled || A->nvec_nonempty < 0) |
| 104 | { |
| 105 | GB_BURBLE_MATRIX (A, "(%swait:%s " GBd " %s, " GBd " pending%s%s) ", |
| 106 | A_iso ? "iso " : "", name, nzombies, |
| 107 | (nzombies == 1) ? "zombie" : "zombies", npending, |
| 108 | A->jumbled ? ", jumbled" : "", |
| 109 | A->nvec_nonempty < 0 ? ", nvec" : "") ; |
| 110 | } |
| 111 | |
| 112 | //-------------------------------------------------------------------------- |
| 113 | // determine the max # of threads to use |
| 114 | //-------------------------------------------------------------------------- |
| 115 | |
| 116 | GB_GET_NTHREADS_MAX (nthreads_max, chunk, Context) ; |
nothing calls this directly
no test coverage detected