コード例 #1
0
ファイル: regstack.c プロジェクト: RSE-Cambridge/IPM
void ipm_region(int op, char *tag) 
{
  int i;
  struct region *reg;
  
  switch( op ) 
    {
    case -1: /* exit */
      
      ipm_region_end(ipm_rstackptr);
      ipm_rstackptr->nexecs++;

      if( ipm_rstackptr->parent ) {
	ipm_rstackptr=ipm_rstackptr->parent;
      }
      
      break;
      
    case 1: /* enter */
      
      /* find region among child regions of current ipm_rstackptr */
      reg = ipm_rstackptr->child;
      while(reg) {
	if( !(strncmp(reg->name, tag, MAXSIZE_REGLABEL)) ) {
	  ipm_rstackptr=reg;
	  break;
	}
	reg=reg->next;
      }
      if( !reg ) {
	/* region not found, create new one */
	reg=(region_t*)IPM_MALLOC(sizeof(region_t));
	rstack_init_region(reg, tag);
	reg->parent=ipm_rstackptr;
	
	if( !(ipm_rstackptr->child) ) {
	  ipm_rstackptr->child=reg;
	}
	else {
	  ipm_rstackptr=ipm_rstackptr->child;
	  while(ipm_rstackptr->next)
	    ipm_rstackptr=ipm_rstackptr->next;
	  ipm_rstackptr->next=reg;
	}

	ipm_rstackptr=reg;
      }
      ipm_region_begin(ipm_rstackptr);
      
      break;
    }
}
コード例 #2
0
ファイル: ipm_core.c プロジェクト: nerscadmin/IPM
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;
}