OpenMPCD
CodeRegion.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  * Defines the `OpenMPCD::Profiling::CodeRegion` class.
4  */
5 
6 #ifndef OPENMPCD_PROFILING_CODEREGION_HPP
7 #define OPENMPCD_PROFILING_CODEREGION_HPP
8 
9 #ifdef OPENMPCD_CUDA_PROFILE
10  #include <nvToolsExt.h>
11 #endif
12 
13 namespace OpenMPCD
14 {
15 /**
16  * Namespace for profiling of the application.
17  */
18 namespace Profiling
19 {
20  /**
21  * Marks a code region.
22  * The marked region starts with the construction of an instance of this class,
23  * and ends with its destruction.
24  */
25  class CodeRegion
26  {
27  public:
28  /**
29  * The constructor.
30  * @param[in] name The name for the code region.
31  */
32  CodeRegion(const char* const name)
33  {
34  #ifdef OPENMPCD_CUDA_PROFILE
35  nvtxRangePushA(name);
36  #endif
37  }
38 
39  private:
40  CodeRegion(const CodeRegion&); ///< The copy constructor.
41 
42  public:
43  /**
44  * The destructor.
45  */
47  {
48  #ifdef OPENMPCD_CUDA_PROFILE
49  nvtxRangePop();
50  #endif
51  }
52 
53  private:
54  const CodeRegion& operator=(const CodeRegion&); ///< The assignment operator.
55  };
56 } //namespace Profiling
57 } //namespace OpenMPCD
58 
59 #endif //OPENMPCD_PROFILING_CODEREGION_HPP
OpenMPCD::Profiling::CodeRegion
Marks a code region.
Definition: CodeRegion.hpp:25
OpenMPCD::Profiling::CodeRegion::CodeRegion
CodeRegion(const char *const name)
The constructor.
Definition: CodeRegion.hpp:32
OpenMPCD::Profiling::CodeRegion::~CodeRegion
~CodeRegion()
The destructor.
Definition: CodeRegion.hpp:46