1 //------------------------------------------------------------------------------
2 // GB_concat_bitmap_template: concatenate a tile into a bitmap 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 {
11 
12     //--------------------------------------------------------------------------
13     // get C and the tile A
14     //--------------------------------------------------------------------------
15 
16     const GB_CTYPE *restrict Ax = (GB_CTYPE *) A->x ;
17     GB_CTYPE *restrict Cx = (GB_CTYPE *) C->x ;
18     int8_t *restrict Cb = C->b ;
19 
20     //--------------------------------------------------------------------------
21     // copy the tile A into C
22     //--------------------------------------------------------------------------
23 
24     switch (GB_sparsity (A))
25     {
26 
27         case GxB_FULL : // A is full
28         {
29             int A_nthreads = GB_nthreads (anz, chunk, nthreads_max) ;
30             int64_t pA ;
31             #pragma omp parallel for num_threads(A_nthreads) schedule(static)
32             for (pA = 0 ; pA < anz ; pA++)
33             {
34                 int64_t i = pA % avlen ;
35                 int64_t j = pA / avlen ;
36                 int64_t iC = cistart + i ;
37                 int64_t jC = cvstart + j ;
38                 int64_t pC = iC + jC * cvlen ;
39                 // Cx [pC] = Ax [pA] ;
40                 GB_COPY (pC, pA) ;
41                 Cb [pC] = 1 ;
42             }
43         }
44         break ;
45 
46         case GxB_BITMAP : // A is bitmap
47         {
48             int A_nthreads = GB_nthreads (anz, chunk, nthreads_max) ;
49             const int8_t *restrict Ab = A->b ;
50             int64_t pA ;
51             #pragma omp parallel for num_threads(A_nthreads) schedule(static)
52             for (pA = 0 ; pA < anz ; pA++)
53             {
54                 if (Ab [pA])
55                 {
56                     int64_t i = pA % avlen ;
57                     int64_t j = pA / avlen ;
58                     int64_t iC = cistart + i ;
59                     int64_t jC = cvstart + j ;
60                     int64_t pC = iC + jC * cvlen ;
61                     // Cx [pC] = Ax [pA] ;
62                     GB_COPY (pC, pA) ;
63                     Cb [pC] = 1 ;
64                 }
65             }
66         }
67         break ;
68 
69         default : // A is sparse or hypersparse
70         {
71             int A_nthreads, A_ntasks ;
72             GB_SLICE_MATRIX (A, 1, chunk) ;
73             const int64_t *restrict Ap = A->p ;
74             const int64_t *restrict Ah = A->h ;
75             const int64_t *restrict Ai = A->i ;
76             int tid ;
77             #pragma omp parallel for num_threads(A_nthreads) schedule(static)
78             for (tid = 0 ; tid < A_ntasks ; tid++)
79             {
80                 int64_t kfirst = kfirst_Aslice [tid] ;
81                 int64_t klast  = klast_Aslice  [tid] ;
82                 for (int64_t k = kfirst ; k <= klast ; k++)
83                 {
84                     int64_t j = GBH (Ah, k) ;
85                     int64_t jC = cvstart + j ;
86                     int64_t pC_start = cistart + jC * cvlen ;
87                     int64_t pA_start, pA_end ;
88                     GB_get_pA (&pA_start, &pA_end, tid, k,
89                         kfirst, klast, pstart_Aslice, Ap, avlen) ;
90                     GB_PRAGMA_SIMD
91                     for (int64_t pA = pA_start ; pA < pA_end ; pA++)
92                     {
93                         int64_t i = Ai [pA] ;
94                         int64_t pC = pC_start + i ;
95                         // Cx [pC] = Ax [pA] ;
96                         GB_COPY (pC, pA) ;
97                         Cb [pC] = 1 ;
98                     }
99                 }
100             }
101         }
102         break ;
103     }
104 
105     done = true ;
106 }
107 
108 #undef GB_CTYPE
109 
110