idamnjanovic@60: /************************************************************************** idamnjanovic@60: * idamnjanovic@60: * File name: ompprof.c idamnjanovic@60: * idamnjanovic@60: * Ron Rubinstein idamnjanovic@60: * Computer Science Department idamnjanovic@60: * Technion, Haifa 32000 Israel idamnjanovic@60: * ronrubin@cs idamnjanovic@60: * idamnjanovic@60: * Last Updated: 11.4.2009 idamnjanovic@60: * idamnjanovic@60: *************************************************************************/ idamnjanovic@60: idamnjanovic@60: idamnjanovic@60: #include "ompprof.h" idamnjanovic@60: idamnjanovic@60: idamnjanovic@60: /* initialize profiling information */ idamnjanovic@60: idamnjanovic@60: void initprofdata(profdata *pd) idamnjanovic@60: { idamnjanovic@60: pd->DtX_time = 0; idamnjanovic@60: pd->XtX_time = 0; idamnjanovic@60: pd->DtR_time = 0; idamnjanovic@60: pd->maxabs_time = 0; idamnjanovic@60: pd->DtD_time = 0; idamnjanovic@60: pd->Lchol_time = 0; idamnjanovic@60: pd->compcoef_time = 0; idamnjanovic@60: pd->update_DtR_time = 0; idamnjanovic@60: pd->update_resnorm_time = 0; idamnjanovic@60: pd->compres_time = 0; idamnjanovic@60: pd->indexsort_time = 0; idamnjanovic@60: idamnjanovic@60: pd->DtX_time_counted = 0; idamnjanovic@60: pd->XtX_time_counted = 0; idamnjanovic@60: pd->DtR_time_counted = 0; idamnjanovic@60: pd->DtD_time_counted = 0; idamnjanovic@60: pd->update_DtR_time_counted = 0; idamnjanovic@60: pd->resnorm_time_counted = 0; idamnjanovic@60: pd->compres_time_counted = 0; idamnjanovic@60: pd->indexsort_time_counted = 0; idamnjanovic@60: idamnjanovic@60: pd->prevtime = clock(); idamnjanovic@60: } idamnjanovic@60: idamnjanovic@60: idamnjanovic@60: /* add elapsed time to profiling data according to specified computation */ idamnjanovic@60: idamnjanovic@60: void addproftime(profdata *pd, int comptype) idamnjanovic@60: { idamnjanovic@60: switch(comptype) { idamnjanovic@60: case DtX_TIME: pd->DtX_time += clock()-pd->prevtime; pd->DtX_time_counted = 1; break; idamnjanovic@60: case XtX_TIME: pd->XtX_time += clock()-pd->prevtime; pd->XtX_time_counted = 1; break; idamnjanovic@60: case DtR_TIME: pd->DtR_time += clock()-pd->prevtime; pd->DtR_time_counted = 1; break; idamnjanovic@60: case DtD_TIME: pd->DtD_time += clock()-pd->prevtime; pd->DtD_time_counted = 1; break; idamnjanovic@60: case COMPRES_TIME: pd->compres_time += clock()-pd->prevtime; pd->compres_time_counted = 1; break; idamnjanovic@60: case UPDATE_DtR_TIME: pd->update_DtR_time += clock()-pd->prevtime; pd->update_DtR_time_counted = 1; break; idamnjanovic@60: case UPDATE_RESNORM_TIME: pd->update_resnorm_time += clock()-pd->prevtime; pd->resnorm_time_counted = 1; break; idamnjanovic@60: case INDEXSORT_TIME: pd->indexsort_time += clock()-pd->prevtime; pd->indexsort_time_counted = 1; break; idamnjanovic@60: case MAXABS_TIME: pd->maxabs_time += clock()-pd->prevtime; break; idamnjanovic@60: case LCHOL_TIME: pd->Lchol_time += clock()-pd->prevtime; break; idamnjanovic@60: case COMPCOEF_TIME: pd->compcoef_time += clock()-pd->prevtime; break; idamnjanovic@60: } idamnjanovic@60: pd->prevtime = clock(); idamnjanovic@60: } idamnjanovic@60: idamnjanovic@60: idamnjanovic@60: /* print profiling info */ idamnjanovic@60: idamnjanovic@60: void printprofinfo(profdata *pd, int erroromp, int batchomp, int signum) idamnjanovic@60: { idamnjanovic@60: clock_t tottime; idamnjanovic@60: idamnjanovic@60: tottime = pd->DtX_time + pd->XtX_time + pd->DtR_time + pd->DtD_time + pd->compres_time + pd->maxabs_time + idamnjanovic@60: pd->Lchol_time + pd->compcoef_time + pd->update_DtR_time + pd->update_resnorm_time + pd->indexsort_time; idamnjanovic@60: idamnjanovic@60: mexPrintf("\n\n***** Profiling information for %s *****\n\n", erroromp? "OMP2" : "OMP"); idamnjanovic@60: idamnjanovic@60: mexPrintf("OMP mode: %s\n\n", batchomp? "Batch-OMP" : "OMP-Cholesky"); idamnjanovic@60: idamnjanovic@60: mexPrintf("Total signals processed: %d\n\n", signum); idamnjanovic@60: idamnjanovic@60: if (pd->DtX_time_counted) { idamnjanovic@60: mexPrintf("Compute DtX time: %7.3lf seconds\n", pd->DtX_time/(double)CLOCKS_PER_SEC); idamnjanovic@60: } idamnjanovic@60: if (pd->XtX_time_counted) { idamnjanovic@60: mexPrintf("Compute XtX time: %7.3lf seconds\n", pd->XtX_time/(double)CLOCKS_PER_SEC); idamnjanovic@60: } idamnjanovic@60: mexPrintf("Max abs time: %7.3lf seconds\n", pd->maxabs_time/(double)CLOCKS_PER_SEC); idamnjanovic@60: if (pd->DtD_time_counted) { idamnjanovic@60: mexPrintf("Compute DtD time: %7.3lf seconds\n", pd->DtD_time/(double)CLOCKS_PER_SEC); idamnjanovic@60: } idamnjanovic@60: mexPrintf("Lchol update time: %7.3lf seconds\n", pd->Lchol_time/(double)CLOCKS_PER_SEC); idamnjanovic@60: mexPrintf("Compute coef time: %7.3lf seconds\n", pd->compcoef_time/(double)CLOCKS_PER_SEC); idamnjanovic@60: if (pd->compres_time_counted) { idamnjanovic@60: mexPrintf("Compute R time: %7.3lf seconds\n", pd->compres_time/(double)CLOCKS_PER_SEC); idamnjanovic@60: } idamnjanovic@60: if (pd->DtR_time_counted) { idamnjanovic@60: mexPrintf("Compute DtR time: %7.3lf seconds\n", pd->DtR_time/(double)CLOCKS_PER_SEC); idamnjanovic@60: } idamnjanovic@60: if (pd->update_DtR_time_counted) { idamnjanovic@60: mexPrintf("Update DtR time: %7.3lf seconds\n", pd->update_DtR_time/(double)CLOCKS_PER_SEC); idamnjanovic@60: } idamnjanovic@60: if (pd->resnorm_time_counted) { idamnjanovic@60: mexPrintf("Update resnorm time: %7.3lf seconds\n", pd->update_resnorm_time/(double)CLOCKS_PER_SEC); idamnjanovic@60: } idamnjanovic@60: if (pd->indexsort_time_counted) { idamnjanovic@60: mexPrintf("Index sort time: %7.3lf seconds\n", pd->indexsort_time/(double)CLOCKS_PER_SEC); idamnjanovic@60: } idamnjanovic@60: mexPrintf("---------------------------------------\n"); idamnjanovic@60: mexPrintf("Total time: %7.3lf seconds\n\n", tottime/(double)CLOCKS_PER_SEC); idamnjanovic@60: } idamnjanovic@60: