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