1 //------------------------------------------------------------------------------ 2 // GB_dense_ewise3_accum_template: C += A+B where all 3 matrices are dense 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 { 11 12 //-------------------------------------------------------------------------- 13 // get A, B, and C 14 //-------------------------------------------------------------------------- 15 16 // any matrix may be aliased to any other (C==A, C==B, and/or A==B) 17 GB_ATYPE *Ax = (GB_ATYPE *) A->x ; 18 GB_BTYPE *Bx = (GB_BTYPE *) B->x ; 19 GB_CTYPE *Cx = (GB_CTYPE *) C->x ; 20 const int64_t cnz = GB_NNZ (C) ; 21 int64_t p ; 22 23 //-------------------------------------------------------------------------- 24 // C += A+B where all 3 matries are dense 25 //-------------------------------------------------------------------------- 26 27 if (A == B) 28 { 29 30 //---------------------------------------------------------------------- 31 // C += A+A where A and C are dense 32 //---------------------------------------------------------------------- 33 34 // C += A+A 35 #pragma omp parallel for num_threads(nthreads) schedule(static) 36 for (p = 0 ; p < cnz ; p++) 37 { 38 GB_GETA (aij, Ax, p) ; // aij = Ax [p] 39 GB_CTYPE_SCALAR (t) ; // declare scalar t 40 GB_BINOP (t, aij, aij, 0, 0) ; // t = aij + aij 41 GB_BINOP (GB_CX (p), GB_CX (p), t, 0, 0) ; // Cx [p] = cij + t 42 } 43 44 } 45 else 46 { 47 48 //---------------------------------------------------------------------- 49 // C += A+B where all 3 matrices are dense 50 //---------------------------------------------------------------------- 51 52 #pragma omp parallel for num_threads(nthreads) schedule(static) 53 for (p = 0 ; p < cnz ; p++) 54 { 55 GB_GETA (aij, Ax, p) ; // aij = Ax [p] 56 GB_GETB (bij, Bx, p) ; // bij = Bx [p] 57 GB_CTYPE_SCALAR (t) ; // declare scalar t 58 GB_BINOP (t, aij, bij, 0, 0) ; // t = aij + bij 59 GB_BINOP (GB_CX (p), GB_CX (p), t, 0, 0) ; // Cx [p] = cij + t 60 } 61 } 62 } 63 64