1 //------------------------------------------------------------------------------ 2 // GB_AxB_rowscale_meta: C=D*B where D is a square diagonal matrix 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 // All entries in C=D*B are computed entirely in parallel. 11 12 // B and C can be jumbled. D cannot, but it is a diagonal matrix so it is 13 // never jumbled. 14 15 { 16 17 //-------------------------------------------------------------------------- 18 // check inputs 19 //-------------------------------------------------------------------------- 20 21 // Bx is unused if the operator is FIRST or PAIR 22 #include "GB_unused.h" 23 24 ASSERT (GB_JUMBLED_OK (C)) ; 25 ASSERT (!GB_JUMBLED (D)) ; 26 ASSERT (GB_JUMBLED_OK (B)) ; 27 28 //-------------------------------------------------------------------------- 29 // get C, D, and B 30 //-------------------------------------------------------------------------- 31 32 const GB_ATYPE *restrict Dx = (GB_ATYPE *) (D_is_pattern ? NULL : D->x) ; 33 const GB_BTYPE *restrict Bx = (GB_BTYPE *) (B_is_pattern ? NULL : B->x) ; 34 const int64_t *restrict Bi = B->i ; 35 const int64_t bnz = GB_IS_FULL (B) ? GB_NNZ_FULL (B) : GB_NNZ (B) ; 36 const int64_t bvlen = B->vlen ; 37 38 //-------------------------------------------------------------------------- 39 // C=D*B 40 //-------------------------------------------------------------------------- 41 42 int ntasks = nthreads ; 43 ntasks = GB_IMIN (bnz, ntasks) ; 44 45 int tid ; 46 #pragma omp parallel for num_threads(nthreads) schedule(static) 47 for (tid = 0 ; tid < ntasks ; tid++) 48 { 49 int64_t pstart, pend ; 50 GB_PARTITION (pstart, pend, bnz, tid, ntasks) ; 51 GB_PRAGMA_SIMD_VECTORIZE 52 for (int64_t p = pstart ; p < pend ; p++) 53 { 54 int64_t i = GBI (Bi, p, bvlen) ; // get row index of B(i,j) 55 GB_GETA (dii, Dx, i) ; // dii = D(i,i) 56 GB_GETB (bij, Bx, p) ; // bij = B(i,j) 57 GB_BINOP (GB_CX (p), dii, bij, 0, 0) ; // C(i,j) = dii*bij 58 } 59 } 60 } 61 62