1 //------------------------------------------------------------------------------
2 // GB_split_sparse_template: split a single tile from a sparse 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 A and C, and the slicing of C
14     //--------------------------------------------------------------------------
15 
16     const GB_CTYPE *restrict Ax = (GB_CTYPE *) A->x ;
17     GB_CTYPE *restrict Cx = (GB_CTYPE *) C->x ;
18 
19     //--------------------------------------------------------------------------
20     // copy the tile from A to C
21     //--------------------------------------------------------------------------
22 
23     int tid ;
24     #pragma omp parallel for num_threads(C_nthreads) schedule(dynamic,1)
25     for (tid = 0 ; tid < C_ntasks ; tid++)
26     {
27         int64_t kfirst = kfirst_Cslice [tid] ;
28         int64_t klast  = klast_Cslice  [tid] ;
29         for (int64_t k = kfirst ; k <= klast ; k++)
30         {
31             // int64_t jA = GBH (Ah, k+akstart) ; not needed
32             int64_t pC_start, pC_end ;
33             GB_get_pA (&pC_start, &pC_end, tid, k,
34                 kfirst, klast, pstart_Cslice, Cp, cvlen) ;
35             int64_t p0 = Cp [k] ;
36             int64_t pA_offset = Wp [k + akstart] ;
37             // copy the vector from A to C
38             for (int64_t pC = pC_start ; pC < pC_end ; pC++)
39             {
40                 // get the index of A(iA,jA)
41                 int64_t pA = pA_offset + pC - p0 ;
42                 int64_t iA = Ai [pA] ;
43                 // shift the index and copy into C(i,j)
44                 Ci [pC] = iA - aistart ;
45                 GB_COPY (pC, pA) ;
46             }
47         }
48     }
49 
50     done = true ;
51 }
52 
53 #undef GB_CTYPE
54 
55