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

Function GB_memset

deps/GraphBLAS/Source/GB_memset.c:16–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14#define GB_MEM_CHUNK (1024*1024)
15
16void GB_memset // parallel memset
17(
18 void *dest, // destination
19 const int c, // value to to set
20 size_t n, // # of bytes to set
21 int nthreads // max # of threads to use
22)
23{
24
25 if (nthreads <= 1 || n <= GB_MEM_CHUNK)
26 {
27
28 //----------------------------------------------------------------------
29 // memset using a single thread
30 //----------------------------------------------------------------------
31
32 memset (dest, c, n) ;
33 }
34 else
35 {
36
37 //----------------------------------------------------------------------
38 // memset using multiple threads
39 //----------------------------------------------------------------------
40
41 size_t nchunks = 1 + (n / GB_MEM_CHUNK) ;
42 if (((size_t) nthreads) > nchunks)
43 {
44 nthreads = (int) nchunks ;
45 }
46 GB_void *pdest = (GB_void *) dest ;
47
48 int64_t k ;
49 #pragma omp parallel for num_threads(nthreads) schedule(dynamic,1)
50 for (k = 0 ; k < nchunks ; k++)
51 {
52 size_t start = k * GB_MEM_CHUNK ;
53 if (start < n)
54 {
55 size_t chunk = GB_IMIN (n - start, GB_MEM_CHUNK) ;
56 memset (pdest + start, c, chunk) ;
57 }
58 }
59 }
60}
61

Callers 14

GB_selectorFunction · 0.85
GB_clearFunction · 0.85
GB_iso_expandFunction · 0.85
GB_AxB_saxpy3_flopcountFunction · 0.85
GB_calloc_helperFunction · 0.85
GB_transpose_bucketFunction · 0.85
GB_bitmap_assign_to_fullFunction · 0.85
ifFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected