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

Function worker

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

Source from the content-addressed store, hash-verified

46//------------------------------------------------------------------------------
47
48int worker (GrB_Matrix *Ahandle, int id)
49{
50
51 printf ("\n================= worker %d starts:\n", id) ;
52 fprintf (stderr, "worker %d\n", id) ;
53
54 OK (GrB_Matrix_new (Ahandle, GrB_FP64, N, N)) ;
55 GrB_Matrix A = *Ahandle ;
56
57 // worker generates an intentional error message
58 GrB_Matrix_setElement_INT32 (A, 42, 1000+id, 1000+id) ;
59
60 // print the intentional error generated when the worker started
61 #pragma omp critical
62 {
63 // critical section
64 printf ("\n----------------- worker %d intentional error:\n", id) ;
65 const char *s ;
66 GrB_Matrix_error (&s, A) ;
67 printf ("%s\n", s) ;
68 }
69
70 for (int hammer_hard = 0 ; hammer_hard < NTRIALS ; hammer_hard++)
71 {
72 for (int i = 0 ; i < N ; i++)
73 {
74 for (int j = 0 ; j < N ; j++)
75 {
76 double x = (i+1)*100000 + (j+1)*1000 + id ;
77 OK (GrB_Matrix_setElement_FP64 (A, x, i, j)) ;
78 }
79 }
80
81 // force completion
82 OK (GrB_Matrix_wait (A, GrB_MATERIALIZE)) ;
83 }
84
85 // Printing is done in a critical section, just so it is not overly
86 // jumbled. Each matrix and error will print in a single body of text,
87 // but the order of the matrices and errors printed will be out of order
88 // because the critical section does not enforce the order that the
89 // threads enter.
90
91 GrB_Info info2 ;
92 #pragma omp critical
93 {
94 // critical section
95 printf ("\n----------------- worker %d is done:\n", id) ;
96 info2 = GxB_Matrix_fprint (A, "A", GxB_SHORT, stdout) ;
97 }
98 OK (info2) ;
99
100 // worker generates an intentional error message
101 GrB_Matrix_setElement_INT32 (A, 42, 1000+id, 1000+id) ;
102
103 // print the intentional error generated when the worker started
104 // It should be unchanged.
105 #pragma omp critical

Callers 1

mainFunction · 0.70

Calls 4

GrB_Matrix_newFunction · 0.85
GrB_Matrix_errorFunction · 0.85
GrB_Matrix_waitFunction · 0.85
GxB_Matrix_fprintFunction · 0.85

Tested by

no test coverage detected