1 //------------------------------------------------------------------------------ 2 // GB_bitmap_assign_M_sub_template: traverse M for GB_SUBASSIGN 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 // M is sparse or hypersparse, not bitmap or full. C(I,J)<M>= ... is being 11 // computed (or !M), and all entries in M are traversed. For a given entry 12 // M(iM,jM) in the mask, at location pM. The entry C(iC,jC) is at location pC, 13 // where iC = I [iM] and jC = J [jM]. The matrix C is bitmap or full. 14 15 // C is bitmap/full. M is sparse/hyper, and can be jumbled. 16 17 { 18 const int64_t *restrict kfirst_Mslice = M_ek_slicing ; 19 const int64_t *restrict klast_Mslice = M_ek_slicing + M_ntasks ; 20 const int64_t *restrict pstart_Mslice = M_ek_slicing + M_ntasks * 2 ; 21 22 int tid ; 23 #pragma omp parallel for num_threads(M_nthreads) schedule(dynamic,1) \ 24 reduction(+:cnvals) 25 for (tid = 0 ; tid < M_ntasks ; tid++) 26 { 27 int64_t kfirst = kfirst_Mslice [tid] ; 28 int64_t klast = klast_Mslice [tid] ; 29 int64_t task_cnvals = 0 ; 30 31 //---------------------------------------------------------------------- 32 // traverse over M (:,kfirst:klast) 33 //---------------------------------------------------------------------- 34 35 for (int64_t k = kfirst ; k <= klast ; k++) 36 { 37 38 //------------------------------------------------------------------ 39 // find the part of M(:,k) for this task 40 //------------------------------------------------------------------ 41 42 int64_t jM = GBH (Mh, k) ; 43 int64_t pM_start, pM_end ; 44 GB_get_pA (&pM_start, &pM_end, tid, k, kfirst, 45 klast, pstart_Mslice, Mp, mvlen) ; 46 47 //------------------------------------------------------------------ 48 // traverse over M(:,jM), the kth vector of M 49 //------------------------------------------------------------------ 50 51 // for subassign, M has same size as C(I,J) and A. 52 int64_t jC = GB_ijlist (J, jM, Jkind, Jcolon) ; 53 int64_t pC0 = jC * cvlen ; 54 55 for (int64_t pM = pM_start ; pM < pM_end ; pM++) 56 { 57 bool mij = GB_mcast (Mx, pM, msize) ; 58 if (mij) 59 { 60 int64_t iM = Mi [pM] ; 61 int64_t iC = GB_ijlist (I, iM, Ikind, Icolon) ; 62 int64_t pC = iC + pC0 ; 63 GB_MASK_WORK (pC) ; // operate on Cx [pC] 64 } 65 } 66 } 67 cnvals += task_cnvals ; 68 } 69 } 70 71