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

Function main

deps/GraphBLAS/Demo/Program/openmp_demo.c:120–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118//------------------------------------------------------------------------------
119
120int main (int argc, char **argv)
121{
122 fprintf (stderr, "Demo: %s:\n", argv [0]) ;
123 printf ("Demo: %s:\n", argv [0]) ;
124
125 // initialize the mutex
126 int id = -1 ;
127
128 // start GraphBLAS
129 OK (GrB_init (GrB_NONBLOCKING)) ;
130 int nthreads ;
131 OK (GxB_Global_Option_get (GxB_GLOBAL_NTHREADS, &nthreads)) ;
132 fprintf (stderr, "openmp demo, nthreads %d\n", nthreads) ;
133
134 // Determine which user-threading model is being used.
135 #ifdef _OPENMP
136 printf ("User threads in this program are OpenMP threads.\n") ;
137 #else
138 printf ("This user program is single threaded.\n") ;
139 #endif
140
141 GrB_Matrix Aarray [NTHREADS] ;
142
143 // create the threads
144 #pragma omp parallel for num_threads(NTHREADS)
145 for (id = 0 ; id < NTHREADS ; id++)
146 {
147 worker (&Aarray [id], id) ;
148 }
149
150 // the leader thread prints them again, and frees them
151 for (int id = 0 ; id < NTHREADS ; id++)
152 {
153 GrB_Matrix A = Aarray [id] ;
154 printf ("\n---- Leader prints matrix %d\n", id) ;
155 OK (GxB_Matrix_fprint (A, "A", GxB_SHORT, stdout)) ;
156 GrB_Matrix_free (&A) ;
157 }
158
159 // finish GraphBLAS
160 GrB_finalize ( ) ;
161
162 // finish OpenMP
163 exit (0) ;
164}
165

Callers

nothing calls this directly

Calls 6

GrB_initFunction · 0.85
GxB_Global_Option_getFunction · 0.85
GxB_Matrix_fprintFunction · 0.85
GrB_Matrix_freeFunction · 0.85
GrB_finalizeFunction · 0.85
workerFunction · 0.70

Tested by

no test coverage detected