| 18 | #include "GB_split.h" |
| 19 | |
| 20 | GrB_Info GB_split_sparse // split a sparse matrix |
| 21 | ( |
| 22 | GrB_Matrix *Tiles, // 2D row-major array of size m-by-n |
| 23 | const GrB_Index m, |
| 24 | const GrB_Index n, |
| 25 | const int64_t *restrict Tile_rows, // size m+1 |
| 26 | const int64_t *restrict Tile_cols, // size n+1 |
| 27 | const GrB_Matrix A, // input matrix |
| 28 | GB_Context Context |
| 29 | ) |
| 30 | { |
| 31 | |
| 32 | //-------------------------------------------------------------------------- |
| 33 | // get inputs |
| 34 | //-------------------------------------------------------------------------- |
| 35 | |
| 36 | GrB_Info info ; |
| 37 | int A_sparsity = GB_sparsity (A) ; |
| 38 | bool A_is_hyper = (A_sparsity == GxB_HYPERSPARSE) ; |
| 39 | ASSERT (A_is_hyper || A_sparsity == GxB_SPARSE) ; |
| 40 | GrB_Matrix C = NULL ; |
| 41 | GB_WERK_DECLARE (C_ek_slicing, int64_t) ; |
| 42 | ASSERT_MATRIX_OK (A, "A sparse for split", GB0) ; |
| 43 | |
| 44 | int sparsity_control = A->sparsity_control ; |
| 45 | float hyper_switch = A->hyper_switch ; |
| 46 | bool csc = A->is_csc ; |
| 47 | GrB_Type atype = A->type ; |
| 48 | // int64_t avlen = A->vlen ; |
| 49 | // int64_t avdim = A->vdim ; |
| 50 | size_t asize = atype->size ; |
| 51 | |
| 52 | GB_GET_NTHREADS_MAX (nthreads_max, chunk, Context) ; |
| 53 | |
| 54 | int64_t nouter = csc ? n : m ; |
| 55 | int64_t ninner = csc ? m : n ; |
| 56 | |
| 57 | const int64_t *Tile_vdim = csc ? Tile_cols : Tile_rows ; |
| 58 | const int64_t *Tile_vlen = csc ? Tile_rows : Tile_cols ; |
| 59 | |
| 60 | int64_t anvec = A->nvec ; |
| 61 | const int64_t *restrict Ap = A->p ; |
| 62 | const int64_t *restrict Ah = A->h ; |
| 63 | const int64_t *restrict Ai = A->i ; |
| 64 | const bool A_iso = A->iso ; |
| 65 | |
| 66 | //-------------------------------------------------------------------------- |
| 67 | // allocate workspace |
| 68 | //-------------------------------------------------------------------------- |
| 69 | |
| 70 | size_t Wp_size = 0 ; |
| 71 | int64_t *restrict Wp = NULL ; |
| 72 | Wp = GB_MALLOC_WORK (anvec, int64_t, &Wp_size) ; |
| 73 | if (Wp == NULL) |
| 74 | { |
| 75 | // out of memory |
| 76 | GB_FREE_ALL ; |
| 77 | return (GrB_OUT_OF_MEMORY) ; |
no test coverage detected