Example #1
0
void elem::buildList(std::list<elem>& tlist, const TraceTimer& timer)
{
  tlist.push_back(elem(&timer, timer.time()));
  const std::vector<TraceTimer*>& children = timer.children();
  for (unsigned int i=0; i<children.size(); i++)
    {
      buildList(tlist, *(children[i]));
    }
}
void elem::buildList(List<elem>& tlist, const TraceTimer& timer)
{
  tlist.append(elem(&timer, timer.time()));
  const std::vector<TraceTimer*>& children = timer.children();
  for (int i=0; i<children.size(); i++)
    {
      buildList(tlist, *(children[i]));
    }
}
Example #3
0
void TraceTimer::prune()
{
  unsigned int i=0;
  for(; i<m_children.size(); ++i){
    TraceTimer* timer =  m_children[i];
    timer->prune();
  }
  m_pruned = true;
}
void TraceTimer::PruneTimersParentChildPercent(double percent)
{
#ifndef CH_NTIMER
  char* timerEnv = getenv("CH_TIMER");
  if (timerEnv == NULL)
    {
      // pout()<<"CH_TIMER environment variable not set. Timers inactive. Not writing time.table \n";
      return;
    }
  TraceTimer* root = s_roots[0]; // in MThread code, loop over roots
  root->currentize();
  PruneTimersParentChildPercent(percent, root);
#endif
}
Example #5
0
void TraceTimer::prune()
{
#ifdef _OPENMP
  if(onThread0()){
#endif
  int i=0;
  for (; i<m_children.size(); ++i)
  {
    TraceTimer* timer =  m_children[i];
    timer->prune();
  }
  m_pruned = true;
#ifdef _OPENMP
  }
#endif
}
 bool operator < (const elem& rhs) const
 {
   if (val->isPruned())
   {
     return false;
   }
   return time > rhs.time;
 }
void TraceTimer::PruneTimersParentChildPercent(double threshold, TraceTimer* parent)
{
  if (parent->isPruned()) return;
  unsigned long long int time = parent->time();
  const std::vector<TraceTimer*>& children = parent->children();

  for (int i=0; i<children.size(); ++i)
    {
      TraceTimer* child = children[i];
      if (!child->isPruned())
        {
          unsigned long long int childtime = child->time();
          if (((double)childtime)/time < threshold) child->prune();
          else PruneTimersParentChildPercent(threshold, child);
        }

    }
}
int TraceTimer::initializer()
{
  static bool initialized = false;
  if (initialized) return -11;

#ifndef CH_NTIMER
  const char* rootName = "main";
  TraceTimer* rootTimer = new TraceTimer(rootName, NULL, 0);
  rootTimer->m_thread_id = 0;
  char mutex = 0;
  s_roots.resize(1);
  s_roots[0] = rootTimer;
  s_currentTimer.resize(1);
  s_currentTimer[0]=rootTimer;

  char* timerEnv = getenv("CH_TIMER");
  if (timerEnv == NULL)
    {
      rootTimer->m_pruned = true;
    }
  else
    {
      s_traceMemory = false;
      if (strcmp(timerEnv, "MEMORY")==0)
        {
#ifdef  CH_USE_MEMORY_TRACKING
          s_traceMemory = true;
#endif

        }
      if (strncmp(timerEnv, "SAMPLE=",7)==0)
        {
          sampleFrequency = atoi(timerEnv+7);
#ifdef CH_DISABLE_SIGNALS
          std::cout<<"You requested profile "<<timerEnv
                   <<"  but CH_DISABLE_SIGNALS is turned on, no sampling possible\n";
#else
          signal(SIGALRM, sampleMem);
          ualarm( sampleFrequency, sampleFrequency );
#endif


        }
    }
  rootTimer->start(&mutex);
  zeroTime = TimerGetTimeStampWC();
  zeroTicks = ch_ticks();
  //  OK, I think I have the atexit vs. static objects bug under AIX worked out. we'll see.
  //#ifndef CH_AIX
  // petermc, 21 April 2006:
  // put "#ifndef CH_AIX" around this because on seaborg,
  // the presence of this line causes a segfault at the termination
  // of the program.
  //   OK, last time around the maypole.  It just seems that atexit and MPI_Finalize are
  //   not going to be cooperative.  bvs
#ifndef CH_MPI
  if (timerEnv != NULL) atexit(writeOnExit);
#endif

  //#endif
#endif // CH_NTIMER
  initialized = true;
  return 0;
}
Example #9
0
int TraceTimer::initializer()
{
#ifdef _OPENMP
  if(onThread0()){
#endif
  static bool initialized = false;
  if (initialized) return -11;

#ifndef CH_NTIMER
  // flop-counting breaks multidim

  //FORTRAN_BASENAME(FLOPINIT,flopinit)() ;

  CountersInit();

  const char* rootName = "main";
  TraceTimer* rootTimer = new TraceTimer(rootName, NULL, 0);
  rootTimer->m_thread_id = 0;
  char mutex = 0;
  s_roots.resize(1);
  s_roots[0] = rootTimer;
  s_currentTimer.resize(1);
  s_currentTimer[0]=rootTimer;

  char* timerEnv = getenv("CH_TIMER");
  s_memorySampling = false;
  s_tracing= false;
  rootTimer->start(&mutex);
  zeroTime = TimerGetTimeStampWC();
  zeroTicks = ch_ticks();

  if (timerEnv == NULL)
    {
      rootTimer->m_pruned = true;
    }
  else if (strncmp(timerEnv, "SAMPLE=",7)==0)
    {
#ifdef CH_USE_MEMORY_TRACKING
#ifndef CH_DISABLE_SIGNALS
      sampleFrequency = atoi(timerEnv+7);
      signal(SIGALRM, sampleMem);
      ualarm( sampleFrequency, sampleFrequency );
      s_memorySampling = true;
#else 
      std::cout<<"Chombo was compiled with memory tracking, but CH_DISABLE_SIGNALS was set.  no samples created"<<std::endl;
#endif
#else
      std::cout<<"CH_USE_MEMORY_TRACKING was not used during compilation, so no memory sampling will happen"<<std::endl;
#endif
      
    } else if (strncmp(timerEnv, "TRACING",7)==0)
    {
#ifdef CH_USE_MEMORY_TRACKING
#ifndef CH_DISABLE_SIGNALS
      s_tracing = true;
#else 
      std::cout<<"Chombo was compiled with memory tracking, but CH_DISABLE_SIGNALS was set.  no samples created"<<std::endl;
#endif
#else
      std::cout<<"CH_USE_MEMORY_TRACKING was not used during compilation, so no memory sampling will happen"<<std::endl;
#endif
    }

  //  OK, I think I have the atexit vs. static objects bug under AIX worked out. we'll see.
  //#ifndef CH_AIX
  // petermc, 21 April 2006:
  // put "#ifndef CH_AIX" around this because on seaborg,
  // the presence of this line causes a segfault at the termination
  // of the program.
  //   OK, last time around the maypole.  It just seems that atexit and MPI_Finalize are
  //   not going to be cooperative.  bvs
//#ifndef CH_MPI
  if (timerEnv != NULL)
   { 
      atexit(writeOnExit);
#ifndef CH_DISABLE_SIGNALS
      signal(SIGABRT, writeOnAbort);
#endif
   }
//#endif

  //#endif
#endif // CH_NTIMER

  initialized = true;
  if (s_memorySampling)
    samplingOn = true;
#ifdef _OPENMP
  }
#endif
  return 0;
}