annotate Problems/private/ompprof.c @ 57:3a58e70e8cbe

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