ivan@137
|
1 /**************************************************************************
|
ivan@137
|
2 *
|
ivan@137
|
3 * File name: ompprof.c
|
ivan@137
|
4 *
|
ivan@137
|
5 * Ron Rubinstein
|
ivan@137
|
6 * Computer Science Department
|
ivan@137
|
7 * Technion, Haifa 32000 Israel
|
ivan@137
|
8 * ronrubin@cs
|
ivan@137
|
9 *
|
ivan@137
|
10 * Last Updated: 11.4.2009
|
ivan@137
|
11 *
|
ivan@137
|
12 *************************************************************************/
|
ivan@137
|
13
|
ivan@137
|
14
|
ivan@137
|
15 #include "ompprof.h"
|
ivan@137
|
16
|
ivan@137
|
17
|
ivan@137
|
18 /* initialize profiling information */
|
ivan@137
|
19
|
ivan@137
|
20 void initprofdata(profdata *pd)
|
ivan@137
|
21 {
|
ivan@137
|
22 pd->DtX_time = 0;
|
ivan@137
|
23 pd->XtX_time = 0;
|
ivan@137
|
24 pd->DtR_time = 0;
|
ivan@137
|
25 pd->maxabs_time = 0;
|
ivan@137
|
26 pd->DtD_time = 0;
|
ivan@137
|
27 pd->Lchol_time = 0;
|
ivan@137
|
28 pd->compcoef_time = 0;
|
ivan@137
|
29 pd->update_DtR_time = 0;
|
ivan@137
|
30 pd->update_resnorm_time = 0;
|
ivan@137
|
31 pd->compres_time = 0;
|
ivan@137
|
32 pd->indexsort_time = 0;
|
ivan@137
|
33
|
ivan@137
|
34 pd->DtX_time_counted = 0;
|
ivan@137
|
35 pd->XtX_time_counted = 0;
|
ivan@137
|
36 pd->DtR_time_counted = 0;
|
ivan@137
|
37 pd->DtD_time_counted = 0;
|
ivan@137
|
38 pd->update_DtR_time_counted = 0;
|
ivan@137
|
39 pd->resnorm_time_counted = 0;
|
ivan@137
|
40 pd->compres_time_counted = 0;
|
ivan@137
|
41 pd->indexsort_time_counted = 0;
|
ivan@137
|
42
|
ivan@137
|
43 pd->prevtime = clock();
|
ivan@137
|
44 }
|
ivan@137
|
45
|
ivan@137
|
46
|
ivan@137
|
47 /* add elapsed time to profiling data according to specified computation */
|
ivan@137
|
48
|
ivan@137
|
49 void addproftime(profdata *pd, int comptype)
|
ivan@137
|
50 {
|
ivan@137
|
51 switch(comptype) {
|
ivan@137
|
52 case DtX_TIME: pd->DtX_time += clock()-pd->prevtime; pd->DtX_time_counted = 1; break;
|
ivan@137
|
53 case XtX_TIME: pd->XtX_time += clock()-pd->prevtime; pd->XtX_time_counted = 1; break;
|
ivan@137
|
54 case DtR_TIME: pd->DtR_time += clock()-pd->prevtime; pd->DtR_time_counted = 1; break;
|
ivan@137
|
55 case DtD_TIME: pd->DtD_time += clock()-pd->prevtime; pd->DtD_time_counted = 1; break;
|
ivan@137
|
56 case COMPRES_TIME: pd->compres_time += clock()-pd->prevtime; pd->compres_time_counted = 1; break;
|
ivan@137
|
57 case UPDATE_DtR_TIME: pd->update_DtR_time += clock()-pd->prevtime; pd->update_DtR_time_counted = 1; break;
|
ivan@137
|
58 case UPDATE_RESNORM_TIME: pd->update_resnorm_time += clock()-pd->prevtime; pd->resnorm_time_counted = 1; break;
|
ivan@137
|
59 case INDEXSORT_TIME: pd->indexsort_time += clock()-pd->prevtime; pd->indexsort_time_counted = 1; break;
|
ivan@137
|
60 case MAXABS_TIME: pd->maxabs_time += clock()-pd->prevtime; break;
|
ivan@137
|
61 case LCHOL_TIME: pd->Lchol_time += clock()-pd->prevtime; break;
|
ivan@137
|
62 case COMPCOEF_TIME: pd->compcoef_time += clock()-pd->prevtime; break;
|
ivan@137
|
63 }
|
ivan@137
|
64 pd->prevtime = clock();
|
ivan@137
|
65 }
|
ivan@137
|
66
|
ivan@137
|
67
|
ivan@137
|
68 /* print profiling info */
|
ivan@137
|
69
|
ivan@137
|
70 void printprofinfo(profdata *pd, int erroromp, int batchomp, int signum)
|
ivan@137
|
71 {
|
ivan@137
|
72 clock_t tottime;
|
ivan@137
|
73
|
ivan@137
|
74 tottime = pd->DtX_time + pd->XtX_time + pd->DtR_time + pd->DtD_time + pd->compres_time + pd->maxabs_time +
|
ivan@137
|
75 pd->Lchol_time + pd->compcoef_time + pd->update_DtR_time + pd->update_resnorm_time + pd->indexsort_time;
|
ivan@137
|
76
|
ivan@137
|
77 mexPrintf("\n\n***** Profiling information for %s *****\n\n", erroromp? "OMP2" : "OMP");
|
ivan@137
|
78
|
ivan@137
|
79 mexPrintf("OMP mode: %s\n\n", batchomp? "Batch-OMP" : "OMP-Cholesky");
|
ivan@137
|
80
|
ivan@137
|
81 mexPrintf("Total signals processed: %d\n\n", signum);
|
ivan@137
|
82
|
ivan@137
|
83 if (pd->DtX_time_counted) {
|
ivan@137
|
84 mexPrintf("Compute DtX time: %7.3lf seconds\n", pd->DtX_time/(double)CLOCKS_PER_SEC);
|
ivan@137
|
85 }
|
ivan@137
|
86 if (pd->XtX_time_counted) {
|
ivan@137
|
87 mexPrintf("Compute XtX time: %7.3lf seconds\n", pd->XtX_time/(double)CLOCKS_PER_SEC);
|
ivan@137
|
88 }
|
ivan@137
|
89 mexPrintf("Max abs time: %7.3lf seconds\n", pd->maxabs_time/(double)CLOCKS_PER_SEC);
|
ivan@137
|
90 if (pd->DtD_time_counted) {
|
ivan@137
|
91 mexPrintf("Compute DtD time: %7.3lf seconds\n", pd->DtD_time/(double)CLOCKS_PER_SEC);
|
ivan@137
|
92 }
|
ivan@137
|
93 mexPrintf("Lchol update time: %7.3lf seconds\n", pd->Lchol_time/(double)CLOCKS_PER_SEC);
|
ivan@137
|
94 mexPrintf("Compute coef time: %7.3lf seconds\n", pd->compcoef_time/(double)CLOCKS_PER_SEC);
|
ivan@137
|
95 if (pd->compres_time_counted) {
|
ivan@137
|
96 mexPrintf("Compute R time: %7.3lf seconds\n", pd->compres_time/(double)CLOCKS_PER_SEC);
|
ivan@137
|
97 }
|
ivan@137
|
98 if (pd->DtR_time_counted) {
|
ivan@137
|
99 mexPrintf("Compute DtR time: %7.3lf seconds\n", pd->DtR_time/(double)CLOCKS_PER_SEC);
|
ivan@137
|
100 }
|
ivan@137
|
101 if (pd->update_DtR_time_counted) {
|
ivan@137
|
102 mexPrintf("Update DtR time: %7.3lf seconds\n", pd->update_DtR_time/(double)CLOCKS_PER_SEC);
|
ivan@137
|
103 }
|
ivan@137
|
104 if (pd->resnorm_time_counted) {
|
ivan@137
|
105 mexPrintf("Update resnorm time: %7.3lf seconds\n", pd->update_resnorm_time/(double)CLOCKS_PER_SEC);
|
ivan@137
|
106 }
|
ivan@137
|
107 if (pd->indexsort_time_counted) {
|
ivan@137
|
108 mexPrintf("Index sort time: %7.3lf seconds\n", pd->indexsort_time/(double)CLOCKS_PER_SEC);
|
ivan@137
|
109 }
|
ivan@137
|
110 mexPrintf("---------------------------------------\n");
|
ivan@137
|
111 mexPrintf("Total time: %7.3lf seconds\n\n", tottime/(double)CLOCKS_PER_SEC);
|
ivan@137
|
112 }
|
ivan@137
|
113
|