OpenMPI  0.1.1
vt_unify_tkfac_scope.h
1 /**
2  * VampirTrace
3  * http://www.tu-dresden.de/zih/vampirtrace
4  *
5  * Copyright (c) 2005-2012, ZIH, TU Dresden, Federal Republic of Germany
6  *
7  * Copyright (c) 1998-2005, Forschungszentrum Juelich, Juelich Supercomputing
8  * Centre, Federal Republic of Germany
9  *
10  * See the file COPYING in the package base directory for details
11  **/
12 
13 #ifndef _VT_UNIFY_TKFAC_SCOPE_H_
14 #define _VT_UNIFY_TKFAC_SCOPE_H_
15 
16 #include "config.h"
17 
18 #include "vt_unify.h"
19 
20 #include <algorithm>
21 #include <iostream>
22 #include <map>
23 #include <set>
24 
25 //
26 // TokenFactoryScopeI interface class
27 //
29 {
30 public:
31 
32  // constructor
34 
35  // destructor
36  virtual ~TokenFactoryScopeI() {}
37 
38  // create global definition
39  virtual uint32_t create( const void * localDef,
40  uint32_t globalToken = 0 ) = 0;
41 
42  // set token translation for process
43  virtual void setTranslation( const uint32_t & process,
44  const uint32_t & localToken,
45  const uint32_t & globalToken ) = 0;
46 
47  // translate local to global token
48  virtual uint32_t translate( const uint32_t & process,
49  const uint32_t & localToken,
50  const bool showError = true ) const = 0;
51 
52  // get next unused global token
53  virtual uint32_t getNextToken() = 0;
54 
55 #ifdef VT_MPI
56 
57  // get size needed to pack token translation tables of certain process into
58  // a buffer
59  virtual VT_MPI_INT getPackSize( const uint32_t & process ) = 0;
60 
61  // pack token translation tables of certain process into a buffer
62  virtual void pack( const uint32_t & process, char *& buffer,
63  const VT_MPI_INT & bufferSize, VT_MPI_INT & bufferPos,
64  const bool clear = true ) = 0;
65 
66  // unpack token translation tables from a buffer
67  virtual void unpack( char *& buffer, const VT_MPI_INT & bufferSize,
68  VT_MPI_INT & bufferPos ) = 0;
69 
70 #endif // VT_MPI
71 
72 };
73 
74 //
75 // TokenFactoryScopeC template class
76 //
77 template <class T>
79 {
80 public:
81 
82  // constructor
83  TokenFactoryScopeC( std::set<T> * _globdefs, const uint32_t & _tkoffs = 1 );
84 
85  // destructor
87 
88  // create global definition
89  uint32_t create( const void * localDef, uint32_t globalToken = 0 );
90 
91  // set token translation for process
92  inline void setTranslation( const uint32_t & process,
93  const uint32_t & localToken, const uint32_t & globalToken );
94 
95  // translate local to global token
96  inline uint32_t translate( const uint32_t & process,
97  const uint32_t & localToken,
98  const bool showError = true ) const;
99 
100  // get next unused global token
101  inline uint32_t getNextToken();
102 
103 #ifdef VT_MPI
104 
105  // get size needed to pack token translation tables of certain process into
106  // a buffer
107  VT_MPI_INT getPackSize( const uint32_t & process );
108 
109  // pack token translation tables of certain process into a buffer
110  void pack( const uint32_t & process, char *& buffer,
111  const VT_MPI_INT & bufferSize, VT_MPI_INT & bufferPos,
112  const bool clear = true );
113 
114  // unpack token translation tables from a buffer
115  void unpack( char *& buffer, const VT_MPI_INT & bufferSize,
116  VT_MPI_INT & bufferPos );
117 
118 #endif // VT_MPI
119 
120 private:
121 
122  // map process id <-> map local/global token
123  std::map<uint32_t, std::map<uint32_t, uint32_t> > m_proc2TokenMap;
124 
125  // pointer to target global definitions
126  std::set<T> * m_globDefs;
127 
128  // sequential global token
129  uint32_t m_seqToken;
130 
131 };
132 
133 #include "vt_unify_tkfac_scope.hh"
134 
135 #endif // _VT_UNIFY_TKFAC_SCOPE_H_
Definition: vt_unify_tkfac_scope.h:78
VampirTrace http://www.tu-dresden.de/zih/vampirtrace.
Definition: vt_unify_tkfac_scope.h:28