Last change
on this file since 2142 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
|
Rev | Line | |
---|
[347] | 1 | #include "tracer.hpp" |
---|
[1655] | 2 | |
---|
| 3 | #if defined(VTRACE) |
---|
| 4 | |
---|
[1639] | 5 | #include <vt_user.h> |
---|
[1655] | 6 | |
---|
| 7 | #elif defined(SCOREP) |
---|
| 8 | |
---|
| 9 | #include <scorep/SCOREP_User.h> |
---|
| 10 | |
---|
[1657] | 11 | #elif defined(ITAC) |
---|
| 12 | |
---|
| 13 | #include <VT.h> |
---|
| 14 | |
---|
[347] | 15 | #endif |
---|
[1655] | 16 | |
---|
[347] | 17 | #include <string> |
---|
[1657] | 18 | #include <map> |
---|
| 19 | #include <iostream> |
---|
[347] | 20 | |
---|
| 21 | namespace xios |
---|
| 22 | { |
---|
| 23 | using namespace std ; |
---|
[1657] | 24 | |
---|
| 25 | std::map<std::string,int> regionId ; |
---|
| 26 | int count=0 ; |
---|
[1750] | 27 | bool traceIsOn=true ; |
---|
| 28 | int stackOnOffdeep=0 ; |
---|
[347] | 29 | |
---|
| 30 | void traceOn(void) |
---|
| 31 | { |
---|
[1750] | 32 | stackOnOffdeep-- ; |
---|
| 33 | if (stackOnOffdeep!=0) return ; |
---|
| 34 | traceIsOn=true; |
---|
| 35 | |
---|
[1655] | 36 | #if defined(VTRACE) |
---|
[1639] | 37 | VT_ON() ; |
---|
[1655] | 38 | #elif defined(SCOREP) |
---|
[1657] | 39 | SCOREP_RECORDING_ON() ; |
---|
| 40 | #elif defined(ITAC) |
---|
| 41 | VT_traceon() ; |
---|
[347] | 42 | #endif |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | void traceOff(void) |
---|
| 46 | { |
---|
[1750] | 47 | stackOnOffdeep++ ; |
---|
| 48 | if (stackOnOffdeep!=1) return ; |
---|
| 49 | traceIsOn=false; |
---|
[1655] | 50 | #if defined(VTRACE) |
---|
[1639] | 51 | VT_OFF() ; |
---|
[1655] | 52 | #elif defined(SCOREP) |
---|
| 53 | SCOREP_RECORDING_OFF() |
---|
[1657] | 54 | #elif defined(ITAC) |
---|
| 55 | VT_traceoff() ; |
---|
[347] | 56 | #endif |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | void traceBegin(const string& name) |
---|
| 60 | { |
---|
[1655] | 61 | #if defined(VTRACE) |
---|
[1750] | 62 | |
---|
| 63 | if (traceIsOn) VT_USER_START(name.c_str()) ; |
---|
[1655] | 64 | #elif defined(SCOREP) |
---|
| 65 | SCOREP_USER_REGION_BY_NAME_BEGIN(name.c_str(),SCOREP_USER_REGION_TYPE_COMMON) |
---|
[1657] | 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 | |
---|
[347] | 81 | #endif |
---|
[1657] | 82 | |
---|
[347] | 83 | } |
---|
| 84 | |
---|
| 85 | void traceEnd(const string& name) |
---|
| 86 | { |
---|
[1657] | 87 | #if defined (VTRACE) |
---|
[1750] | 88 | if (traceIsOn) VT_USER_END(name.c_str()) ; |
---|
[1655] | 89 | #elif defined(SCOREP) |
---|
| 90 | SCOREP_USER_REGION_BY_NAME_END(name.c_str()) |
---|
[1657] | 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 | |
---|
[347] | 104 | #endif |
---|
| 105 | } |
---|
| 106 | |
---|
[1657] | 107 | |
---|
[347] | 108 | // void marker(const string& name,const string& text) ; |
---|
| 109 | |
---|
| 110 | |
---|
| 111 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.