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

Function GB_nvec_nonempty

deps/GraphBLAS/Source/GB_nvec_nonempty.c:15–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13#include "GB.h"
14
15GB_PUBLIC
16int64_t GB_nvec_nonempty // return # of non-empty vectors
17(
18 const GrB_Matrix A, // input matrix to examine
19 GB_Context Context
20)
21{
22
23 //--------------------------------------------------------------------------
24 // check inputs
25 //--------------------------------------------------------------------------
26
27 ASSERT (A != NULL) ;
28 ASSERT (GB_ZOMBIES_OK (A)) ;
29 ASSERT (GB_JUMBLED_OK (A)) ;
30 ASSERT (GB_PENDING_OK (A)) ;
31
32 //--------------------------------------------------------------------------
33 // trivial cases
34 //--------------------------------------------------------------------------
35
36 if (GB_IS_FULL (A) || GB_IS_BITMAP (A))
37 {
38 // A is full or bitmap; nvec_nonempty depends only on the dimensions
39 return ((A->vlen == 0) ? 0 : A->vdim) ;
40 }
41
42 if (GB_nnz (A) == 0)
43 {
44 // A is sparse or hypersparse, with no entries
45 return (0) ;
46 }
47
48 //--------------------------------------------------------------------------
49 // determine the number of threads to use
50 //--------------------------------------------------------------------------
51
52 int64_t anvec = A->nvec ;
53 GB_GET_NTHREADS_MAX (nthreads_max, chunk, Context) ;
54 int nthreads = GB_nthreads (anvec, chunk, nthreads_max) ;
55
56 //--------------------------------------------------------------------------
57 // count the non-empty columns
58 //--------------------------------------------------------------------------
59
60 int64_t nvec_nonempty = 0 ;
61 const int64_t *restrict Ap = A->p ;
62
63 int64_t k ;
64 #pragma omp parallel for num_threads(nthreads) schedule(static) \
65 reduction(+:nvec_nonempty)
66 for (k = 0 ; k < anvec ; k++)
67 {
68 if (Ap [k] < Ap [k+1]) nvec_nonempty++ ;
69 }
70
71 ASSERT (nvec_nonempty >= 0 && nvec_nonempty <= A->vdim) ;
72

Callers 11

GB_selectorFunction · 0.85
GB_matvec_checkFunction · 0.85
GB_AxB_dot2Function · 0.85
GrB_InfoFunction · 0.85
GB_conform_hyperFunction · 0.85
GB_unjumbleFunction · 0.85
GB_hypermatrix_pruneFunction · 0.85
GB_AxB_dot2_controlFunction · 0.85
GB_conformFunction · 0.85
GB_AxB_saxpy_sparsityFunction · 0.85
mexFunctionFunction · 0.85

Calls 2

GB_nthreadsFunction · 0.85
GB_nnzFunction · 0.50

Tested by

no test coverage detected