MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / GB_task_cumsum

Function GB_task_cumsum

deps/GraphBLAS/Source/GB_task_cumsum.c:14–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12#include "GB.h"
13
14void GB_task_cumsum
15(
16 int64_t *Cp, // size Cnvec+1
17 const int64_t Cnvec,
18 int64_t *Cnvec_nonempty, // # of non-empty vectors in C
19 GB_task_struct *restrict TaskList, // array of structs
20 const int ntasks, // # of tasks
21 const int nthreads, // # of threads
22 GB_Context Context
23)
24{
25
26 //--------------------------------------------------------------------------
27 // check inputs
28 //--------------------------------------------------------------------------
29
30 ASSERT (Cp != NULL) ;
31 ASSERT (Cnvec >= 0) ;
32 ASSERT (Cnvec_nonempty != NULL) ;
33 ASSERT (TaskList != NULL) ;
34 ASSERT (ntasks >= 0) ;
35 ASSERT (nthreads >= 1) ;
36
37 //--------------------------------------------------------------------------
38 // local cumulative sum of the fine tasks
39 //--------------------------------------------------------------------------
40
41 for (int taskid = 0 ; taskid < ntasks ; taskid++)
42 {
43 int64_t k = TaskList [taskid].kfirst ;
44 if (TaskList [taskid].klast < 0)
45 {
46 // Compute the sum of all fine tasks for vector k, in Cp [k]. Also
47 // compute the cumulative sum of TaskList [taskid].pC, for the
48 // tasks that work on vector k. The first fine task for vector k
49 // starts with TaskList [taskid].pC = 0, which is an offset from
50 // the final Cp [k]. A subsequent fine task t for a vector k
51 // starts on offset of TaskList [t].pC from the start of C(:,k).
52 // Cp [k] has not been cumsum'd across all of Cp. It is just the
53 // count of the entries in C(:,k). The final Cp [k] is added to
54 // each fine task below, after the GB_cumsum of Cp.
55 int64_t pC = Cp [k] ;
56 Cp [k] += TaskList [taskid].pC ;
57 TaskList [taskid].pC = pC ;
58 }
59 }
60
61 //--------------------------------------------------------------------------
62 // replace Cp with its cumulative sum
63 //--------------------------------------------------------------------------
64
65 GB_cumsum (Cp, Cnvec, Cnvec_nonempty, nthreads, Context) ;
66
67 //--------------------------------------------------------------------------
68 // shift the cumulative sum of the fine tasks
69 //--------------------------------------------------------------------------
70
71 for (int taskid = 0 ; taskid < ntasks ; taskid++)

Callers 4

GB_add_phase1Function · 0.85
GB_emult_phase1Function · 0.85
GB_subref_phase2Function · 0.85
GB_masker_phase1Function · 0.85

Calls 1

GB_cumsumFunction · 0.85

Tested by

no test coverage detected