void ipm_region_end(struct region *reg) { int i; #ifdef HAVE_PAPI long long ctr1[MAXNUM_PAPI_EVENTS]; // long long ctr2[MAXNUM_PAPI_EVENTS]; #endif /* fprintf(stderr, "region_end for reg=%x name='%s'\n", reg, reg->name); */ #ifdef HAVE_PAPI ipm_papi_read(ctr1); #endif /* update data for region 'reg' */ reg->wtime += (ipm_wtime()) - (reg->wtime_e); reg->utime += (ipm_utime()) - (reg->utime_e); reg->stime += (ipm_stime()) - (reg->stime_e); reg->mtime += (ipm_mtime()) - (reg->mtime_e); for( i=0; i<MAXNUM_MODULES; i++ ) { if( modules[i].regfunc ) { modules[i].regfunc(&(modules[i]), -1, reg); } } #ifdef HAVE_PAPI // ipm_papi_read(ctr2); for( i=0; i<MAXNUM_PAPI_EVENTS; i++ ) { //reg->ctr_ipm[i] += (ctr2[i]-ctr1[i]); reg->ctr[i] += (ctr1[i]-reg->ctr_e[i]); } #endif }
void ipm_region_begin(struct region *reg) { int i; #ifdef HAVE_PAPI //long long ctr1[MAXNUM_PAPI_EVENTS]; long long ctr2[MAXNUM_PAPI_EVENTS]; #endif #ifdef HAVE_PAPI //ipm_papi_read(ctr1); #endif /* fprintf(stderr, "region_begin for reg=%x '%s'\n", reg, reg->name); */ /* update enter stats for ipm_rstackptr */ reg->wtime_e = ipm_wtime(); reg->utime_e = ipm_utime(); reg->stime_e = ipm_stime(); reg->mtime_e = ipm_mtime(); for( i=0; i<MAXNUM_MODULES; i++ ) { if( modules[i].regfunc ) { modules[i].regfunc(&(modules[i]), 1, reg); } } #ifdef HAVE_PAPI ipm_papi_read(ctr2); for( i=0; i<MAXNUM_PAPI_EVENTS; i++ ) { //reg->ctr_ipm[i] += (ctr2[i]-ctr1[i]); reg->ctr_e[i]=ctr2[i]; } #endif }
int ipm_finalize(int flags) { int rv, i; if(ipm_state!=STATE_ACTIVE && ipm_state!=STATE_NOTACTIVE ) { IPMERR("ipm_finalize() called with ipm_state=%d\n", ipm_state); return IPM_EOTHER; } ipm_state = STATE_IN_FINALIZE; /* this should be close to user code */ ipm_region_end(&ipm_app); ipm_region(-1, "ipm_main"); /* update global timing statistics */ gettimeofday( &(task.t_stop), 0); task.wtime = ipm_wtime() -task.wtime; task.utime = ipm_utime() -task.utime; task.stime = ipm_stime() -task.stime; task.mtime = ipm_mtime() -task.mtime; task.iotime = ipm_iotime() -task.iotime; task.omptime = ipm_omptime()-task.omptime; ipm_get_procmem(&(task.procmem)); task.procmem /= (1024.0*1024.0*1024.0); #ifdef HAVE_SELFMONITOR ipm_selfmon.t_finalize = ipm_wtime()-ipm_selfmon.t_finalize; #endif #ifdef HAVE_PAPI //rstack_adjust_ctrs(); #endif /* write out banner report */ if( !(task.flags&FLAG_REPORT_NONE) ) { fflush(stdout); ipm_banner(stdout); } #if defined(HAVE_MPI) && defined(HAVE_CALLPATH) ipm_unify_callsite_ids(); #endif /* call output routine for each module */ for( i=0; i<MAXNUM_MODULES; i++ ) { if( i==IPM_MODULE_SELFMONITOR || i==IPM_MODULE_MPI) continue; if( modules[i].output!=0 ) { IPMDBG("calling output() for module %d\n", i); rv = modules[i].output(&(modules[i]), flags); } } ipm_write_profile_log(); rstack_cleanup(ipm_rstack); #ifdef HAVE_SELFMONITOR mod_selfmonitor_output(&(modules[IPM_MODULE_SELFMONITOR]), flags); #endif /* call finalization routine for each module */ for( i=0; i<MAXNUM_MODULES; i++ ) { if( modules[i].finalize!=0 ) { IPMDBG("calling finalize() for module %d\n", i); rv = modules[i].finalize(&(modules[i]), flags); } } /* TODO: check errors in modules */ ipm_state=STATE_FINALIZED; return IPM_OK; }