source: XIOS/dev/dev_ym/XIOS_COUPLING/src/tracer.cpp @ 1878

Last change on this file since 1878 was 1750, checked in by ymipsl, 5 years ago

Improve timer and tracing functionnalities

YM

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
  • Property svn:eol-style set to native
File size: 2.0 KB
Line 
1#include "tracer.hpp"
2
3#if defined(VTRACE)
4
5#include <vt_user.h>
6
7#elif defined(SCOREP)
8
9#include <scorep/SCOREP_User.h>
10
11#elif defined(ITAC)
12
13#include <VT.h>
14
15#endif
16
17#include <string>
18#include <map>
19#include <iostream>
20
21namespace xios
22{
23  using namespace std ;
24
25  std::map<std::string,int> regionId ;
26  int count=0 ;
27  bool traceIsOn=true ;
28  int stackOnOffdeep=0 ;
29 
30  void traceOn(void)
31  {
32    stackOnOffdeep-- ;
33    if (stackOnOffdeep!=0) return ;
34    traceIsOn=true; 
35
36#if defined(VTRACE)
37    VT_ON() ;
38#elif defined(SCOREP)
39    SCOREP_RECORDING_ON() ;
40#elif defined(ITAC)
41    VT_traceon() ;
42#endif
43  }
44 
45  void traceOff(void) 
46  {
47    stackOnOffdeep++ ;
48    if (stackOnOffdeep!=1) return ;
49    traceIsOn=false; 
50#if defined(VTRACE)
51    VT_OFF() ;
52#elif defined(SCOREP)
53    SCOREP_RECORDING_OFF()
54#elif defined(ITAC)
55    VT_traceoff()   ; 
56#endif
57  }
58 
59  void traceBegin(const string& name)
60  {
61#if defined(VTRACE)
62   
63    if (traceIsOn) VT_USER_START(name.c_str()) ;
64#elif defined(SCOREP)
65    SCOREP_USER_REGION_BY_NAME_BEGIN(name.c_str(),SCOREP_USER_REGION_TYPE_COMMON)
66
67#elif defined(ITAC)
68    int classhandle ;
69    auto it = regionId.find(name);
70    if (it==regionId.end())
71    {
72      classhandle=count ;
73      count++ ;
74      VT_symdef (classhandle, name.c_str(), "XIOS") ;
75      regionId[name]=classhandle;
76    }
77    else classhandle = it->second ;
78    VT_begin(classhandle) ;
79    cout<<"VT_begin "<<name<<"  "<<classhandle<<endl ;
80
81#endif
82
83  }
84 
85  void traceEnd(const string& name)
86  {
87#if defined (VTRACE)
88    if (traceIsOn) VT_USER_END(name.c_str()) ;
89#elif defined(SCOREP)
90    SCOREP_USER_REGION_BY_NAME_END(name.c_str())
91#elif defined(ITAC)
92    int classhandle ;
93    auto it = regionId.find(name);
94    if (it==regionId.end())
95    {
96      return ;
97      VT_classdef (name.c_str(), &classhandle) ;
98      regionId[name]=classhandle;
99    }
100    else classhandle = it->second ;
101    VT_end(classhandle) ;   
102    cout<<"VT_end "<<name<<"  "<<classhandle<<endl ;
103
104#endif
105  }
106 
107   
108//  void marker(const string& name,const string& text) ;
109 
110 
111}
Note: See TracBrowser for help on using the repository browser.