source:
XIOS/trunk/src/tracer.cpp
@
2328
Last change on this file since 2328 was 1657, checked in by ymipsl, 6 years ago | |
---|---|
|
|
File size: 1.8 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 ; | |
[347] | 27 | |
28 | void traceOn(void) | |
29 | { | |
[1655] | 30 | #if defined(VTRACE) |
[1639] | 31 | VT_ON() ; |
[1655] | 32 | #elif defined(SCOREP) |
[1657] | 33 | SCOREP_RECORDING_ON() ; |
34 | #elif defined(ITAC) | |
35 | VT_traceon() ; | |
[347] | 36 | #endif |
37 | } | |
38 | ||
39 | void traceOff(void) | |
40 | { | |
[1655] | 41 | #if defined(VTRACE) |
[1639] | 42 | VT_OFF() ; |
[1655] | 43 | #elif defined(SCOREP) |
44 | SCOREP_RECORDING_OFF() | |
[1657] | 45 | #elif defined(ITAC) |
46 | VT_traceoff() ; | |
[347] | 47 | #endif |
48 | } | |
49 | ||
50 | void traceBegin(const string& name) | |
51 | { | |
[1655] | 52 | #if defined(VTRACE) |
[1639] | 53 | VT_USER_START(name.c_str()) ; |
[1655] | 54 | #elif defined(SCOREP) |
55 | SCOREP_USER_REGION_BY_NAME_BEGIN(name.c_str(),SCOREP_USER_REGION_TYPE_COMMON) | |
[1657] | 56 | |
57 | #elif defined(ITAC) | |
58 | int classhandle ; | |
59 | auto it = regionId.find(name); | |
60 | if (it==regionId.end()) | |
61 | { | |
62 | classhandle=count ; | |
63 | count++ ; | |
64 | VT_symdef (classhandle, name.c_str(), "XIOS") ; | |
65 | regionId[name]=classhandle; | |
66 | } | |
67 | else classhandle = it->second ; | |
68 | VT_begin(classhandle) ; | |
69 | cout<<"VT_begin "<<name<<" "<<classhandle<<endl ; | |
70 | ||
[347] | 71 | #endif |
[1657] | 72 | |
[347] | 73 | } |
74 | ||
75 | void traceEnd(const string& name) | |
76 | { | |
[1657] | 77 | #if defined (VTRACE) |
[1639] | 78 | VT_USER_END(name.c_str()) ; |
[1655] | 79 | #elif defined(SCOREP) |
80 | SCOREP_USER_REGION_BY_NAME_END(name.c_str()) | |
[1657] | 81 | #elif defined(ITAC) |
82 | int classhandle ; | |
83 | auto it = regionId.find(name); | |
84 | if (it==regionId.end()) | |
85 | { | |
86 | return ; | |
87 | VT_classdef (name.c_str(), &classhandle) ; | |
88 | regionId[name]=classhandle; | |
89 | } | |
90 | else classhandle = it->second ; | |
91 | VT_end(classhandle) ; | |
92 | cout<<"VT_end "<<name<<" "<<classhandle<<endl ; | |
93 | ||
[347] | 94 | #endif |
95 | } | |
96 | ||
[1657] | 97 | |
[347] | 98 | // void marker(const string& name,const string& text) ; |
99 | ||
100 | ||
101 | } |
Note: See TracBrowser
for help on using the repository browser.