1 //------------------------------------------------------------------------------ 2 // GB_masker_template: R = masker (C, M, Z) 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 // Computes C<M>=Z or C<!M>=Z, returning the result in R. The input matrix C 11 // is not modified. Effectively, this computes R=C and then R<M>=Z or R<!M>=Z. 12 // If the C_replace descriptor is enabled, then C has already been cleared, and 13 // is an empty (but non-NULL) matrix. 14 15 // phase1: does not compute R itself, but just counts the # of entries in each 16 // vector of R. Fine tasks compute the # of entries in their slice of a 17 // single vector of R, and the results are cumsum'd. 18 19 // phase2: computes R, using the counts computed by phase1. 20 21 // FUTURE:: add special cases for C==Z, C==M, and Z==M aliases 22 23 { 24 25 //-------------------------------------------------------------------------- 26 // get C, Z, M, and R 27 //-------------------------------------------------------------------------- 28 29 int taskid ; 30 31 const int64_t *restrict Cp = C->p ; 32 const int64_t *restrict Ch = C->h ; 33 const int8_t *restrict Cb = C->b ; 34 const int64_t *restrict Ci = C->i ; 35 const int64_t vlen = C->vlen ; 36 const bool C_is_hyper = GB_IS_HYPERSPARSE (C) ; 37 const bool C_is_sparse = GB_IS_SPARSE (C) ; 38 const bool C_is_bitmap = GB_IS_BITMAP (C) ; 39 const bool C_is_full = GB_IS_FULL (C) ; 40 int C_nthreads, C_ntasks ; 41 42 const int64_t *restrict Zp = Z->p ; 43 const int64_t *restrict Zh = Z->h ; 44 const int8_t *restrict Zb = Z->b ; 45 const int64_t *restrict Zi = Z->i ; 46 const bool Z_is_hyper = GB_IS_HYPERSPARSE (Z) ; 47 const bool Z_is_sparse = GB_IS_SPARSE (Z) ; 48 const bool Z_is_bitmap = GB_IS_BITMAP (Z) ; 49 const bool Z_is_full = GB_IS_FULL (Z) ; 50 int Z_nthreads, Z_ntasks ; 51 52 const int64_t *restrict Mp = NULL ; 53 const int64_t *restrict Mh = NULL ; 54 const int8_t *restrict Mb = NULL ; 55 const int64_t *restrict Mi = NULL ; 56 const GB_void *restrict Mx = NULL ; 57 const bool M_is_hyper = GB_IS_HYPERSPARSE (M) ; 58 const bool M_is_sparse = GB_IS_SPARSE (M) ; 59 const bool M_is_bitmap = GB_IS_BITMAP (M) ; 60 const bool M_is_full = GB_IS_FULL (M) ; 61 const bool M_is_sparse_or_hyper = M_is_sparse || M_is_hyper ; 62 int M_nthreads, M_ntasks ; 63 size_t msize = 0 ; 64 if (M != NULL) 65 { 66 Mp = M->p ; 67 Mh = M->h ; 68 Mb = M->b ; 69 Mi = M->i ; 70 Mx = (GB_void *) (Mask_struct ? NULL : (M->x)) ; 71 msize = M->type->size ; 72 } 73 74 #if defined ( GB_PHASE_2_OF_2 ) 75 const GB_void *restrict Cx = (GB_void *) C->x ; 76 const GB_void *restrict Zx = (GB_void *) Z->x ; 77 const int64_t *restrict Rp = R->p ; 78 const int64_t *restrict Rh = R->h ; 79 int8_t *restrict Rb = R->b ; 80 int64_t *restrict Ri = R->i ; 81 GB_void *restrict Rx = (GB_void *) R->x ; 82 size_t rsize = R->type->size ; 83 // when R is bitmap or full: 84 const int64_t rnz = GB_NNZ_HELD (R) ; 85 GB_GET_NTHREADS_MAX (nthreads_max, chunk, Context) ; 86 #endif 87 88 //-------------------------------------------------------------------------- 89 // 90 //-------------------------------------------------------------------------- 91 92 #if defined ( GB_PHASE_1_OF_2 ) 93 94 // phase1 95 #include "GB_sparse_masker_template.c" 96 97 #else 98 99 // phase2 100 if (R_sparsity == GxB_SPARSE || R_sparsity == GxB_HYPERSPARSE) 101 { 102 // R is sparse or hypersparse (phase1 and phase2) 103 #include "GB_sparse_masker_template.c" 104 } 105 else // R_sparsity == GxB_BITMAP 106 { 107 // R is bitmap (phase2 only) 108 ASSERT (R_sparsity == GxB_BITMAP) ; 109 #include "GB_bitmap_masker_template.c" 110 } 111 112 #endif 113 } 114 115