File: GB_bitmap_assign_C_template.c

package info (click to toggle)
suitesparse 1%3A7.10.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 254,920 kB
  • sloc: ansic: 1,134,743; cpp: 46,133; makefile: 4,875; fortran: 2,087; java: 1,826; sh: 996; ruby: 725; python: 495; asm: 371; sed: 166; awk: 44
file content (120 lines) | stat: -rw-r--r-- 4,694 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//------------------------------------------------------------------------------
// GB_bitmap_assign_C_template: iterate over a bitmap matrix C
//------------------------------------------------------------------------------

// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2025, All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

//------------------------------------------------------------------------------

// The #include'ing file defines a GB_CIJ_WORK macro for the body of the loop,
// which operates on the entry C(iC,jC) at position Cx [pC] and Cb [pC].  The C
// matrix held in bitmap form.  If the mask matrix is also a bitmap matrix or
// full matrix, the GB_GET_MIJ macro can compute the effective value of the
// mask for the C(iC,jC) entry.

// C must be bitmap or full.  If M is accessed, it must also be bitmap or full.

#ifndef GB_GET_MIJ
#define GB_GET_MIJ(mij,pM) ;
#endif

{
    switch (assign_kind)
    {

        //----------------------------------------------------------------------
        // row assignment: C<M'>(iC,:), M is a column vector
        //----------------------------------------------------------------------

        case GB_ROW_ASSIGN : 
        {
            // iterate over all of C(iC,:)
            const int64_t iC = GB_IGET (I, 0) ;
            const int nthreads = GB_nthreads (Cvdim, chunk, nthreads_max) ;
            int tid ;
            #pragma omp parallel for num_threads(nthreads) schedule(static) \
                reduction(+:cnvals)
            for (tid = 0 ; tid < nthreads ; tid++)
            {
                int64_t jC_start, jC_end, task_cnvals = 0 ;
                GB_PARTITION (jC_start, jC_end, Cvdim, tid, nthreads) ;
                for (int64_t jC = jC_start ; jC < jC_end ; jC++)
                { 
                    int64_t pC = iC + jC * Cvlen ;
                    GB_GET_MIJ (mij, jC) ;          // mij = Mask (jC)
                    GB_CIJ_WORK (pC) ;              // operate on C(iC,jC)
                }
                #ifndef GB_NO_CNVALS
                cnvals += task_cnvals ;
                #endif
            }
        }
        break ;

        //----------------------------------------------------------------------
        // column assignment: C<M>(:,jC), M is a column vector
        //----------------------------------------------------------------------

        case GB_COL_ASSIGN : 
        {
            // iterate over all of C(:,jC)
            const int64_t jC = GB_IGET (J, 0) ;
            const int64_t pC0 = jC * Cvlen ;
            const int nthreads = GB_nthreads (Cvlen, chunk, nthreads_max) ;
            int tid ;
            #pragma omp parallel for num_threads(nthreads) schedule(static) \
                reduction(+:cnvals)
            for (tid = 0 ; tid < nthreads ; tid++)
            {
                int64_t iC_start, iC_end, task_cnvals = 0 ;
                GB_PARTITION (iC_start, iC_end, Cvlen, tid, nthreads) ;
                for (int64_t iC = iC_start ; iC < iC_end ; iC++)
                { 
                    int64_t pC = iC + pC0 ;
                    GB_GET_MIJ (mij, iC) ;          // mij = Mask (iC)
                    GB_CIJ_WORK (pC) ;              // operate on C(iC,jC)
                }
                #ifndef GB_NO_CNVALS
                cnvals += task_cnvals ;
                #endif
            }
        }
        break ;

        //----------------------------------------------------------------------
        // GrB_assign: C<M>(I,J), M is a matrix the same size as C
        //----------------------------------------------------------------------

        #ifndef GB_NO_ASSIGN_CASE
        case GB_ASSIGN : 
        {
            // iterate over all of C(:,:).
            #include "template/GB_bitmap_assign_C_whole_template.c"
        }
        break ;
        #endif

        //----------------------------------------------------------------------
        // GxB_subassign: C(I,J)<M>, M is a matrix the same size as C(I,J)
        //----------------------------------------------------------------------

        #ifndef GB_NO_SUBASSIGN_CASE
        case GB_SUBASSIGN : 
        {
            // iterate over all of C(I,J)
            #undef  GB_IXJ_WORK
            #define GB_IXJ_WORK(pC,pA)                                      \
            {                                                               \
                GB_GET_MIJ (mij, pA) ;          /* mij = Mask (pA)      */  \
                GB_CIJ_WORK (pC) ;              /* operate on C(iC,jC)  */  \
            }
            #include "template/GB_bitmap_assign_IxJ_template.c"
        }
        break ;
        #endif

        default: ;
    }
}