Block-Structured AMR Software Framework
AMReX_CuptiTrace.H
Go to the documentation of this file.
1 #ifndef AMREX_CUPTI_TRACE_H_
2 #define AMREX_CUPTI_TRACE_H_
3 #include <AMReX_Config.H>
4 
5 #ifdef AMREX_USE_CUPTI
6 #include <stdio.h>
7 #include <vector>
8 #include <memory>
9 #include <cuda.h>
10 #include <cupti.h>
11 
12 
13 namespace amrex {
14 
15 void CUPTIAPI bfrRequestCallback (uint8_t* *bfr, size_t* size,
16  size_t* maxNumRecords) noexcept;
17 void CUPTIAPI bfrCompleteCallback (CUcontext ctx, uint32_t streamId, uint8_t* bfr,
18  size_t size, size_t validSize) noexcept;
19 
20 void initCuptiTrace () noexcept;
21 void cuptiTraceStart () noexcept;
22 void cuptiTraceStop () noexcept;
23 void cuptiTraceStop (unsigned boxUintID) noexcept;
24 
25 class CUpti_Activity_Userdata {
26 private:
27  unsigned uintID_;
28  std::string charID_;
29  unsigned long long startTime_;
30  unsigned long long endTime_;
31  unsigned long long timeElapsed_;
32  int streamID_;
33  std::string name_;
34 
35 public:
36  void setUintID (unsigned) noexcept;
37  void setCharID (std::string) noexcept;
38  void setStartTime (unsigned long long) noexcept;
39  void setEndTime (unsigned long long) noexcept;
40  void setTimeElapsed (unsigned long long) noexcept;
41  void setStreamID (int) noexcept;
42  void setName (std::string) noexcept;
43  unsigned getUintID () const noexcept;
44  std::string const& getCharID () const noexcept;
45  unsigned long long getStartTime () const noexcept;
46  unsigned long long getEndTime () const noexcept;
47  unsigned long long getTimeElapsed () const noexcept;
48  int getStreamID () const noexcept;
49  std::string const& getName () const noexcept;
50 };
51 
52 class CuptiTrace {
53 public:
54  CuptiTrace () noexcept;
55  ~CuptiTrace () noexcept;
56  void start () noexcept;
57  void stop () noexcept;
58  void stop (unsigned boxUintID) noexcept;
59 };
60 
61 extern std::vector<std::unique_ptr<CUpti_Activity_Userdata>> activityRecordUserdata;
62 double computeElapsedTimeUserdata(const std::vector<std::unique_ptr<CUpti_Activity_Userdata>>&
63  activityRecordUserdata) noexcept;
64 
65 void CuptiInitialize ();
66 void CuptiFinalize ();
67 }
68 
69 #endif
70 #endif
AMREX_GPU_HOST_DEVICE Long size(T const &b) noexcept
integer version
Definition: AMReX_GpuRange.H:26
Definition: AMReX_Amr.cpp:49